source: dev/trunk/abdev/BasicCompiler32/Opcode.h@ 260

Last change on this file since 260 was 260, checked in by dai_9181, 17 years ago

Labelクラスをリファクタリング

File size: 9.3 KB
Line 
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
17extern int cp;
18
19#define breakpoint compiler.codeGenerator.PutOld( (char)0xCC );
20
21
22//ラベルアドレス
23class Label
24{
25public:
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};
43typedef 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//プロシージャ
52struct 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情報
61struct WITHINFO{
62 char **ppName;
63 int *pWithCp;
64 int num;
65};
66
67
68//RSrcSection.cpp
69char *GetRSrcSectionBuffer(int *pLen);
70
71//Compile.cpp
72void ChangeOpcode(char *Command);
73void GetGlobalDataForDll(void);
74DWORD CompileBuffer(char Return_Sequence,WORD Return_Command);
75
76//Compile_Calc.cpp
77void ChangeTypeToDouble_ToFpuReg(int OldType);
78void ChangeTypeToDouble(int OldType);
79void ChangeTypeToSingle(int OldType);
80void ChangeTypeToInt64(int OldType);
81void ChangeTypeToLong(int OldType);
82void ChangeTypeToInteger(int OldType);
83void ChangeTypeToByte(int OldType);
84void SetVariableFromEax(int VarType,int CalcType,RELATIVE_VAR *pRelativeVar);
85void OpcodeCalc( const char *Command );
86
87//NumOpe.cpp
88void PushReturnValue(int type);
89bool 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 );
98bool NumOpe( int reg,
99 const char *expression,
100 const Type &baseType,
101 Type &resultType,
102 BOOL *pbUseHeap = NULL );
103bool NumOpe( const char *Command,
104 const Type &baseType,
105 Type &resultType,
106 BOOL *pbUseHeap = NULL );
107
108//NumOpe_Arithmetic.cpp
109void GetStackData_ToRegister(int *type,int sp);
110BOOL CalcTwoTerm_Arithmetic(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer);
111BOOL Calc_Mod(int *type,int *pStackPointer);
112BOOL Calc_Divide(int *type,int *pStackPointer,int BaseType);
113BOOL Calc_IntDivide(int *type,LONG_PTR *index_stack,int *pStackPointer);
114BOOL Calc_MinusMark(int *type,int sp);
115BOOL Calc_Power(int *type,int *pStackPointer);
116BOOL Calc_Cast(int *type,LONG_PTR *index_stack,int *pStackPointer);
117BOOL Calc_SHL(int *type,int *pStackPointer);
118BOOL Calc_SHR(int *type,int *pStackPointer);
119
120//NumOpe_Logical.cpp
121BOOL Calc_Xor(int *type,LONG_PTR *index_stack,int *pStackPointer);
122BOOL Calc_Or(int *type,LONG_PTR *index_stack,int *pStackPointer);
123BOOL Calc_And(int *type,LONG_PTR *index_stack,int *pStackPointer);
124BOOL Calc_Not(int *type,int sp);
125
126//NumOpe_Relation.cpp
127BOOL Calc_Relation_PE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
128BOOL Calc_Relation_QE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
129BOOL Calc_Relation_P(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
130BOOL Calc_Relation_Q(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
131BOOL Calc_Relation_NotEqual(int *type,int *pStackPointer);
132BOOL Calc_Relation_Equal(int *type,int *pStackPointer);
133
134//NumOpe_TypeOperation.cpp
135void ExtendStackTo64(int type);
136void ChangeTypeToWhole(int OldType,int NewType);
137
138//Compile_Set_Var.cpp
139BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
140void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
141void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
142void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
143
144void SetDoubleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
145void SetSingleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
146void SetInt64Variable(int type,RELATIVE_VAR *pRelative);
147void SetDWordVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
148void SetLongVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
149void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
150void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
151void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
152void ExtendTypeTo64(int type);
153void ExtendTypeTo32(int type,int reg);
154void ExtendTypeTo16(int type,int reg);
155
156//increment.cpp
157void 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
164int NumOpEx(char *Command,double *pDbl,DWORD *pdwType,RELATIVE_VAR *pRelativeVar);
165
166//SetVar.cpp
167BOOL SetVariable(DWORD dwVarType,RELATIVE_VAR *pVarRelativeVar,
168 DWORD dwExpType,DWORD dwType,void *data);
169
170//Compile_Calc_PushVar.cpp
171void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar);
172void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
173void PushLongVariable(RELATIVE_VAR *pRelativeVar);
174
175//Compile_Object.cpp
176void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
177void OpcodeDelete(const char *Parameter, bool isSweeping);
178
179//Compile_Var.cpp
180void SetRelativeOffset( RELATIVE_VAR &relativeVar );
181bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
182void SetThisPtrToReg(int reg);
183bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
184bool 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
189void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
190void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
191void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
192bool Compile_AddGlobalRootsForGc();
193
194//ParamImpl.cpp
195class 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
207public:
208 ParamImpl(const char *buffer);
209 ParamImpl(const Parameters &params);
210 ~ParamImpl();
211 void SetReturnType( const Type &returnType );
212
213private:
214 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
215public:
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 &params );
220 bool ErrorCheck( const string &procName, const Parameters &params, int SecondParmNum = -1 );
221 void MacroParameterSupport( const Parameters &params );
222 void SetStructParameter( const Type &baseType, const char *expression );
223 int SetParameter( const string &procName, const Parameters &params, int SecondParmNum = -1 );
224
225 //一時オブジェクトパラメータの生成と破棄
226 int NewTempParameters( const string &procName, const Parameters &params, int SecondParmNum = -1 );
227 void DeleteTempParameters();
228};
229
230//Compile_CallProc.cpp
231#define PROCFLAG_NEW 1
232bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
233bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);
234bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
235
236//Compile_ProcOp.cpp
237void CompileLocal();
238
239//Compile_Func.cpp
240int GetFunctionFromName(char *FuncName);
241bool Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &resultType, bool isCallOn = true );
242
243//OperatorProc.cpp
244void FreeTempObject(int reg,const CClass *pobj_c);
245int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
246void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
247void CallIndexerGetterProc(const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType);
248
249//Compile_Statement.cpp
250void OpcodeOthers( const char *Command );
251void OpcodeIf(char *Parameter);
252void OpcodeGoto(char *Parameter);
253void OpcodeWhile(char *Parameter);
254void OpcodeFor(char *Parameter);
255void OpcodeDo(char *Parameter);
256void OpcodeContinue(void);
257void OpcodeExitSub(void);
258void OpcodeSelect(const char *lpszParms);
259void OpcodeCase(char *Parameter);
260void OpcodeGosub(char *Parameter);
261void OpcodeReturn(char *Parameter);
262void OpcodeSetPtrData(char *Parameter,int type);
263
264
265
266
267//op32_main.cpp
268BOOL IsSafeReg(int reg);
Note: See TracBrowser for help on using the repository browser.