source: dev/BasicCompiler_Common/Class.h@ 50

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

オーバーロード解決用の関数保持リストを "SUBINFO " ではなく、"vector<SUBINFO *>" に変更した。

File size: 4.7 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 CClass{
63 //静的メソッド情報
64 std::vector<CMethod *> StaticMethods;
65
66public:
67 //クラス名
68 char *name;
69
70 //継承クラスへのポインタ
71 CClass *pobj_InheritsClass;
72
73 //メンバ情報
74 CMember **ppobj_Member;
75 int iMemberNum;
76
77 //メソッド情報
78 CMethod **ppobj_Method;
79 int iMethodNum;
80 int ConstructorMemberSubIndex;
81 int DestructorMemberSubIndex;
82 int CopyConstructorMemberSubIndex;
83
84 //静的メンバ情報
85 CMember **ppobj_StaticMember;
86 int iStaticMemberNum;
87
88 //仮想関数の数
89 int vtbl_num;
90
91 //アラインメント値
92 int iAlign;
93
94
95public:
96 CClass(const char *name);
97 ~CClass();
98
99 //継承させる
100 void Inherits( CClass *pInheritsClass );
101
102 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer );
103 void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine );
104 void AddMethod( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
105 void AddStaticMethod(SUBINFO *psi,DWORD dwAccess);
106
107 BOOL DupliCheckAll(const char *name);
108 BOOL DupliCheckMember(const char *name);
109
110 //メソッド取得
111 CMethod *GetMethodInfo( SUBINFO *psi );
112 CMethod *GetStaticMethodInfo( SUBINFO *psi );
113
114 //メソッドの存在を確認
115 bool IsExistMethod( const char *name );
116 bool IsExistStaticMethod( const char *name );
117
118 //メソッドを列挙
119 void EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const;
120 void EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const;
121 void EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const;
122
123
124 //vtbl
125private:
126 long vtbl_offset;
127 LONG_PTR AddVtblDataTable(SUBINFO **ppsi,int length);
128public:
129 LONG_PTR GetVtblGlobalOffset(void);
130 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
131 bool IsAbstract();
132
133
134 //コンストラクタをコンパイルしているかどうかのチェックフラグ
135private:
136 bool isCompilingConstructor;
137public:
138 void NotifyStartConstructorCompile();
139 void NotifyFinishConstructorCompile();
140 bool IsCompilingConstructor();
141
142 //デストラクタをコンパイルしているかどうかのチェックフラグ
143private:
144 bool isCompilingDestructor;
145public:
146 void NotifyStartDestructorCompile();
147 void NotifyFinishDestructorCompile();
148 bool IsCompilingDestructor();
149
150
151 //自身と等しいクラスかどうかを確認
152 bool IsEquals( CClass *pClass );
153
154 //自身の派生クラスかどうかを確認
155 bool IsSubClass( CClass *pClass );
156
157
158 //線形リスト用
159 CClass *pobj_NextClass;
160};
161
162#define MAX_CLASS_HASH 65535
163class CDBClass{
164 int hash(const char *name);
165 void DestroyClass(CClass *pobj_c);
166public:
167 CClass *pobj_ClassHash[MAX_CLASS_HASH];
168
169 CDBClass();
170 ~CDBClass();
171
172 CClass *check(const char *name);
173
174 CClass *AddClass(const char *name,int NowLine);
175
176 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
177
178private:
179 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
180 BOOL bVirtual, BOOL bOverride, char *buffer, int NowLine);
181 BOOL MemberVar_LoopRefCheck(CClass *pobj_c);
182public:
183 void InitNames(void);
184 void GetClass_recur(const char *lpszInheritsClass);
185 void GetObjectClassInfo(void);
186
187
188 /////////////////////////////
189 // 現在コンパイル中の情報
190 /////////////////////////////
191private:
192 CClass *pCompilingClass;
193 CMethod *pCompilingMethod;
194public:
195 //コンパイル開始の通知を受け取るメソッド
196 void StartCompile( SUBINFO *psi );
197
198 //現在コンパイル中のメソッド情報を取得
199 CClass *GetNowCompilingClass();
200 CMethod *GetNowCompilingMethodInfo();
201
202
203 /////////////////////
204 // イテレータ
205 /////////////////////
206private:
207 CClass **ppobj_IteClass;
208 int iIteMaxNum;
209 int iIteNextNum;
210public:
211 void Iterator_Reset(void);
212 BOOL Iterator_HasNext(void);
213 CClass *Iterator_GetNext(void);
214 int Iterator_GetMaxCount(void);
215};
216
217
218extern CDBClass *pobj_DBClass;
219extern CClass *pobj_CompilingClass;
Note: See TracBrowser for help on using the repository browser.