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

Last change on this file since 424 was 424, checked in by dai_9181, 16 years ago

・ジェネリックな型をパラメータに持つメソッドのオーバーロード解決に対応した。
・型パラメータの制約クラス指定に対応した。

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