source: dev/BasicCompiler_Common/Class.h@ 128

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

Blittable型を導入した。

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