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