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