Changeset 559 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src
- Timestamp:
- May 5, 2008, 12:26:44 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.