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