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