Changeset ba3706f for src/ControlStruct/ExceptTranslate.cc
- Timestamp:
- Nov 30, 2017, 4:43:59 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- c50d54d
- Parents:
- 4429b04
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ExceptTranslate.cc
r4429b04 rba3706f 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 , noLabels32 #include "SynTree/Label.h" // for Label 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( noLabels,item));59 block->push_back(new DeclStmt(item)); 60 60 } 61 61 … … 205 205 throwStmt->set_expr( nullptr ); 206 206 delete throwStmt; 207 return new ExprStmt( noLabels,call );207 return new ExprStmt( call ); 208 208 } 209 209 … … 220 220 assert( handler_except_decl ); 221 221 222 CompoundStmt * result = new CompoundStmt( throwStmt->get_labels() ); 223 result->push_back( new ExprStmt( noLabels, UntypedExpr::createAssign( 222 CompoundStmt * result = new CompoundStmt(); 223 result->labels = throwStmt->labels; 224 result->push_back( new ExprStmt( UntypedExpr::createAssign( 224 225 nameOf( handler_except_decl ), 225 226 new ConstantExpr( Constant::null( … … 231 232 ) ) ); 232 233 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(),251 250 new ConstantExpr( Constant::from_bool( false ) ) 252 251 ); 252 result->labels = throwStmt->labels; 253 253 delete throwStmt; 254 254 return result; … … 291 291 // } 292 292 // return; 293 CompoundStmt * block = new CompoundStmt( noLabels);293 CompoundStmt * block = new CompoundStmt(); 294 294 295 295 // Just copy the exception value. (Post Validation) … … 304 304 ) }) 305 305 ); 306 block->push_back( new DeclStmt( noLabels,local_except ) );306 block->push_back( new DeclStmt( local_except ) ); 307 307 308 308 // Add the cleanup attribute. … … 324 324 325 325 std::list<Statement *> caseBody 326 { block, new ReturnStmt( n oLabels, nullptr ) };326 { block, new ReturnStmt( nullptr ) }; 327 327 handler_wrappers.push_back( new CaseStmt( 328 noLabels,329 328 new ConstantExpr( Constant::from_int( index ) ), 330 329 caseBody … … 340 339 341 340 SwitchStmt * handler_lookup = new SwitchStmt( 342 noLabels,343 341 nameOf( index_obj ), 344 342 stmt_handlers 345 343 ); 346 CompoundStmt * body = new CompoundStmt( noLabels);344 CompoundStmt * body = new CompoundStmt(); 347 345 body->push_back( handler_lookup ); 348 346 … … 363 361 // } 364 362 365 CompoundStmt * block = new CompoundStmt( noLabels);363 CompoundStmt * block = new CompoundStmt(); 366 364 367 365 // Local Declaration … … 369 367 dynamic_cast<ObjectDecl *>( modded_handler->get_decl() ); 370 368 assert( local_except ); 371 block->push_back( new DeclStmt( noLabels,local_except ) );369 block->push_back( new DeclStmt( local_except ) ); 372 370 373 371 // Check for type match. … … 381 379 } 382 380 // Construct the match condition. 383 block->push_back( new IfStmt( noLabels,381 block->push_back( new IfStmt( 384 382 cond, modded_handler->get_body(), nullptr ) ); 385 383 … … 397 395 // } 398 396 399 CompoundStmt * body = new CompoundStmt( noLabels);397 CompoundStmt * body = new CompoundStmt(); 400 398 401 399 FunctionType * func_type = match_func_t.clone(); … … 413 411 414 412 // Create new body. 415 handler->set_body( new ReturnStmt( noLabels,413 handler->set_body( new ReturnStmt( 416 414 new ConstantExpr( Constant::from_int( index ) ) ) ); 417 415 … … 421 419 } 422 420 423 body->push_back( new ReturnStmt( noLabels,421 body->push_back( new ReturnStmt( 424 422 new ConstantExpr( Constant::from_int( 0 ) ) ) ); 425 423 … … 441 439 args.push_back( nameOf( terminate_match ) ); 442 440 443 CompoundStmt * callStmt = new CompoundStmt( noLabels);444 callStmt->push_back( new ExprStmt( noLabels,caller ) );441 CompoundStmt * callStmt = new CompoundStmt(); 442 callStmt->push_back( new ExprStmt( caller ) ); 445 443 return callStmt; 446 444 } … … 451 449 // HANDLER WRAPPERS { `hander->body`; return true; } 452 450 // } 453 CompoundStmt * body = new CompoundStmt( noLabels);451 CompoundStmt * body = new CompoundStmt(); 454 452 455 453 FunctionType * func_type = handle_func_t.clone(); … … 464 462 dynamic_cast<CompoundStmt*>( handler->get_body() ); 465 463 if ( ! handling_code ) { 466 handling_code = new CompoundStmt( noLabels);464 handling_code = new CompoundStmt(); 467 465 handling_code->push_back( handler->get_body() ); 468 466 } 469 handling_code->push_back( new ReturnStmt( noLabels,467 handling_code->push_back( new ReturnStmt( 470 468 new ConstantExpr( Constant::from_bool( true ) ) ) ); 471 469 handler->set_body( handling_code ); … … 476 474 } 477 475 478 body->push_back( new ReturnStmt( noLabels,476 body->push_back( new ReturnStmt( 479 477 new ConstantExpr( Constant::from_bool( false ) ) ) ); 480 478 … … 486 484 Statement * wraps, 487 485 FunctionDecl * resume_handler ) { 488 CompoundStmt * body = new CompoundStmt( noLabels);486 CompoundStmt * body = new CompoundStmt(); 489 487 490 488 // struct __try_resume_node __resume_node … … 521 519 setup->get_args().push_back( nameOf( resume_handler ) ); 522 520 523 body->push_back( new ExprStmt( noLabels,setup ) );521 body->push_back( new ExprStmt( setup ) ); 524 522 525 523 body->push_back( wraps ); … … 646 644 // Generate a prefix for the function names? 647 645 648 CompoundStmt * block = new CompoundStmt( noLabels);646 CompoundStmt * block = new CompoundStmt(); 649 647 CompoundStmt * inner = take_try_block( tryStmt ); 650 648
Note: See TracChangeset
for help on using the changeset viewer.