source: dev/BasicCompiler_Common/Class.h@ 78

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

CTypeDef → TypeDef
Houseクラスを追加。
オーバーロードレベルの種類を追加(レベル1に挿入)

File size: 5.7 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 Structure,
74 Interface,
75 };
76
77 ClassType classType;
78
79public:
80 //クラス名
81 char *name;
82
83 //継承クラスへのポインタ
84 CClass *pobj_InheritsClass;
85
86 //メンバ情報
87 CMember **ppobj_Member;
88 int iMemberNum;
89
90 //仮想関数の数
91 int vtbl_num;
92
93 //アラインメント値
94 int iAlign;
95
96
97public:
98 CClass(const char *name);
99 ~CClass();
100
101 bool IsStructure() const;
102
103 //継承させる
104 void Inherits( CClass *pInheritsClass );
105
106 //メンバ、メソッドの追加
107 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer );
108 void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int nowLine );
109 void AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
110 void AddStaticMethod(UserProc *pUserProc,DWORD dwAccess);
111
112 //重複チェック
113 BOOL DupliCheckAll(const char *name);
114 BOOL DupliCheckMember(const char *name);
115
116 //メソッド取得
117 CMethod *GetMethodInfo( UserProc *pUserProc ) const;
118 CMethod *GetStaticMethodInfo( UserProc *pUserProc ) const;
119
120 //メソッドの存在を確認
121 bool IsExistMethod( const char *name ) const;
122 bool IsExistStaticMethod( const char *name ) const;
123
124 //メソッドを列挙
125 void EnumStaticMethod( const char *methodName, std::vector<UserProc *> &subs ) const;
126 void EnumMethod( const char *methodName, std::vector<UserProc *> &subs ) const;
127 void EnumMethod( const BYTE idOperatorCalc, std::vector<UserProc *> &subs ) const;
128
129 //デフォルト コンストラクタ メソッドを取得
130 CMethod *GetConstructorMethod() const;
131
132 //デストラクタ メソッドを取得
133 CMethod *GetDestructorMethod() const;
134
135 // メンバの総合サイズを取得
136 int GetSize() const;
137
138 // メンバのオフセットを取得
139 int GetMemberOffset( const char *memberName, int *pMemberNum ) const;
140
141private:
142 // アラインメント値を取得
143 int GetAlignment() const;
144
145
146 //vtbl
147private:
148 long vtbl_offset;
149public:
150 int GetFuncNumInVtbl( const UserProc *pUserProc ) const;
151 LONG_PTR GetVtblGlobalOffset(void);
152 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
153 bool IsAbstract() const;
154
155
156 //コンストラクタをコンパイルしているかどうかのチェックフラグ
157private:
158 bool isCompilingConstructor;
159public:
160 void NotifyStartConstructorCompile();
161 void NotifyFinishConstructorCompile();
162 bool IsCompilingConstructor() const;
163
164 //デストラクタをコンパイルしているかどうかのチェックフラグ
165private:
166 bool isCompilingDestructor;
167public:
168 void NotifyStartDestructorCompile();
169 void NotifyFinishDestructorCompile();
170 bool IsCompilingDestructor() const;
171
172
173 //自身と等しいクラスかどうかを確認
174 bool IsEquals( const CClass *pClass ) const;
175
176 //自身の派生クラスかどうかを確認
177 bool IsSubClass( const CClass *pClass ) const;
178
179 //自身と等しいまたは派生クラスかどうかを確認
180 bool IsEqualsOrSubClass( const CClass *pClass ) const;
181
182
183 //線形リスト用
184 CClass *pobj_NextClass;
185
186
187 //メンバの参照方法
188 enum RefType{
189 Dot, // obj.member
190 Pointer, // obj->member
191 Non, // no reference member
192 };
193};
194
195#define MAX_CLASS_HASH 65535
196class CDBClass{
197 int hash(const char *name);
198 void DestroyClass(CClass *pobj_c);
199public:
200 CClass *pobj_ClassHash[MAX_CLASS_HASH];
201
202 CDBClass();
203 ~CDBClass();
204
205 CClass *check(const char *name);
206
207 CClass *AddClass(const char *name,int nowLine);
208
209 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
210
211private:
212 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
213 BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine);
214 BOOL MemberVar_LoopRefCheck(const CClass &objClass);
215public:
216 void InitNames(void);
217 void GetClass_recur(const char *lpszInheritsClass);
218 void GetAllClassInfo(void);
219
220
221 /////////////////////////////
222 // 特殊クラス
223 /////////////////////////////
224 CClass *pStringClass;
225 CClass *pObjectClass;
226 CClass *GetStringClass() const;
227 CClass *GetObjectClass() const;
228
229
230 /////////////////////////////
231 // 現在コンパイル中の情報
232 /////////////////////////////
233private:
234 CClass *pCompilingClass;
235 CMethod *pCompilingMethod;
236public:
237 //コンパイル開始の通知を受け取るメソッド
238 void StartCompile( UserProc *pUserProc );
239
240 //現在コンパイル中のメソッド情報を取得
241 CClass *GetNowCompilingClass();
242 CMethod *GetNowCompilingMethodInfo();
243
244
245 /////////////////////
246 // イテレータ
247 /////////////////////
248private:
249 CClass **ppobj_IteClass;
250 int iIteMaxNum;
251 int iIteNextNum;
252public:
253 void Iterator_Reset(void);
254 BOOL Iterator_HasNext(void);
255 CClass *Iterator_GetNext(void);
256 int Iterator_GetMaxCount(void);
257};
258
259
260extern CDBClass *pobj_DBClass;
261extern CClass *pobj_CompilingClass;
Note: See TracBrowser for help on using the repository browser.