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