[78] | 1 | #pragma once
|
---|
| 2 |
|
---|
[50] | 3 | #include <vector>
|
---|
[75] | 4 | #include "Type.h"
|
---|
[4] | 5 |
|
---|
| 6 | class CClass;
|
---|
[75] | 7 | class 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] | 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 | };
|
---|
| 39 | class CMethod{
|
---|
| 40 | public:
|
---|
[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] | 53 | class CDBClass;
|
---|
| 54 | class CDebugSection;
|
---|
[4] | 55 | class 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] | 83 | public:
|
---|
| 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 |
|
---|
| 101 | public:
|
---|
[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 | // メンバのオフセットを取得
|
---|
| 159 | int GetMemberOffset( const char *memberName, int *pMemberNum ) const;
|
---|
| 160 |
|
---|
| 161 | private:
|
---|
| 162 | // アラインメント値を取得
|
---|
| 163 | int GetAlignment() const;
|
---|
| 164 |
|
---|
| 165 |
|
---|
[4] | 166 | //vtbl
|
---|
| 167 | private:
|
---|
| 168 | long vtbl_offset;
|
---|
| 169 | public:
|
---|
[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 | //コンストラクタをコンパイルしているかどうかのチェックフラグ
|
---|
| 177 | private:
|
---|
| 178 | bool isCompilingConstructor;
|
---|
| 179 | public:
|
---|
| 180 | void NotifyStartConstructorCompile();
|
---|
| 181 | void NotifyFinishConstructorCompile();
|
---|
[75] | 182 | bool IsCompilingConstructor() const;
|
---|
[17] | 183 |
|
---|
[18] | 184 | //デストラクタをコンパイルしているかどうかのチェックフラグ
|
---|
| 185 | private:
|
---|
| 186 | bool isCompilingDestructor;
|
---|
| 187 | public:
|
---|
| 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 |
|
---|
[59] | 202 |
|
---|
[4] | 203 | //線形リスト用
|
---|
| 204 | CClass *pobj_NextClass;
|
---|
[64] | 205 |
|
---|
| 206 |
|
---|
| 207 | //メンバの参照方法
|
---|
| 208 | enum RefType{
|
---|
| 209 | Dot, // obj.member
|
---|
| 210 | Pointer, // obj->member
|
---|
| 211 | Non, // no reference member
|
---|
| 212 | };
|
---|
[4] | 213 | };
|
---|
| 214 |
|
---|
| 215 | #define MAX_CLASS_HASH 65535
|
---|
| 216 | class CDBClass{
|
---|
[46] | 217 | int hash(const char *name);
|
---|
[4] | 218 | void DestroyClass(CClass *pobj_c);
|
---|
| 219 | public:
|
---|
| 220 | CClass *pobj_ClassHash[MAX_CLASS_HASH];
|
---|
| 221 |
|
---|
| 222 | CDBClass();
|
---|
| 223 | ~CDBClass();
|
---|
| 224 |
|
---|
[46] | 225 | CClass *check(const char *name);
|
---|
[4] | 226 |
|
---|
[75] | 227 | CClass *AddClass(const char *name,int nowLine);
|
---|
[4] | 228 |
|
---|
| 229 | void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
|
---|
| 230 |
|
---|
| 231 | private:
|
---|
[18] | 232 | void AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
|
---|
[75] | 233 | BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine);
|
---|
| 234 | BOOL MemberVar_LoopRefCheck(const CClass &objClass);
|
---|
[4] | 235 | public:
|
---|
| 236 | void InitNames(void);
|
---|
[46] | 237 | void GetClass_recur(const char *lpszInheritsClass);
|
---|
[67] | 238 | void GetAllClassInfo(void);
|
---|
[89] | 239 | void Compile_System_InitializeUserTypes();
|
---|
[4] | 240 |
|
---|
| 241 |
|
---|
[18] | 242 | /////////////////////////////
|
---|
[67] | 243 | // 特殊クラス
|
---|
| 244 | /////////////////////////////
|
---|
| 245 | CClass *pStringClass;
|
---|
| 246 | CClass *pObjectClass;
|
---|
| 247 | CClass *GetStringClass() const;
|
---|
| 248 | CClass *GetObjectClass() const;
|
---|
| 249 |
|
---|
| 250 |
|
---|
| 251 | /////////////////////////////
|
---|
[18] | 252 | // 現在コンパイル中の情報
|
---|
| 253 | /////////////////////////////
|
---|
[4] | 254 | private:
|
---|
[18] | 255 | CClass *pCompilingClass;
|
---|
| 256 | CMethod *pCompilingMethod;
|
---|
| 257 | public:
|
---|
| 258 | //コンパイル開始の通知を受け取るメソッド
|
---|
[75] | 259 | void StartCompile( UserProc *pUserProc );
|
---|
[18] | 260 |
|
---|
| 261 | //現在コンパイル中のメソッド情報を取得
|
---|
| 262 | CClass *GetNowCompilingClass();
|
---|
| 263 | CMethod *GetNowCompilingMethodInfo();
|
---|
| 264 |
|
---|
| 265 |
|
---|
| 266 | /////////////////////
|
---|
| 267 | // イテレータ
|
---|
| 268 | /////////////////////
|
---|
| 269 | private:
|
---|
[4] | 270 | CClass **ppobj_IteClass;
|
---|
| 271 | int iIteMaxNum;
|
---|
| 272 | int iIteNextNum;
|
---|
| 273 | public:
|
---|
[89] | 274 | void Iterator_Init(void);
|
---|
[4] | 275 | void Iterator_Reset(void);
|
---|
| 276 | BOOL Iterator_HasNext(void);
|
---|
| 277 | CClass *Iterator_GetNext(void);
|
---|
| 278 | int Iterator_GetMaxCount(void);
|
---|
| 279 | };
|
---|
| 280 |
|
---|
| 281 |
|
---|
| 282 | extern CDBClass *pobj_DBClass;
|
---|
| 283 | extern CClass *pobj_CompilingClass;
|
---|