[78] | 1 | #pragma once
|
---|
| 2 |
|
---|
[50] | 3 | #include <vector>
|
---|
[75] | 4 | #include "Type.h"
|
---|
[100] | 5 | #include "Procedure.h"
|
---|
[4] | 6 |
|
---|
| 7 | class CClass;
|
---|
| 8 |
|
---|
| 9 | #define ACCESS_NON 0
|
---|
| 10 | #define ACCESS_PRIVATE 1
|
---|
| 11 | #define ACCESS_PUBLIC 2
|
---|
| 12 | #define ACCESS_PROTECTED 3
|
---|
| 13 |
|
---|
[75] | 14 | class CMember : public Type
|
---|
| 15 | {
|
---|
[17] | 16 | bool isConst;
|
---|
[4] | 17 | public:
|
---|
| 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] | 39 | class CMethod
|
---|
| 40 | {
|
---|
[4] | 41 | public:
|
---|
[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] | 57 | class CDBClass;
|
---|
| 58 | class CDebugSection;
|
---|
[4] | 59 | class 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] | 90 | public:
|
---|
| 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 |
|
---|
| 108 | public:
|
---|
[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 |
|
---|
| 117 | bool IsEqualSymbol() const;
|
---|
| 118 |
|
---|
[91] | 119 | bool IsUsing() const;
|
---|
| 120 | void Using();
|
---|
| 121 |
|
---|
[90] | 122 | bool IsClass() const;
|
---|
| 123 | bool IsInterface() const;
|
---|
| 124 | bool IsEnum() const;
|
---|
| 125 | bool IsDelegate() const;
|
---|
[64] | 126 | bool IsStructure() const;
|
---|
| 127 |
|
---|
[29] | 128 | //継承させる
|
---|
[90] | 129 | bool Inherits( CClass &inheritsClass, int nowLine );
|
---|
| 130 | bool InheritsInterface( CClass &inheritsClass, int nowLine );
|
---|
[29] | 131 |
|
---|
[53] | 132 | //メンバ、メソッドの追加
|
---|
[40] | 133 | void AddMember( DWORD dwAccess, bool idConst, bool isRef, char *buffer );
|
---|
[75] | 134 | void AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int nowLine );
|
---|
| 135 | void AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual );
|
---|
| 136 | void AddStaticMethod(UserProc *pUserProc,DWORD dwAccess);
|
---|
[4] | 137 |
|
---|
[53] | 138 | //重複チェック
|
---|
[46] | 139 | BOOL DupliCheckAll(const char *name);
|
---|
| 140 | BOOL DupliCheckMember(const char *name);
|
---|
[4] | 141 |
|
---|
[28] | 142 | //メソッド取得
|
---|
[75] | 143 | CMethod *GetMethodInfo( UserProc *pUserProc ) const;
|
---|
| 144 | CMethod *GetStaticMethodInfo( UserProc *pUserProc ) const;
|
---|
[28] | 145 |
|
---|
| 146 | //メソッドの存在を確認
|
---|
[75] | 147 | bool IsExistMethod( const char *name ) const;
|
---|
| 148 | bool IsExistStaticMethod( const char *name ) const;
|
---|
[4] | 149 |
|
---|
[50] | 150 | //メソッドを列挙
|
---|
[100] | 151 | void EnumStaticMethod( const char *methodName, vector<UserProc *> &subs ) const;
|
---|
| 152 | void EnumMethod( const char *methodName, vector<UserProc *> &subs ) const;
|
---|
| 153 | void EnumMethod( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const;
|
---|
[91] | 154 | const std::vector<CMethod *> &GetMethods() const
|
---|
| 155 | {
|
---|
| 156 | return methods;
|
---|
| 157 | }
|
---|
| 158 | const std::vector<CMethod *> &GetStaticMethods() const
|
---|
| 159 | {
|
---|
| 160 | return staticMethods;
|
---|
| 161 | }
|
---|
[18] | 162 |
|
---|
[51] | 163 | //デフォルト コンストラクタ メソッドを取得
|
---|
| 164 | CMethod *GetConstructorMethod() const;
|
---|
[50] | 165 |
|
---|
[51] | 166 | //デストラクタ メソッドを取得
|
---|
| 167 | CMethod *GetDestructorMethod() const;
|
---|
| 168 |
|
---|
[63] | 169 | // メンバの総合サイズを取得
|
---|
| 170 | int GetSize() const;
|
---|
[51] | 171 |
|
---|
[63] | 172 | // メンバのオフセットを取得
|
---|
[94] | 173 | int GetMemberOffset( const char *memberName, int *pMemberNum = NULL ) const;
|
---|
[63] | 174 |
|
---|
| 175 | private:
|
---|
| 176 | // アラインメント値を取得
|
---|
| 177 | int GetAlignment() const;
|
---|
| 178 |
|
---|
| 179 |
|
---|
[4] | 180 | //vtbl
|
---|
| 181 | private:
|
---|
| 182 | long vtbl_offset;
|
---|
| 183 | public:
|
---|
[75] | 184 | int GetFuncNumInVtbl( const UserProc *pUserProc ) const;
|
---|
[51] | 185 | LONG_PTR GetVtblGlobalOffset(void);
|
---|
[4] | 186 | void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
|
---|
[75] | 187 | bool IsAbstract() const;
|
---|
[4] | 188 |
|
---|
| 189 |
|
---|
[17] | 190 | //コンストラクタをコンパイルしているかどうかのチェックフラグ
|
---|
| 191 | private:
|
---|
| 192 | bool isCompilingConstructor;
|
---|
| 193 | public:
|
---|
| 194 | void NotifyStartConstructorCompile();
|
---|
| 195 | void NotifyFinishConstructorCompile();
|
---|
[75] | 196 | bool IsCompilingConstructor() const;
|
---|
[17] | 197 |
|
---|
[18] | 198 | //デストラクタをコンパイルしているかどうかのチェックフラグ
|
---|
| 199 | private:
|
---|
| 200 | bool isCompilingDestructor;
|
---|
| 201 | public:
|
---|
| 202 | void NotifyStartDestructorCompile();
|
---|
| 203 | void NotifyFinishDestructorCompile();
|
---|
[75] | 204 | bool IsCompilingDestructor() const;
|
---|
[17] | 205 |
|
---|
[18] | 206 |
|
---|
[28] | 207 | //自身と等しいクラスかどうかを確認
|
---|
[75] | 208 | bool IsEquals( const CClass *pClass ) const;
|
---|
[28] | 209 |
|
---|
| 210 | //自身の派生クラスかどうかを確認
|
---|
[75] | 211 | bool IsSubClass( const CClass *pClass ) const;
|
---|
[28] | 212 |
|
---|
[59] | 213 | //自身と等しいまたは派生クラスかどうかを確認
|
---|
[75] | 214 | bool IsEqualsOrSubClass( const CClass *pClass ) const;
|
---|
[28] | 215 |
|
---|
[94] | 216 | // 自身と等しいまたは派生クラス、基底クラスかどうかを確認
|
---|
| 217 | bool IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const;
|
---|
[59] | 218 |
|
---|
[94] | 219 |
|
---|
[4] | 220 | //線形リスト用
|
---|
| 221 | CClass *pobj_NextClass;
|
---|
[64] | 222 |
|
---|
| 223 |
|
---|
| 224 | //メンバの参照方法
|
---|
| 225 | enum RefType{
|
---|
[97] | 226 | Non = 0, // no reference member
|
---|
[64] | 227 | Dot, // obj.member
|
---|
| 228 | Pointer, // obj->member
|
---|
| 229 | };
|
---|
[4] | 230 | };
|
---|
| 231 |
|
---|
| 232 | #define MAX_CLASS_HASH 65535
|
---|
| 233 | class CDBClass{
|
---|
[46] | 234 | int hash(const char *name);
|
---|
[4] | 235 | void DestroyClass(CClass *pobj_c);
|
---|
| 236 | public:
|
---|
| 237 | CClass *pobj_ClassHash[MAX_CLASS_HASH];
|
---|
| 238 |
|
---|
| 239 | CDBClass();
|
---|
| 240 | ~CDBClass();
|
---|
| 241 |
|
---|
[46] | 242 | CClass *check(const char *name);
|
---|
[4] | 243 |
|
---|
[101] | 244 | CClass *AddClass( const NamespaceScopes &namespaceScopes, const char *name,int nowLine);
|
---|
[4] | 245 |
|
---|
| 246 | void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
|
---|
| 247 |
|
---|
| 248 | private:
|
---|
[18] | 249 | void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
|
---|
[75] | 250 | BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine);
|
---|
| 251 | BOOL MemberVar_LoopRefCheck(const CClass &objClass);
|
---|
[4] | 252 | public:
|
---|
| 253 | void InitNames(void);
|
---|
[46] | 254 | void GetClass_recur(const char *lpszInheritsClass);
|
---|
[67] | 255 | void GetAllClassInfo(void);
|
---|
[89] | 256 | void Compile_System_InitializeUserTypes();
|
---|
[4] | 257 |
|
---|
| 258 |
|
---|
[18] | 259 | /////////////////////////////
|
---|
[67] | 260 | // 特殊クラス
|
---|
| 261 | /////////////////////////////
|
---|
| 262 | CClass *pStringClass;
|
---|
| 263 | CClass *pObjectClass;
|
---|
| 264 | CClass *GetStringClass() const;
|
---|
| 265 | CClass *GetObjectClass() const;
|
---|
| 266 |
|
---|
| 267 |
|
---|
| 268 | /////////////////////////////
|
---|
[18] | 269 | // 現在コンパイル中の情報
|
---|
| 270 | /////////////////////////////
|
---|
[4] | 271 | private:
|
---|
[18] | 272 | CClass *pCompilingClass;
|
---|
| 273 | CMethod *pCompilingMethod;
|
---|
| 274 | public:
|
---|
| 275 | //コンパイル開始の通知を受け取るメソッド
|
---|
[75] | 276 | void StartCompile( UserProc *pUserProc );
|
---|
[18] | 277 |
|
---|
| 278 | //現在コンパイル中のメソッド情報を取得
|
---|
| 279 | CClass *GetNowCompilingClass();
|
---|
| 280 | CMethod *GetNowCompilingMethodInfo();
|
---|
| 281 |
|
---|
| 282 |
|
---|
| 283 | /////////////////////
|
---|
| 284 | // イテレータ
|
---|
| 285 | /////////////////////
|
---|
| 286 | private:
|
---|
[4] | 287 | CClass **ppobj_IteClass;
|
---|
| 288 | int iIteMaxNum;
|
---|
| 289 | int iIteNextNum;
|
---|
| 290 | public:
|
---|
[89] | 291 | void Iterator_Init(void);
|
---|
[4] | 292 | void Iterator_Reset(void);
|
---|
| 293 | BOOL Iterator_HasNext(void);
|
---|
| 294 | CClass *Iterator_GetNext(void);
|
---|
| 295 | int Iterator_GetMaxCount(void);
|
---|
| 296 | };
|
---|
| 297 |
|
---|
| 298 |
|
---|
| 299 | extern CDBClass *pobj_DBClass;
|
---|
| 300 | extern CClass *pobj_CompilingClass;
|
---|