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