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