[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 |
|
---|
[114] | 119 | mutable bool isUsing;
|
---|
[91] | 120 |
|
---|
[4] | 121 | public:
|
---|
| 122 |
|
---|
| 123 | //継承クラスへのポインタ
|
---|
[114] | 124 | const CClass *pobj_InheritsClass;
|
---|
[4] | 125 |
|
---|
| 126 | //メンバ情報
|
---|
| 127 | CMember **ppobj_Member;
|
---|
| 128 | int iMemberNum;
|
---|
| 129 |
|
---|
| 130 | //仮想関数の数
|
---|
| 131 | int vtbl_num;
|
---|
| 132 |
|
---|
| 133 | //アラインメント値
|
---|
| 134 | int iAlign;
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | public:
|
---|
[131] | 138 | CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name );
|
---|
[4] | 139 | ~CClass();
|
---|
| 140 |
|
---|
[108] | 141 | const NamespaceScopesCollection &GetImportedNamespaces() const
|
---|
| 142 | {
|
---|
| 143 | return importedNamespaces;
|
---|
| 144 | }
|
---|
[101] | 145 |
|
---|
[131] | 146 | // インターフェイス
|
---|
| 147 | bool HasInterfaces() const
|
---|
[102] | 148 | {
|
---|
[131] | 149 | return ( interfaces.size() != 0 );
|
---|
[102] | 150 | }
|
---|
[131] | 151 | bool IsInheritsInterface( const CClass *pInterfaceClass ) const;
|
---|
[101] | 152 |
|
---|
[131] | 153 | // Blittable型
|
---|
[127] | 154 | bool IsBlittableType() const
|
---|
| 155 | {
|
---|
[128] | 156 | return !blittableType.IsNull();
|
---|
[127] | 157 | }
|
---|
| 158 | const Type &GetBlittableType() const
|
---|
| 159 | {
|
---|
| 160 | return blittableType;
|
---|
| 161 | }
|
---|
| 162 | void SetBlittableType( const Type &type ){
|
---|
| 163 | blittableType = type;
|
---|
| 164 | }
|
---|
| 165 |
|
---|
[131] | 166 | // シンボル比較
|
---|
[102] | 167 | bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
|
---|
| 168 | bool IsEqualSymbol( const CClass &objClass ) const;
|
---|
| 169 | bool IsEqualSymbol( const string &name ) const;
|
---|
| 170 |
|
---|
[91] | 171 | bool IsUsing() const;
|
---|
[114] | 172 | void Using() const;
|
---|
[91] | 173 |
|
---|
[90] | 174 | bool IsClass() const;
|
---|
| 175 | bool IsInterface() const;
|
---|
| 176 | bool IsEnum() const;
|
---|
| 177 | bool IsDelegate() const;
|
---|
[64] | 178 | bool IsStructure() const;
|
---|
| 179 |
|
---|
[29] | 180 | //継承させる
|
---|
[131] | 181 | bool Inherits( const char *inheritNames, int nowLine );
|
---|
| 182 | bool InheritsClass( const CClass &inheritsClass, int nowLine );
|
---|
[114] | 183 | bool InheritsInterface( const CClass &inheritsClass, int nowLine );
|
---|
[29] | 184 |
|
---|
[53] | 185 | //メンバ、メソッドの追加
|
---|
[40] | 186 | void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer );
|
---|
[75] | 187 | void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int nowLine );
|
---|
| 188 | void AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
|
---|
| 189 | void AddStaticMethod(UserProc *pUserProc,DWORD dwAccess);
|
---|
[4] | 190 |
|
---|
[53] | 191 | //重複チェック
|
---|
[46] | 192 | BOOL DupliCheckAll(const char *name);
|
---|
| 193 | BOOL DupliCheckMember(const char *name);
|
---|
[4] | 194 |
|
---|
[28] | 195 | //メソッド取得
|
---|
[75] | 196 | CMethod *GetMethodInfo( UserProc *pUserProc ) const;
|
---|
| 197 | CMethod *GetStaticMethodInfo( UserProc *pUserProc ) const;
|
---|
[28] | 198 |
|
---|
| 199 | //メソッドの存在を確認
|
---|
[75] | 200 | bool IsExistMethod( const char *name ) const;
|
---|
| 201 | bool IsExistStaticMethod( const char *name ) const;
|
---|
[4] | 202 |
|
---|
[50] | 203 | //メソッドを列挙
|
---|
[100] | 204 | void EnumStaticMethod( const char *methodName, vector<UserProc *> &subs ) const;
|
---|
| 205 | void EnumMethod( const char *methodName, vector<UserProc *> &subs ) const;
|
---|
| 206 | void EnumMethod( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const;
|
---|
[91] | 207 | const std::vector<CMethod *> &GetMethods() const
|
---|
| 208 | {
|
---|
| 209 | return methods;
|
---|
| 210 | }
|
---|
| 211 | const std::vector<CMethod *> &GetStaticMethods() const
|
---|
| 212 | {
|
---|
| 213 | return staticMethods;
|
---|
| 214 | }
|
---|
[18] | 215 |
|
---|
[51] | 216 | //デフォルト コンストラクタ メソッドを取得
|
---|
| 217 | CMethod *GetConstructorMethod() const;
|
---|
[50] | 218 |
|
---|
[51] | 219 | //デストラクタ メソッドを取得
|
---|
| 220 | CMethod *GetDestructorMethod() const;
|
---|
| 221 |
|
---|
[63] | 222 | // メンバの総合サイズを取得
|
---|
| 223 | int GetSize() const;
|
---|
[51] | 224 |
|
---|
[63] | 225 | // メンバのオフセットを取得
|
---|
[94] | 226 | int GetMemberOffset( const char *memberName, int *pMemberNum = NULL ) const;
|
---|
[63] | 227 |
|
---|
| 228 | private:
|
---|
| 229 | // アラインメント値を取得
|
---|
| 230 | int GetAlignment() const;
|
---|
| 231 |
|
---|
| 232 |
|
---|
[4] | 233 | //vtbl
|
---|
| 234 | private:
|
---|
[114] | 235 | mutable long vtbl_offset;
|
---|
[4] | 236 | public:
|
---|
[75] | 237 | int GetFuncNumInVtbl( const UserProc *pUserProc ) const;
|
---|
[114] | 238 | LONG_PTR GetVtblGlobalOffset(void) const;
|
---|
[4] | 239 | void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
|
---|
[75] | 240 | bool IsAbstract() const;
|
---|
[4] | 241 |
|
---|
| 242 |
|
---|
[17] | 243 | //コンストラクタをコンパイルしているかどうかのチェックフラグ
|
---|
| 244 | private:
|
---|
[114] | 245 | mutable bool isCompilingConstructor;
|
---|
[17] | 246 | public:
|
---|
[114] | 247 | void NotifyStartConstructorCompile() const;
|
---|
| 248 | void NotifyFinishConstructorCompile() const;
|
---|
[75] | 249 | bool IsCompilingConstructor() const;
|
---|
[17] | 250 |
|
---|
[18] | 251 | //デストラクタをコンパイルしているかどうかのチェックフラグ
|
---|
| 252 | private:
|
---|
[114] | 253 | mutable bool isCompilingDestructor;
|
---|
[18] | 254 | public:
|
---|
[114] | 255 | void NotifyStartDestructorCompile() const;
|
---|
| 256 | void NotifyFinishDestructorCompile() const;
|
---|
[75] | 257 | bool IsCompilingDestructor() const;
|
---|
[17] | 258 |
|
---|
[18] | 259 |
|
---|
[28] | 260 | //自身と等しいクラスかどうかを確認
|
---|
[75] | 261 | bool IsEquals( const CClass *pClass ) const;
|
---|
[28] | 262 |
|
---|
| 263 | //自身の派生クラスかどうかを確認
|
---|
[75] | 264 | bool IsSubClass( const CClass *pClass ) const;
|
---|
[28] | 265 |
|
---|
[59] | 266 | //自身と等しいまたは派生クラスかどうかを確認
|
---|
[75] | 267 | bool IsEqualsOrSubClass( const CClass *pClass ) const;
|
---|
[28] | 268 |
|
---|
[94] | 269 | // 自身と等しいまたは派生クラス、基底クラスかどうかを確認
|
---|
| 270 | bool IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const;
|
---|
[59] | 271 |
|
---|
[94] | 272 |
|
---|
[4] | 273 | //線形リスト用
|
---|
| 274 | CClass *pobj_NextClass;
|
---|
[64] | 275 |
|
---|
| 276 |
|
---|
| 277 | //メンバの参照方法
|
---|
| 278 | enum RefType{
|
---|
[97] | 279 | Non = 0, // no reference member
|
---|
[64] | 280 | Dot, // obj.member
|
---|
| 281 | Pointer, // obj->member
|
---|
| 282 | };
|
---|
[4] | 283 | };
|
---|
| 284 |
|
---|
| 285 | #define MAX_CLASS_HASH 65535
|
---|
| 286 | class CDBClass{
|
---|
[102] | 287 | int hash(const char *name) const;
|
---|
[4] | 288 | void DestroyClass(CClass *pobj_c);
|
---|
| 289 | public:
|
---|
| 290 | CClass *pobj_ClassHash[MAX_CLASS_HASH];
|
---|
| 291 |
|
---|
| 292 | CDBClass();
|
---|
| 293 | ~CDBClass();
|
---|
| 294 |
|
---|
[114] | 295 | const CClass *Find( const string &fullName ) const;
|
---|
| 296 | const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const;
|
---|
[4] | 297 |
|
---|
[108] | 298 | CClass *AddClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine);
|
---|
[4] | 299 |
|
---|
| 300 | void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
|
---|
| 301 |
|
---|
| 302 | private:
|
---|
[18] | 303 | void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
|
---|
[75] | 304 | BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine);
|
---|
| 305 | BOOL MemberVar_LoopRefCheck(const CClass &objClass);
|
---|
[4] | 306 | public:
|
---|
| 307 | void InitNames(void);
|
---|
[46] | 308 | void GetClass_recur(const char *lpszInheritsClass);
|
---|
[67] | 309 | void GetAllClassInfo(void);
|
---|
[89] | 310 | void Compile_System_InitializeUserTypes();
|
---|
[4] | 311 |
|
---|
| 312 |
|
---|
[18] | 313 | /////////////////////////////
|
---|
[67] | 314 | // 特殊クラス
|
---|
| 315 | /////////////////////////////
|
---|
| 316 | CClass *pStringClass;
|
---|
| 317 | CClass *pObjectClass;
|
---|
[117] | 318 | CClass *GetStringClassPtr() const;
|
---|
| 319 | CClass *GetObjectClassPtr() const;
|
---|
[67] | 320 |
|
---|
| 321 |
|
---|
| 322 | /////////////////////////////
|
---|
[18] | 323 | // 現在コンパイル中の情報
|
---|
| 324 | /////////////////////////////
|
---|
[4] | 325 | private:
|
---|
[114] | 326 | const CClass *pCompilingClass;
|
---|
[18] | 327 | CMethod *pCompilingMethod;
|
---|
| 328 | public:
|
---|
| 329 | //コンパイル開始の通知を受け取るメソッド
|
---|
[75] | 330 | void StartCompile( UserProc *pUserProc );
|
---|
[18] | 331 |
|
---|
| 332 | //現在コンパイル中のメソッド情報を取得
|
---|
[114] | 333 | const CClass *GetNowCompilingClass() const;
|
---|
[18] | 334 | CMethod *GetNowCompilingMethodInfo();
|
---|
| 335 |
|
---|
| 336 |
|
---|
| 337 | /////////////////////
|
---|
| 338 | // イテレータ
|
---|
| 339 | /////////////////////
|
---|
| 340 | private:
|
---|
[4] | 341 | CClass **ppobj_IteClass;
|
---|
| 342 | int iIteMaxNum;
|
---|
| 343 | int iIteNextNum;
|
---|
| 344 | public:
|
---|
[89] | 345 | void Iterator_Init(void);
|
---|
[4] | 346 | void Iterator_Reset(void);
|
---|
| 347 | BOOL Iterator_HasNext(void);
|
---|
| 348 | CClass *Iterator_GetNext(void);
|
---|
| 349 | int Iterator_GetMaxCount(void);
|
---|
| 350 | };
|
---|
| 351 |
|
---|
| 352 |
|
---|
| 353 | extern CDBClass *pobj_DBClass;
|
---|
[114] | 354 | extern const CClass *pobj_CompilingClass;
|
---|