Changeset 282 in dev for trunk/abdev/BasicCompiler_Common/src
- Timestamp:
- Aug 14, 2007, 11:57:32 PM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r276 r282 720 720 return vtbl_offset; 721 721 } 722 void CClass::GenerateVTables() 723 { 724 if( IsAbstract() ) 725 { 726 // 抽象クラスは無視 727 return; 728 } 729 if( !IsUsing() ) 730 { 731 // 使われていないクラスは無視 732 return; 733 } 734 735 const UserProc **ppsi; 736 ppsi=(const UserProc **)malloc(GetVtblNum()*sizeof(UserProc *)); 737 738 //関数テーブルに値をセット 739 int i2 = 0; 740 BOOST_FOREACH( const CMethod *pMethod, methods ){ 741 if(pMethod->IsVirtual()){ 742 if( !pMethod->GetUserProc().IsUsing() ) 743 { 744 ts((char *)pMethod->GetUserProc().GetFullName().c_str()); 745 } 746 pMethod->GetUserProc().Using(); 747 748 if(pMethod->IsAbstract()){ 749 extern int cp; 750 SmoothieException::Throw(300,NULL,cp); 751 752 ppsi[i2]=0; 753 } 754 else{ 755 ppsi[i2]=&pMethod->GetUserProc(); 756 } 757 i2++; 758 } 759 } 760 761 vtbl_offset=compiler.GetObjectModule().dataTable.AddBinary((void *)ppsi,GetVtblNum()*sizeof(LONG_PTR)); 762 763 for( int i=0; i < GetVtblNum(); i++ ){ 764 pobj_Reloc->AddSchedule_DataSection(vtbl_offset+i*sizeof(LONG_PTR)); 765 } 766 767 free(ppsi); 768 } 722 769 void CClass::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){ 770 if( IsAbstract() ) 771 { 772 // 抽象クラスは無視 773 return; 774 } 775 if( !IsUsing() ) 776 { 777 // 使われていないクラスは無視 778 return; 779 } 723 780 if(vtbl_offset==-1) return; 724 781 … … 731 788 pUserProc=(UserProc *)pVtbl[i]; 732 789 if(!pUserProc) continue; 790 791 if( pUserProc->GetBeginOpAddress() == 0 792 && pUserProc->GetEndOpAddress() == 0 ) 793 { 794 Jenga::Throw( "未解決の仮想関数が存在する" ); 795 } 733 796 734 797 pVtbl[i]=pUserProc->GetBeginOpAddress()+ImageBase+MemPos_CodeSection; … … 908 971 } 909 972 } 973 } 974 } 975 976 void Classes::GenerateVTables() 977 { 978 Iterator_Reset(); 979 while( Iterator_HasNext() ) 980 { 981 CClass *pClass = Iterator_GetNext(); 982 pClass->GenerateVTables(); 910 983 } 911 984 } … … 1615 1688 pParentClass->Using(); 1616 1689 1690 // 仮想関数になるメソッドに使用チェックをつける 1691 BOOST_FOREACH( const CMethod *pMethod, pParentClass->GetMethods() ) 1692 { 1693 if( pMethod->IsVirtual() ) 1694 { 1695 pMethod->GetUserProc().Using(); 1696 } 1697 } 1698 1617 1699 pCompilingMethod = pParentClass->GetMethods().GetMethodPtr( pUserProc ); 1618 1700 if( !pCompilingMethod ){ -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r276 r282 102 102 } 103 103 104 void Linker::ResolveVtblSchedule( long dataSectionBaseOffset ) 105 { 106 BOOST_FOREACH( const Schedule &schedule, nativeCode.GetSchedules() ) 107 { 108 if( schedule.GetType() == Schedule::Vtbl ) 109 { 110 LONG_PTR vtblAddress = schedule.GetClass().GetVtblGlobalOffset(); 111 112 nativeCode.Overwrite( 113 schedule.GetOffset(), 114 static_cast<long>( vtblAddress + imageBase + dataSectionBaseOffset ) 115 ); 116 } 117 } 118 } 119 104 120 void Linker::Link( ObjectModule &masterObjectModule ) 105 121 { -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r280 r282 64 64 } 65 65 66 void NativeCode::PutVtblSchedule( const CClass *pClass ) 67 { 68 schedules.push_back( Schedule( pClass, size ) ); 69 70 *((long *)(codeBuffer+size))=0; 71 size += sizeof(long); 72 } 73 66 74 void NativeCode::NextSourceLine() 67 75 { -
trunk/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r280 r282 33 33 this->sources.push_back( source ); 34 34 } 35 36 // TODO: basbufがいらなくなったら消す 37 extern char *basbuf; 38 basbuf = this->sources[0].GetBuffer(); 35 39 } 36 40
Note:
See TracChangeset
for help on using the changeset viewer.