source: dev/BasicCompiler_Common/Class.h@ 64

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

すべてのオブジェクトを参照型に切り替えた。

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