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