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

Last change on this file since 397 was 376, checked in by dai_9181, 17 years ago
File size: 9.2 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 TermOpe(
62 const char *term,
63 const Type &baseType,
64 Type &resultType,
65 bool &isLiteral,
66 BOOL *pbUseHeap,
67 bool isWantObject = false,
68 bool *pIsClassName = NULL,
69 bool isProcedureCallOnly = false );
70bool NumOpe( int reg,
71 const char *expression,
72 const Type &baseType,
73 Type &resultType,
74 BOOL *pbUseHeap = NULL );
75bool NumOpe( const char *Command,
76 const Type &baseType,
77 Type &resultType,
78 BOOL *pbUseHeap = NULL );
79
80//NumOpe_Arithmetic.cpp
81void GetStackData_ToRegister(int *type,int sp);
82BOOL CalcTwoTerm_Arithmetic(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer);
83BOOL Calc_Mod(int *type,int *pStackPointer);
84BOOL Calc_Divide(int *type,int *pStackPointer,int BaseType);
85BOOL Calc_IntDivide(int *type,LONG_PTR *index_stack,int *pStackPointer);
86BOOL Calc_MinusMark(int *type,int sp);
87BOOL Calc_Power(int *type,int *pStackPointer);
88BOOL Calc_Cast(int *type,LONG_PTR *index_stack,int *pStackPointer);
89BOOL Calc_SHL(int *type,int *pStackPointer);
90BOOL Calc_SHR(int *type,int *pStackPointer);
91
92//NumOpe_Logical.cpp
93BOOL Calc_Xor(int *type,LONG_PTR *index_stack,int *pStackPointer);
94BOOL Calc_Or(int *type,LONG_PTR *index_stack,int *pStackPointer);
95BOOL Calc_And(int *type,LONG_PTR *index_stack,int *pStackPointer);
96BOOL Calc_Not(int *type,int sp);
97
98//NumOpe_Relation.cpp
99BOOL Calc_Relation_PE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
100BOOL Calc_Relation_QE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
101BOOL Calc_Relation_P(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
102BOOL Calc_Relation_Q(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
103BOOL Calc_Relation_NotEqual(int *type,int *pStackPointer);
104BOOL Calc_Relation_Equal(int *type,int *pStackPointer);
105
106//NumOpe_TypeOperation.cpp
107void ExtendStackTo64( const Type &oldType );
108void ChangeTypeToWhole( const Type &oldType, const Type &newType );
109
110//Compile_Set_Var.cpp
111BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
112void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
113void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
114void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
115
116void SetDoubleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
117void SetSingleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
118void SetInt64Variable(int type,RELATIVE_VAR *pRelative);
119void SetDWordVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
120void SetLongVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
121void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
122void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
123void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
124void ExtendTypeTo64(int type);
125void ExtendTypeTo32(int type,int reg);
126void ExtendTypeTo16(int type,int reg);
127
128//increment.cpp
129void IncDec(int idCalc, const char *lpszLeft, const char *lpszRight);
130
131//calc2.cpp
132#define EXP_TYPE_NUMBER 1
133#define EXP_TYPE_EAX 2
134#define EXP_TYPE_FPU 3
135#define EXP_TYPE_VAR 4
136int NumOpEx(char *Command,double *pDbl,DWORD *pdwType,RELATIVE_VAR *pRelativeVar);
137
138//SetVar.cpp
139BOOL SetVariable(DWORD dwVarType,RELATIVE_VAR *pVarRelativeVar,
140 DWORD dwExpType,DWORD dwType,void *data);
141
142//Compile_Calc_PushVar.cpp
143void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar);
144void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
145void PushLongVariable(RELATIVE_VAR *pRelativeVar);
146
147//Compile_Object.cpp
148void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
149void OpcodeDelete(const char *Parameter, bool isSweeping);
150
151//Compile_Var.cpp
152void SetRelativeOffset( RELATIVE_VAR &relativeVar );
153bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const Type &classType, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
154void SetThisPtrToReg(int reg);
155bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
156bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *InitBuf);
157#define DIMFLAG_INITDEBUGVAR 1
158#define DIMFLAG_NONCALL_CONSTRACTOR 2
159#define DIMFLAG_STATIC 4
160#define DIMFLAG_CONST 8
161void dim( char *VarName, const Subscripts &subscripts, const Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
162void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
163void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
164bool Compile_AddGlobalRootsForGc();
165
166//ParamImpl.cpp
167class ParamImpl{
168 char *Parms[255];
169 Types types;
170 int ParmsNum;
171
172 Type leftType;
173 Type returnType;
174
175 //一時オブジェクト管理用
176 bool useTempObject;
177 bool useTempParameters[255];
178 int nCountOfTempObjects;
179
180public:
181 ParamImpl(const char *buffer);
182 ParamImpl(const Parameters &params);
183 ~ParamImpl();
184 void SetLeftType( const Type &type )
185 {
186 this->leftType = type;
187 }
188 void SetReturnType( const Type &returnType );
189
190private:
191 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, bool &isErrored );
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, const UserProc *pUserProc = NULL );
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 );
211bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
212void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params );
213
214//Compile_ProcOp.cpp
215void _compile_proc(const UserProc *pUserProc);
216
217//Compile_Func.cpp
218int GetFunctionFromName(char *FuncName);
219bool Opcode_CallFunc( const char *Parameter, const int FuncNum, const Type &baseType, Type &resultType, bool isCallOn = true );
220
221//OperatorProc.cpp
222void FreeTempObject(int reg,const CClass *pobj_c);
223int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack, LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
224void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
225void CallIndexerGetterProc( const Type &classType, const char *ObjectName, char *Parameter,Type &resultType, DWORD dwProcFlags = 0 );
226
227//Compile_Statement.cpp
228void OpcodeOthers( const char *Command );
229void OpcodeIf(char *Parameter);
230void OpcodeGoto(char *Parameter);
231void OpcodeWhile(char *Parameter);
232void OpcodeFor(char *Parameter);
233void OpcodeForeach( const char *Parameter );
234void OpcodeDo(char *Parameter);
235void OpcodeContinue(void);
236void OpcodeExitSub(void);
237void OpcodeSelect(const char *lpszParms);
238void OpcodeCase(char *Parameter);
239void OpcodeGosub(char *Parameter);
240void OpcodeReturn(char *Parameter);
241void OpcodeSetPtrData(char *Parameter,int type);
242
243
244
245
246//op32_main.cpp
247BOOL IsSafeReg(int reg);
Note: See TracBrowser for help on using the repository browser.