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