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