- Timestamp:
- May 5, 2008, 12:26:44 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h
r558 r559 437 437 long comVtblOffset; 438 438 long vtblMasterListOffset; 439 public: 439 440 std::vector<long> vtblMasterList; 440 public: 441 LONG_PTR GetVtblOffset() const 442 { 443 return vtbl_offset; 444 } 445 void SetVtblOffset( int vtblOffset ) 446 { 447 this->vtbl_offset = vtblOffset; 448 } 449 long GetComVtblOffset() const 450 { 451 return comVtblOffset; 452 } 453 void SetComVtblOffset( int comVtblOffset ) 454 { 455 this->comVtblOffset = comVtblOffset; 456 } 441 457 void GetVtblMasterListIndexAndVtblIndex( const UserProc *pUserProc, int &vtblMasterListIndex, int &vtblIndex ) const; 442 458 int GetVtblMasterListIndex( const CClass *pClass ) const; 443 long GetComVtblOffset() const;444 459 long GetVtblMasterListOffset() const; 445 void GenerateVTableMasterList( const std::vector<long> &vtableMasterList, long &offset ); 446 void GenerateFullVTables(); 447 void ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ); 460 void SetVtblMasterListOffset( int vtblMasterListOffset ) 461 { 462 this->vtblMasterListOffset = vtblMasterListOffset; 463 } 448 464 bool IsAbstract() const; 449 465 … … 484 500 bool Insert( CClass *pClass, int nowLine ); 485 501 CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); 486 487 // vtblを一時的に生成488 void GenerateVTables();489 490 // vtblのを正規のオフセットで再構築491 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection );492 502 493 503 virtual void InitStaticMember(); -
trunk/ab5.0/abdev/BasicCompiler_Common/include/Method.h
r558 r559 273 273 // 仮想メソッドの個数を取得 274 274 int GetVtblNum() const; 275 276 // vtblを生成 277 void GenerateVTablePart( long &vtableDataTableOffset ) const; 278 }; 275 }; -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp
r558 r559 724 724 return 0; 725 725 } 726 long CClass::GetComVtblOffset() const727 {728 return comVtblOffset;729 }730 726 long CClass::GetVtblMasterListOffset() const 731 727 { … … 737 733 738 734 return vtblMasterListOffset; 739 }740 void CClass::GenerateVTableMasterList( const std::vector<long> &vtableMasterList, long &offset )741 {742 offset = compiler.GetObjectModule().dataTable.AddBinary(743 (void *)&vtableMasterList[0],744 static_cast<int>(vtableMasterList.size()*sizeof(LONG_PTR))745 );746 }747 void CClass::GenerateFullVTables()748 {749 if( IsAbstract() )750 {751 // 抽象クラスは無視752 return;753 }754 if( !IsUsing() )755 {756 // 使われていないクラスは無視757 return;758 }759 760 // vtblマスターリストの元データに不要なデータが含まれていたらエラー761 if( vtblMasterList.size() )762 {763 compiler.errorMessenger.OutputFatalError();764 }765 766 // 自身のクラスのvtblを生成767 GetDynamicMethods().GenerateVTablePart( this->vtbl_offset );768 vtblMasterList.push_back( this->vtbl_offset );769 770 // インターフェイスのvtblを生成771 BOOST_FOREACH( const ::Interface *pInterface, interfaces )772 {773 long tempVtblOffset;774 pInterface->GetDynamicMethods().GenerateVTablePart( tempVtblOffset );775 vtblMasterList.push_back( tempVtblOffset );776 777 pInterface->SetVtblOffset( tempVtblOffset );778 779 if( pInterface->GetClass().IsComInterface() )780 {781 if( this->comVtblOffset )782 {783 compiler.errorMessenger.OutputFatalError();784 }785 this->comVtblOffset = tempVtblOffset;786 }787 }788 789 // vtblマスターリストを生成790 GenerateVTableMasterList( vtblMasterList, this->vtblMasterListOffset );791 }792 void CClass::ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection )793 {794 if( IsAbstract() )795 {796 // 抽象クラスは無視797 return;798 }799 if( !IsUsing() )800 {801 // 使われていないクラスは無視802 return;803 }804 if(vtbl_offset==-1) return;805 806 // 自身のクラスのvtbl807 {808 LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + vtbl_offset);809 810 for( int i=0; i<GetVtblNum(); i++ ){811 const UserProc *pUserProc = (UserProc *)pVtbl[i];812 if(!pUserProc) continue;813 814 if( pUserProc->GetBeginOpAddress() == 0815 && pUserProc->GetEndOpAddress() == 0 )816 {817 Jenga::Throw( "未解決の仮想関数が存在する" );818 }819 820 pVtbl[i] = pUserProc->GetBeginOpAddress() + ImageBase + MemPos_CodeSection;821 }822 }823 824 // インターフェイスのvtbl825 BOOST_FOREACH( const ::Interface *pInterface, interfaces )826 {827 LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + pInterface->GetVtblOffset());828 829 for( int i=0; i<pInterface->GetClass().GetVtblNum(); i++ ){830 const UserProc *pUserProc = (UserProc *)pVtbl[i];831 if(!pUserProc) continue;832 833 if( pUserProc->GetBeginOpAddress() == 0834 && pUserProc->GetEndOpAddress() == 0 )835 {836 Jenga::Throw( "未解決の仮想関数が存在する" );837 }838 839 pVtbl[i] = pUserProc->GetBeginOpAddress() + ImageBase + MemPos_CodeSection;840 }841 }842 843 // vtblマスターリスト844 LONG_PTR *pVtblMasterList = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + vtblMasterListOffset );845 for( int i=0; i<static_cast<int>(vtblMasterList.size()); i++ )846 {847 pVtblMasterList[i] = vtblMasterList[i] + ImageBase + MemPos_DataSection;848 }849 735 } 850 736 bool CClass::IsAbstract() const … … 905 791 906 792 return pClass; 907 }908 909 void Classes::GenerateVTables()910 {911 Iterator_Reset();912 while( Iterator_HasNext() )913 {914 CClass *pClass = Iterator_GetNext();915 pClass->GenerateFullVTables();916 }917 }918 919 void Classes::ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ){920 Iterator_Reset();921 while( Iterator_HasNext() )922 {923 CClass *pClass = Iterator_GetNext();924 pClass->ActionVtblSchedule( ImageBase, MemPos_CodeSection, MemPos_DataSection);925 }926 793 } 927 794 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Method.cpp
r558 r559 36 36 { 37 37 // 静的メソッドがコピーコンストラトされることは想定しない 38 compiler.errorMessenger.OutputFatalError();38 throw; 39 39 } 40 40 … … 144 144 return count; 145 145 } 146 147 void Methods::GenerateVTablePart( long &vtableDataTableOffset ) const148 {149 const UserProc **ppsi = (const UserProc **)malloc(GetVtblNum()*sizeof(UserProc *));150 151 //関数テーブルに値をセット152 int i2 = 0;153 const Methods &methods = *this;154 BOOST_FOREACH( const CMethod *pMethod, methods ){155 if(pMethod->IsVirtual()){156 if( !pMethod->GetUserProc().IsUsing() )157 {158 //ts((char *)pMethod->GetUserProc().GetFullName().c_str());159 }160 pMethod->GetUserProc().Using();161 162 if(pMethod->IsAbstract()){163 compiler.errorMessenger.OutputFatalError();164 165 ppsi[i2]=0;166 }167 else{168 ppsi[i2]=&pMethod->GetUserProc();169 }170 i2++;171 }172 }173 174 vtableDataTableOffset = compiler.GetObjectModule().dataTable.AddBinary( (void *)ppsi, GetVtblNum()*sizeof(LONG_PTR) );175 176 for( int i=0; i < GetVtblNum(); i++ ){177 pobj_Reloc->AddSchedule_DataSection(static_cast<DWORD>(vtableDataTableOffset+i*sizeof(LONG_PTR)));178 }179 180 free(ppsi);181 } -
trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp
r552 r559 537 537 ///////////////////////////////////////////////////////////////// 538 538 539 compiler.GetObjectModule().meta.GetClasses().GenerateVTables(); 539 ActiveBasic::Compiler::VtblGenerator::GenerateVTablesForAllClasses( 540 compiler.GetObjectModule().meta.GetClasses() 541 ); 540 542 541 543 … … 1089 1091 //////////////////////////////////////// 1090 1092 //仮想関数データテーブルスケジュール 1091 compiler.GetObjectModule().meta.GetClasses().ActionVtblSchedule( ImageBase, MemPos_CodeSection, MemPos_DataSection ); 1093 ActiveBasic::Compiler::VtblGenerator::ActionVtblScheduleForAllClasses( 1094 compiler.GetObjectModule().meta.GetClasses(), 1095 ImageBase, 1096 MemPos_CodeSection, 1097 MemPos_DataSection 1098 ); 1092 1099 1093 1100 -
trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj
r547 r559 1288 1288 > 1289 1289 </File> 1290 <File 1291 RelativePath="..\BasicCompiler_Common\src\VtblGenerator.cpp" 1292 > 1293 </File> 1290 1294 <Filter 1291 1295 Name="Langauge Classes" … … 1481 1485 > 1482 1486 </File> 1487 <File 1488 RelativePath="..\BasicCompiler_Common\include\VtblGenerator.h" 1489 > 1490 </File> 1483 1491 <Filter 1484 1492 Name="Language Classes" -
trunk/ab5.0/abdev/compiler_x86/stdafx.h
r548 r559 71 71 #include <Program.h> 72 72 #include <LexicalAnalyzer.h> 73 #include <VtblGenerator.h>
Note:
See TracChangeset
for help on using the changeset viewer.