Changeset e9145a3 for src/ControlStruct
- Timestamp:
- Aug 17, 2017, 4:13:42 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:
- 8f6dfe7
- Parents:
- 21f0aa8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ExceptTranslate.cc
r21f0aa8 re9145a3 10 10 // Created On : Wed Jun 14 16:49:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T us Aug 8 16:54:00 201713 // Update Count : 712 // Last Modified On : Thr Aug 17 15:48:00 2017 13 // Update Count : 8 14 14 // 15 15 … … 387 387 } 388 388 389 // TODO: Stoping the function from generating the 'return variable' 390 // entirely would be cleaner. But this does get ride of warnings. 391 CompoundStmt * set_and_ret(DeclarationWithType * var, Expression * val) { 392 CompoundStmt * block = new CompoundStmt( noLabels ); 393 block->push_back( new ExprStmt( noLabels, 394 UntypedExpr::createAssign( new VariableExpr( var ), val ) 395 ) ); 396 block->push_back( new ReturnStmt( noLabels, 397 new VariableExpr( var ) 398 ) ); 399 return block; 400 } 401 389 402 FunctionDecl * ExceptionMutatorCore::create_terminate_match( 390 403 CatchList &handlers ) { … … 397 410 FunctionType * func_type = match_func_t.clone(); 398 411 DeclarationWithType * except_obj = func_type->get_parameters().back(); 412 DeclarationWithType * index_obj = func_type->get_returnVals().front(); 399 413 400 414 // Index 1..{number of handlers} … … 409 423 410 424 // Create new body. 411 handler->set_body( new ReturnStmt( noLabels,425 handler->set_body( set_and_ret( index_obj, 412 426 new ConstantExpr( Constant::from_int( index ) ) ) ); 413 427 … … 417 431 } 418 432 419 body->push_back( new ReturnStmt( noLabels, new ConstantExpr(420 Constant::from_int( 0 ) ) ) );433 body->push_back( set_and_ret( index_obj, 434 new ConstantExpr( Constant::from_int( 0 ) ) ) ); 421 435 422 436 return new FunctionDecl("match", Type::StorageClasses(), … … 449 463 CompoundStmt * body = new CompoundStmt( noLabels ); 450 464 451 FunctionType * func_type = match_func_t.clone();465 FunctionType * func_type = handle_func_t.clone(); 452 466 DeclarationWithType * except_obj = func_type->get_parameters().back(); 467 DeclarationWithType * bool_obj = func_type->get_returnVals().front(); 453 468 454 469 CatchList::iterator it; … … 463 478 handling_code->push_back( handler->get_body() ); 464 479 } 465 handling_code->push_back( new ReturnStmt( noLabels,480 handling_code->push_back( set_and_ret( bool_obj, 466 481 new ConstantExpr( Constant::from_bool( true ) ) ) ); 467 482 handler->set_body( handling_code ); … … 472 487 } 473 488 474 body->push_back( new ReturnStmt( noLabels, new ConstantExpr(475 Constant::from_bool( false ) ) ) );489 body->push_back( set_and_ret( bool_obj, 490 new ConstantExpr( Constant::from_bool( false ) ) ) ); 476 491 477 492 return new FunctionDecl("handle", Type::StorageClasses(),
Note: See TracChangeset
for help on using the changeset viewer.