source: dev/BasicCompiler_Common/Class.h@ 90

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

実行時型情報の生成にほぼ対応した。

File size: 6.0 KB
RevLine 
[78]1#pragma once
2
[50]3#include <vector>
[75]4#include "Type.h"
[4]5
6class CClass;
[75]7class UserProc;
[4]8
9#define ACCESS_NON 0
10#define ACCESS_PRIVATE 1
11#define ACCESS_PUBLIC 2
12#define ACCESS_PROTECTED 3
13
[75]14class CMember : public Type
15{
[17]16 bool isConst;
[4]17public:
18 char *name;
19 int SubScripts[MAX_ARRAYDIM];
20
21 DWORD dwAccess;
22
23 char *InitBuf;
24 char *ConstractParameter;
25
26 int source_code_address;
27
28
[75]29 CMember( CClass *pobj_c, DWORD access, bool idConst, bool isRef, char *buffer, int nowLine=-1 );
30 CMember( CMember &member );
[4]31 CMember();
32 ~CMember();
33
[17]34 bool IsConst();
[4]35
[17]36
[4]37 static void InitStaticMember(void);
38};
39class CMethod{
40public:
[75]41 UserProc *pUserProc;
[4]42 DWORD dwAccess;
43 BOOL bAbstract;
44 BOOL bVirtual;
[18]45 bool isConst;
[4]46
47 CClass *pobj_InheritsClass;
48
49 CMethod(CMethod *pobj);
50 CMethod();
51 ~CMethod();
52};
[51]53class CDBClass;
54class CDebugSection;
[4]55class CClass{
[53]56 friend CMember;
[51]57 friend CDBClass;
58 friend CDebugSection;
59
[53]60 //静的メンバ情報
61 std::vector<CMember *>staticMembers;
62
[51]63 //メソッド情報
64 std::vector<CMethod *> methods;
65 int ConstructorMemberSubIndex;
66 int DestructorMemberSubIndex;
67
[50]68 //静的メソッド情報
[51]69 std::vector<CMethod *> staticMethods;
[50]70
[64]71 enum ClassType{
72 Class,
[90]73 Interface,
74 Enum,
75 Delegate,
[64]76 Structure,
77 };
78
79 ClassType classType;
80
[4]81public:
82 //クラス名
83 char *name;
84
85 //継承クラスへのポインタ
86 CClass *pobj_InheritsClass;
87
88 //メンバ情報
89 CMember **ppobj_Member;
90 int iMemberNum;
91
92 //仮想関数の数
93 int vtbl_num;
94
95 //アラインメント値
96 int iAlign;
97
98
99public:
[46]100 CClass(const char *name);
[4]101 ~CClass();
102
[90]103 bool IsClass() const;
104 bool IsInterface() const;
105 bool IsEnum() const;
106 bool IsDelegate() const;
[64]107 bool IsStructure() const;
108
[29]109 //継承させる
[90]110 bool Inherits( CClass &inheritsClass, int nowLine );
111 bool InheritsInterface( CClass &inheritsClass, int nowLine );
[29]112
[53]113 //メンバ、メソッドの追加
[40]114 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer );
[75]115 void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int nowLine );
116 void AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
117 void AddStaticMethod(UserProc *pUserProc,DWORD dwAccess);
[4]118
[53]119 //重複チェック
[46]120 BOOL DupliCheckAll(const char *name);
121 BOOL DupliCheckMember(const char *name);
[4]122
[28]123 //メソッド取得
[75]124 CMethod *GetMethodInfo( UserProc *pUserProc ) const;
125 CMethod *GetStaticMethodInfo( UserProc *pUserProc ) const;
[28]126
127 //メソッドの存在を確認
[75]128 bool IsExistMethod( const char *name ) const;
129 bool IsExistStaticMethod( const char *name ) const;
[4]130
[50]131 //メソッドを列挙
[75]132 void EnumStaticMethod( const char *methodName, std::vector<UserProc *> &subs ) const;
133 void EnumMethod( const char *methodName, std::vector<UserProc *> &subs ) const;
134 void EnumMethod( const BYTE idOperatorCalc, std::vector<UserProc *> &subs ) const;
[18]135
[51]136 //デフォルト コンストラクタ メソッドを取得
137 CMethod *GetConstructorMethod() const;
[50]138
[51]139 //デストラクタ メソッドを取得
140 CMethod *GetDestructorMethod() const;
141
[63]142 // メンバの総合サイズを取得
143 int GetSize() const;
[51]144
[63]145 // メンバのオフセットを取得
146 int GetMemberOffset( const char *memberName, int *pMemberNum ) const;
147
148private:
149 // アラインメント値を取得
150 int GetAlignment() const;
151
152
[4]153 //vtbl
154private:
155 long vtbl_offset;
156public:
[75]157 int GetFuncNumInVtbl( const UserProc *pUserProc ) const;
[51]158 LONG_PTR GetVtblGlobalOffset(void);
[4]159 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
[75]160 bool IsAbstract() const;
[4]161
162
[17]163 //コンストラクタをコンパイルしているかどうかのチェックフラグ
164private:
165 bool isCompilingConstructor;
166public:
167 void NotifyStartConstructorCompile();
168 void NotifyFinishConstructorCompile();
[75]169 bool IsCompilingConstructor() const;
[17]170
[18]171 //デストラクタをコンパイルしているかどうかのチェックフラグ
172private:
173 bool isCompilingDestructor;
174public:
175 void NotifyStartDestructorCompile();
176 void NotifyFinishDestructorCompile();
[75]177 bool IsCompilingDestructor() const;
[17]178
[18]179
[28]180 //自身と等しいクラスかどうかを確認
[75]181 bool IsEquals( const CClass *pClass ) const;
[28]182
183 //自身の派生クラスかどうかを確認
[75]184 bool IsSubClass( const CClass *pClass ) const;
[28]185
[59]186 //自身と等しいまたは派生クラスかどうかを確認
[75]187 bool IsEqualsOrSubClass( const CClass *pClass ) const;
[28]188
[59]189
[4]190 //線形リスト用
191 CClass *pobj_NextClass;
[64]192
193
194 //メンバの参照方法
195 enum RefType{
196 Dot, // obj.member
197 Pointer, // obj->member
198 Non, // no reference member
199 };
[4]200};
201
202#define MAX_CLASS_HASH 65535
203class CDBClass{
[46]204 int hash(const char *name);
[4]205 void DestroyClass(CClass *pobj_c);
206public:
207 CClass *pobj_ClassHash[MAX_CLASS_HASH];
208
209 CDBClass();
210 ~CDBClass();
211
[46]212 CClass *check(const char *name);
[4]213
[75]214 CClass *AddClass(const char *name,int nowLine);
[4]215
216 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
217
218private:
[18]219 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
[75]220 BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine);
221 BOOL MemberVar_LoopRefCheck(const CClass &objClass);
[4]222public:
223 void InitNames(void);
[46]224 void GetClass_recur(const char *lpszInheritsClass);
[67]225 void GetAllClassInfo(void);
[89]226 void Compile_System_InitializeUserTypes();
[4]227
228
[18]229 /////////////////////////////
[67]230 // 特殊クラス
231 /////////////////////////////
232 CClass *pStringClass;
233 CClass *pObjectClass;
234 CClass *GetStringClass() const;
235 CClass *GetObjectClass() const;
236
237
238 /////////////////////////////
[18]239 // 現在コンパイル中の情報
240 /////////////////////////////
[4]241private:
[18]242 CClass *pCompilingClass;
243 CMethod *pCompilingMethod;
244public:
245 //コンパイル開始の通知を受け取るメソッド
[75]246 void StartCompile( UserProc *pUserProc );
[18]247
248 //現在コンパイル中のメソッド情報を取得
249 CClass *GetNowCompilingClass();
250 CMethod *GetNowCompilingMethodInfo();
251
252
253 /////////////////////
254 // イテレータ
255 /////////////////////
256private:
[4]257 CClass **ppobj_IteClass;
258 int iIteMaxNum;
259 int iIteNextNum;
260public:
[89]261 void Iterator_Init(void);
[4]262 void Iterator_Reset(void);
263 BOOL Iterator_HasNext(void);
264 CClass *Iterator_GetNext(void);
265 int Iterator_GetMaxCount(void);
266};
267
268
269extern CDBClass *pobj_DBClass;
270extern CClass *pobj_CompilingClass;
Note: See TracBrowser for help on using the repository browser.