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 | #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);
|
---|
61 | void SetVariableFromEax( const Type &varType, int CalcType,RELATIVE_VAR *pRelativeVar);
|
---|
62 | void OpcodeCalc( const char *Command );
|
---|
63 |
|
---|
64 | //NumOpe.cpp
|
---|
65 | void PushReturnValue(int type);
|
---|
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 );
|
---|
75 | bool NumOpe( int reg,
|
---|
76 | const char *expression,
|
---|
77 | const Type &baseType,
|
---|
78 | Type &resultType,
|
---|
79 | BOOL *pbUseHeap = NULL );
|
---|
80 | bool NumOpe( const char *Command,
|
---|
81 | const Type &baseType,
|
---|
82 | Type &resultType,
|
---|
83 | BOOL *pbUseHeap = NULL );
|
---|
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( const Type &oldType );
|
---|
113 | void ChangeTypeToWhole( const Type &oldType, const Type &newType );
|
---|
114 |
|
---|
115 | //Compile_Set_Var.cpp
|
---|
116 | BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
|
---|
117 | void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
|
---|
118 | void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
|
---|
119 | void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
|
---|
120 |
|
---|
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);
|
---|
128 | void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
|
---|
129 | void ExtendTypeTo64(int type);
|
---|
130 | void ExtendTypeTo32(int type,int reg);
|
---|
131 | void ExtendTypeTo16(int type,int reg);
|
---|
132 |
|
---|
133 | //increment.cpp
|
---|
134 | void IncDec(int idCalc, const char *lpszLeft, const char *lpszRight);
|
---|
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);
|
---|
149 | void SetReg_WholeVariable( Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
|
---|
150 | void PushLongVariable(RELATIVE_VAR *pRelativeVar);
|
---|
151 |
|
---|
152 | //Compile_Object.cpp
|
---|
153 | void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
|
---|
154 | void OpcodeDelete(const char *Parameter, bool isSweeping);
|
---|
155 |
|
---|
156 | //Compile_Var.cpp
|
---|
157 | void SetRelativeOffset( RELATIVE_VAR &relativeVar );
|
---|
158 | bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const Type &classType, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
|
---|
159 | void SetThisPtrToReg(int reg);
|
---|
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);
|
---|
162 | #define DIMFLAG_INITDEBUGVAR 1
|
---|
163 | #define DIMFLAG_NONCALL_CONSTRACTOR 2
|
---|
164 | #define DIMFLAG_STATIC 4
|
---|
165 | #define DIMFLAG_CONST 8
|
---|
166 | void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
|
---|
167 | void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
|
---|
168 | void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
|
---|
169 | bool Compile_AddGlobalRootsForGc();
|
---|
170 |
|
---|
171 | //ParamImpl.cpp
|
---|
172 | class ParamImpl{
|
---|
173 | char *Parms[255];
|
---|
174 | vector<Type> types;
|
---|
175 | int ParmsNum;
|
---|
176 |
|
---|
177 | Type leftType;
|
---|
178 | Type returnType;
|
---|
179 |
|
---|
180 | //一時オブジェクト管理用
|
---|
181 | bool useTempObject;
|
---|
182 | bool useTempParameters[255];
|
---|
183 | int nCountOfTempObjects;
|
---|
184 |
|
---|
185 | public:
|
---|
186 | ParamImpl(const char *buffer);
|
---|
187 | ParamImpl(const Parameters ¶ms);
|
---|
188 | ~ParamImpl();
|
---|
189 | void SetLeftType( const Type &type )
|
---|
190 | {
|
---|
191 | this->leftType = type;
|
---|
192 | }
|
---|
193 | void SetReturnType( const Type &returnType );
|
---|
194 |
|
---|
195 | private:
|
---|
196 | bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
|
---|
197 | public:
|
---|
198 | const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
|
---|
199 | const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
|
---|
200 |
|
---|
201 | void ApplyDefaultParameters( const Parameters ¶ms );
|
---|
202 | bool ErrorCheck( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
203 | void MacroParameterSupport( const Parameters ¶ms );
|
---|
204 | void SetStructParameter( const Type &baseType, const char *expression );
|
---|
205 | int SetParameter( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
206 |
|
---|
207 | //一時オブジェクトパラメータの生成と破棄
|
---|
208 | int NewTempParameters( const string &procName, const Parameters ¶ms, int SecondParmNum = -1 );
|
---|
209 | void DeleteTempParameters();
|
---|
210 | };
|
---|
211 |
|
---|
212 | //Compile_CallProc.cpp
|
---|
213 | #define PROCFLAG_NEW 1
|
---|
214 | bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
|
---|
215 | bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName );
|
---|
216 | bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
|
---|
217 |
|
---|
218 | //Compile_ProcOp.cpp
|
---|
219 | void CompileLocal();
|
---|
220 |
|
---|
221 | //Compile_Func.cpp
|
---|
222 | int GetFunctionFromName(char *FuncName);
|
---|
223 | bool Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &resultType, bool isCallOn = true );
|
---|
224 |
|
---|
225 | //OperatorProc.cpp
|
---|
226 | void FreeTempObject(int reg,const CClass *pobj_c);
|
---|
227 | int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
|
---|
228 | void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
|
---|
229 | void CallIndexerGetterProc( const Type &classType, char *ObjectName, char *Parameter,Type &resultType);
|
---|
230 |
|
---|
231 | //Compile_Statement.cpp
|
---|
232 | void OpcodeOthers( const char *Command );
|
---|
233 | void OpcodeIf(char *Parameter);
|
---|
234 | void OpcodeGoto(char *Parameter);
|
---|
235 | void OpcodeWhile(char *Parameter);
|
---|
236 | void OpcodeFor(char *Parameter);
|
---|
237 | void OpcodeDo(char *Parameter);
|
---|
238 | void OpcodeContinue(void);
|
---|
239 | void OpcodeExitSub(void);
|
---|
240 | void OpcodeSelect(const char *lpszParms);
|
---|
241 | void OpcodeCase(char *Parameter);
|
---|
242 | void OpcodeGosub(char *Parameter);
|
---|
243 | void OpcodeReturn(char *Parameter);
|
---|
244 | void OpcodeSetPtrData(char *Parameter,int type);
|
---|
245 |
|
---|
246 |
|
---|
247 |
|
---|
248 |
|
---|
249 | //op32_main.cpp
|
---|
250 | BOOL IsSafeReg(int reg);
|
---|