#pragma once #include "Prototype.h" #include "Member.h" #include "Method.h" 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 { public: // メンバの参照方法 enum RefType{ Non = 0, // no reference member Dot, // obj.member Pointer, // obj->member }; // 型の種類 enum ClassType{ Class, Interface, Enum, Delegate, Structure, }; private: ClassType classType; bool isReady; void Readed(){ isReady = true; } bool IsReady() const{ return isReady; } // importされている名前空間 NamespaceScopesCollection importedNamespaces; // 継承するインターフェイス Interfaces interfaces; // Blittable型情報 Type blittableType; // 動的メンバ Members dynamicMembers; // 静的メンバ Members staticMembers; // 動的メソッド Methods methods; int ConstructorMemberSubIndex; int DestructorMemberSubIndex; int vtblNum; // 仮想関数の数 // 静的メソッド Methods staticMethods; public: //継承クラスへのポインタ const CClass *pobj_InheritsClass; //アラインメント値 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 Members &GetDynamicMembers() const { return dynamicMembers; } const Methods &GetMethods() const { return methods; } const Methods &GetStaticMethods() const { return staticMethods; } //デフォルト コンストラクタ メソッドを取得 const CMethod *GetConstructorMethod() const; //デストラクタ メソッドを取得 const CMethod *GetDestructorMethod() const; // vtblに存在する仮想関数の数 int GetVtblNum() const { return vtblNum; } void SetVtblNum( int vtblNum ) { this->vtblNum = vtblNum; } void AddVtblNum( int vtblNum ) { this->vtblNum += vtblNum; } bool IsExistVirtualFunctions() const { return ( vtblNum > 0 ); } // メンバの総合サイズを取得 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; static bool SplitName( const char *desc, char *object, char *member, CClass::RefType &refType ){ int lastIndex = -1; for( int i=0; desc[i]; i++ ){ if( desc[i] == '(' ){ i=BasicSource::JumpStringInPare(desc,i+1); continue; } else if( desc[i] == '[' ){ i=BasicSource::JumpStringInBracket(desc,i+1); continue; } else if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM)){ lastIndex = i; } } if( lastIndex == -1 ){ lstrcpy( member, desc ); return false; } if(desc[lastIndex]=='.'){ lstrcpy(member,desc+lastIndex+1); refType = CClass::Dot; } else{ lstrcpy(member,desc+lastIndex+2); refType = CClass::Pointer; } if( object ){ lstrcpy( object, desc ); object[lastIndex]=0; } return true; } static bool SplitName( const char *desc, char *object, char *member ){ CClass::RefType dummyRefType; return SplitName( desc, object, member, dummyRefType ); } }; class Classes { };