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

Last change on this file since 828 was 828, checked in by イグトランス (egtra), 12 years ago

egtraブランチの内容をマージ。

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