#pragma once #include #include #include #include #include #include "Procedure.h" class CDBClass; class CDebugSection; class CClass; class InheritedInterface { CClass *pInterfaceClass; int vtblOffset; public: InheritedInterface( CClass *pInterfaceClass, int vtblOffset ) : pInterfaceClass( pInterfaceClass ) , vtblOffset( vtblOffset ) { } CClass &GetInterfaceClass() const{ return *pInterfaceClass; } int GetVtblOffset() const { return vtblOffset; } }; typedef vector Interfaces; class CClass : public Prototype { friend CMember; friend CDBClass; friend CDebugSection; // importされている名前空間 NamespaceScopesCollection importedNamespaces; // 継承するインターフェイス Interfaces interfaces; // Blittable型情報 Type blittableType; //静的メンバ情報 std::vector staticMembers; //メソッド情報 Methods methods; int ConstructorMemberSubIndex; int DestructorMemberSubIndex; //静的メソッド情報 Methods staticMethods; enum ClassType{ Class, Interface, Enum, Delegate, Structure, }; ClassType classType; public: //継承クラスへのポインタ const CClass *pobj_InheritsClass; //メンバ情報 CMember **ppobj_Member; int iMemberNum; //仮想関数の数 int vtbl_num; //アラインメント値 int iAlign; CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ); ~CClass(); const NamespaceScopesCollection &GetImportedNamespaces() const { return importedNamespaces; } // インターフェイス bool HasInterfaces() const { return ( interfaces.size() != 0 ); } bool IsInheritsInterface( const CClass *pInterfaceClass ) const; // Blittable型 bool IsBlittableType() const { return !blittableType.IsNull(); } const Type &GetBlittableType() const { return blittableType; } void SetBlittableType( const Type &type ){ blittableType = type; } bool IsClass() const; bool IsInterface() const; bool IsEnum() const; bool IsDelegate() const; bool IsStructure() const; //継承させる bool Inherits( const char *inheritNames, int nowLine ); bool InheritsClass( const CClass &inheritsClass, int nowLine ); bool InheritsInterface( const CClass &inheritsClass, int nowLine ); //メンバ、メソッドの追加 void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer ); void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ); //重複チェック BOOL DupliCheckAll(const char *name); BOOL DupliCheckMember(const char *name); const Methods &GetMethods() const { return methods; } const Methods &GetStaticMethods() const { return staticMethods; } //デフォルト コンストラクタ メソッドを取得 const CMethod *GetConstructorMethod() const; //デストラクタ メソッドを取得 const CMethod *GetDestructorMethod() const; // メンバの総合サイズを取得 int GetSize() const; // メンバのオフセットを取得 int GetMemberOffset( const char *memberName, int *pMemberNum = NULL ) const; private: // アラインメント値を取得 int GetAlignment() const; //vtbl private: mutable long vtbl_offset; public: int GetFuncNumInVtbl( const UserProc *pUserProc ) const; LONG_PTR GetVtblGlobalOffset(void) const; void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); bool IsAbstract() const; //コンストラクタをコンパイルしているかどうかのチェックフラグ private: mutable bool isCompilingConstructor; public: void NotifyStartConstructorCompile() const; void NotifyFinishConstructorCompile() const; bool IsCompilingConstructor() const; //デストラクタをコンパイルしているかどうかのチェックフラグ private: mutable bool isCompilingDestructor; public: void NotifyStartDestructorCompile() const; void NotifyFinishDestructorCompile() const; bool IsCompilingDestructor() const; //自身の派生クラスかどうかを確認 bool IsSubClass( const CClass *pClass ) const; //自身と等しいまたは派生クラスかどうかを確認 bool IsEqualsOrSubClass( const CClass *pClass ) const; // 自身と等しいまたは派生クラス、基底クラスかどうかを確認 bool IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const; //線形リスト用 CClass *pobj_NextClass; //メンバの参照方法 enum RefType{ Non = 0, // no reference member Dot, // obj.member Pointer, // obj->member }; }; #define MAX_CLASS_HASH 65535 class CDBClass{ int hash(const char *name) const; void DestroyClass(CClass *pobj_c); public: CClass *pobj_ClassHash[MAX_CLASS_HASH]; CDBClass(); ~CDBClass(); const CClass *Find( const string &fullName ) const; const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const; CClass *AddClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); private: void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, bool isVirtual, bool isOverride, char *buffer, int nowLine); BOOL MemberVar_LoopRefCheck(const CClass &objClass); public: void InitNames(void); void GetClass_recur(const char *lpszInheritsClass); void GetAllClassInfo(void); void Compile_System_InitializeUserTypes(); ///////////////////////////// // 特殊クラス ///////////////////////////// CClass *pStringClass; CClass *pObjectClass; CClass *GetStringClassPtr() const; CClass *GetObjectClassPtr() const; ///////////////////////////// // 現在コンパイル中の情報 ///////////////////////////// private: const CClass *pCompilingClass; const CMethod *pCompilingMethod; public: //コンパイル開始の通知を受け取るメソッド void StartCompile( UserProc *pUserProc ); //現在コンパイル中のメソッド情報を取得 const CClass *GetNowCompilingClass() const; const CMethod *GetNowCompilingMethodInfo(); ///////////////////// // イテレータ ///////////////////// private: CClass **ppobj_IteClass; int iIteMaxNum; int iIteNextNum; public: void Iterator_Init(void); void Iterator_Reset(void); BOOL Iterator_HasNext(void); CClass *Iterator_GetNext(void); int Iterator_GetMaxCount(void); }; extern CDBClass *pobj_DBClass; extern const CClass *pobj_CompilingClass;