Changeset 190a833 for src/ControlStruct/ExceptDecl.cpp
- Timestamp:
- Jan 7, 2025, 4:31:21 PM (13 days ago)
- Branches:
- master
- Children:
- d84f2ae
- Parents:
- 10b5970
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ExceptDecl.cpp
r10b5970 r190a833 445 445 } 446 446 447 ast::NameExpr const * designatedName( ast::Designation const * des ) { 448 if ( des && 1 == des->designators.size() ) { 449 return des->designators.front().as<ast::NameExpr>(); 450 } 451 return nullptr; 452 } 453 447 454 ast::ObjectDecl const * ExceptDeclCore::transformVTable( 448 455 ast::ObjectDecl const * decl, ast::VTableType const * type ) { … … 467 474 createTypeIdValue( location, exceptionName, params ) ); 468 475 } 469 declsToAddBefore.push_back(470 createCopy( location, exceptionName, params ) );471 declsToAddBefore.push_back(472 createMsg( location, exceptionName, params ) );473 476 retDecl = createVirtualTable( 474 477 location, exceptionName, params, tableName ); 478 // There is quite a bit of work to pull over any initializers and 479 // decide if we want to insert the default functions. 480 bool foundCopy = false; 481 bool foundMsg = false; 482 ast::ListInit const * init = decl->init.as<ast::ListInit>(); 483 if ( init ) { 484 for ( size_t i = 0 ; i < init->initializers.size() ; ++i ) { 485 ast::Designation const * des = init->designations.at(i); 486 auto name = designatedName( des ); 487 if ( nullptr == name ) continue; 488 if ( "copy" == name->name ) { 489 foundCopy = true; 490 } else if ( "msg" == name->name ) { 491 foundMsg = true; 492 } 493 auto retInit = retDecl->init.as<ast::ListInit>(); 494 for ( size_t j = 0 ; j < retInit->initializers.size() ; ++j ) { 495 ast::Designation const * des = retInit->designations.at(j); 496 auto retName = designatedName( des ); 497 if ( retName && name->name == retName->name ) { 498 retInit = ast::mutate_field_index( retInit, 499 &ast::ListInit::initializers, j, 500 init->initializers.at(i) ); 501 } 502 } 503 retDecl->init = retInit; 504 } 505 } 506 if ( !foundCopy ) { 507 declsToAddBefore.push_back( 508 createCopy( location, exceptionName, params ) ); 509 } 510 if ( !foundMsg ) { 511 declsToAddBefore.push_back( 512 createMsg( location, exceptionName, params ) ); 513 } 475 514 } 476 515
Note: See TracChangeset
for help on using the changeset viewer.