- File:
-
- 1 edited
-
src/ControlStruct/ForExprMutator.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ForExprMutator.cc
r8bafacc r6d49ea3 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:00201713 // Update Count : 1 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 17 15:32:46 2017 13 // Update Count : 11 14 14 // 15 15 … … 21 21 22 22 namespace ControlStruct { 23 Statement * hoist( Statement *originalStmt, std::list<Statement *> &init ) {24 // If no hoisting is needed, skip:25 if ( 0 == init.size()) {26 return originalStmt;27 } 23 Statement *ForExprMutator::postmutate( IfStmt *ifStmt ) { 24 std::list<Statement *> &init = ifStmt->get_initialization(); 25 if ( init.size() == 0 ) { 26 return ifStmt; 27 } // if 28 28 29 // Create compound statement, move initializers outside, 30 // the resut of the original stays as is. 29 // create compound statement, move initializers outside, leave _for_ as-is 31 30 CompoundStmt *block = new CompoundStmt( std::list< Label >() ); 32 31 std::list<Statement *> &stmts = block->get_kids(); 33 32 stmts.splice( stmts.end(), init ); 34 33 35 // Add for to the new block.36 stmts.push_back( originalStmt );34 // add for to the new block 35 stmts.push_back( ifStmt ); 37 36 return block; 38 37 } 39 38 40 Statement *ForExprMutator::postmutate( IfStmt *ifStmt ) {41 return hoist( ifStmt, ifStmt->initialization );42 }43 39 Statement *ForExprMutator::postmutate( ForStmt *forStmt ) { 44 40 // hoist any initializer declarations to make them C89 (rather than C99) 45 return hoist( forStmt, forStmt->initialization ); 41 std::list<Statement *> &init = forStmt->get_initialization(); 42 if ( init.size() == 0 ) { 43 return forStmt; 44 } // if 45 46 // create compound statement, move initializers outside, leave _for_ as-is 47 CompoundStmt *block = new CompoundStmt( std::list< Label >() ); 48 std::list<Statement *> &stmts = block->get_kids(); 49 stmts.splice( stmts.end(), init ); 50 51 // add for to the new block 52 stmts.push_back( forStmt ); 53 return block; 46 54 } 47 55 } // namespace ControlStruct
Note:
See TracChangeset
for help on using the changeset viewer.