- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ExceptTranslate.cc
rba3706f r7543dec 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 … … 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( 233 noLabels, 234 234 new UntypedExpr( new NameExpr( "__cfaehm__rethrow_terminate" ) ) 235 235 ) ); … … 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. … … 315 315 { 316 316 VarExprReplacer::DeclMap mapping; 317 mapping[ handler_decl ] = local_except;317 mapping[ handler_decl ] = new VariableExpr( local_except ); 318 318 VarExprReplacer mapper( mapping ); 319 handler-> get_body()->accept( mapper );319 handler->body->acceptMutator( mapper ); 320 320 } 321 321 322 block->push_back( handler-> get_body());323 handler-> set_body( nullptr );322 block->push_back( handler->body ); 323 handler->body = nullptr; 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 … … 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 … … 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 ); … … 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.