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