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