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