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