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

Last change on this file since 433 was 424, checked in by dai_9181, 17 years ago

・ジェネリックな型をパラメータに持つメソッドのオーバーロード解決に対応した。
・型パラメータの制約クラス指定に対応した。

File size: 9.4 KB
RevLine 
[206]1#pragma once
[3]2
[206]3#include <Type.h>
4#include <Procedure.h>
[225]5#include "MachineFixed.h"
[206]6
7
[3]8//変数の種類
[62]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
[3]15
[49]16
[3]17extern int cp;
18
[253]19#define breakpoint compiler.codeGenerator.PutOld( (char)0xCC );
[49]20
21
[3]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
[372]43void Compile( const char *source );
[3]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);
[290]56void SetVariableFromEax( const Type &varType, int CalcType,RELATIVE_VAR *pRelativeVar);
[129]57void OpcodeCalc( const char *Command );
[3]58
59//NumOpe.cpp
60void PushReturnValue(int type);
[415]61bool TermOpeOnlyVariable( const char *term, Type &resultType, RELATIVE_VAR &relativeVar, bool isWriteAccess );
[128]62bool TermOpe(
63 const char *term,
64 const Type &baseType,
65 Type &resultType,
66 bool &isLiteral,
67 BOOL *pbUseHeap,
68 bool *pIsClassName = NULL,
[415]69 bool isProcedureCallOnly = false,
70 bool isWriteAccess = false );
[97]71bool NumOpe( int reg,
72 const char *expression,
73 const Type &baseType,
74 Type &resultType,
75 BOOL *pbUseHeap = NULL );
[75]76bool NumOpe( const char *Command,
77 const Type &baseType,
78 Type &resultType,
79 BOOL *pbUseHeap = NULL );
[3]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
[290]108void ExtendStackTo64( const Type &oldType );
109void ChangeTypeToWhole( const Type &oldType, const Type &newType );
[3]110
111//Compile_Set_Var.cpp
112BOOL IsUse_ecx(RELATIVE_VAR *pRelativeVar);
[75]113void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap);
[64]114void SetRealVariable(int VarType, int CalcType, RELATIVE_VAR *pRelativeVar);
[66]115void SetWholeVariable( int varSize,int calcType, RELATIVE_VAR *pRelative );
[64]116
[3]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);
[36]124void SetBooleanVariable(int type,RELATIVE_VAR *pRelative);
[97]125void ExtendTypeTo64(int type);
126void ExtendTypeTo32(int type,int reg);
127void ExtendTypeTo16(int type,int reg);
[3]128
129//increment.cpp
[129]130void IncDec(int idCalc, const char *lpszLeft, const char *lpszRight);
[3]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);
[308]145void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);
[3]146void PushLongVariable(RELATIVE_VAR *pRelativeVar);
147
148//Compile_Object.cpp
[75]149void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType );
[64]150void OpcodeDelete(const char *Parameter, bool isSweeping);
[3]151
152//Compile_Var.cpp
[66]153void SetRelativeOffset( RELATIVE_VAR &relativeVar );
[290]154bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const Type &classType, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess);
[3]155void SetThisPtrToReg(int reg);
[206]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);
[8]158#define DIMFLAG_INITDEBUGVAR 1
159#define DIMFLAG_NONCALL_CONSTRACTOR 2
160#define DIMFLAG_STATIC 4
161#define DIMFLAG_CONST 8
[299]162void dim( char *VarName, const Subscripts &subscripts, const Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);
[3]163void SetVarPtrToEax(RELATIVE_VAR *pRelativeVar);
[97]164void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
[95]165bool Compile_AddGlobalRootsForGc();
[3]166
[71]167//ParamImpl.cpp
168class ParamImpl{
[3]169 char *Parms[255];
[376]170 Types types;
[3]171 int ParmsNum;
172
[292]173 Type leftType;
[76]174 Type returnType;
[3]175
[20]176 //一時オブジェクト管理用
177 bool useTempObject;
178 bool useTempParameters[255];
179 int nCountOfTempObjects;
180
[3]181public:
[71]182 ParamImpl(const char *buffer);
[75]183 ParamImpl(const Parameters &params);
[71]184 ~ParamImpl();
[292]185 void SetLeftType( const Type &type )
186 {
187 this->leftType = type;
188 }
[75]189 void SetReturnType( const Type &returnType );
[3]190
191private:
[424]192 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, const Type &leftType, const UserProc &userProc, bool &isErrored );
[3]193public:
[424]194 const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType );
195 const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType = false );
[3]196
[77]197 void ApplyDefaultParameters( const Parameters &params );
[75]198 bool ErrorCheck( const string &procName, const Parameters &params, int SecondParmNum = -1 );
[73]199 void MacroParameterSupport( const Parameters &params );
[76]200 void SetStructParameter( const Type &baseType, const char *expression );
[301]201 int SetParameter( const string &procName, const Parameters &params, int SecondParmNum = -1, const UserProc *pUserProc = NULL );
[20]202
203 //一時オブジェクトパラメータの生成と破棄
[75]204 int NewTempParameters( const string &procName, const Parameters &params, int SecondParmNum = -1 );
[20]205 void DeleteTempParameters();
[3]206};
207
208//Compile_CallProc.cpp
209#define PROCFLAG_NEW 1
[76]210bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer);
[290]211bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName );
[250]212bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc );
[325]213void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params );
[3]214
215//Compile_ProcOp.cpp
[316]216void _compile_proc(const UserProc *pUserProc);
[3]217
218//Compile_Func.cpp
219int GetFunctionFromName(char *FuncName);
[331]220bool Opcode_CallFunc( const char *Parameter, const int FuncNum, const Type &baseType, Type &resultType, bool isCallOn = true );
[3]221
222//OperatorProc.cpp
[76]223void FreeTempObject(int reg,const CClass *pobj_c);
[350]224int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack, LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
[75]225void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
[334]226void CallIndexerGetterProc( const Type &classType, const char *ObjectName, char *Parameter,Type &resultType, DWORD dwProcFlags = 0 );
[3]227
228//Compile_Statement.cpp
[129]229void OpcodeOthers( const char *Command );
[3]230void OpcodeIf(char *Parameter);
231void OpcodeGoto(char *Parameter);
232void OpcodeWhile(char *Parameter);
233void OpcodeFor(char *Parameter);
[372]234void OpcodeForeach( const char *Parameter );
[3]235void OpcodeDo(char *Parameter);
236void OpcodeContinue(void);
237void OpcodeExitSub(void);
[76]238void OpcodeSelect(const char *lpszParms);
[3]239void OpcodeCase(char *Parameter);
240void OpcodeGosub(char *Parameter);
241void OpcodeReturn(char *Parameter);
242void OpcodeSetPtrData(char *Parameter,int type);
243
244
245
246
247//op32_main.cpp
248BOOL IsSafeReg(int reg);
Note: See TracBrowser for help on using the repository browser.