source: dev/BasicCompiler_Common/Class.h@ 117

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

String/ObjectをSystem名前空間に依存しない特殊型として扱うようにした

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