source: dev/branches/egtra/ab5.0/abdev/compiler_x86/Opcode.h@ 818

Last change on this file since 818 was 817, checked in by イグトランス (egtra), 14 years ago

compilerにおいて、各クラスのコピー禁止を明確化、ならびにコピー可能なものにムーブコンストラクタ・ムーブ代入演算子を追加。

File size: 10.2 KB
Line 
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
15extern int cp;
16
17#define breakpoint compiler.codeGenerator.PutOld( (char)0xCC );
18
19
20//プロシージャ
21struct 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情報
30struct 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};
65typedef std::vector<WithInfo> WithInfos;
66
67
68//RSrcSection.cpp
69char *GetRSrcSectionBuffer(int *pLen);
70
71//Compile.cpp
72void Compile( const char *source );
73void ChangeOpcode(char *Command);
74void GetGlobalDataForDll(void);
75DWORD CompileBuffer(char Return_Sequence,WORD Return_Command);
76
77//Compile_Calc.cpp
78void ChangeTypeToDouble_ToFpuReg(int OldType);
79void ChangeTypeToDouble(int OldType);
80void ChangeTypeToSingle(int OldType);
81void ChangeTypeToInt64(int OldType);
82void ChangeTypeToLong(int OldType);
83void ChangeTypeToInteger(int OldType);
84void ChangeTypeToByte(int OldType);
85void SetVariableFromEax( const Type &varType, int CalcType,RELATIVE_VAR *pRelativeVar);
86void OpcodeCalc( const char *Command );
87
88//NumOpe.cpp
89void PushReturnValue( const Type &type );
90bool TermOpeOnlyVariable( const char *term, Type &resultType, RELATIVE_VAR &relativeVar, bool isWriteAccess );
91bool 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 );
100bool NumOpe( int reg,
101 const char *expression,
102 const Type &baseType,
103 Type &resultType,
104 bool *pbIsNeedHeapFreeStructure = NULL );
105bool NumOpe( const char *Command,
106 const Type &baseType,
107 Type &resultType,
108 bool *pbIsNeedHeapFreeStructure = NULL );
109
110//NumOpe_Arithmetic.cpp
111void GetStackData_ToRegister(int *type,int sp);
112BOOL CalcTwoTerm_Arithmetic(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer);
113BOOL Calc_Mod(int *type,int *pStackPointer);
114BOOL Calc_Divide(int *type,int *pStackPointer,int BaseType);
115BOOL Calc_IntDivide(int *type,LONG_PTR *index_stack,int *pStackPointer);
116BOOL Calc_MinusMark(int *type,int sp);
117BOOL Calc_Power(int *type,int *pStackPointer);
118BOOL Calc_Cast(int *type,LONG_PTR *index_stack,int *pStackPointer);
119BOOL Calc_SHL(int *type,int *pStackPointer);
120BOOL Calc_SHR(int *type,int *pStackPointer);
121
122//NumOpe_Logical.cpp
123BOOL Calc_Xor(int *type,LONG_PTR *index_stack,int *pStackPointer);
124BOOL Calc_Or(int *type,LONG_PTR *index_stack,int *pStackPointer);
125BOOL Calc_And(int *type,LONG_PTR *index_stack,int *pStackPointer);
126BOOL Calc_Not(int *type,int sp);
127
128//NumOpe_Relation.cpp
129BOOL Calc_Relation_PE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
130BOOL Calc_Relation_QE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
131BOOL Calc_Relation_P(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
132BOOL Calc_Relation_Q(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
133BOOL Calc_Relation_NotEqual(int *type,int *pStackPointer);
134BOOL Calc_Relation_Equal(int *type,int *pStackPointer);
135
136//NumOpe_TypeOperation.cpp
137void ExtendStackTo64( const Type &oldType );
138void ChangeTypeToWhole( const Type &oldType, const Type &newType );
139
140//Compile_Set_Var.cpp
141BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
142void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
143void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
144void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
145
146void SetDoubleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
147void SetSingleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
148void SetInt64Variable(int type,RELATIVE_VAR *pRelative);
149void SetDWordVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
150void SetLongVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
151void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
152void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
153void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
154void ExtendTypeTo64(int type);
155void ExtendTypeTo32(int type,int reg);
156void ExtendTypeTo16(int type,int reg);
157
158//increment.cpp
159void 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
166int NumOpEx(char *Command,double *pDbl,DWORD *pdwType,RELATIVE_VAR *pRelativeVar);
167
168//SetVar.cpp
169BOOL SetVariable(DWORD dwVarType,RELATIVE_VAR *pVarRelativeVar,
170 DWORD dwExpType,DWORD dwType,void *data);
171
172//Compile_Calc_PushVar.cpp
173void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar);
174void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
175void PushLongVariable(RELATIVE_VAR *pRelativeVar);
176
177//Compile_Object.cpp
178void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
179void OpcodeDelete(const char *Parameter, bool isSweeping);
180
181//Compile_Var.cpp
182void SetRelativeOffset( RELATIVE_VAR &relativeVar );
183bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const Type &classType, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
184void SetThisPtrToReg(int reg);
185bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
186bool 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
191void dim( char *VarName, const Subscripts &subscripts, const Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
192void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
193void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
194bool Compile_AddGlobalRootsForGc();
195
196//ParamImpl.cpp
197class 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
211public:
212 ParamImpl(const char *buffer);
213 ParamImpl(const Parameters &params);
214 ~ParamImpl();
215 void SetLeftType( const Type &type )
216 {
217 this->leftType = type;
218 }
219 void SetReturnType( const Type &returnType );
220
221private:
222 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, const Type &leftType, const UserProc &userProc, bool &isErrored );
223public:
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 &params );
228 bool ErrorCheck( const std::string &procName, const Parameters &params, int SecondParmNum = -1 );
229 void MacroParameterSupport( const Parameters &params );
230 void SetStructParameter( const Type &baseType, const char *expression );
231 int SetParameter( const std::string &procName, const Parameters &params, int SecondParmNum = -1, const UserProc *pUserProc = NULL );
232
233 //一時オブジェクトパラメータの生成と破棄
234 int NewTempParameters( const std::string &procName, const Parameters &params, int SecondParmNum = -1 );
235 void DeleteTempParameters();
236
237private:
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
246bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
247bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName );
248bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
249void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params );
250
251//Compile_ProcOp.cpp
252void _compile_proc(const UserProc *pUserProc);
253
254//Compile_Func.cpp
255int GetFunctionFromName(char *FuncName);
256bool Opcode_CallFunc( const char *Parameter, const int FuncNum, const Type &baseType, Type &resultType, bool isCallOn = true );
257
258//OperatorProc.cpp
259void FreeTempObject(int reg,const CClass *pobj_c);
260int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack, LONG_PTR *index_stack,bool isNeedHeapFreeStructureStack[],int &sp);
261void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
262void CallIndexerGetterProc( const Type &classType, const char *ObjectName, char *Parameter,Type &resultType, DWORD dwProcFlags = 0 );
263
264//Compile_Statement.cpp
265void OpcodeOthers( const char *Command );
266void OpcodeIf(char *Parameter);
267void OpcodeGoto(char *Parameter);
268void OpcodeWhile(char *Parameter);
269void OpcodeFor(char *Parameter);
270void OpcodeForeach( const char *Parameter );
271void OpcodeDo(char *Parameter);
272void OpcodeContinue(void);
273void OpcodeExitSub(void);
274void OpcodeSelect(const char *lpszParms);
275void OpcodeCase(char *Parameter);
276void OpcodeGosub(char *Parameter);
277void OpcodeReturn(char *Parameter);
278void OpcodeSetPtrData(char *Parameter,int type);
279
280
281
282
283//op32_main.cpp
284BOOL IsSafeReg(int reg);
Note: See TracBrowser for help on using the repository browser.