[206] | 1 | #pragma once
|
---|
[3] | 2 |
|
---|
[206] | 3 | #include <Type.h>
|
---|
| 4 | #include <Procedure.h>
|
---|
[225] | 5 | #include "MachineFixed.h"
|
---|
[206] | 6 |
|
---|
| 7 |
|
---|
[3] | 8 | //変数の種類
|
---|
[62] | 9 | #define NON_VAR 0
|
---|
| 10 | #define VAR_GLOBAL 1 // Global Variable
|
---|
| 11 | #define VAR_REFGLOBAL 2 // Global Refference Variable
|
---|
| 12 | #define VAR_LOCAL 3 // Local Variable
|
---|
| 13 | #define VAR_REFLOCAL 4 // Local Refference Variable
|
---|
| 14 | #define VAR_DIRECTMEM 5 // Direct memory
|
---|
[3] | 15 |
|
---|
[49] | 16 |
|
---|
[3] | 17 | extern int cp;
|
---|
| 18 |
|
---|
[253] | 19 | #define breakpoint compiler.codeGenerator.PutOld( (char)0xCC );
|
---|
[49] | 20 |
|
---|
| 21 |
|
---|
[3] | 22 | //ラベルアドレス
|
---|
[260] | 23 | class Label
|
---|
| 24 | {
|
---|
| 25 | public:
|
---|
| 26 | std::string name;
|
---|
[3] | 27 | int line;
|
---|
| 28 | DWORD address;
|
---|
[260] | 29 |
|
---|
| 30 | Label( const std::string &name, long nativeCodePos )
|
---|
| 31 | : name( name )
|
---|
| 32 | , line( -1 )
|
---|
| 33 | , address( nativeCodePos )
|
---|
| 34 | {
|
---|
| 35 | }
|
---|
| 36 | Label( int line, long nativeCodePos )
|
---|
| 37 | : name( "" )
|
---|
| 38 | , line( line )
|
---|
| 39 | , address( nativeCodePos )
|
---|
| 40 | {
|
---|
| 41 | }
|
---|
[3] | 42 | };
|
---|
[260] | 43 | typedef std::vector<Label> Labels;
|
---|
[3] | 44 |
|
---|
| 45 | //プロシージャの種類
|
---|
| 46 | #define PROC_DEFAULT 1 //ユーザー定義関数
|
---|
| 47 | #define PROC_DLL 2 //DLL関数
|
---|
| 48 | #define PROC_BUILTIN 3 //コンパイラ埋め込み型
|
---|
| 49 | #define PROC_PTR 4 //関数ポインタ
|
---|
| 50 |
|
---|
| 51 | //プロシージャ
|
---|
| 52 | struct PROCEDURE{
|
---|
| 53 | char name[255];
|
---|
| 54 | int address;
|
---|
| 55 | int types[MAX_PARMS];
|
---|
| 56 | _int8 ByVal[MAX_PARMS];
|
---|
| 57 | BOOL ReturnType;
|
---|
| 58 | };
|
---|
| 59 |
|
---|
| 60 | //With情報
|
---|
| 61 | struct WITHINFO{
|
---|
| 62 | char **ppName;
|
---|
| 63 | int *pWithCp;
|
---|
| 64 | int num;
|
---|
| 65 | };
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 | //RSrcSection.cpp
|
---|
| 69 | char *GetRSrcSectionBuffer(int *pLen);
|
---|
| 70 |
|
---|
| 71 | //Compile.cpp
|
---|
| 72 | void ChangeOpcode(char *Command);
|
---|
| 73 | void GetGlobalDataForDll(void);
|
---|
| 74 | DWORD CompileBuffer(char Return_Sequence,WORD Return_Command);
|
---|
| 75 |
|
---|
| 76 | //Compile_Calc.cpp
|
---|
| 77 | void ChangeTypeToDouble_ToFpuReg(int OldType);
|
---|
| 78 | void ChangeTypeToDouble(int OldType);
|
---|
| 79 | void ChangeTypeToSingle(int OldType);
|
---|
| 80 | void ChangeTypeToInt64(int OldType);
|
---|
| 81 | void ChangeTypeToLong(int OldType);
|
---|
| 82 | void ChangeTypeToInteger(int OldType);
|
---|
| 83 | void ChangeTypeToByte(int OldType);
|
---|
[64] | 84 | void SetVariableFromEax(int VarType,int CalcType,RELATIVE_VAR *pRelativeVar);
|
---|
[129] | 85 | void OpcodeCalc( const char *Command );
|
---|
[3] | 86 |
|
---|
| 87 | //NumOpe.cpp
|
---|
| 88 | void PushReturnValue(int type);
|
---|
[128] | 89 | bool TermOpe(
|
---|
| 90 | const char *term,
|
---|
| 91 | const Type &baseType,
|
---|
| 92 | Type &resultType,
|
---|
| 93 | bool &isLiteral,
|
---|
| 94 | BOOL *pbUseHeap,
|
---|
| 95 | bool isWantObject = false,
|
---|
| 96 | bool *pIsClassName = NULL,
|
---|
| 97 | bool isProcedureCallOnly = false );
|
---|
[97] | 98 | bool NumOpe( int reg,
|
---|
| 99 | const char *expression,
|
---|
| 100 | const Type &baseType,
|
---|
| 101 | Type &resultType,
|
---|
| 102 | BOOL *pbUseHeap = NULL );
|
---|
[75] | 103 | bool NumOpe( const char *Command,
|
---|
| 104 | const Type &baseType,
|
---|
| 105 | Type &resultType,
|
---|
| 106 | BOOL *pbUseHeap = NULL );
|
---|
[3] | 107 |
|
---|
| 108 | //NumOpe_Arithmetic.cpp
|
---|
| 109 | void GetStackData_ToRegister(int *type,int sp);
|
---|
| 110 | BOOL CalcTwoTerm_Arithmetic(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 111 | BOOL Calc_Mod(int *type,int *pStackPointer);
|
---|
| 112 | BOOL Calc_Divide(int *type,int *pStackPointer,int BaseType);
|
---|
| 113 | BOOL Calc_IntDivide(int *type,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 114 | BOOL Calc_MinusMark(int *type,int sp);
|
---|
| 115 | BOOL Calc_Power(int *type,int *pStackPointer);
|
---|
| 116 | BOOL Calc_Cast(int *type,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 117 | BOOL Calc_SHL(int *type,int *pStackPointer);
|
---|
| 118 | BOOL Calc_SHR(int *type,int *pStackPointer);
|
---|
| 119 |
|
---|
| 120 | //NumOpe_Logical.cpp
|
---|
| 121 | BOOL Calc_Xor(int *type,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 122 | BOOL Calc_Or(int *type,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 123 | BOOL Calc_And(int *type,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 124 | BOOL Calc_Not(int *type,int sp);
|
---|
| 125 |
|
---|
| 126 | //NumOpe_Relation.cpp
|
---|
| 127 | BOOL Calc_Relation_PE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 128 | BOOL Calc_Relation_QE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 129 | BOOL Calc_Relation_P(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 130 | BOOL Calc_Relation_Q(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
|
---|
| 131 | BOOL Calc_Relation_NotEqual(int *type,int *pStackPointer);
|
---|
| 132 | BOOL Calc_Relation_Equal(int *type,int *pStackPointer);
|
---|
| 133 |
|
---|
| 134 | //NumOpe_TypeOperation.cpp
|
---|
| 135 | void ExtendStackTo64(int type);
|
---|
| 136 | void ChangeTypeToWhole(int OldType,int NewType);
|
---|
| 137 |
|
---|
| 138 | //Compile_Set_Var.cpp
|
---|
| 139 | BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
|
---|
[75] | 140 | void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
|
---|
[64] | 141 | void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
|
---|
[66] | 142 | void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
|
---|
[64] | 143 |
|
---|
[3] | 144 | void SetDoubleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
|
---|
| 145 | void SetSingleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
|
---|
| 146 | void SetInt64Variable(int type,RELATIVE_VAR *pRelative);
|
---|
| 147 | void SetDWordVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
|
---|
| 148 | void SetLongVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
|
---|
| 149 | void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
|
---|
| 150 | void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
|
---|
[36] | 151 | void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
|
---|
[97] | 152 | void ExtendTypeTo64(int type);
|
---|
| 153 | void ExtendTypeTo32(int type,int reg);
|
---|
| 154 | void ExtendTypeTo16(int type,int reg);
|
---|
[3] | 155 |
|
---|
| 156 | //increment.cpp
|
---|
[129] | 157 | void IncDec(int idCalc, const char *lpszLeft, const char *lpszRight);
|
---|
[3] | 158 |
|
---|
| 159 | //calc2.cpp
|
---|
| 160 | #define EXP_TYPE_NUMBER 1
|
---|
| 161 | #define EXP_TYPE_EAX 2
|
---|
| 162 | #define EXP_TYPE_FPU 3
|
---|
| 163 | #define EXP_TYPE_VAR 4
|
---|
| 164 | int NumOpEx(char *Command,double *pDbl,DWORD *pdwType,RELATIVE_VAR *pRelativeVar);
|
---|
| 165 |
|
---|
| 166 | //SetVar.cpp
|
---|
| 167 | BOOL SetVariable(DWORD dwVarType,RELATIVE_VAR *pVarRelativeVar,
|
---|
| 168 | DWORD dwExpType,DWORD dwType,void *data);
|
---|
| 169 |
|
---|
| 170 | //Compile_Calc_PushVar.cpp
|
---|
| 171 | void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar);
|
---|
[97] | 172 | void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
|
---|
[3] | 173 | void PushLongVariable(RELATIVE_VAR *pRelativeVar);
|
---|
| 174 |
|
---|
| 175 | //Compile_Object.cpp
|
---|
[75] | 176 | void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
|
---|
[64] | 177 | void OpcodeDelete(const char *Parameter, bool isSweeping);
|
---|
[3] | 178 |
|
---|
| 179 | //Compile_Var.cpp
|
---|
[66] | 180 | void SetRelativeOffset( RELATIVE_VAR &relativeVar );
|
---|
[97] | 181 | bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
|
---|
[3] | 182 | void SetThisPtrToReg(int reg);
|
---|
[206] | 183 | bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
|
---|
| 184 | bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *InitBuf);
|
---|
[8] | 185 | #define DIMFLAG_INITDEBUGVAR 1
|
---|
| 186 | #define DIMFLAG_NONCALL_CONSTRACTOR 2
|
---|
| 187 | #define DIMFLAG_STATIC 4
|
---|
| 188 | #define DIMFLAG_CONST 8
|
---|
[206] | 189 | void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
|
---|
[3] | 190 | void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
|
---|
[97] | 191 | void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
|
---|
[95] | 192 | bool Compile_AddGlobalRootsForGc();
|
---|
[3] | 193 |
|
---|
[71] | 194 | //ParamImpl.cpp
|
---|
| 195 | class ParamImpl{
|
---|
[3] | 196 | char *Parms[255];
|
---|
[76] | 197 | vector<Type> types;
|
---|
[3] | 198 | int ParmsNum;
|
---|
| 199 |
|
---|
[76] | 200 | Type returnType;
|
---|
[3] | 201 |
|
---|
[20] | 202 | //一時オブジェクト管理用
|
---|
| 203 | bool useTempObject;
|
---|
| 204 | bool useTempParameters[255];
|
---|
| 205 | int nCountOfTempObjects;
|
---|
| 206 |
|
---|
[3] | 207 | public:
|
---|
[71] | 208 | ParamImpl(const char *buffer);
|
---|
[75] | 209 | ParamImpl(const Parameters ¶ms);
|
---|
[71] | 210 | ~ParamImpl();
|
---|
[75] | 211 | void SetReturnType( const Type &returnType );
|
---|
[3] | 212 |
|
---|
| 213 | private:
|
---|
[140] | 214 | bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
|
---|
[3] | 215 | public:
|
---|
[206] | 216 | const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
|
---|
| 217 | const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
|
---|
[3] | 218 |
|
---|
[77] | 219 | void ApplyDefaultParameters( const Parameters ¶ms );
|
---|
[75] | 220 | bool ErrorCheck( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
[73] | 221 | void MacroParameterSupport( const Parameters ¶ms );
|
---|
[76] | 222 | void SetStructParameter( const Type &baseType, const char *expression );
|
---|
[75] | 223 | int SetParameter( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
[20] | 224 |
|
---|
| 225 | //一時オブジェクトパラメータの生成と破棄
|
---|
[75] | 226 | int NewTempParameters( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
[20] | 227 | void DeleteTempParameters();
|
---|
[3] | 228 | };
|
---|
| 229 |
|
---|
| 230 | //Compile_CallProc.cpp
|
---|
| 231 | #define PROCFLAG_NEW 1
|
---|
[76] | 232 | bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
|
---|
[206] | 233 | bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);
|
---|
[250] | 234 | bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
|
---|
[3] | 235 |
|
---|
| 236 | //Compile_ProcOp.cpp
|
---|
| 237 | void CompileLocal();
|
---|
| 238 |
|
---|
| 239 | //Compile_Func.cpp
|
---|
| 240 | int GetFunctionFromName(char *FuncName);
|
---|
[76] | 241 | bool Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &resultType, bool isCallOn = true );
|
---|
[3] | 242 |
|
---|
| 243 | //OperatorProc.cpp
|
---|
[76] | 244 | void FreeTempObject(int reg,const CClass *pobj_c);
|
---|
| 245 | int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
|
---|
[75] | 246 | void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
|
---|
[76] | 247 | void CallIndexerGetterProc(const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType);
|
---|
[3] | 248 |
|
---|
| 249 | //Compile_Statement.cpp
|
---|
[129] | 250 | void OpcodeOthers( const char *Command );
|
---|
[3] | 251 | void OpcodeIf(char *Parameter);
|
---|
| 252 | void OpcodeGoto(char *Parameter);
|
---|
| 253 | void OpcodeWhile(char *Parameter);
|
---|
| 254 | void OpcodeFor(char *Parameter);
|
---|
| 255 | void OpcodeDo(char *Parameter);
|
---|
| 256 | void OpcodeContinue(void);
|
---|
| 257 | void OpcodeExitSub(void);
|
---|
[76] | 258 | void OpcodeSelect(const char *lpszParms);
|
---|
[3] | 259 | void OpcodeCase(char *Parameter);
|
---|
| 260 | void OpcodeGosub(char *Parameter);
|
---|
| 261 | void OpcodeReturn(char *Parameter);
|
---|
| 262 | void OpcodeSetPtrData(char *Parameter,int type);
|
---|
| 263 |
|
---|
| 264 |
|
---|
| 265 |
|
---|
| 266 |
|
---|
| 267 | //op32_main.cpp
|
---|
| 268 | BOOL IsSafeReg(int reg);
|
---|