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