#pragma once #include #include "Type.h" #include "Procedure.h" class CClass; #define ACCESS_NON 0 #define ACCESS_PRIVATE 1 #define ACCESS_PUBLIC 2 #define ACCESS_PROTECTED 3 class CMember : public Type { bool isConst; public: char *name; int SubScripts[MAX_ARRAYDIM]; DWORD dwAccess; char *InitBuf; char *ConstractParameter; int source_code_address; CMember( CClass *pobj_c, DWORD access, bool idConst, bool isRef, char *buffer, int nowLine=-1 ); CMember( CMember &member ); CMember(); ~CMember(); bool IsConst(); static void InitStaticMember(void); }; class CMethod { public: UserProc *pUserProc; DWORD dwAccess; BOOL bAbstract; BOOL bVirtual; bool isConst; bool isStatic; const CClass *pobj_InheritsClass; CMethod(CMethod *pobj); CMethod( UserProc *pUserProc, DWORD dwAccess, BOOL bAbstract, BOOL bVirtual, bool isConst, bool isStatic ); ~CMethod(); }; class CDBClass; class CDebugSection; class CClass{ friend CMember; friend CDBClass; friend CDebugSection; // 名前空間 NamespaceScopes namespaceScopes; NamespaceScopesCollection importedNamespaces; // Blittable型情報 Type blittableType; //静的メンバ情報 std::vector staticMembers; //メソッド情報 std::vector methods; int ConstructorMemberSubIndex; int DestructorMemberSubIndex; //静的メソッド情報 std::vector staticMethods; enum ClassType{ Class, Interface, Enum, Delegate, Structure, }; ClassType classType; mutable bool isUsing; public: //クラス名 char *name; //継承クラスへのポインタ const CClass *pobj_InheritsClass; //メンバ情報 CMember **ppobj_Member; int iMemberNum; //仮想関数の数 int vtbl_num; //アラインメント値 int iAlign; public: CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name ); ~CClass(); const NamespaceScopes &GetNamespaceScopes() const { return namespaceScopes; } const NamespaceScopesCollection &GetImportedNamespaces() const { return importedNamespaces; } const string GetName() const { return name; } bool IsBlittableType() const { return !blittableType.IsNull(); } const Type &GetBlittableType() const { return blittableType; } void SetBlittableType( const Type &type ){ blittableType = type; } bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; bool IsEqualSymbol( const CClass &objClass ) const; bool IsEqualSymbol( const string &name ) const; bool IsUsing() const; void Using() const; bool IsClass() const; bool IsInterface() const; bool IsEnum() const; bool IsDelegate() const; bool IsStructure() const; //継承させる bool Inherits( const CClass &inheritsClass, int nowLine ); bool InheritsInterface( const CClass &inheritsClass, int nowLine ); //メンバ、メソッドの追加 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer ); void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int nowLine ); void AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ); void AddStaticMethod(UserProc *pUserProc,DWORD dwAccess); //重複チェック BOOL DupliCheckAll(const char *name); BOOL DupliCheckMember(const char *name); //メソッド取得 CMethod *GetMethodInfo( UserProc *pUserProc ) const; CMethod *GetStaticMethodInfo( UserProc *pUserProc ) const; //メソッドの存在を確認 bool IsExistMethod( const char *name ) const; bool IsExistStaticMethod( const char *name ) const; //メソッドを列挙 void EnumStaticMethod( const char *methodName, vector &subs ) const; void EnumMethod( const char *methodName, vector &subs ) const; void EnumMethod( const BYTE idOperatorCalc, vector &subs ) const; const std::vector &GetMethods() const { return methods; } const std::vector &GetStaticMethods() const { return staticMethods; } //デフォルト コンストラクタ メソッドを取得 CMethod *GetConstructorMethod() 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 IsEquals( const CClass *pClass ) 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, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract, BOOL bVirtual, BOOL bOverride, 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; CMethod *pCompilingMethod; public: //コンパイル開始の通知を受け取るメソッド void StartCompile( UserProc *pUserProc ); //現在コンパイル中のメソッド情報を取得 const CClass *GetNowCompilingClass() 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;