Changeset 342 in dev for trunk/abdev/BasicCompiler_Common/include
- Timestamp:
- Oct 9, 2007, 1:10:33 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/include/Class.h
r340 r342 12 12 class Delegate; 13 13 14 class InheritedInterface14 class ClassPrototype : public Prototype 15 15 { 16 CClass *pInterfaceClass; 17 int vtblOffset; 18 public: 19 InheritedInterface( CClass *pInterfaceClass, int vtblOffset ) 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_BASE_OBJECT_NVP( Prototype ); 25 ar & BOOST_SERIALIZATION_NVP( dynamicMethods ); 26 } 27 28 public: 29 ClassPrototype( const NamespaceScopes &namespaceScopes, const string &name ) 30 : Prototype( namespaceScopes, name ) 31 { 32 } 33 ClassPrototype() 34 : Prototype() 35 { 36 } 37 const Methods &GetDynamicMethods() const 38 { 39 return dynamicMethods; 40 } 41 Methods &GetDynamicMethods() 42 { 43 return dynamicMethods; 44 } 45 }; 46 47 class Interface : public ClassPrototype 48 { 49 const CClass *pInterfaceClass; 50 mutable int vtblOffset; 51 public: 52 Interface( const CClass *pInterfaceClass ) 20 53 : pInterfaceClass( pInterfaceClass ) 21 , vtblOffset( vtblOffset)22 { 23 } 24 25 CClass &GetInterfaceClass() const{54 , vtblOffset( -1 ) 55 { 56 } 57 58 const CClass &GetClass() const{ 26 59 return *pInterfaceClass; 27 60 } 28 intGetVtblOffset() const61 LONG_PTR GetVtblOffset() const 29 62 { 30 63 return vtblOffset; 31 64 } 65 void SetVtblOffset( LONG_PTR vtblOffset ) const 66 { 67 this->vtblOffset = vtblOffset; 68 } 32 69 }; 33 typedef vector<InheritedInterface> Interfaces;34 35 class CClass: public Prototype, public Jenga::Common::ObjectInHashmap<CClass>70 typedef std::vector<Interface> Interfaces; 71 72 class CClass: public ClassPrototype, public Jenga::Common::ObjectInHashmap<CClass> 36 73 { 37 74 public: … … 73 110 74 111 // 動的メソッド 75 Methods methods;76 112 int ConstructorMemberSubIndex; 77 113 int DestructorMemberSubIndex; … … 92 128 trace_for_serialize( "serializing - CClass" ); 93 129 94 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Prototype );130 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( ClassPrototype ); 95 131 ar & BOOST_SERIALIZATION_NVP( classType ); 96 132 ar & BOOST_SERIALIZATION_NVP( importedNamespaces ); … … 102 138 ar & BOOST_SERIALIZATION_NVP( dynamicMembers ); 103 139 ar & BOOST_SERIALIZATION_NVP( staticMembers ); 104 ar & BOOST_SERIALIZATION_NVP( methods );105 140 ar & BOOST_SERIALIZATION_NVP( ConstructorMemberSubIndex ); 106 141 ar & BOOST_SERIALIZATION_NVP( DestructorMemberSubIndex ); … … 114 149 115 150 CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ) 116 : Prototype( namespaceScopes, name )151 : ClassPrototype( namespaceScopes, name ) 117 152 , importedNamespaces( importedNamespaces ) 118 153 , classType( Class ) … … 131 166 } 132 167 CClass() 133 : Prototype()168 : ClassPrototype() 134 169 , importedNamespaces() 135 170 , classType() … … 292 327 return ( interfaces.size() != 0 ); 293 328 } 329 const Interfaces &GetInterfaces() const 330 { 331 return interfaces; 332 } 294 333 bool IsInheritsInterface( const CClass *pInterfaceClass ) const; 295 334 … … 300 339 301 340 // インターフェイス実装 341 bool Implements( const CClass &interfaceClass, int nowLine ); 302 342 bool Implements( const char *interfaceNames, int nowLine ); 303 343 … … 331 371 } 332 372 333 const Methods &GetMethods() const334 {335 return methods;336 }337 373 const Methods &GetStaticMethods() const 338 374 { 339 375 return staticMethods; 340 }341 Methods &GetMethods()342 {343 return methods;344 376 } 345 377 Methods &GetStaticMethods() … … 352 384 { 353 385 if( ConstructorMemberSubIndex == -1 ) return NULL; 354 return methods[ConstructorMemberSubIndex];386 return GetDynamicMethods()[ConstructorMemberSubIndex]; 355 387 } 356 388 void SetConstructorMemberSubIndex( int constructorMemberSubIndex ) … … 363 395 { 364 396 if( DestructorMemberSubIndex == -1 ) return NULL; 365 return methods[DestructorMemberSubIndex];397 return GetDynamicMethods()[DestructorMemberSubIndex]; 366 398 } 367 399 void SetDestructorMemberSubIndex( int destructorMemberSubIndex ) … … 373 405 const ::Delegate &GetDelegate() const; 374 406 407 // ユーザ指定のアラインメント固定値 408 int GetFixedAlignment() const 409 { 410 return fixedAlignment; 411 } 412 void SetFixedAlignment( int fixedAlignment ) 413 { 414 this->fixedAlignment = fixedAlignment; 415 } 416 417 // メンバの総合サイズを取得 418 int GetSize() const; 419 420 // メンバのオフセットを取得 421 int GetMemberOffset( const char *memberName, int *pMemberNum = NULL ) const; 422 private: 423 // アラインメント値を取得 424 int GetAlignment() const; 425 426 427 ///////////////////////////////////////////////////////////////// 428 // vtbl 429 ///////////////////////////////////////////////////////////////// 430 public: 375 431 // vtblに存在する仮想関数の数 376 432 int GetVtblNum() const … … 390 446 return ( vtblNum > 0 ); 391 447 } 392 393 // ユーザ指定のアラインメント固定値 394 int GetFixedAlignment() const 395 { 396 return fixedAlignment; 397 } 398 void SetFixedAlignment( int fixedAlignment ) 399 { 400 this->fixedAlignment = fixedAlignment; 401 } 402 403 // メンバの総合サイズを取得 404 int GetSize() const; 405 406 // メンバのオフセットを取得 407 int GetMemberOffset( const char *memberName, int *pMemberNum = NULL ) const; 408 private: 409 // アラインメント値を取得 410 int GetAlignment() const; 411 412 //vtbl 413 protected: 414 mutable long vtbl_offset; 415 public: 448 449 private: 450 long vtbl_offset; 451 long vtblMasterListOffset; 452 std::vector<LONG_PTR> vtblMasterList; 453 public: 454 int GetVtblMasterListIndex( const UserProc *pUserProc ) const; 416 455 int GetFuncNumInVtbl( const UserProc *pUserProc ) const; 417 LONG_PTR GetVtblGlobalOffset(void) const; 418 void GenerateVTables(); 419 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 456 LONG_PTR GetVtblMasterListOffset() const; 457 void GenerateVTablePart( LONG_PTR &vtableDataTableOffset ) const; 458 void GenerateVTableMasterList( const std::vector<LONG_PTR> &vtableMasterList, LONG_PTR &offset ); 459 void GenerateFullVTables(); 460 void ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ); 420 461 bool IsAbstract() const; 421 462 … … 444 485 virtual void CollectClassesForNameOnly( const BasicSource &source ); 445 486 487 // vtblを一時的に生成 446 488 void GenerateVTables(); 447 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 489 490 // vtblのを正規のオフセットで再構築 491 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ); 448 492 449 493 virtual void InitStaticMember();
Note:
See TracChangeset
for help on using the changeset viewer.