[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);
|
---|
[64] | 61 | void SetVariableFromEax(int 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
|
---|
| 112 | void ExtendStackTo64(int type);
|
---|
| 113 | void ChangeTypeToWhole(int OldType,int NewType);
|
---|
| 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);
|
---|
[97] | 149 | void SetReg_WholeVariable(int 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 );
|
---|
[97] | 158 | bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, 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
|
---|
[206] | 166 | void dim( char *VarName, const Subscripts &subscripts, 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 |
|
---|
[76] | 177 | Type returnType;
|
---|
[3] | 178 |
|
---|
[20] | 179 | //一時オブジェクト管理用
|
---|
| 180 | bool useTempObject;
|
---|
| 181 | bool useTempParameters[255];
|
---|
| 182 | int nCountOfTempObjects;
|
---|
| 183 |
|
---|
[3] | 184 | public:
|
---|
[71] | 185 | ParamImpl(const char *buffer);
|
---|
[75] | 186 | ParamImpl(const Parameters ¶ms);
|
---|
[71] | 187 | ~ParamImpl();
|
---|
[75] | 188 | void SetReturnType( const Type &returnType );
|
---|
[3] | 189 |
|
---|
| 190 | private:
|
---|
[140] | 191 | bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
|
---|
[3] | 192 | public:
|
---|
[206] | 193 | const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
|
---|
| 194 | const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
|
---|
[3] | 195 |
|
---|
[77] | 196 | void ApplyDefaultParameters( const Parameters ¶ms );
|
---|
[75] | 197 | bool ErrorCheck( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
[73] | 198 | void MacroParameterSupport( const Parameters ¶ms );
|
---|
[76] | 199 | void SetStructParameter( const Type &baseType, const char *expression );
|
---|
[75] | 200 | int SetParameter( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
[20] | 201 |
|
---|
| 202 | //一時オブジェクトパラメータの生成と破棄
|
---|
[75] | 203 | int NewTempParameters( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
[20] | 204 | void DeleteTempParameters();
|
---|
[3] | 205 | };
|
---|
| 206 |
|
---|
| 207 | //Compile_CallProc.cpp
|
---|
| 208 | #define PROCFLAG_NEW 1
|
---|
[76] | 209 | bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
|
---|
[206] | 210 | bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);
|
---|
[250] | 211 | bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
|
---|
[3] | 212 |
|
---|
| 213 | //Compile_ProcOp.cpp
|
---|
| 214 | void CompileLocal();
|
---|
| 215 |
|
---|
| 216 | //Compile_Func.cpp
|
---|
| 217 | int GetFunctionFromName(char *FuncName);
|
---|
[76] | 218 | bool Opcode_CallFunc( const char *Parameter, const int FuncNum, 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);
|
---|
[76] | 224 | void CallIndexerGetterProc(const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType);
|
---|
[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);
|
---|