Changeset 0577df2
- Timestamp:
- Jul 18, 2022, 5:13:33 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 11df881
- Parents:
- efcd8f2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/MultiLevelExit.cpp
refcd8f2 r0577df2 149 149 }; 150 150 151 NullStmt * labelledNullStmt( 152 const CodeLocation & cl, const Label & label ) { 151 NullStmt * labelledNullStmt( const CodeLocation & cl, const Label & label ) { 153 152 return new NullStmt( cl, vector<Label>{ label } ); 154 153 } … … 164 163 165 164 const CompoundStmt * MultiLevelExitCore::previsit( 166 const CompoundStmt * stmt ) {165 const CompoundStmt * stmt ) { 167 166 visit_children = false; 168 167 … … 189 188 } 190 189 191 size_t getUnusedIndex( 192 const Stmt * stmt, const Label & originalTarget ) { 190 size_t getUnusedIndex( const Stmt * stmt, const Label & originalTarget ) { 193 191 const size_t size = stmt->labels.size(); 194 192 … … 210 208 } 211 209 212 const Stmt * addUnused( 213 const Stmt * stmt, const Label & originalTarget ) { 210 const Stmt * addUnused( const Stmt * stmt, const Label & originalTarget ) { 214 211 size_t i = getUnusedIndex( stmt, originalTarget ); 215 212 if ( i == stmt->labels.size() ) { … … 356 353 357 354 // Mimic what the built-in push_front would do anyways. It is O(n). 358 void push_front( 359 vector<ptr<Stmt>> & vec, const Stmt * element ) { 355 void push_front( vector<ptr<Stmt>> & vec, const Stmt * element ) { 360 356 vec.emplace_back( nullptr ); 361 357 for ( size_t i = vec.size() - 1 ; 0 < i ; --i ) { … … 590 586 591 587 ptr<Stmt> else_stmt = nullptr; 592 Stmt * loop_kid = nullptr;588 const Stmt * loop_kid = nullptr; 593 589 // check if loop node and if so add else clause if it exists 594 const WhileDoStmt * whilePtr = dynamic_cast<const WhileDoStmt *>(kid.get());595 if ( whilePtr && whilePtr->else_ ) {590 const WhileDoStmt * whilePtr = kid.as<WhileDoStmt>(); 591 if ( whilePtr && whilePtr->else_ ) { 596 592 else_stmt = whilePtr->else_; 597 WhileDoStmt * mutate_ptr = mutate(whilePtr); 598 mutate_ptr->else_ = nullptr; 599 loop_kid = mutate_ptr; 600 } 601 const ForStmt * forPtr = dynamic_cast<const ForStmt *>(kid.get()); 602 if ( forPtr && forPtr->else_) { 593 loop_kid = mutate_field( whilePtr, &WhileDoStmt::else_, nullptr ); 594 } 595 const ForStmt * forPtr = kid.as<ForStmt>(); 596 if ( forPtr && forPtr->else_ ) { 603 597 else_stmt = forPtr->else_; 604 ForStmt * mutate_ptr = mutate(forPtr); 605 mutate_ptr->else_ = nullptr; 606 loop_kid = mutate_ptr; 598 loop_kid = mutate_field( forPtr, &ForStmt::else_, nullptr ); 607 599 } 608 600
Note: See TracChangeset
for help on using the changeset viewer.