Changeset 370 in dev for trunk/abdev/BasicCompiler_Common/src
- Timestamp:
- Nov 15, 2007, 3:18:41 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r369 r370 116 116 return classType == CClass::Interface; 117 117 } 118 bool CClass::IsComInterface() const 119 { 120 return classType == CClass::ComInterface; 121 } 118 122 bool CClass::IsEnum() const 119 123 { … … 241 245 } 242 246 243 if( pInheritsClass->IsInterface() ){ 244 // インターフェイスはあとで継承する 245 } 246 else if( pInheritsClass->IsClass() ){ 247 if( pInheritsClass->IsClass() ){ 247 248 // クラスを継承する 248 249 isInheritsClass = true; … … 253 254 } 254 255 else{ 255 S moothieException::Throw(135,NULL,nowLine);256 SetError(135,pInheritsClass->GetFullName().c_str(),nowLine); 256 257 return false; 257 258 } … … 268 269 return false; 269 270 } 270 }271 272 i=0;273 while( true ){274 275 char temporary[VN_SIZE];276 for( int i2=0;; i++, i2++ ){277 if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){278 temporary[i2] = 0;279 break;280 }281 temporary[i2] = inheritNames[i];282 }283 284 char className[VN_SIZE];285 Jenga::Common::Strings typeParameters;286 SplitGenericClassInstance( temporary, className, typeParameters );287 288 //継承元クラスを取得289 const CClass *pInheritsClass = compiler.GetObjectModule().meta.GetClasses().Find(className);290 if( !pInheritsClass ){291 SmoothieException::Throw(106,className,nowLine);292 return false;293 }294 295 if( pInheritsClass->IsInterface() ){296 // インターフェイスを継承する297 if( !InheritsInterface( *pInheritsClass, nowLine ) ){298 return false;299 }300 }301 else if( pInheritsClass->IsClass() ){302 // クラスはさっき継承した303 }304 else{305 SmoothieException::Throw(135,NULL,nowLine);306 return false;307 }308 309 if( inheritNames[i] == '\0' ){310 break;311 }312 i++;313 271 } 314 272 … … 388 346 } 389 347 348 if( this->IsInterface() && inheritsClass.IsComInterface() ) 349 { 350 // COMインターフェイスを継承した場合はCOMインターフェイスにする 351 this->SetClassType( CClass::ComInterface ); 352 } 353 390 354 return true; 391 355 } 392 bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){393 394 //ループ継承でないかをチェック395 if(pobj_LoopRefCheck->check(inheritsInterface)){396 SmoothieException::Throw(123,inheritsInterface.GetName(),nowLine);397 return false;398 }399 400 if( !inheritsInterface.IsReady() ){401 //継承先が読み取られていないとき402 pobj_LoopRefCheck->add(this->GetName().c_str());403 compiler.GetObjectModule().meta.GetClasses().GetClass_recur(inheritsInterface.GetName().c_str());404 pobj_LoopRefCheck->del(this->GetName().c_str());405 }406 407 //メソッドをコピー408 BOOST_FOREACH( const CMethod *pBaseMethod, inheritsInterface.GetDynamicMethods() ){409 CMethod *pMethod = new DynamicMethod( *pBaseMethod );410 411 // アクセシビリティ412 if(pBaseMethod->GetAccessibility() == Prototype::Private){413 pMethod->SetAccessibility( Prototype::None );414 }415 else{416 pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );417 }418 419 //pobj_Inherits420 // ※継承元のClassIndexをセット(入れ子継承を考慮する)421 if(pBaseMethod->GetInheritsClassPtr()==0){422 pMethod->SetInheritsClassPtr( &inheritsInterface );423 }424 else{425 pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );426 }427 428 GetDynamicMethods().push_back( pMethod );429 }430 431 //interfaces.push_back( Interface( &inheritsInterface, vtblNum ) );432 433 //仮想関数の数434 AddVtblNum( inheritsInterface.GetVtblNum() );435 436 return true;437 }438 356 439 357 bool CClass::Implements( const CClass &interfaceClass, int nowLine ) 440 358 { 441 if( !interfaceClass.IsInterface() )359 if( !interfaceClass.IsInterface() && !interfaceClass.IsComInterface() ) 442 360 { 443 361 // インターフェイスではないとき … … 477 395 // キャストメソッドを追加(内部コードは自動生成すること) 478 396 ///////////////////////////////////////////////////////////////// 397 if( interfaceClass.IsInterface() ) 479 398 { 480 399 // Function Operator() As ITest … … 793 712 int i2; 794 713 795 //仮想関数が存在する場合は 関数リストへのポインタのサイズを追加796 int offset = IsExistVirtualFunctions() ? PTR_SIZE : 0;714 //仮想関数が存在する場合はvtbl及びvtblMasterListへのポインタのサイズを追加 715 int offset = IsExistVirtualFunctions() ? PTR_SIZE*2 : 0; 797 716 798 717 int alignment = 1; … … 944 863 return 0; 945 864 } 865 long CClass::GetComVtblOffset() const 866 { 867 return comVtblOffset; 868 } 946 869 long CClass::GetVtblMasterListOffset() const 947 870 { … … 992 915 993 916 pInterface->SetVtblOffset( tempVtblOffset ); 917 918 if( pInterface->GetClass().IsComInterface() ) 919 { 920 if( this->comVtblOffset ) 921 { 922 SetError(); 923 } 924 this->comVtblOffset = tempVtblOffset; 925 } 994 926 } 995 927 … … 1445 1377 pobj_c->SetConstructorMemberSubIndex( -1 ); 1446 1378 pobj_c->SetDestructorMemberSubIndex( -1 ); 1379 1380 if( memcmp( basbuf+i+1, "__COM", 5 ) == 0 && IsCommandDelimitation( basbuf[i+1+5] ) ) 1381 { 1382 // COMインターフェイス 1383 pobj_c->SetClassType( CClass::ComInterface ); 1384 1385 i += 6; 1386 } 1447 1387 1448 1388 if(basbuf[i+1]==1&&basbuf[i+2]==ESC_INHERITS){ -
trunk/abdev/BasicCompiler_Common/src/Compiler.cpp
r318 r370 36 36 if( !pGenericClass ) 37 37 { 38 extern int cp;39 SetError(106, className, cp );40 38 return false; 41 39 } -
trunk/abdev/BasicCompiler_Common/src/DataTable.cpp
r355 r370 84 84 this->lastMadeConstObjectDataTableOffset = dataTableOffset; 85 85 86 // com_vtblスケジュール 87 this->schedules.push_back( Schedule( Schedule::ComVtbl, &objClass, dataTableOffset ) ); 88 86 89 // vtblスケジュール 87 this->schedules.push_back( Schedule( &objClass, dataTableOffset) );90 this->schedules.push_back( Schedule( Schedule::Vtbl, &objClass, dataTableOffset + PTR_SIZE ) ); 88 91 89 92 // TypeInfoスケジュール … … 235 238 236 239 // スケジューリング 237 this->schedules.push_back( Schedule( &strClass, headOffset ) ); 240 this->schedules.push_back( Schedule( Schedule::ComVtbl, &strClass, headOffset ) ); 241 this->schedules.push_back( Schedule( Schedule::Vtbl, &strClass, headOffset + PTR_SIZE ) ); 238 242 this->schedules.push_back( Schedule( Schedule::TypeInfo, &strClass, headOffset + offsetForTypeInfo ) ); 239 243 this->schedules.push_back( Schedule( Schedule::DataTable, headOffset + offsetForChars ) ); -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r361 r370 165 165 BOOST_FOREACH( const Schedule &schedule, nativeCode.GetSchedules() ) 166 166 { 167 if( schedule.GetType() == Schedule::ComVtbl ) 168 { 169 LONG_PTR vtblOffset = schedule.GetClass().GetComVtblOffset(); 170 171 nativeCode.Overwrite( 172 schedule.GetOffset(), 173 static_cast<long>( vtblOffset + imageBase + dataSectionBaseOffset ) 174 ); 175 } 176 167 177 if( schedule.GetType() == Schedule::Vtbl ) 168 178 { … … 178 188 BOOST_FOREACH( const Schedule &schedule, dataTable.schedules ) 179 189 { 190 if( schedule.GetType() == Schedule::ComVtbl ) 191 { 192 LONG_PTR vtblOffset = schedule.GetClass().GetComVtblOffset(); 193 194 #ifdef _WIN64 195 dataTable.OverwriteInt64( 196 schedule.GetOffset(), 197 vtblOffset + imageBase + dataSectionBaseOffset 198 ); 199 #else 200 dataTable.Overwrite( 201 schedule.GetOffset(), 202 vtblOffset + imageBase + dataSectionBaseOffset 203 ); 204 #endif 205 } 206 180 207 if( schedule.GetType() == Schedule::Vtbl ) 181 208 { -
trunk/abdev/BasicCompiler_Common/src/Method.cpp
r353 r370 155 155 if( !pMethod->GetUserProc().IsUsing() ) 156 156 { 157 ts((char *)pMethod->GetUserProc().GetFullName().c_str());157 //ts((char *)pMethod->GetUserProc().GetFullName().c_str()); 158 158 } 159 159 pMethod->GetUserProc().Using(); -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r364 r370 95 95 } 96 96 97 void NativeCode::PutComVtblSchedule( const CClass *pClass ) 98 { 99 schedules.push_back( Schedule( Schedule::ComVtbl, pClass, GetSize() ) ); 100 101 Put( (long)0 ); 102 } 103 97 104 void NativeCode::PutVtblSchedule( const CClass *pClass ) 98 105 { 99 schedules.push_back( Schedule( pClass, GetSize() ) );106 schedules.push_back( Schedule( Schedule::Vtbl, pClass, GetSize() ) ); 100 107 101 108 Put( (long)0 ); -
trunk/abdev/BasicCompiler_Common/src/Type.cpp
r350 r370 452 452 { 453 453 return ( IsObject() && GetClass().IsInterface() ); 454 } 455 bool Type::IsComInterface() const 456 { 457 return ( IsObject() && GetClass().IsComInterface() ); 454 458 } 455 459
Note:
See TracChangeset
for help on using the changeset viewer.