source: dev/BasicCompiler_Common/Class.h@ 91

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

ログ機構(Smoothie::Logger)を導入。
動的型情報生成において、未使用クラスの登録は行わないようにした。

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