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