source: dev/BasicCompiler_Common/Class.h@ 102

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

名前空間機能をクラスに適用。

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