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

Last change on this file since 261 was 261, checked in by dai_9181, 17 years ago
File size: 8.9 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//プロシージャの種類
23#define PROC_DEFAULT 1 //ユーザー定義関数
24#define PROC_DLL 2 //DLL関数
25#define PROC_BUILTIN 3 //コンパイラ埋め込み型
26#define PROC_PTR 4 //関数ポインタ
27
28//プロシージャ
29struct PROCEDURE{
30 char name[255];
31 int address;
32 int types[MAX_PARMS];
33 _int8 ByVal[MAX_PARMS];
34 BOOL ReturnType;
35};
36
37//With情報
38struct WITHINFO{
39 char **ppName;
40 int *pWithCp;
41 int num;
42};
43
44
45//RSrcSection.cpp
46char *GetRSrcSectionBuffer(int *pLen);
47
48//Compile.cpp
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(int VarType,int CalcType,RELATIVE_VAR *pRelativeVar);
62void OpcodeCalc( const char *Command );
63
64//NumOpe.cpp
65void PushReturnValue(int type);
66bool TermOpe(
67 const char *term,
68 const Type &baseType,
69 Type &resultType,
70 bool &isLiteral,
71 BOOL *pbUseHeap,
72 bool isWantObject = false,
73 bool *pIsClassName = NULL,
74 bool isProcedureCallOnly = false );
75bool NumOpe( int reg,
76 const char *expression,
77 const Type &baseType,
78 Type &resultType,
79 BOOL *pbUseHeap = NULL );
80bool NumOpe( const char *Command,
81 const Type &baseType,
82 Type &resultType,
83 BOOL *pbUseHeap = NULL );
84
85//NumOpe_Arithmetic.cpp
86void GetStackData_ToRegister(int *type,int sp);
87BOOL CalcTwoTerm_Arithmetic(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer);
88BOOL Calc_Mod(int *type,int *pStackPointer);
89BOOL Calc_Divide(int *type,int *pStackPointer,int BaseType);
90BOOL Calc_IntDivide(int *type,LONG_PTR *index_stack,int *pStackPointer);
91BOOL Calc_MinusMark(int *type,int sp);
92BOOL Calc_Power(int *type,int *pStackPointer);
93BOOL Calc_Cast(int *type,LONG_PTR *index_stack,int *pStackPointer);
94BOOL Calc_SHL(int *type,int *pStackPointer);
95BOOL Calc_SHR(int *type,int *pStackPointer);
96
97//NumOpe_Logical.cpp
98BOOL Calc_Xor(int *type,LONG_PTR *index_stack,int *pStackPointer);
99BOOL Calc_Or(int *type,LONG_PTR *index_stack,int *pStackPointer);
100BOOL Calc_And(int *type,LONG_PTR *index_stack,int *pStackPointer);
101BOOL Calc_Not(int *type,int sp);
102
103//NumOpe_Relation.cpp
104BOOL Calc_Relation_PE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
105BOOL Calc_Relation_QE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
106BOOL Calc_Relation_P(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
107BOOL Calc_Relation_Q(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
108BOOL Calc_Relation_NotEqual(int *type,int *pStackPointer);
109BOOL Calc_Relation_Equal(int *type,int *pStackPointer);
110
111//NumOpe_TypeOperation.cpp
112void ExtendStackTo64(int type);
113void ChangeTypeToWhole(int OldType,int NewType);
114
115//Compile_Set_Var.cpp
116BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
117void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
118void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
119void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
120
121void SetDoubleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
122void SetSingleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
123void SetInt64Variable(int type,RELATIVE_VAR *pRelative);
124void SetDWordVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
125void SetLongVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
126void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
127void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
128void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
129void ExtendTypeTo64(int type);
130void ExtendTypeTo32(int type,int reg);
131void ExtendTypeTo16(int type,int reg);
132
133//increment.cpp
134void IncDec(int idCalc, const char *lpszLeft, const char *lpszRight);
135
136//calc2.cpp
137#define EXP_TYPE_NUMBER 1
138#define EXP_TYPE_EAX 2
139#define EXP_TYPE_FPU 3
140#define EXP_TYPE_VAR 4
141int NumOpEx(char *Command,double *pDbl,DWORD *pdwType,RELATIVE_VAR *pRelativeVar);
142
143//SetVar.cpp
144BOOL SetVariable(DWORD dwVarType,RELATIVE_VAR *pVarRelativeVar,
145 DWORD dwExpType,DWORD dwType,void *data);
146
147//Compile_Calc_PushVar.cpp
148void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar);
149void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
150void PushLongVariable(RELATIVE_VAR *pRelativeVar);
151
152//Compile_Object.cpp
153void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
154void OpcodeDelete(const char *Parameter, bool isSweeping);
155
156//Compile_Var.cpp
157void SetRelativeOffset( RELATIVE_VAR &relativeVar );
158bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
159void SetThisPtrToReg(int reg);
160bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
161bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *InitBuf);
162#define DIMFLAG_INITDEBUGVAR 1
163#define DIMFLAG_NONCALL_CONSTRACTOR 2
164#define DIMFLAG_STATIC 4
165#define DIMFLAG_CONST 8
166void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
167void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
168void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
169bool Compile_AddGlobalRootsForGc();
170
171//ParamImpl.cpp
172class ParamImpl{
173 char *Parms[255];
174 vector<Type> types;
175 int ParmsNum;
176
177 Type returnType;
178
179 //一時オブジェクト管理用
180 bool useTempObject;
181 bool useTempParameters[255];
182 int nCountOfTempObjects;
183
184public:
185 ParamImpl(const char *buffer);
186 ParamImpl(const Parameters &params);
187 ~ParamImpl();
188 void SetReturnType( const Type &returnType );
189
190private:
191 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
192public:
193 const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
194 const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
195
196 void ApplyDefaultParameters( const Parameters &params );
197 bool ErrorCheck( const string &procName, const Parameters &params, int SecondParmNum = -1 );
198 void MacroParameterSupport( const Parameters &params );
199 void SetStructParameter( const Type &baseType, const char *expression );
200 int SetParameter( const string &procName, const Parameters &params, int SecondParmNum = -1 );
201
202 //一時オブジェクトパラメータの生成と破棄
203 int NewTempParameters( const string &procName, const Parameters &params, int SecondParmNum = -1 );
204 void DeleteTempParameters();
205};
206
207//Compile_CallProc.cpp
208#define PROCFLAG_NEW 1
209bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
210bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType);
211bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
212
213//Compile_ProcOp.cpp
214void CompileLocal();
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 CClass *pobj_Class,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.