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