- File:
-
- 1 edited
-
src/ControlStruct/ExceptTranslate.cc (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ExceptTranslate.cc
rba3706f r36982fc 30 30 #include "SynTree/Expression.h" // for UntypedExpr, ConstantExpr, Name... 31 31 #include "SynTree/Initializer.h" // for SingleInit, ListInit 32 #include "SynTree/Label.h" // for Label 32 #include "SynTree/Label.h" // for Label, noLabels 33 33 #include "SynTree/Mutator.h" // for mutateAll 34 34 #include "SynTree/Statement.h" // for CompoundStmt, CatchStmt, ThrowStmt … … 57 57 58 58 void appendDeclStmt( CompoundStmt * block, Declaration * item ) { 59 block->push_back(new DeclStmt( item));59 block->push_back(new DeclStmt(noLabels, item)); 60 60 } 61 61 … … 205 205 throwStmt->set_expr( nullptr ); 206 206 delete throwStmt; 207 return new ExprStmt( call );207 return new ExprStmt( noLabels, call ); 208 208 } 209 209 … … 211 211 ThrowStmt *throwStmt ) { 212 212 // __throw_terminate( `throwStmt->get_name()` ); } 213 return create_given_throw( "__cfa ehm__throw_terminate", throwStmt );213 return create_given_throw( "__cfaabi_ehm__throw_terminate", throwStmt ); 214 214 } 215 215 … … 220 220 assert( handler_except_decl ); 221 221 222 CompoundStmt * result = new CompoundStmt(); 223 result->labels = throwStmt->labels; 224 result->push_back( new ExprStmt( UntypedExpr::createAssign( 222 CompoundStmt * result = new CompoundStmt( throwStmt->get_labels() ); 223 result->push_back( new ExprStmt( noLabels, UntypedExpr::createAssign( 225 224 nameOf( handler_except_decl ), 226 225 new ConstantExpr( Constant::null( … … 232 231 ) ) ); 233 232 result->push_back( new ExprStmt( 234 new UntypedExpr( new NameExpr( "__cfaehm__rethrow_terminate" ) ) 233 noLabels, 234 new UntypedExpr( new NameExpr( "__cfaabi_ehm__rethrow_terminate" ) ) 235 235 ) ); 236 236 delete throwStmt; … … 241 241 ThrowStmt *throwStmt ) { 242 242 // __throw_resume( `throwStmt->get_name` ); 243 return create_given_throw( "__cfa ehm__throw_resume", throwStmt );243 return create_given_throw( "__cfaabi_ehm__throw_resume", throwStmt ); 244 244 } 245 245 … … 248 248 // return false; 249 249 Statement * result = new ReturnStmt( 250 throwStmt->get_labels(), 250 251 new ConstantExpr( Constant::from_bool( false ) ) 251 252 ); 252 result->labels = throwStmt->labels;253 253 delete throwStmt; 254 254 return result; … … 291 291 // } 292 292 // return; 293 CompoundStmt * block = new CompoundStmt( );293 CompoundStmt * block = new CompoundStmt( noLabels ); 294 294 295 295 // Just copy the exception value. (Post Validation) … … 304 304 ) }) 305 305 ); 306 block->push_back( new DeclStmt( local_except ) );306 block->push_back( new DeclStmt( noLabels, local_except ) ); 307 307 308 308 // Add the cleanup attribute. 309 309 local_except->get_attributes().push_back( new Attribute( 310 310 "cleanup", 311 { new NameExpr( "__cfa ehm__cleanup_terminate" ) }311 { new NameExpr( "__cfaabi_ehm__cleanup_terminate" ) } 312 312 ) ); 313 313 … … 324 324 325 325 std::list<Statement *> caseBody 326 { block, new ReturnStmt( n ullptr ) };326 { block, new ReturnStmt( noLabels, nullptr ) }; 327 327 handler_wrappers.push_back( new CaseStmt( 328 noLabels, 328 329 new ConstantExpr( Constant::from_int( index ) ), 329 330 caseBody … … 339 340 340 341 SwitchStmt * handler_lookup = new SwitchStmt( 342 noLabels, 341 343 nameOf( index_obj ), 342 344 stmt_handlers 343 345 ); 344 CompoundStmt * body = new CompoundStmt( );346 CompoundStmt * body = new CompoundStmt( noLabels ); 345 347 body->push_back( handler_lookup ); 346 348 … … 361 363 // } 362 364 363 CompoundStmt * block = new CompoundStmt( );365 CompoundStmt * block = new CompoundStmt( noLabels ); 364 366 365 367 // Local Declaration … … 367 369 dynamic_cast<ObjectDecl *>( modded_handler->get_decl() ); 368 370 assert( local_except ); 369 block->push_back( new DeclStmt( local_except ) );371 block->push_back( new DeclStmt( noLabels, local_except ) ); 370 372 371 373 // Check for type match. … … 379 381 } 380 382 // Construct the match condition. 381 block->push_back( new IfStmt( 383 block->push_back( new IfStmt( noLabels, 382 384 cond, modded_handler->get_body(), nullptr ) ); 383 385 … … 395 397 // } 396 398 397 CompoundStmt * body = new CompoundStmt( );399 CompoundStmt * body = new CompoundStmt( noLabels ); 398 400 399 401 FunctionType * func_type = match_func_t.clone(); … … 411 413 412 414 // Create new body. 413 handler->set_body( new ReturnStmt( 415 handler->set_body( new ReturnStmt( noLabels, 414 416 new ConstantExpr( Constant::from_int( index ) ) ) ); 415 417 … … 419 421 } 420 422 421 body->push_back( new ReturnStmt( 423 body->push_back( new ReturnStmt( noLabels, 422 424 new ConstantExpr( Constant::from_int( 0 ) ) ) ); 423 425 … … 430 432 FunctionDecl * terminate_catch, 431 433 FunctionDecl * terminate_match ) { 432 // { __cfa ehm__try_terminate(`try`, `catch`, `match`); }434 // { __cfaabi_ehm__try_terminate(`try`, `catch`, `match`); } 433 435 434 436 UntypedExpr * caller = new UntypedExpr( new NameExpr( 435 "__cfa ehm__try_terminate" ) );437 "__cfaabi_ehm__try_terminate" ) ); 436 438 std::list<Expression *>& args = caller->get_args(); 437 439 args.push_back( nameOf( try_wrapper ) ); … … 439 441 args.push_back( nameOf( terminate_match ) ); 440 442 441 CompoundStmt * callStmt = new CompoundStmt( );442 callStmt->push_back( new ExprStmt( caller ) );443 CompoundStmt * callStmt = new CompoundStmt( noLabels ); 444 callStmt->push_back( new ExprStmt( noLabels, caller ) ); 443 445 return callStmt; 444 446 } … … 449 451 // HANDLER WRAPPERS { `hander->body`; return true; } 450 452 // } 451 CompoundStmt * body = new CompoundStmt( );453 CompoundStmt * body = new CompoundStmt( noLabels ); 452 454 453 455 FunctionType * func_type = handle_func_t.clone(); … … 462 464 dynamic_cast<CompoundStmt*>( handler->get_body() ); 463 465 if ( ! handling_code ) { 464 handling_code = new CompoundStmt( );466 handling_code = new CompoundStmt( noLabels ); 465 467 handling_code->push_back( handler->get_body() ); 466 468 } 467 handling_code->push_back( new ReturnStmt( 469 handling_code->push_back( new ReturnStmt( noLabels, 468 470 new ConstantExpr( Constant::from_bool( true ) ) ) ); 469 471 handler->set_body( handling_code ); … … 474 476 } 475 477 476 body->push_back( new ReturnStmt( 478 body->push_back( new ReturnStmt( noLabels, 477 479 new ConstantExpr( Constant::from_bool( false ) ) ) ); 478 480 … … 484 486 Statement * wraps, 485 487 FunctionDecl * resume_handler ) { 486 CompoundStmt * body = new CompoundStmt( );488 CompoundStmt * body = new CompoundStmt( noLabels ); 487 489 488 490 // struct __try_resume_node __resume_node 489 // __attribute__((cleanup( __cfa ehm__try_resume_cleanup )));491 // __attribute__((cleanup( __cfaabi_ehm__try_resume_cleanup ))); 490 492 // ** unwinding of the stack here could cause problems ** 491 493 // ** however I don't think that can happen currently ** 492 // __cfa ehm__try_resume_setup( &__resume_node, resume_handler );494 // __cfaabi_ehm__try_resume_setup( &__resume_node, resume_handler ); 493 495 494 496 std::list< Attribute * > attributes; … … 496 498 std::list< Expression * > attr_params; 497 499 attr_params.push_back( new NameExpr( 498 "__cfa ehm__try_resume_cleanup" ) );500 "__cfaabi_ehm__try_resume_cleanup" ) ); 499 501 attributes.push_back( new Attribute( "cleanup", attr_params ) ); 500 502 } … … 515 517 516 518 UntypedExpr *setup = new UntypedExpr( new NameExpr( 517 "__cfa ehm__try_resume_setup" ) );519 "__cfaabi_ehm__try_resume_setup" ) ); 518 520 setup->get_args().push_back( new AddressExpr( nameOf( obj ) ) ); 519 521 setup->get_args().push_back( nameOf( resume_handler ) ); 520 522 521 body->push_back( new ExprStmt( setup ) );523 body->push_back( new ExprStmt( noLabels, setup ) ); 522 524 523 525 body->push_back( wraps ); … … 540 542 ObjectDecl * ExceptionMutatorCore::create_finally_hook( 541 543 FunctionDecl * finally_wrapper ) { 542 // struct __cfa ehm__cleanup_hook __finally_hook544 // struct __cfaabi_ehm__cleanup_hook __finally_hook 543 545 // __attribute__((cleanup( finally_wrapper ))); 544 546 … … 594 596 // Skip children? 595 597 return; 596 } else if ( structDecl->get_name() == "__cfa ehm__base_exception_t" ) {598 } else if ( structDecl->get_name() == "__cfaabi_ehm__base_exception_t" ) { 597 599 assert( nullptr == except_decl ); 598 600 except_decl = structDecl; 599 601 init_func_types(); 600 } else if ( structDecl->get_name() == "__cfa ehm__try_resume_node" ) {602 } else if ( structDecl->get_name() == "__cfaabi_ehm__try_resume_node" ) { 601 603 assert( nullptr == node_decl ); 602 604 node_decl = structDecl; 603 } else if ( structDecl->get_name() == "__cfa ehm__cleanup_hook" ) {605 } else if ( structDecl->get_name() == "__cfaabi_ehm__cleanup_hook" ) { 604 606 assert( nullptr == hook_decl ); 605 607 hook_decl = structDecl; … … 644 646 // Generate a prefix for the function names? 645 647 646 CompoundStmt * block = new CompoundStmt( );648 CompoundStmt * block = new CompoundStmt( noLabels ); 647 649 CompoundStmt * inner = take_try_block( tryStmt ); 648 650
Note:
See TracChangeset
for help on using the changeset viewer.