source: dev/BasicCompiler_Common/Class.h@ 137

Last change on this file since 137 was 137, checked in by dai_9181, 17 years ago

アクセシビリティ周りをリファクタリングした。

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