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