source: dev/BasicCompiler_Common/Class.h@ 27

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

静的メンバ、静的メソッド周りを修正。

File size: 4.2 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 void AddMember( DWORD dwAccess, bool idConst, char *buffer );
98 void AddStaticMember( DWORD dwAccess, bool isConst, char *buffer, int NowLine );
99 void AddMethod( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
100 void AddStaticMethod(SUBINFO *psi,DWORD dwAccess);
101
102 BOOL DupliCheckAll(char *name);
103 BOOL DupliCheckMember(char *name);
104
105 CMethod *GetMethodInfo( SUBINFO *psi );
106 CMethod *GetStaticMethodInfo( SUBINFO *psi );
107 bool IsExistMethod( char *name );
108 bool IsExistStaticMethod( char *name );
109
110
111 //vtbl
112private:
113 long vtbl_offset;
114 LONG_PTR AddVtblDataTable(SUBINFO **ppsi,int length);
115public:
116 LONG_PTR GetVtblGlobalOffset(void);
117 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
118 BOOL IsHoldAbstractFunction(void);
119
120
121 //オペレータ関数の取得
122 SUBINFO **GetOperatorSubInfo(BYTE idCalc,int &num);
123
124
125 //コンストラクタをコンパイルしているかどうかのチェックフラグ
126private:
127 bool isCompilingConstructor;
128public:
129 void NotifyStartConstructorCompile();
130 void NotifyFinishConstructorCompile();
131 bool IsCompilingConstructor();
132
133 //デストラクタをコンパイルしているかどうかのチェックフラグ
134private:
135 bool isCompilingDestructor;
136public:
137 void NotifyStartDestructorCompile();
138 void NotifyFinishDestructorCompile();
139 bool IsCompilingDestructor();
140
141
142 //線形リスト用
143 CClass *pobj_NextClass;
144};
145
146#define MAX_CLASS_HASH 65535
147class CDBClass{
148 int hash(char *name);
149 void DestroyClass(CClass *pobj_c);
150public:
151 CClass *pobj_ClassHash[MAX_CLASS_HASH];
152
153 CDBClass();
154 ~CDBClass();
155
156 CClass *check(char *name);
157
158 CClass *AddClass(char *name,int NowLine);
159
160 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
161
162private:
163 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
164 BOOL bVirtual, BOOL bOverride, char *buffer, int NowLine);
165 BOOL MemberVar_LoopRefCheck(CClass *pobj_c);
166public:
167 void InitNames(void);
168 void GetClass_recur(char *lpszInheritsClass);
169 void GetObjectClassInfo(void);
170
171
172 /////////////////////////////
173 // 現在コンパイル中の情報
174 /////////////////////////////
175private:
176 CClass *pCompilingClass;
177 CMethod *pCompilingMethod;
178public:
179 //コンパイル開始の通知を受け取るメソッド
180 void StartCompile( SUBINFO *psi );
181
182 //現在コンパイル中のメソッド情報を取得
183 CClass *GetNowCompilingClass();
184 CMethod *GetNowCompilingMethodInfo();
185
186
187 /////////////////////
188 // イテレータ
189 /////////////////////
190private:
191 CClass **ppobj_IteClass;
192 int iIteMaxNum;
193 int iIteNextNum;
194public:
195 void Iterator_Reset(void);
196 BOOL Iterator_HasNext(void);
197 CClass *Iterator_GetNext(void);
198 int Iterator_GetMaxCount(void);
199};
200
201
202extern CDBClass *pobj_DBClass;
203extern CClass *pobj_CompilingClass;
Note: See TracBrowser for help on using the repository browser.