source: dev/trunk/ab5.0/abdev/compiler_x86/Opcode.h@ 481

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

関数の戻り値の構造体など、一時メモリに保持された構造体のメンバに直接アクセスした場合、その一時メモリの解放が正常に行われないバグを修正(64bit版も修正した)。

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