Changeset b067d9b for src/ControlStruct
- Timestamp:
- Oct 29, 2019, 4:01:24 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 773db65, 9421f3d8
- Parents:
- 7951100 (diff), 8364209 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/ControlStruct
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ExceptTranslate.cc
r7951100 rb067d9b 9 9 // Author : Andrew Beach 10 10 // Created On : Wed Jun 14 16:49:00 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Aug 17 17:19:00 201713 // Update Count : 911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 13 18:15:29 2019 13 // Update Count : 11 14 14 // 15 15 … … 319 319 } 320 320 321 block->push_back( handler-> get_body());322 handler-> set_body( nullptr );321 block->push_back( handler->body ); 322 handler->body = nullptr; 323 323 324 324 std::list<Statement *> caseBody … … 617 617 return create_terminate_rethrow( throwStmt ); 618 618 } else { 619 a ssertf(false,"Invalid throw in %s at %i\n",619 abort("Invalid throw in %s at %i\n", 620 620 throwStmt->location.filename.c_str(), 621 621 throwStmt->location.first_line); 622 return nullptr;623 622 } 624 623 } else { … … 628 627 return create_resume_rethrow( throwStmt ); 629 628 } else { 630 a ssertf(false,"Invalid throwResume in %s at %i\n",629 abort("Invalid throwResume in %s at %i\n", 631 630 throwStmt->location.filename.c_str(), 632 631 throwStmt->location.first_line); 633 return nullptr;634 632 } 635 633 } -
src/ControlStruct/ForExprMutator.cc
r7951100 rb067d9b 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Aug 18 10:22:00 201713 // Update Count : 1 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 11 22:26:52 2019 13 // Update Count : 14 14 14 // 15 15 … … 21 21 22 22 namespace ControlStruct { 23 Statement * hoist( Statement *originalStmt, std::list<Statement *> &init ) {23 Statement * hoist( Statement * originalStmt, std::list<Statement *> & init ) { 24 24 // If no hoisting is needed, skip: 25 25 if ( 0 == init.size() ) { … … 29 29 // Create compound statement, move initializers outside, 30 30 // the resut of the original stays as is. 31 CompoundStmt * block = new CompoundStmt();32 std::list<Statement *> & stmts = block->get_kids();31 CompoundStmt * block = new CompoundStmt(); 32 std::list<Statement *> & stmts = block->get_kids(); 33 33 stmts.splice( stmts.end(), init ); 34 34 … … 38 38 } 39 39 40 Statement * ForExprMutator::postmutate( IfStmt *ifStmt ) {40 Statement * ForExprMutator::postmutate( IfStmt * ifStmt ) { 41 41 return hoist( ifStmt, ifStmt->initialization ); 42 42 } 43 Statement * ForExprMutator::postmutate( ForStmt *forStmt ) {43 Statement * ForExprMutator::postmutate( ForStmt * forStmt ) { 44 44 // hoist any initializer declarations to make them C89 (rather than C99) 45 45 return hoist( forStmt, forStmt->initialization ); 46 46 } 47 Statement * ForExprMutator::postmutate( WhileStmt *whileStmt ) {47 Statement * ForExprMutator::postmutate( WhileStmt * whileStmt ) { 48 48 return hoist( whileStmt, whileStmt->initialization ); 49 49 } -
src/ControlStruct/LabelFixer.cc
r7951100 rb067d9b 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Jul 28 13:32:43 201513 // Update Count : 15 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 11 22:26:02 2019 13 // Update Count : 159 14 14 // 15 15 … … 32 32 } 33 33 34 LabelFixer::LabelFixer( LabelGenerator * gen ) : generator ( gen ) {34 LabelFixer::LabelFixer( LabelGenerator * gen ) : generator ( gen ) { 35 35 if ( generator == 0 ) 36 36 generator = LabelGenerator::getGenerator(); … … 49 49 50 50 // prune to at most one label definition for each statement 51 void LabelFixer::previsit( Statement * stmt ) {51 void LabelFixer::previsit( Statement * stmt ) { 52 52 std::list< Label > &labels = stmt->get_labels(); 53 53 … … 58 58 } 59 59 60 void LabelFixer::previsit( BranchStmt * branchStmt ) {60 void LabelFixer::previsit( BranchStmt * branchStmt ) { 61 61 previsit( ( Statement *)branchStmt ); 62 62 … … 75 75 76 76 77 // sets the definition of the labelTable entry to be the provided 78 // statement for every label in the listparameter. Happens for every kind of statement79 Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement *definition ) {77 // sets the definition of the labelTable entry to be the provided statement for every label in the list 78 // parameter. Happens for every kind of statement 79 Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) { 80 80 assert( definition != 0 ); 81 81 assert( llabel.size() > 0 ); … … 100 100 } // for 101 101 102 // produce one of the labels attached to this statement to be 103 // temporarily used as the canonical label 102 // produce one of the labels attached to this statement to be temporarily used as the canonical label 104 103 return labelTable[ llabel.front() ]->get_label(); 105 104 } … … 117 116 118 117 // Builds a table that maps a label to its defining statement. 119 std::map<Label, Statement * > * LabelFixer::resolveJumps() throw ( SemanticErrorException ) {118 std::map<Label, Statement * > * LabelFixer::resolveJumps() throw ( SemanticErrorException ) { 120 119 std::map< Label, Statement * > *ret = new std::map< Label, Statement * >(); 121 120 for ( std::map< Label, Entry * >::iterator i = labelTable.begin(); i != labelTable.end(); ++i ) { -
src/ControlStruct/LabelGenerator.cc
r7951100 rb067d9b 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Aug 14 14:14:00 201513 // Update Count : 1 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 11 22:23:20 2019 13 // Update Count : 15 14 14 // 15 15 … … 24 24 25 25 namespace ControlStruct { 26 LabelGenerator * LabelGenerator::labelGenerator = 0;26 LabelGenerator * LabelGenerator::labelGenerator = 0; 27 27 28 LabelGenerator * LabelGenerator::getGenerator() {28 LabelGenerator * LabelGenerator::getGenerator() { 29 29 if ( LabelGenerator::labelGenerator == 0 ) 30 30 LabelGenerator::labelGenerator = new LabelGenerator(); 31 32 31 return labelGenerator; 33 32 } … … 38 37 if ( stmt && ! stmt->get_labels().empty() ) { 39 38 os << "_" << stmt->get_labels().front() << "__"; 40 } 39 } // if 41 40 std::string ret = os.str(); 42 41 Label l( ret ); -
src/ControlStruct/MLEMutator.cc
r7951100 rb067d9b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Mar 8 17:08:25 201813 // Update Count : 2 1912 // Last Modified On : Tue Oct 22 17:22:44 2019 13 // Update Count : 220 14 14 // 15 15 … … 313 313 } 314 314 315 void MLEMutator::premutate( TryStmt * tryStmt ) { 316 // generate a label for breaking out of a labeled if 317 bool labeledBlock = !(tryStmt->get_labels().empty()); 318 if ( labeledBlock ) { 319 Label brkLabel = generator->newLabel("blockBreak", tryStmt); 320 enclosingControlStructures.push_back( Entry( tryStmt, brkLabel ) ); 321 GuardAction( [this]() { enclosingControlStructures.pop_back(); } ); 322 } // if 323 } 324 325 Statement * MLEMutator::postmutate( TryStmt * tryStmt ) { 326 bool labeledBlock = !(tryStmt->get_labels().empty()); 327 if ( labeledBlock ) { 328 if ( ! enclosingControlStructures.back().useBreakExit().empty() ) { 329 set_breakLabel( enclosingControlStructures.back().useBreakExit() ); 330 } // if 331 } // if 332 return tryStmt; 333 } 334 315 335 void MLEMutator::premutate( CaseStmt *caseStmt ) { 316 336 visit_children = false; -
src/ControlStruct/MLEMutator.h
r7951100 rb067d9b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Mar 8 16:42:32 201813 // Update Count : 4 112 // Last Modified On : Tue Oct 22 17:22:47 2019 13 // Update Count : 45 14 14 // 15 15 … … 47 47 void premutate( SwitchStmt *switchStmt ); 48 48 Statement * postmutate( SwitchStmt *switchStmt ); 49 void premutate( TryStmt *tryStmt ); 50 Statement * postmutate( TryStmt *tryStmt ); 49 51 50 52 Statement *mutateLoop( Statement *bodyLoop, Entry &e ); … … 73 75 explicit Entry( SwitchStmt *stmt, Label breakExit, Label fallDefaultExit ) : 74 76 stmt( stmt ), breakExit( breakExit ), fallDefaultExit( fallDefaultExit ) {} 77 78 explicit Entry( TryStmt *stmt, Label breakExit ) : 79 stmt( stmt ), breakExit( breakExit ) {} 75 80 76 81 bool operator==( const Statement *other ) { return stmt == other; } -
src/ControlStruct/module.mk
r7951100 rb067d9b 15 15 ############################################################################### 16 16 17 SRC += ControlStruct/LabelGenerator.cc \ 17 SRC_CONTROLSTRUCT = \ 18 ControlStruct/ForExprMutator.cc \ 18 19 ControlStruct/LabelFixer.cc \ 20 ControlStruct/LabelGenerator.cc \ 19 21 ControlStruct/MLEMutator.cc \ 20 ControlStruct/Mutate.cc \ 21 ControlStruct/ForExprMutator.cc \ 22 ControlStruct/ExceptTranslate.cc 22 ControlStruct/Mutate.cc 23 24 SRC += $(SRC_CONTROLSTRUCT) ControlStruct/ExceptTranslate.cc 25 SRCDEMANGLE += $(SRC_CONTROLSTRUCT) 26
Note:
See TracChangeset
for help on using the changeset viewer.