source: dev/BasicCompiler_Common/Class.h@ 51

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

ppobj_Member及びppobj_StaticMemberを廃止し、vectorに統一した(methods及びstaticMethods)。

File size: 5.1 KB
Line 
1#include <vector>
2
3class CClass;
4struct SUBINFO;
5
6//データ型
7struct TYPEINFO{
8 int type;
9 union{
10 LONG_PTR lpIndex;
11 CClass *pobj_Class;
12 }u;
13};
14
15#define ACCESS_NON 0
16#define ACCESS_PRIVATE 1
17#define ACCESS_PUBLIC 2
18#define ACCESS_PROTECTED 3
19
20class CMember{
21 bool isConst;
22 bool isRef;
23public:
24 char *name;
25 int SubScripts[MAX_ARRAYDIM];
26 TYPEINFO TypeInfo;
27
28 DWORD dwAccess;
29
30 char *InitBuf;
31 char *ConstractParameter;
32
33 int source_code_address;
34
35
36 CMember( CClass *pobj_c, DWORD access, bool idConst, bool isRef, char *buffer, int NowLine=-1 );
37 CMember( CMember *pobj );
38 CMember();
39 ~CMember();
40
41 bool IsConst();
42 bool IsRef();
43 int GetSize();
44
45
46 static void InitStaticMember(void);
47};
48class CMethod{
49public:
50 SUBINFO *psi;
51 DWORD dwAccess;
52 BOOL bAbstract;
53 BOOL bVirtual;
54 bool isConst;
55
56 CClass *pobj_InheritsClass;
57
58 CMethod(CMethod *pobj);
59 CMethod();
60 ~CMethod();
61};
62class CDBClass;
63class CDebugSection;
64class CClass{
65 friend CDBClass;
66 friend CDebugSection;
67
68 //メソッド情報
69 std::vector<CMethod *> methods;
70 int ConstructorMemberSubIndex;
71 int CopyConstructorMemberSubIndex;
72 int DestructorMemberSubIndex;
73
74 //静的メソッド情報
75 std::vector<CMethod *> staticMethods;
76
77public:
78 //クラス名
79 char *name;
80
81 //継承クラスへのポインタ
82 CClass *pobj_InheritsClass;
83
84 //メンバ情報
85 CMember **ppobj_Member;
86 int iMemberNum;
87
88 //静的メンバ情報
89 CMember **ppobj_StaticMember;
90 int iStaticMemberNum;
91
92 //仮想関数の数
93 int vtbl_num;
94
95 //アラインメント値
96 int iAlign;
97
98
99public:
100 CClass(const char *name);
101 ~CClass();
102
103 //継承させる
104 void Inherits( CClass *pInheritsClass );
105
106 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer );
107 void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine );
108 void AddMethod( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
109 void AddStaticMethod(SUBINFO *psi,DWORD dwAccess);
110
111 BOOL DupliCheckAll(const char *name);
112 BOOL DupliCheckMember(const char *name);
113
114 //メソッド取得
115 CMethod *GetMethodInfo( SUBINFO *psi );
116 CMethod *GetStaticMethodInfo( SUBINFO *psi );
117
118 //メソッドの存在を確認
119 bool IsExistMethod( const char *name );
120 bool IsExistStaticMethod( const char *name );
121
122 //メソッドを列挙
123 void EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const;
124 void EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const;
125 void EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const;
126
127 //デフォルト コンストラクタ メソッドを取得
128 CMethod *GetConstructorMethod() const;
129
130 //デフォルト コピーコンストラクタ メソッドを取得
131 CMethod *GetCopyConstructorMethod() const;
132
133 //デストラクタ メソッドを取得
134 CMethod *GetDestructorMethod() const;
135
136
137 //vtbl
138private:
139 long vtbl_offset;
140 LONG_PTR AddVtblDataTable(SUBINFO **ppsi,int length);
141public:
142 int GetFuncNumInVtbl( const SUBINFO *psi ) const;
143 LONG_PTR GetVtblGlobalOffset(void);
144 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
145 bool IsAbstract();
146
147
148 //コンストラクタをコンパイルしているかどうかのチェックフラグ
149private:
150 bool isCompilingConstructor;
151public:
152 void NotifyStartConstructorCompile();
153 void NotifyFinishConstructorCompile();
154 bool IsCompilingConstructor();
155
156 //デストラクタをコンパイルしているかどうかのチェックフラグ
157private:
158 bool isCompilingDestructor;
159public:
160 void NotifyStartDestructorCompile();
161 void NotifyFinishDestructorCompile();
162 bool IsCompilingDestructor();
163
164
165 //自身と等しいクラスかどうかを確認
166 bool IsEquals( CClass *pClass );
167
168 //自身の派生クラスかどうかを確認
169 bool IsSubClass( CClass *pClass );
170
171
172 //線形リスト用
173 CClass *pobj_NextClass;
174};
175
176#define MAX_CLASS_HASH 65535
177class CDBClass{
178 int hash(const char *name);
179 void DestroyClass(CClass *pobj_c);
180public:
181 CClass *pobj_ClassHash[MAX_CLASS_HASH];
182
183 CDBClass();
184 ~CDBClass();
185
186 CClass *check(const char *name);
187
188 CClass *AddClass(const char *name,int NowLine);
189
190 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
191
192private:
193 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
194 BOOL bVirtual, BOOL bOverride, char *buffer, int NowLine);
195 BOOL MemberVar_LoopRefCheck(CClass *pobj_c);
196public:
197 void InitNames(void);
198 void GetClass_recur(const char *lpszInheritsClass);
199 void GetObjectClassInfo(void);
200
201
202 /////////////////////////////
203 // 現在コンパイル中の情報
204 /////////////////////////////
205private:
206 CClass *pCompilingClass;
207 CMethod *pCompilingMethod;
208public:
209 //コンパイル開始の通知を受け取るメソッド
210 void StartCompile( SUBINFO *psi );
211
212 //現在コンパイル中のメソッド情報を取得
213 CClass *GetNowCompilingClass();
214 CMethod *GetNowCompilingMethodInfo();
215
216
217 /////////////////////
218 // イテレータ
219 /////////////////////
220private:
221 CClass **ppobj_IteClass;
222 int iIteMaxNum;
223 int iIteNextNum;
224public:
225 void Iterator_Reset(void);
226 BOOL Iterator_HasNext(void);
227 CClass *Iterator_GetNext(void);
228 int Iterator_GetMaxCount(void);
229};
230
231
232extern CDBClass *pobj_DBClass;
233extern CClass *pobj_CompilingClass;
Note: See TracBrowser for help on using the repository browser.