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

Last change on this file since 710 was 702, checked in by dai_9181, 16 years ago
  • コンストラクタ、デストラクタの直接呼出しをエラー扱いにした。
    • コンストラクタ … New演算子にて、呼ばれるものとする。また、コンストラクタの1ステップ目にて、基底クラスのコンストラクタ呼び出しを許可する。
    • デストラクタ … Delete演算子にて呼ばれるものとする。また、デストラクタ内にて、基底クラスのコンストラクタ呼び出しが自動的に行われるものとする。

※まずは32bit版のみ対応。速やかに64bit版にマージすること。

File size: 9.7 KB
RevLine 
[206]1#pragma once
[3]2
[225]3#include "MachineFixed.h"
[206]4
5
[3]6//変数の種類
[62]7#define NON_VAR 0
8#define VAR_GLOBAL 1 // Global Variable
9#define VAR_REFGLOBAL 2 // Global Refference Variable
10#define VAR_LOCAL 3 // Local Variable
11#define VAR_REFLOCAL 4 // Local Refference Variable
12#define VAR_DIRECTMEM 5 // Direct memory
[3]13
[49]14
[3]15extern int cp;
16
[253]17#define breakpoint compiler.codeGenerator.PutOld( (char)0xCC );
[49]18
19
[3]20//プロシージャ
21struct PROCEDURE{
22 char name[255];
23 int address;
24 int types[MAX_PARMS];
25 _int8 ByVal[MAX_PARMS];
26 BOOL ReturnType;
27};
28
29//With情報
[684]30struct WithInfo
31{
32 std::string name;
33 int sourceCodePos;
34
35 WithInfo( const std::string &name, int sourceCodePos )
36 : name( name )
37 , sourceCodePos( sourceCodePos )
38 {
39 }
[3]40};
[684]41typedef std::vector<WithInfo> WithInfos;
[3]42
43
44//RSrcSection.cpp
45char *GetRSrcSectionBuffer(int *pLen);
46
47//Compile.cpp
[372]48void Compile( const char *source );
[3]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);
[290]61void SetVariableFromEax( const Type &varType, int CalcType,RELATIVE_VAR *pRelativeVar);
[129]62void OpcodeCalc( const char *Command );
[3]63
64//NumOpe.cpp
[673]65void PushReturnValue( const Type &type );
[415]66bool TermOpeOnlyVariable( const char *term, Type &resultType, RELATIVE_VAR &relativeVar, bool isWriteAccess );
[128]67bool TermOpe(
68 const char *term,
69 const Type &baseType,
70 Type &resultType,
71 bool &isLiteral,
[435]72 bool &isNeedHeapFreeStructure,
[128]73 bool *pIsClassName = NULL,
[415]74 bool isProcedureCallOnly = false,
75 bool isWriteAccess = false );
[97]76bool NumOpe( int reg,
77 const char *expression,
78 const Type &baseType,
79 Type &resultType,
[436]80 bool *pbIsNeedHeapFreeStructure = NULL );
[75]81bool NumOpe( const char *Command,
82 const Type &baseType,
83 Type &resultType,
[436]84 bool *pbIsNeedHeapFreeStructure = NULL );
[3]85
86//NumOpe_Arithmetic.cpp
87void GetStackData_ToRegister(int *type,int sp);
88BOOL CalcTwoTerm_Arithmetic(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer);
89BOOL Calc_Mod(int *type,int *pStackPointer);
90BOOL Calc_Divide(int *type,int *pStackPointer,int BaseType);
91BOOL Calc_IntDivide(int *type,LONG_PTR *index_stack,int *pStackPointer);
92BOOL Calc_MinusMark(int *type,int sp);
93BOOL Calc_Power(int *type,int *pStackPointer);
94BOOL Calc_Cast(int *type,LONG_PTR *index_stack,int *pStackPointer);
95BOOL Calc_SHL(int *type,int *pStackPointer);
96BOOL Calc_SHR(int *type,int *pStackPointer);
97
98//NumOpe_Logical.cpp
99BOOL Calc_Xor(int *type,LONG_PTR *index_stack,int *pStackPointer);
100BOOL Calc_Or(int *type,LONG_PTR *index_stack,int *pStackPointer);
101BOOL Calc_And(int *type,LONG_PTR *index_stack,int *pStackPointer);
102BOOL Calc_Not(int *type,int sp);
103
104//NumOpe_Relation.cpp
105BOOL Calc_Relation_PE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
106BOOL Calc_Relation_QE(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
107BOOL Calc_Relation_P(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
108BOOL Calc_Relation_Q(int *type_stack,LONG_PTR *index_stack,int *pStackPointer);
109BOOL Calc_Relation_NotEqual(int *type,int *pStackPointer);
110BOOL Calc_Relation_Equal(int *type,int *pStackPointer);
111
112//NumOpe_TypeOperation.cpp
[290]113void ExtendStackTo64( const Type &oldType );
114void ChangeTypeToWhole( const Type &oldType, const Type &newType );
[3]115
116//Compile_Set_Var.cpp
117BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
[75]118void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
[64]119void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
[66]120void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
[64]121
[3]122void SetDoubleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
123void SetSingleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
124void SetInt64Variable(int type,RELATIVE_VAR *pRelative);
125void SetDWordVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
126void SetLongVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
127void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
128void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset);
[36]129void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
[97]130void ExtendTypeTo64(int type);
131void ExtendTypeTo32(int type,int reg);
132void ExtendTypeTo16(int type,int reg);
[3]133
134//increment.cpp
[129]135void IncDec(int idCalc, const char *lpszLeft, const char *lpszRight);
[3]136
137//calc2.cpp
138#define EXP_TYPE_NUMBER 1
139#define EXP_TYPE_EAX 2
140#define EXP_TYPE_FPU 3
141#define EXP_TYPE_VAR 4
142int NumOpEx(char *Command,double *pDbl,DWORD *pdwType,RELATIVE_VAR *pRelativeVar);
143
144//SetVar.cpp
145BOOL SetVariable(DWORD dwVarType,RELATIVE_VAR *pVarRelativeVar,
146 DWORD dwExpType,DWORD dwType,void *data);
147
148//Compile_Calc_PushVar.cpp
149void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar);
[308]150void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
[3]151void PushLongVariable(RELATIVE_VAR *pRelativeVar);
152
153//Compile_Object.cpp
[75]154void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
[64]155void OpcodeDelete(const char *Parameter, bool isSweeping);
[3]156
157//Compile_Var.cpp
[66]158void SetRelativeOffset( RELATIVE_VAR &relativeVar );
[290]159bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const Type &classType, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
[3]160void SetThisPtrToReg(int reg);
[206]161bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts = NULL );
162bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *InitBuf);
[8]163#define DIMFLAG_INITDEBUGVAR 1
164#define DIMFLAG_NONCALL_CONSTRACTOR 2
165#define DIMFLAG_STATIC 4
166#define DIMFLAG_CONST 8
[299]167void dim( char *VarName, const Subscripts &subscripts, const Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
[3]168void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
[97]169void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
[95]170bool Compile_AddGlobalRootsForGc();
[3]171
[71]172//ParamImpl.cpp
173class ParamImpl{
[3]174 char *Parms[255];
[376]175 Types types;
[3]176 int ParmsNum;
177
[292]178 Type leftType;
[76]179 Type returnType;
[3]180
[20]181 //一時オブジェクト管理用
182 bool useTempObject;
183 bool useTempParameters[255];
[436]184 bool isNeedFreeStructures[255];
[20]185 int nCountOfTempObjects;
186
[3]187public:
[71]188 ParamImpl(const char *buffer);
[75]189 ParamImpl(const Parameters &params);
[71]190 ~ParamImpl();
[292]191 void SetLeftType( const Type &type )
192 {
193 this->leftType = type;
194 }
[75]195 void SetReturnType( const Type &returnType );
[3]196
197private:
[424]198 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, const Type &leftType, const UserProc &userProc, bool &isErrored );
[3]199public:
[424]200 const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType );
201 const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType = false );
[3]202
[77]203 void ApplyDefaultParameters( const Parameters &params );
[523]204 bool ErrorCheck( const std::string &procName, const Parameters &params, int SecondParmNum = -1 );
[73]205 void MacroParameterSupport( const Parameters &params );
[76]206 void SetStructParameter( const Type &baseType, const char *expression );
[523]207 int SetParameter( const std::string &procName, const Parameters &params, int SecondParmNum = -1, const UserProc *pUserProc = NULL );
[20]208
209 //一時オブジェクトパラメータの生成と破棄
[523]210 int NewTempParameters( const std::string &procName, const Parameters &params, int SecondParmNum = -1 );
[20]211 void DeleteTempParameters();
[3]212};
213
214//Compile_CallProc.cpp
[702]215#define PROCFLAG_NEW 1
216#define PROCFLAG_PERMIT_CONSTRUCTOR 2
217#define PROCFLAG_PERMIT_DESTRUCTOR 4
[76]218bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
[290]219bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName );
[250]220bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
[325]221void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params );
[3]222
223//Compile_ProcOp.cpp
[316]224void _compile_proc(const UserProc *pUserProc);
[3]225
226//Compile_Func.cpp
227int GetFunctionFromName(char *FuncName);
[331]228bool Opcode_CallFunc( const char *Parameter, const int FuncNum, const Type &baseType, Type &resultType, bool isCallOn = true );
[3]229
230//OperatorProc.cpp
[76]231void FreeTempObject(int reg,const CClass *pobj_c);
[435]232int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack, LONG_PTR *index_stack,bool isNeedHeapFreeStructureStack[],int &sp);
[75]233void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
[334]234void CallIndexerGetterProc( const Type &classType, const char *ObjectName, char *Parameter,Type &resultType, DWORD dwProcFlags = 0 );
[3]235
236//Compile_Statement.cpp
[129]237void OpcodeOthers( const char *Command );
[3]238void OpcodeIf(char *Parameter);
239void OpcodeGoto(char *Parameter);
240void OpcodeWhile(char *Parameter);
241void OpcodeFor(char *Parameter);
[372]242void OpcodeForeach( const char *Parameter );
[3]243void OpcodeDo(char *Parameter);
244void OpcodeContinue(void);
245void OpcodeExitSub(void);
[76]246void OpcodeSelect(const char *lpszParms);
[3]247void OpcodeCase(char *Parameter);
248void OpcodeGosub(char *Parameter);
249void OpcodeReturn(char *Parameter);
250void OpcodeSetPtrData(char *Parameter,int type);
251
252
253
254
255//op32_main.cpp
256BOOL IsSafeReg(int reg);
Note: See TracBrowser for help on using the repository browser.