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

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

デリゲートのベースがほぼ実装できた

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