source: dev/BasicCompiler_Common/Class.h@ 94

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

New[]を禁止した。
一部の動的型情報が生成されないバグを修正。
As演算子によるダウンキャストを許可(プログラム的なチェックはまだ走っていない)

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