source: dev/trunk/ab5.0/abdev/compiler_x86/Opcode.h@ 827

Last change on this file since 827 was 702, checked in by dai_9181, 16 years ago
  • コンストラクタ、デストラクタの直接呼出しをエラー扱いにした。
    • コンストラクタ … New演算子にて、呼ばれるものとする。また、コンストラクタの1ステップ目にて、基底クラスのコンストラクタ呼び出しを許可する。
    • デストラクタ … Delete演算子にて呼ばれるものとする。また、デストラクタ内にて、基底クラスのコンストラクタ呼び出しが自動的に行われるものとする。

※まずは32bit版のみ対応。速やかに64bit版にマージすること。

File size: 9.7 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};
41typedef std::vector<WithInfo> WithInfos;
42
43
44//RSrcSection.cpp
45char *GetRSrcSectionBuffer(int *pLen);
46
47//Compile.cpp
48void Compile( const char *source );
49void ChangeOpcode(char *Command);
50void GetGlobalDataForDll(void);
51DWORD CompileBuffer(char Return_Sequence,WORD Return_Command);
52
53//Compile_Calc.cpp
54void ChangeTypeToDouble_ToFpuReg(int OldType);
55void ChangeTypeToDouble(int OldType);
56void ChangeTypeToSingle(int OldType);
57void ChangeTypeToInt64(int OldType);
58void ChangeTypeToLong(int OldType);
59void ChangeTypeToInteger(int OldType);
60void ChangeTypeToByte(int OldType);
61void SetVariableFromEax( const Type &varType, int CalcType,RELATIVE_VAR *pRelativeVar);
62void OpcodeCalc( const char *Command );
63
64//NumOpe.cpp
65void PushReturnValue( const Type &type );
66bool TermOpeOnlyVariable( const char *term, Type &resultType, RELATIVE_VAR &relativeVar, bool isWriteAccess );
67bool 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 );
76bool NumOpe( int reg,
77 const char *expression,
78 const Type &baseType,
79 Type &resultType,
80 bool *pbIsNeedHeapFreeStructure = NULL );
81bool NumOpe( const char *Command,
82 const Type &baseType,
83 Type &resultType,
84 bool *pbIsNeedHeapFreeStructure = NULL );
85
86//NumOpe_Arithmetic.cpp
87void GetStackData_ToRegister(int *type,int sp);
88BOOL CalcTwoTerm_Arithmetic(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer);
89BOOL Calc_Mod(int *type,int *pStackPointer);
90BOOL Calc_Divide(int *type,int *pStackPointer,int BaseType);
91BOOL Calc_IntDivide(int *type,LONG_PTR *index_stack,int *pStackPointer);
92BOOL Calc_MinusMark(int *type,int sp);
93BOOL Calc_Power(int *type,int *pStackPointer);
94BOOL Calc_Cast(int *type,LONG_PTR *index_stack,int *pStackPointer);
95BOOL Calc_SHL(int *type,int *pStackPointer);
96BOOL Calc_SHR(int *type,int *pStackPointer);
97
98//NumOpe_Logical.cpp
99BOOL Calc_Xor(int *type,LONG_PTR *index_stack,int *pStackPointer);
100BOOL Calc_Or(int *type,LONG_PTR *index_stack,int *pStackPointer);
101BOOL Calc_And(int *type,LONG_PTR *index_stack,int *pStackPointer);
102BOOL Calc_Not(int *type,int sp);
103
104//NumOpe_Relation.cpp
105BOOL Calc_Relation_PE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
106BOOL Calc_Relation_QE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
107BOOL Calc_Relation_P(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
108BOOL Calc_Relation_Q(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
109BOOL Calc_Relation_NotEqual(int *type,int *pStackPointer);
110BOOL Calc_Relation_Equal(int *type,int *pStackPointer);
111
112//NumOpe_TypeOperation.cpp
113void ExtendStackTo64( const Type &oldType );
114void ChangeTypeToWhole( const Type &oldType, const Type &newType );
115
116//Compile_Set_Var.cpp
117BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
118void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
119void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
120void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
121
122void SetDoubleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
123void SetSingleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
124void SetInt64Variable(int type,RELATIVE_VAR *pRelative);
125void SetDWordVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
126void SetLongVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
127void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
128void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
129void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
130void ExtendTypeTo64(int type);
131void ExtendTypeTo32(int type,int reg);
132void ExtendTypeTo16(int type,int reg);
133
134//increment.cpp
135void 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
142int NumOpEx(char *Command,double *pDbl,DWORD *pdwType,RELATIVE_VAR *pRelativeVar);
143
144//SetVar.cpp
145BOOL SetVariable(DWORD dwVarType,RELATIVE_VAR *pVarRelativeVar,
146 DWORD dwExpType,DWORD dwType,void *data);
147
148//Compile_Calc_PushVar.cpp
149void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar);
150void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
151void PushLongVariable(RELATIVE_VAR *pRelativeVar);
152
153//Compile_Object.cpp
154void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
155void OpcodeDelete(const char *Parameter, bool isSweeping);
156
157//Compile_Var.cpp
158void SetRelativeOffset( RELATIVE_VAR &relativeVar );
159bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const Type &classType, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
160void SetThisPtrToReg(int reg);
161bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
162bool 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
167void dim( char *VarName, const Subscripts &subscripts, const Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
168void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
169void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
170bool Compile_AddGlobalRootsForGc();
171
172//ParamImpl.cpp
173class 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
187public:
188 ParamImpl(const char *buffer);
189 ParamImpl(const Parameters &params);
190 ~ParamImpl();
191 void SetLeftType( const Type &type )
192 {
193 this->leftType = type;
194 }
195 void SetReturnType( const Type &returnType );
196
197private:
198 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, const Type &leftType, const UserProc &userProc, bool &isErrored );
199public:
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 &params );
204 bool ErrorCheck( const std::string &procName, const Parameters &params, int SecondParmNum = -1 );
205 void MacroParameterSupport( const Parameters &params );
206 void SetStructParameter( const Type &baseType, const char *expression );
207 int SetParameter( const std::string &procName, const Parameters &params, int SecondParmNum = -1, const UserProc *pUserProc = NULL );
208
209 //一時オブジェクトパラメータの生成と破棄
210 int NewTempParameters( const std::string &procName, const Parameters &params, 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
218bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
219bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName );
220bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
221void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params );
222
223//Compile_ProcOp.cpp
224void _compile_proc(const UserProc *pUserProc);
225
226//Compile_Func.cpp
227int GetFunctionFromName(char *FuncName);
228bool Opcode_CallFunc( const char *Parameter, const int FuncNum, const Type &baseType, Type &resultType, bool isCallOn = true );
229
230//OperatorProc.cpp
231void FreeTempObject(int reg,const CClass *pobj_c);
232int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack, LONG_PTR *index_stack,bool isNeedHeapFreeStructureStack[],int &sp);
233void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
234void CallIndexerGetterProc( const Type &classType, const char *ObjectName, char *Parameter,Type &resultType, DWORD dwProcFlags = 0 );
235
236//Compile_Statement.cpp
237void OpcodeOthers( const char *Command );
238void OpcodeIf(char *Parameter);
239void OpcodeGoto(char *Parameter);
240void OpcodeWhile(char *Parameter);
241void OpcodeFor(char *Parameter);
242void OpcodeForeach( const char *Parameter );
243void OpcodeDo(char *Parameter);
244void OpcodeContinue(void);
245void OpcodeExitSub(void);
246void OpcodeSelect(const char *lpszParms);
247void OpcodeCase(char *Parameter);
248void OpcodeGosub(char *Parameter);
249void OpcodeReturn(char *Parameter);
250void OpcodeSetPtrData(char *Parameter,int type);
251
252
253
254
255//op32_main.cpp
256BOOL IsSafeReg(int reg);
Note: See TracBrowser for help on using the repository browser.