source: dev/BasicCompiler_Common/Class.h@ 59

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

派生クラスから基底クラスへのインスタンスコピーまたは参照を可能にした

File size: 5.2 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
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:
100 CClass(const char *name);
101 ~CClass();
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( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
110 void AddStaticMethod(SUBINFO *psi,DWORD dwAccess);
111
112 //重複チェック
113 BOOL DupliCheckAll(const char *name);
114 BOOL DupliCheckMember(const char *name);
115
116 //メソッド取得
117 CMethod *GetMethodInfo( SUBINFO *psi );
118 CMethod *GetStaticMethodInfo( SUBINFO *psi );
119
120 //メソッドの存在を確認
121 bool IsExistMethod( const char *name );
122 bool IsExistStaticMethod( const char *name );
123
124 //メソッドを列挙
125 void EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const;
126 void EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const;
127 void EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const;
128
129 //デフォルト コンストラクタ メソッドを取得
130 CMethod *GetConstructorMethod() const;
131
132 //デフォルト コピーコンストラクタ メソッドを取得
133 CMethod *GetCopyConstructorMethod() const;
134
135 //デストラクタ メソッドを取得
136 CMethod *GetDestructorMethod() const;
137
138
139 //vtbl
140private:
141 long vtbl_offset;
142public:
143 int GetFuncNumInVtbl( const SUBINFO *psi ) const;
144 LONG_PTR GetVtblGlobalOffset(void);
145 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
146 bool IsAbstract();
147
148
149 //コンストラクタをコンパイルしているかどうかのチェックフラグ
150private:
151 bool isCompilingConstructor;
152public:
153 void NotifyStartConstructorCompile();
154 void NotifyFinishConstructorCompile();
155 bool IsCompilingConstructor();
156
157 //デストラクタをコンパイルしているかどうかのチェックフラグ
158private:
159 bool isCompilingDestructor;
160public:
161 void NotifyStartDestructorCompile();
162 void NotifyFinishDestructorCompile();
163 bool IsCompilingDestructor();
164
165
166 //自身と等しいクラスかどうかを確認
167 bool IsEquals( CClass *pClass );
168
169 //自身の派生クラスかどうかを確認
170 bool IsSubClass( CClass *pClass );
171
172 //自身と等しいまたは派生クラスかどうかを確認
173 bool IsEqualsOrSubClass( CClass *pClass );
174
175
176 //線形リスト用
177 CClass *pobj_NextClass;
178};
179
180#define MAX_CLASS_HASH 65535
181class CDBClass{
182 int hash(const char *name);
183 void DestroyClass(CClass *pobj_c);
184public:
185 CClass *pobj_ClassHash[MAX_CLASS_HASH];
186
187 CDBClass();
188 ~CDBClass();
189
190 CClass *check(const char *name);
191
192 CClass *AddClass(const char *name,int NowLine);
193
194 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
195
196private:
197 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
198 BOOL bVirtual, BOOL bOverride, char *buffer, int NowLine);
199 BOOL MemberVar_LoopRefCheck(CClass *pobj_c);
200public:
201 void InitNames(void);
202 void GetClass_recur(const char *lpszInheritsClass);
203 void GetObjectClassInfo(void);
204
205
206 /////////////////////////////
207 // 現在コンパイル中の情報
208 /////////////////////////////
209private:
210 CClass *pCompilingClass;
211 CMethod *pCompilingMethod;
212public:
213 //コンパイル開始の通知を受け取るメソッド
214 void StartCompile( SUBINFO *psi );
215
216 //現在コンパイル中のメソッド情報を取得
217 CClass *GetNowCompilingClass();
218 CMethod *GetNowCompilingMethodInfo();
219
220
221 /////////////////////
222 // イテレータ
223 /////////////////////
224private:
225 CClass **ppobj_IteClass;
226 int iIteMaxNum;
227 int iIteNextNum;
228public:
229 void Iterator_Reset(void);
230 BOOL Iterator_HasNext(void);
231 CClass *Iterator_GetNext(void);
232 int Iterator_GetMaxCount(void);
233};
234
235
236extern CDBClass *pobj_DBClass;
237extern CClass *pobj_CompilingClass;
Note: See TracBrowser for help on using the repository browser.