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