source: dev/BasicCompiler_Common/Class.h@ 56

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

・[Unicode]リテラル文字列のスイッチング
・[Unicode]Char型を文字型として扱うようにする
・[Unicode]SByte型を追加する
に対応。

/unicodeコマンドオプションに対応。

File size: 5.1 KB
RevLine 
[50]1#include <vector>
[4]2
3class CClass;
4struct SUBINFO;
5
6//データ型
7struct TYPEINFO{
8 int type;
9 union{
10 LONG_PTR lpIndex;
11 CClass *pobj_Class;
12 }u;
13};
14
15#define ACCESS_NON 0
16#define ACCESS_PRIVATE 1
17#define ACCESS_PUBLIC 2
18#define ACCESS_PROTECTED 3
19
20class CMember{
[17]21 bool isConst;
[40]22 bool isRef;
[4]23public:
24 char *name;
25 int SubScripts[MAX_ARRAYDIM];
26 TYPEINFO TypeInfo;
27
28 DWORD dwAccess;
29
30 char *InitBuf;
31 char *ConstractParameter;
32
33 int source_code_address;
34
35
[40]36 CMember( CClass *pobj_c, DWORD access, bool idConst, bool isRef, char *buffer, int NowLine=-1 );
[17]37 CMember( CMember *pobj );
[4]38 CMember();
39 ~CMember();
40
[17]41 bool IsConst();
[40]42 bool IsRef();
43 int GetSize();
[4]44
[17]45
[4]46 static void InitStaticMember(void);
47};
48class CMethod{
49public:
50 SUBINFO *psi;
51 DWORD dwAccess;
52 BOOL bAbstract;
53 BOOL bVirtual;
[18]54 bool isConst;
[4]55
56 CClass *pobj_InheritsClass;
57
58 CMethod(CMethod *pobj);
59 CMethod();
60 ~CMethod();
61};
[51]62class CDBClass;
63class CDebugSection;
[4]64class CClass{
[53]65 friend CMember;
[51]66 friend CDBClass;
67 friend CDebugSection;
68
[53]69 //静的メンバ情報
70 std::vector<CMember *>staticMembers;
71
[51]72 //メソッド情報
73 std::vector<CMethod *> methods;
74 int ConstructorMemberSubIndex;
75 int CopyConstructorMemberSubIndex;
76 int DestructorMemberSubIndex;
77
[50]78 //静的メソッド情報
[51]79 std::vector<CMethod *> staticMethods;
[50]80
[4]81public:
82 //クラス名
83 char *name;
84
85 //継承クラスへのポインタ
86 CClass *pobj_InheritsClass;
87
88 //メンバ情報
89 CMember **ppobj_Member;
90 int iMemberNum;
91
92 //仮想関数の数
93 int vtbl_num;
94
95 //アラインメント値
96 int iAlign;
97
98
99public:
[46]100 CClass(const char *name);
[4]101 ~CClass();
102
[29]103 //継承させる
104 void Inherits( CClass *pInheritsClass );
105
[53]106 //メンバ、メソッドの追加
[40]107 void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer );
108 void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine );
[18]109 void AddMethod( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
[4]110 void AddStaticMethod(SUBINFO *psi,DWORD dwAccess);
111
[53]112 //重複チェック
[46]113 BOOL DupliCheckAll(const char *name);
114 BOOL DupliCheckMember(const char *name);
[4]115
[28]116 //メソッド取得
[18]117 CMethod *GetMethodInfo( SUBINFO *psi );
118 CMethod *GetStaticMethodInfo( SUBINFO *psi );
[28]119
120 //メソッドの存在を確認
[46]121 bool IsExistMethod( const char *name );
122 bool IsExistStaticMethod( const char *name );
[4]123
[50]124 //メソッドを列挙
125 void EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const;
126 void EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const;
127 void EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const;
[18]128
[51]129 //デフォルト コンストラクタ メソッドを取得
130 CMethod *GetConstructorMethod() const;
[50]131
[51]132 //デフォルト コピーコンストラクタ メソッドを取得
133 CMethod *GetCopyConstructorMethod() const;
134
135 //デストラクタ メソッドを取得
136 CMethod *GetDestructorMethod() const;
137
138
[4]139 //vtbl
140private:
141 long vtbl_offset;
142public:
[51]143 int GetFuncNumInVtbl( const SUBINFO *psi ) const;
144 LONG_PTR GetVtblGlobalOffset(void);
[4]145 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
[28]146 bool IsAbstract();
[4]147
148
[17]149 //コンストラクタをコンパイルしているかどうかのチェックフラグ
150private:
151 bool isCompilingConstructor;
152public:
153 void NotifyStartConstructorCompile();
154 void NotifyFinishConstructorCompile();
155 bool IsCompilingConstructor();
156
[18]157 //デストラクタをコンパイルしているかどうかのチェックフラグ
158private:
159 bool isCompilingDestructor;
160public:
161 void NotifyStartDestructorCompile();
162 void NotifyFinishDestructorCompile();
163 bool IsCompilingDestructor();
[17]164
[18]165
[28]166 //自身と等しいクラスかどうかを確認
167 bool IsEquals( CClass *pClass );
168
169 //自身の派生クラスかどうかを確認
170 bool IsSubClass( CClass *pClass );
171
172
[4]173 //線形リスト用
174 CClass *pobj_NextClass;
175};
176
177#define MAX_CLASS_HASH 65535
178class CDBClass{
[46]179 int hash(const char *name);
[4]180 void DestroyClass(CClass *pobj_c);
181public:
182 CClass *pobj_ClassHash[MAX_CLASS_HASH];
183
184 CDBClass();
185 ~CDBClass();
186
[46]187 CClass *check(const char *name);
[4]188
[46]189 CClass *AddClass(const char *name,int NowLine);
[4]190
191 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
192
193private:
[18]194 void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
195 BOOL bVirtual, BOOL bOverride, char *buffer, int NowLine);
[4]196 BOOL MemberVar_LoopRefCheck(CClass *pobj_c);
197public:
198 void InitNames(void);
[46]199 void GetClass_recur(const char *lpszInheritsClass);
[4]200 void GetObjectClassInfo(void);
201
202
[18]203 /////////////////////////////
204 // 現在コンパイル中の情報
205 /////////////////////////////
[4]206private:
[18]207 CClass *pCompilingClass;
208 CMethod *pCompilingMethod;
209public:
210 //コンパイル開始の通知を受け取るメソッド
211 void StartCompile( SUBINFO *psi );
212
213 //現在コンパイル中のメソッド情報を取得
214 CClass *GetNowCompilingClass();
215 CMethod *GetNowCompilingMethodInfo();
216
217
218 /////////////////////
219 // イテレータ
220 /////////////////////
221private:
[4]222 CClass **ppobj_IteClass;
223 int iIteMaxNum;
224 int iIteNextNum;
225public:
226 void Iterator_Reset(void);
227 BOOL Iterator_HasNext(void);
228 CClass *Iterator_GetNext(void);
229 int Iterator_GetMaxCount(void);
230};
231
232
233extern CDBClass *pobj_DBClass;
234extern CClass *pobj_CompilingClass;
Note: See TracBrowser for help on using the repository browser.