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

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

静的リンクライブラリにより、複数のグローバル領域が存在することになったのでそれぞれを関数ベースに分けた

File size: 9.1 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( const Type &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( const Type &oldType );
113void ChangeTypeToWhole( const Type &oldType, const Type &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( const Type &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 Type &classType, 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, const 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 leftType;
178 Type returnType;
179
180 //一時オブジェクト管理用
181 bool useTempObject;
182 bool useTempParameters[255];
183 int nCountOfTempObjects;
184
185public:
186 ParamImpl(const char *buffer);
187 ParamImpl(const Parameters &params);
188 ~ParamImpl();
189 void SetLeftType( const Type &type )
190 {
191 this->leftType = type;
192 }
193 void SetReturnType( const Type &returnType );
194
195private:
196 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
197public:
198 const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
199 const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
200
201 void ApplyDefaultParameters( const Parameters &params );
202 bool ErrorCheck( const string &procName, const Parameters &params, int SecondParmNum = -1 );
203 void MacroParameterSupport( const Parameters &params );
204 void SetStructParameter( const Type &baseType, const char *expression );
205 int SetParameter( const string &procName, const Parameters &params, int SecondParmNum = -1, const UserProc *pUserProc = NULL );
206
207 //一時オブジェクトパラメータの生成と破棄
208 int NewTempParameters( const string &procName, const Parameters &params, int SecondParmNum = -1 );
209 void DeleteTempParameters();
210};
211
212//Compile_CallProc.cpp
213#define PROCFLAG_NEW 1
214bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
215bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName );
216bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
217
218//Compile_ProcOp.cpp
219void CompileLocal();
220
221//Compile_Func.cpp
222int GetFunctionFromName(char *FuncName);
223bool Opcode_CallFunc( const char *Parameter, const int FuncNum, Type &resultType, bool isCallOn = true );
224
225//OperatorProc.cpp
226void FreeTempObject(int reg,const CClass *pobj_c);
227int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
228void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
229void CallIndexerGetterProc( const Type &classType, char *ObjectName, char *Parameter,Type &resultType);
230
231//Compile_Statement.cpp
232void OpcodeOthers( const char *Command );
233void OpcodeIf(char *Parameter);
234void OpcodeGoto(char *Parameter);
235void OpcodeWhile(char *Parameter);
236void OpcodeFor(char *Parameter);
237void OpcodeDo(char *Parameter);
238void OpcodeContinue(void);
239void OpcodeExitSub(void);
240void OpcodeSelect(const char *lpszParms);
241void OpcodeCase(char *Parameter);
242void OpcodeGosub(char *Parameter);
243void OpcodeReturn(char *Parameter);
244void OpcodeSetPtrData(char *Parameter,int type);
245
246
247
248
249//op32_main.cpp
250BOOL IsSafeReg(int reg);
Note: See TracBrowser for help on using the repository browser.