source: dev/BasicCompiler_Common/Class.h@ 78

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

CTypeDef → TypeDef
Houseクラスを追加。
オーバーロードレベルの種類を追加(レベル1に挿入)

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