source: dev/BasicCompiler_Common/Class.h@ 135

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

Method/Memberのリファクタリング

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