#include class CClass; struct SUBINFO; //データ型 struct TYPEINFO{ int type; union{ LONG_PTR lpIndex; CClass *pobj_Class; }u; }; #define ACCESS_NON 0 #define ACCESS_PRIVATE 1 #define ACCESS_PUBLIC 2 #define ACCESS_PROTECTED 3 class CMember{ bool isConst; bool isRef; public: char *name; int SubScripts[MAX_ARRAYDIM]; TYPEINFO TypeInfo; 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 *pobj ); CMember(); ~CMember(); bool IsConst(); bool IsRef(); int GetSize(); static void InitStaticMember(void); }; class CMethod{ public: SUBINFO *psi; DWORD dwAccess; BOOL bAbstract; BOOL bVirtual; bool isConst; CClass *pobj_InheritsClass; CMethod(CMethod *pobj); CMethod(); ~CMethod(); }; class CDBClass; class CDebugSection; class CClass{ friend CMember; friend CDBClass; friend CDebugSection; //静的メンバ情報 std::vectorstaticMembers; //メソッド情報 std::vector methods; int ConstructorMemberSubIndex; int CopyConstructorMemberSubIndex; int DestructorMemberSubIndex; //静的メソッド情報 std::vector staticMethods; enum ClassType{ Class, Structure, Interface, }; ClassType classType; public: //クラス名 char *name; //継承クラスへのポインタ CClass *pobj_InheritsClass; //メンバ情報 CMember **ppobj_Member; int iMemberNum; //仮想関数の数 int vtbl_num; //アラインメント値 int iAlign; public: CClass(const char *name); ~CClass(); bool IsStructure() const; //継承させる void Inherits( CClass *pInheritsClass ); //メンバ、メソッドの追加 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer ); void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine ); void AddMethod( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ); void AddStaticMethod(SUBINFO *psi,DWORD dwAccess); //重複チェック BOOL DupliCheckAll(const char *name); BOOL DupliCheckMember(const char *name); //メソッド取得 CMethod *GetMethodInfo( SUBINFO *psi ); CMethod *GetStaticMethodInfo( SUBINFO *psi ); //メソッドの存在を確認 bool IsExistMethod( const char *name ); bool IsExistStaticMethod( const char *name ); //メソッドを列挙 void EnumStaticMethod( const char *methodName, std::vector &subs ) const; void EnumMethod( const char *methodName, std::vector &subs ) const; void EnumMethod( const BYTE idOperatorCalc, std::vector &subs ) const; //デフォルト コンストラクタ メソッドを取得 CMethod *GetConstructorMethod() const; //デフォルト コピーコンストラクタ メソッドを取得 CMethod *GetCopyConstructorMethod() const; //デストラクタ メソッドを取得 CMethod *GetDestructorMethod() const; // メンバの総合サイズを取得 int GetSize() const; // メンバのオフセットを取得 int GetMemberOffset( const char *memberName, int *pMemberNum ) const; private: // アラインメント値を取得 int GetAlignment() const; //vtbl private: long vtbl_offset; public: int GetFuncNumInVtbl( const SUBINFO *psi ) const; LONG_PTR GetVtblGlobalOffset(void); void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); bool IsAbstract(); //コンストラクタをコンパイルしているかどうかのチェックフラグ private: bool isCompilingConstructor; public: void NotifyStartConstructorCompile(); void NotifyFinishConstructorCompile(); bool IsCompilingConstructor(); //デストラクタをコンパイルしているかどうかのチェックフラグ private: bool isCompilingDestructor; public: void NotifyStartDestructorCompile(); void NotifyFinishDestructorCompile(); bool IsCompilingDestructor(); //自身と等しいクラスかどうかを確認 bool IsEquals( CClass *pClass ); //自身の派生クラスかどうかを確認 bool IsSubClass( CClass *pClass ); //自身と等しいまたは派生クラスかどうかを確認 bool IsEqualsOrSubClass( CClass *pClass ); //線形リスト用 CClass *pobj_NextClass; //メンバの参照方法 enum RefType{ Dot, // obj.member Pointer, // obj->member Non, // no reference member }; }; #define MAX_CLASS_HASH 65535 class CDBClass{ int hash(const char *name); void DestroyClass(CClass *pobj_c); public: CClass *pobj_ClassHash[MAX_CLASS_HASH]; CDBClass(); ~CDBClass(); CClass *check(const char *name); CClass *AddClass(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(CClass *pobj_c); public: void InitNames(void); void GetClass_recur(const char *lpszInheritsClass); void GetAllClassInfo(void); ///////////////////////////// // 特殊クラス ///////////////////////////// CClass *pStringClass; CClass *pObjectClass; CClass *GetStringClass() const; CClass *GetObjectClass() const; ///////////////////////////// // 現在コンパイル中の情報 ///////////////////////////// private: CClass *pCompilingClass; CMethod *pCompilingMethod; public: //コンパイル開始の通知を受け取るメソッド void StartCompile( SUBINFO *psi ); //現在コンパイル中のメソッド情報を取得 CClass *GetNowCompilingClass(); CMethod *GetNowCompilingMethodInfo(); ///////////////////// // イテレータ ///////////////////// private: CClass **ppobj_IteClass; int iIteMaxNum; int iIteNextNum; public: void Iterator_Reset(void); BOOL Iterator_HasNext(void); CClass *Iterator_GetNext(void); int Iterator_GetMaxCount(void); }; extern CDBClass *pobj_DBClass; extern CClass *pobj_CompilingClass;