| 1 | #pragma once | 
|---|
| 2 |  | 
|---|
| 3 | #include <option.h> | 
|---|
| 4 | #include <Program.h> | 
|---|
| 5 | #include <Prototype.h> | 
|---|
| 6 | #include <Method.h> | 
|---|
| 7 | #include <Member.h> | 
|---|
| 8 | #include <Source.h> | 
|---|
| 9 |  | 
|---|
| 10 | class UserProc; | 
|---|
| 11 | class CClass; | 
|---|
| 12 | class Delegate; | 
|---|
| 13 |  | 
|---|
| 14 | class DynamicMethodsPrototype | 
|---|
| 15 | { | 
|---|
| 16 | // 動的メソッド | 
|---|
| 17 | Methods dynamicMethods; | 
|---|
| 18 |  | 
|---|
| 19 | // XMLシリアライズ用 | 
|---|
| 20 | private: | 
|---|
| 21 | friend class boost::serialization::access; | 
|---|
| 22 | template<class Archive> void serialize(Archive& ar, const unsigned int version) | 
|---|
| 23 | { | 
|---|
| 24 | ar & BOOST_SERIALIZATION_NVP( dynamicMethods ); | 
|---|
| 25 | } | 
|---|
| 26 |  | 
|---|
| 27 | public: | 
|---|
| 28 | DynamicMethodsPrototype(){} | 
|---|
| 29 | DynamicMethodsPrototype( const DynamicMethodsPrototype &dynamicMethodsPrototype ) | 
|---|
| 30 | : dynamicMethods( dynamicMethodsPrototype.dynamicMethods ) | 
|---|
| 31 | { | 
|---|
| 32 | } | 
|---|
| 33 | ~DynamicMethodsPrototype(){} | 
|---|
| 34 |  | 
|---|
| 35 | const Methods &GetDynamicMethods() const | 
|---|
| 36 | { | 
|---|
| 37 | return dynamicMethods; | 
|---|
| 38 | } | 
|---|
| 39 | Methods &GetDynamicMethods() | 
|---|
| 40 | { | 
|---|
| 41 | return dynamicMethods; | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 | void AddDynamicMethods( CMethod *pMethod ) | 
|---|
| 45 | { | 
|---|
| 46 | dynamicMethods.push_back( pMethod ); | 
|---|
| 47 | } | 
|---|
| 48 | }; | 
|---|
| 49 |  | 
|---|
| 50 | class ClassPrototype : public Prototype, public DynamicMethodsPrototype | 
|---|
| 51 | { | 
|---|
| 52 | // XMLシリアライズ用 | 
|---|
| 53 | private: | 
|---|
| 54 | friend class boost::serialization::access; | 
|---|
| 55 | template<class Archive> void serialize(Archive& ar, const unsigned int version) | 
|---|
| 56 | { | 
|---|
| 57 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Prototype ); | 
|---|
| 58 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( DynamicMethodsPrototype ); | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | public: | 
|---|
| 62 | ClassPrototype( const NamespaceScopes &namespaceScopes, const string &name ) | 
|---|
| 63 | : Prototype( namespaceScopes, name ) | 
|---|
| 64 | , DynamicMethodsPrototype() | 
|---|
| 65 | { | 
|---|
| 66 | } | 
|---|
| 67 | ClassPrototype() | 
|---|
| 68 | : Prototype() | 
|---|
| 69 | , DynamicMethodsPrototype() | 
|---|
| 70 | { | 
|---|
| 71 | } | 
|---|
| 72 | }; | 
|---|
| 73 |  | 
|---|
| 74 | class Interface : public DynamicMethodsPrototype | 
|---|
| 75 | { | 
|---|
| 76 | const CClass *pInterfaceClass; | 
|---|
| 77 | mutable LONG_PTR vtblOffset; | 
|---|
| 78 |  | 
|---|
| 79 | // 型パラメータ(実パラメータ) | 
|---|
| 80 | Types actualTypeParameters; | 
|---|
| 81 |  | 
|---|
| 82 | // XMLシリアライズ用 | 
|---|
| 83 | private: | 
|---|
| 84 | friend class boost::serialization::access; | 
|---|
| 85 | template<class Archive> void serialize(Archive& ar, const unsigned int version) | 
|---|
| 86 | { | 
|---|
| 87 | trace_for_serialize( "serializing - Interface" ); | 
|---|
| 88 |  | 
|---|
| 89 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( DynamicMethodsPrototype ); | 
|---|
| 90 | ar & boost::serialization::make_nvp("pInterfaceClass", const_cast<CClass *&>(pInterfaceClass) ); | 
|---|
| 91 | ar & BOOST_SERIALIZATION_NVP( vtblOffset ); | 
|---|
| 92 | ar & BOOST_SERIALIZATION_NVP( actualTypeParameters ); | 
|---|
| 93 | } | 
|---|
| 94 |  | 
|---|
| 95 | public: | 
|---|
| 96 | Interface( const CClass *pInterfaceClass, const Types &actualTypeParameters ); | 
|---|
| 97 | Interface( const Interface &objInterface ) | 
|---|
| 98 | : DynamicMethodsPrototype( objInterface ) | 
|---|
| 99 | , pInterfaceClass( objInterface.pInterfaceClass ) | 
|---|
| 100 | , vtblOffset( objInterface.vtblOffset ) | 
|---|
| 101 | { | 
|---|
| 102 | } | 
|---|
| 103 | Interface() | 
|---|
| 104 | { | 
|---|
| 105 | } | 
|---|
| 106 |  | 
|---|
| 107 | const CClass &GetClass() const{ | 
|---|
| 108 | return *pInterfaceClass; | 
|---|
| 109 | } | 
|---|
| 110 | LONG_PTR GetVtblOffset() const | 
|---|
| 111 | { | 
|---|
| 112 | return vtblOffset; | 
|---|
| 113 | } | 
|---|
| 114 | void SetVtblOffset( LONG_PTR vtblOffset ) const | 
|---|
| 115 | { | 
|---|
| 116 | this->vtblOffset = vtblOffset; | 
|---|
| 117 | } | 
|---|
| 118 |  | 
|---|
| 119 | const Types &GetActualTypeParameters() const | 
|---|
| 120 | { | 
|---|
| 121 | return actualTypeParameters; | 
|---|
| 122 | } | 
|---|
| 123 |  | 
|---|
| 124 | std::string GetFullNameWithActualGenericTypeParameters() const; | 
|---|
| 125 | }; | 
|---|
| 126 | typedef std::vector<Interface *> Interfaces; | 
|---|
| 127 |  | 
|---|
| 128 | class CClass: public ClassPrototype, public Jenga::Common::ObjectInHashmap<CClass> | 
|---|
| 129 | { | 
|---|
| 130 | public: | 
|---|
| 131 | // 型の種類 | 
|---|
| 132 | enum ClassType{ | 
|---|
| 133 | Class, | 
|---|
| 134 | Interface, | 
|---|
| 135 | ComInterface, | 
|---|
| 136 | Enum, | 
|---|
| 137 | Delegate, | 
|---|
| 138 | Structure, | 
|---|
| 139 | }; | 
|---|
| 140 |  | 
|---|
| 141 | private: | 
|---|
| 142 | ClassType classType; | 
|---|
| 143 |  | 
|---|
| 144 | // importされている名前空間 | 
|---|
| 145 | NamespaceScopesCollection importedNamespaces; | 
|---|
| 146 |  | 
|---|
| 147 | // 型パラメータ | 
|---|
| 148 | GenericTypes formalGenericTypes; | 
|---|
| 149 |  | 
|---|
| 150 | // 継承クラス | 
|---|
| 151 | const CClass *pSuperClass; | 
|---|
| 152 |  | 
|---|
| 153 | // 継承クラスの型パラメータ(実パラメータ) | 
|---|
| 154 | Types superClassActualTypeParameters; | 
|---|
| 155 |  | 
|---|
| 156 | // Blittable型情報 | 
|---|
| 157 | Type blittableType; | 
|---|
| 158 |  | 
|---|
| 159 | // 実装するインターフェイス | 
|---|
| 160 | Interfaces interfaces; | 
|---|
| 161 |  | 
|---|
| 162 | // 動的メンバ | 
|---|
| 163 | Members dynamicMembers; | 
|---|
| 164 |  | 
|---|
| 165 | // 静的メンバ | 
|---|
| 166 | Members staticMembers; | 
|---|
| 167 |  | 
|---|
| 168 | // 動的メソッド | 
|---|
| 169 | int ConstructorMemberSubIndex; | 
|---|
| 170 | int DestructorMemberSubIndex; | 
|---|
| 171 | int vtblNum;                    // 仮想関数の数 | 
|---|
| 172 |  | 
|---|
| 173 | // 静的メソッド | 
|---|
| 174 | Methods staticMethods; | 
|---|
| 175 |  | 
|---|
| 176 | //アラインメント値 | 
|---|
| 177 | int fixedAlignment; | 
|---|
| 178 |  | 
|---|
| 179 | // XMLシリアライズ用 | 
|---|
| 180 | private: | 
|---|
| 181 | friend class boost::serialization::access; | 
|---|
| 182 | template<class Archive> void serialize(Archive& ar, const unsigned int version) | 
|---|
| 183 | { | 
|---|
| 184 | trace_for_serialize( "serializing - CClass" ); | 
|---|
| 185 |  | 
|---|
| 186 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( ClassPrototype ); | 
|---|
| 187 | ar & BOOST_SERIALIZATION_NVP( classType ); | 
|---|
| 188 | ar & BOOST_SERIALIZATION_NVP( importedNamespaces ); | 
|---|
| 189 | ar & BOOST_SERIALIZATION_NVP( formalGenericTypes ); | 
|---|
| 190 | ar & boost::serialization::make_nvp( "pSuperClass", const_cast<CClass *&>(pSuperClass) ); | 
|---|
| 191 | ar & BOOST_SERIALIZATION_NVP( superClassActualTypeParameters ); | 
|---|
| 192 | ar & BOOST_SERIALIZATION_NVP( blittableType ); | 
|---|
| 193 | ar & BOOST_SERIALIZATION_NVP( interfaces ); | 
|---|
| 194 | ar & BOOST_SERIALIZATION_NVP( dynamicMembers ); | 
|---|
| 195 | ar & BOOST_SERIALIZATION_NVP( staticMembers ); | 
|---|
| 196 | ar & BOOST_SERIALIZATION_NVP( ConstructorMemberSubIndex ); | 
|---|
| 197 | ar & BOOST_SERIALIZATION_NVP( DestructorMemberSubIndex ); | 
|---|
| 198 | ar & BOOST_SERIALIZATION_NVP( vtblNum ); | 
|---|
| 199 | ar & BOOST_SERIALIZATION_NVP( staticMethods ); | 
|---|
| 200 | ar & BOOST_SERIALIZATION_NVP( fixedAlignment ); | 
|---|
| 201 | } | 
|---|
| 202 |  | 
|---|
| 203 | bool isReady; | 
|---|
| 204 | public: | 
|---|
| 205 |  | 
|---|
| 206 | CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ) | 
|---|
| 207 | : ClassPrototype( namespaceScopes, name ) | 
|---|
| 208 | , importedNamespaces( importedNamespaces ) | 
|---|
| 209 | , classType( Class ) | 
|---|
| 210 | , pSuperClass( NULL ) | 
|---|
| 211 | , blittableType( Type() ) | 
|---|
| 212 | , isReady( false ) | 
|---|
| 213 | , fixedAlignment( 0 ) | 
|---|
| 214 | , ConstructorMemberSubIndex( -1 ) | 
|---|
| 215 | , DestructorMemberSubIndex( -1 ) | 
|---|
| 216 | , vtblNum( 0 ) | 
|---|
| 217 | , vtbl_offset( -1 ) | 
|---|
| 218 | , comVtblOffset( 0 ) | 
|---|
| 219 | , isCompilingConstructor( false ) | 
|---|
| 220 | , isCompilingDestructor( false ) | 
|---|
| 221 | , pobj_NextClass( NULL ) | 
|---|
| 222 | { | 
|---|
| 223 | } | 
|---|
| 224 | CClass() | 
|---|
| 225 | : ClassPrototype() | 
|---|
| 226 | , importedNamespaces() | 
|---|
| 227 | , classType() | 
|---|
| 228 | , pSuperClass( NULL ) | 
|---|
| 229 | , blittableType( Type() ) | 
|---|
| 230 | , isReady( false ) | 
|---|
| 231 | , fixedAlignment( 0 ) | 
|---|
| 232 | , ConstructorMemberSubIndex( -1 ) | 
|---|
| 233 | , DestructorMemberSubIndex( -1 ) | 
|---|
| 234 | , vtblNum( 0 ) | 
|---|
| 235 | , vtbl_offset( -1 ) | 
|---|
| 236 | , comVtblOffset( 0 ) | 
|---|
| 237 | , isCompilingConstructor( false ) | 
|---|
| 238 | , isCompilingDestructor( false ) | 
|---|
| 239 | , pobj_NextClass( NULL ) | 
|---|
| 240 | { | 
|---|
| 241 | } | 
|---|
| 242 | ~CClass() | 
|---|
| 243 | { | 
|---|
| 244 | // 動的メンバ | 
|---|
| 245 | BOOST_FOREACH( CMember *member, dynamicMembers ) | 
|---|
| 246 | { | 
|---|
| 247 | delete member; | 
|---|
| 248 | } | 
|---|
| 249 |  | 
|---|
| 250 | // 静的メンバ | 
|---|
| 251 | BOOST_FOREACH( CMember *member, staticMembers ) | 
|---|
| 252 | { | 
|---|
| 253 | delete member; | 
|---|
| 254 | } | 
|---|
| 255 |  | 
|---|
| 256 | // インターフェイス | 
|---|
| 257 | BOOST_FOREACH( ::Interface *pInterface, interfaces ) | 
|---|
| 258 | { | 
|---|
| 259 | delete pInterface; | 
|---|
| 260 | } | 
|---|
| 261 | } | 
|---|
| 262 |  | 
|---|
| 263 | virtual const std::string &GetKeyName() const | 
|---|
| 264 | { | 
|---|
| 265 | return GetName(); | 
|---|
| 266 | } | 
|---|
| 267 | virtual bool IsDuplication( const CClass *pClass ) const | 
|---|
| 268 | { | 
|---|
| 269 | if( pClass->IsEqualSymbol( *this ) ) | 
|---|
| 270 | { | 
|---|
| 271 | return true; | 
|---|
| 272 | } | 
|---|
| 273 | return false; | 
|---|
| 274 | } | 
|---|
| 275 |  | 
|---|
| 276 | void Readed(){ | 
|---|
| 277 | isReady = true; | 
|---|
| 278 | } | 
|---|
| 279 | bool IsReady() const{ | 
|---|
| 280 | return isReady; | 
|---|
| 281 | } | 
|---|
| 282 |  | 
|---|
| 283 | const NamespaceScopesCollection &GetImportedNamespaces() const | 
|---|
| 284 | { | 
|---|
| 285 | return importedNamespaces; | 
|---|
| 286 | } | 
|---|
| 287 |  | 
|---|
| 288 | // 型パラメータ | 
|---|
| 289 | void AddFormalGenericType( GenericType genericType ) | 
|---|
| 290 | { | 
|---|
| 291 | this->formalGenericTypes.push_back( genericType ); | 
|---|
| 292 | } | 
|---|
| 293 | int GetFormalGenericTypeParameterIndex( const std::string &name ) const | 
|---|
| 294 | { | 
|---|
| 295 | int i = 0; | 
|---|
| 296 | BOOST_FOREACH( const GenericType &genericType, formalGenericTypes ) | 
|---|
| 297 | { | 
|---|
| 298 | if( genericType.GetName() == name ) | 
|---|
| 299 | { | 
|---|
| 300 | return i; | 
|---|
| 301 | } | 
|---|
| 302 | i++; | 
|---|
| 303 | } | 
|---|
| 304 | return -1; | 
|---|
| 305 | } | 
|---|
| 306 | bool IsExistFormalGenericTypeParameter( const std::string &name ) const | 
|---|
| 307 | { | 
|---|
| 308 | BOOST_FOREACH( const GenericType &genericType, formalGenericTypes ) | 
|---|
| 309 | { | 
|---|
| 310 | if( genericType.GetName() == name ) | 
|---|
| 311 | { | 
|---|
| 312 | return true; | 
|---|
| 313 | } | 
|---|
| 314 | } | 
|---|
| 315 | return false; | 
|---|
| 316 | } | 
|---|
| 317 |  | 
|---|
| 318 | // 継承元クラス | 
|---|
| 319 | bool HasSuperClass() const | 
|---|
| 320 | { | 
|---|
| 321 | return ( pSuperClass != NULL ); | 
|---|
| 322 | } | 
|---|
| 323 | const CClass &GetSuperClass() const | 
|---|
| 324 | { | 
|---|
| 325 | return *pSuperClass; | 
|---|
| 326 | } | 
|---|
| 327 | void SetSuperClass( const CClass *pSuperClass ) | 
|---|
| 328 | { | 
|---|
| 329 | this->pSuperClass = pSuperClass; | 
|---|
| 330 | } | 
|---|
| 331 | const Types &GetSuperClassActualTypeParameters() const | 
|---|
| 332 | { | 
|---|
| 333 | return superClassActualTypeParameters; | 
|---|
| 334 | } | 
|---|
| 335 | void SetSuperClassActualTypeParameters( const Types &actualTypeParameters ) | 
|---|
| 336 | { | 
|---|
| 337 | this->superClassActualTypeParameters = actualTypeParameters; | 
|---|
| 338 | } | 
|---|
| 339 |  | 
|---|
| 340 | // Blittable型 | 
|---|
| 341 | bool IsBlittableType() const | 
|---|
| 342 | { | 
|---|
| 343 | return !blittableType.IsNull(); | 
|---|
| 344 | } | 
|---|
| 345 | const Type &GetBlittableType() const | 
|---|
| 346 | { | 
|---|
| 347 | return blittableType; | 
|---|
| 348 | } | 
|---|
| 349 | void SetBlittableType( const Type &type ){ | 
|---|
| 350 | blittableType = type; | 
|---|
| 351 | } | 
|---|
| 352 |  | 
|---|
| 353 | bool IsClass() const; | 
|---|
| 354 | bool IsInterface() const; | 
|---|
| 355 | bool IsComInterface() const; | 
|---|
| 356 | bool IsEnum() const; | 
|---|
| 357 | bool IsDelegate() const; | 
|---|
| 358 | bool IsStructure() const; | 
|---|
| 359 | void SetClassType( ClassType classType ) | 
|---|
| 360 | { | 
|---|
| 361 | this->classType = classType; | 
|---|
| 362 | } | 
|---|
| 363 |  | 
|---|
| 364 |  | 
|---|
| 365 | //コンストラクタをコンパイルしているかどうかのチェックフラグ | 
|---|
| 366 | private: | 
|---|
| 367 | mutable bool isCompilingConstructor; | 
|---|
| 368 | public: | 
|---|
| 369 | void NotifyStartConstructorCompile() const; | 
|---|
| 370 | void NotifyFinishConstructorCompile() const; | 
|---|
| 371 | bool IsCompilingConstructor() const; | 
|---|
| 372 |  | 
|---|
| 373 | //デストラクタをコンパイルしているかどうかのチェックフラグ | 
|---|
| 374 | private: | 
|---|
| 375 | mutable bool isCompilingDestructor; | 
|---|
| 376 | public: | 
|---|
| 377 | void NotifyStartDestructorCompile() const; | 
|---|
| 378 | void NotifyFinishDestructorCompile() const; | 
|---|
| 379 | bool IsCompilingDestructor() const; | 
|---|
| 380 |  | 
|---|
| 381 |  | 
|---|
| 382 | //自身の派生クラスかどうかを確認 | 
|---|
| 383 | bool IsSubClass( const CClass *pClass ) const; | 
|---|
| 384 |  | 
|---|
| 385 | //自身と等しいまたは派生クラスかどうかを確認 | 
|---|
| 386 | bool IsEqualsOrSubClass( const CClass *pClass ) const; | 
|---|
| 387 |  | 
|---|
| 388 | // 自身と等しいまたは派生クラス、基底クラスかどうかを確認 | 
|---|
| 389 | bool IsEqualsOrSubClassOrSuperClass( const CClass &objClass ) const; | 
|---|
| 390 |  | 
|---|
| 391 | // インターフェイス | 
|---|
| 392 | bool HasInterfaces() const | 
|---|
| 393 | { | 
|---|
| 394 | return ( interfaces.size() != 0 ); | 
|---|
| 395 | } | 
|---|
| 396 | const Interfaces &GetInterfaces() const | 
|---|
| 397 | { | 
|---|
| 398 | return interfaces; | 
|---|
| 399 | } | 
|---|
| 400 | bool IsInheritsInterface( const CClass *pInterfaceClass ) const; | 
|---|
| 401 |  | 
|---|
| 402 | // クラス継承 | 
|---|
| 403 | bool Inherits( const char *inheritNames, int nowLine ); | 
|---|
| 404 | bool InheritsClass( const CClass &inheritsClass, const Types &actualTypeParameters, int nowLine ); | 
|---|
| 405 | bool InheritsInterface( const CClass &inheritsClass, int nowLine ); | 
|---|
| 406 |  | 
|---|
| 407 | // インターフェイス実装 | 
|---|
| 408 | bool Implements( const CClass &interfaceClass, const Types &actualTypeParameters, int nowLine ); | 
|---|
| 409 | bool Implements( const char *interfaceNames, int nowLine ); | 
|---|
| 410 |  | 
|---|
| 411 | //メンバ、メソッドの追加 | 
|---|
| 412 | CMember *CreateMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ); | 
|---|
| 413 | void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer, int nowLine ); | 
|---|
| 414 | void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ); | 
|---|
| 415 |  | 
|---|
| 416 | void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, | 
|---|
| 417 | bool isVirtual, bool isOverride, bool isAutoGeneration, char *buffer, int nowLine); | 
|---|
| 418 |  | 
|---|
| 419 | //重複チェック | 
|---|
| 420 | bool DupliCheckAll(const char *name); | 
|---|
| 421 | bool DupliCheckMember(const char *name); | 
|---|
| 422 |  | 
|---|
| 423 | const Members &GetDynamicMembers() const | 
|---|
| 424 | { | 
|---|
| 425 | return dynamicMembers; | 
|---|
| 426 | } | 
|---|
| 427 | const Members &GetStaticMembers() const | 
|---|
| 428 | { | 
|---|
| 429 | return staticMembers; | 
|---|
| 430 | } | 
|---|
| 431 | Members &GetDynamicMembers() | 
|---|
| 432 | { | 
|---|
| 433 | return dynamicMembers; | 
|---|
| 434 | } | 
|---|
| 435 | Members &GetStaticMembers() | 
|---|
| 436 | { | 
|---|
| 437 | return staticMembers; | 
|---|
| 438 | } | 
|---|
| 439 |  | 
|---|
| 440 | const CMember *FindDynamicMember( const char *memberName ) const | 
|---|
| 441 | { | 
|---|
| 442 | BOOST_FOREACH( CMember *pMember, GetDynamicMembers() ) | 
|---|
| 443 | { | 
|---|
| 444 | if( pMember->GetName() == memberName ) | 
|---|
| 445 | { | 
|---|
| 446 | return pMember; | 
|---|
| 447 | } | 
|---|
| 448 | } | 
|---|
| 449 | return NULL; | 
|---|
| 450 | } | 
|---|
| 451 |  | 
|---|
| 452 | void EnumDynamicMethodsOrInterfaceMethods( const char *methodName, std::vector<const UserProc *> &subs ) const; | 
|---|
| 453 | const CMethod *GetDynamicMethodOrInterfaceMethod( const UserProc *pUserProc ) const; | 
|---|
| 454 |  | 
|---|
| 455 | const Methods &GetStaticMethods() const | 
|---|
| 456 | { | 
|---|
| 457 | return staticMethods; | 
|---|
| 458 | } | 
|---|
| 459 | Methods &GetStaticMethods() | 
|---|
| 460 | { | 
|---|
| 461 | return staticMethods; | 
|---|
| 462 | } | 
|---|
| 463 |  | 
|---|
| 464 | //デフォルト コンストラクタ | 
|---|
| 465 | const CMethod *GetConstructorMethod() const | 
|---|
| 466 | { | 
|---|
| 467 | if( ConstructorMemberSubIndex == -1 ) return NULL; | 
|---|
| 468 | return GetDynamicMethods()[ConstructorMemberSubIndex]; | 
|---|
| 469 | } | 
|---|
| 470 | void SetConstructorMemberSubIndex( int constructorMemberSubIndex ) | 
|---|
| 471 | { | 
|---|
| 472 | this->ConstructorMemberSubIndex = constructorMemberSubIndex; | 
|---|
| 473 | } | 
|---|
| 474 |  | 
|---|
| 475 | //デストラクタ メソッドを取得 | 
|---|
| 476 | const CMethod *GetDestructorMethod() const | 
|---|
| 477 | { | 
|---|
| 478 | if( DestructorMemberSubIndex == -1 ) return NULL; | 
|---|
| 479 | return GetDynamicMethods()[DestructorMemberSubIndex]; | 
|---|
| 480 | } | 
|---|
| 481 | void SetDestructorMemberSubIndex( int destructorMemberSubIndex ) | 
|---|
| 482 | { | 
|---|
| 483 | this->DestructorMemberSubIndex = destructorMemberSubIndex; | 
|---|
| 484 | } | 
|---|
| 485 |  | 
|---|
| 486 | // デリゲート情報を取得 | 
|---|
| 487 | const ::Delegate &GetDelegate() const; | 
|---|
| 488 |  | 
|---|
| 489 | // ユーザ指定のアラインメント固定値 | 
|---|
| 490 | int GetFixedAlignment() const | 
|---|
| 491 | { | 
|---|
| 492 | return fixedAlignment; | 
|---|
| 493 | } | 
|---|
| 494 | void SetFixedAlignment( int fixedAlignment ) | 
|---|
| 495 | { | 
|---|
| 496 | this->fixedAlignment = fixedAlignment; | 
|---|
| 497 | } | 
|---|
| 498 |  | 
|---|
| 499 | // メンバの総合サイズを取得 | 
|---|
| 500 | int GetSize() const; | 
|---|
| 501 |  | 
|---|
| 502 | // メンバのオフセットを取得 | 
|---|
| 503 | int GetMemberOffset( const char *memberName, int *pMemberNum = NULL ) const; | 
|---|
| 504 | private: | 
|---|
| 505 | // アラインメント値を取得 | 
|---|
| 506 | int GetAlignment() const; | 
|---|
| 507 |  | 
|---|
| 508 |  | 
|---|
| 509 | ///////////////////////////////////////////////////////////////// | 
|---|
| 510 | // vtbl | 
|---|
| 511 | ///////////////////////////////////////////////////////////////// | 
|---|
| 512 | public: | 
|---|
| 513 | // vtblに存在する仮想関数の数 | 
|---|
| 514 | int GetVtblNum() const | 
|---|
| 515 | { | 
|---|
| 516 | return vtblNum; | 
|---|
| 517 | } | 
|---|
| 518 | void SetVtblNum( int vtblNum ) | 
|---|
| 519 | { | 
|---|
| 520 | this->vtblNum = vtblNum; | 
|---|
| 521 | } | 
|---|
| 522 | void AddVtblNum( int vtblNum ) | 
|---|
| 523 | { | 
|---|
| 524 | this->vtblNum += vtblNum; | 
|---|
| 525 | } | 
|---|
| 526 | bool IsExistVirtualFunctions() const | 
|---|
| 527 | { | 
|---|
| 528 | return ( vtblNum > 0 ); | 
|---|
| 529 | } | 
|---|
| 530 |  | 
|---|
| 531 | private: | 
|---|
| 532 | long vtbl_offset; | 
|---|
| 533 | long comVtblOffset; | 
|---|
| 534 | long vtblMasterListOffset; | 
|---|
| 535 | std::vector<long> vtblMasterList; | 
|---|
| 536 | public: | 
|---|
| 537 | void GetVtblMasterListIndexAndVtblIndex( const UserProc *pUserProc, int &vtblMasterListIndex, int &vtblIndex ) const; | 
|---|
| 538 | int GetVtblMasterListIndex( const CClass *pClass ) const; | 
|---|
| 539 | long GetComVtblOffset() const; | 
|---|
| 540 | long GetVtblMasterListOffset() const; | 
|---|
| 541 | void GenerateVTableMasterList( const std::vector<long> &vtableMasterList, long &offset ); | 
|---|
| 542 | void GenerateFullVTables(); | 
|---|
| 543 | void ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ); | 
|---|
| 544 | bool IsAbstract() const; | 
|---|
| 545 |  | 
|---|
| 546 |  | 
|---|
| 547 | // TypeInfo用 | 
|---|
| 548 | mutable int typeInfoDataTableOffset; | 
|---|
| 549 | void SetTypeInfoDataTableOffset( int typeInfoDataTableOffset ) const | 
|---|
| 550 | { | 
|---|
| 551 | this->typeInfoDataTableOffset = typeInfoDataTableOffset; | 
|---|
| 552 | } | 
|---|
| 553 | int GetTypeInfoDataTableOffset() const | 
|---|
| 554 | { | 
|---|
| 555 | return typeInfoDataTableOffset; | 
|---|
| 556 | } | 
|---|
| 557 |  | 
|---|
| 558 |  | 
|---|
| 559 | //線形リスト用 | 
|---|
| 560 | CClass *pobj_NextClass; | 
|---|
| 561 | }; | 
|---|
| 562 |  | 
|---|
| 563 | class Classes : public Jenga::Common::Hashmap<CClass> | 
|---|
| 564 | { | 
|---|
| 565 | // XMLシリアライズ用 | 
|---|
| 566 | public: | 
|---|
| 567 | Classes() | 
|---|
| 568 | : pCompilingMethod( NULL ) | 
|---|
| 569 | , pStringClass( NULL ) | 
|---|
| 570 | , pObjectClass( NULL ) | 
|---|
| 571 | , pInterfaceInfo( NULL ) | 
|---|
| 572 | { | 
|---|
| 573 | } | 
|---|
| 574 | ~Classes() | 
|---|
| 575 | { | 
|---|
| 576 | } | 
|---|
| 577 |  | 
|---|
| 578 | virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name); | 
|---|
| 579 | bool Insert( CClass *pClass, int nowLine ); | 
|---|
| 580 | CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); | 
|---|
| 581 | virtual void CollectClassesForNameOnly( const BasicSource &source ); | 
|---|
| 582 |  | 
|---|
| 583 | // vtblを一時的に生成 | 
|---|
| 584 | void GenerateVTables(); | 
|---|
| 585 |  | 
|---|
| 586 | // vtblのを正規のオフセットで再構築 | 
|---|
| 587 | void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ); | 
|---|
| 588 |  | 
|---|
| 589 | virtual void InitStaticMember(); | 
|---|
| 590 |  | 
|---|
| 591 | private: | 
|---|
| 592 | bool MemberVar_LoopRefCheck(const CClass &objClass); | 
|---|
| 593 | public: | 
|---|
| 594 | virtual void GetClass_recur(const char *lpszInheritsClass); | 
|---|
| 595 | void LookaheadClass( const char *className ); | 
|---|
| 596 | bool LoopRefCheck( const CClass &objClass ); | 
|---|
| 597 | virtual void GetAllClassInfo(); | 
|---|
| 598 | virtual void Compile_System_InitializeUserTypes(); | 
|---|
| 599 | virtual void Compile_System_InitializeUserTypesForBaseType(); | 
|---|
| 600 |  | 
|---|
| 601 | const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const; | 
|---|
| 602 | const CClass *Find( const string &fullName ) const; | 
|---|
| 603 |  | 
|---|
| 604 |  | 
|---|
| 605 | ///////////////////////////// | 
|---|
| 606 | // 現在コンパイル中の情報 | 
|---|
| 607 | ///////////////////////////// | 
|---|
| 608 | private: | 
|---|
| 609 | const CMethod *pCompilingMethod; | 
|---|
| 610 | public: | 
|---|
| 611 | void StartCompile( const UserProc *pUserProc ); | 
|---|
| 612 |  | 
|---|
| 613 | //現在コンパイル中のメソッド情報を取得 | 
|---|
| 614 | const CMethod *GetNowCompilingMethodInfo(){ | 
|---|
| 615 | return pCompilingMethod; | 
|---|
| 616 | } | 
|---|
| 617 |  | 
|---|
| 618 |  | 
|---|
| 619 | ///////////////////////////// | 
|---|
| 620 | // 特殊クラス | 
|---|
| 621 | ///////////////////////////// | 
|---|
| 622 | mutable const CClass *pStringClass; | 
|---|
| 623 | mutable const CClass *pObjectClass; | 
|---|
| 624 | mutable const CClass *pInterfaceInfo; | 
|---|
| 625 | const CClass *GetStringClassPtr() const; | 
|---|
| 626 | const CClass *GetObjectClassPtr() const; | 
|---|
| 627 | const CClass *GetInterfaceInfoClassPtr() const; | 
|---|
| 628 | }; | 
|---|