source: dev/BasicCompiler_Common/Class.h@ 29

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

Ver5.0β10としてリリース。
すべてのクラスをObjectからの派生にした。

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