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