- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ForExprMutator.cc
r145f1fc r843054c2 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 14 12:14:44201513 // Update Count : 1011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 19 15:31:47 2015 13 // Update Count : 2 14 14 // 15 15 … … 22 22 // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99) 23 23 forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) ); 24 if ( DeclStmt *decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() ) ) { 25 // create compound statement, move initializer declaration outside, leave _for_ as-is 26 CompoundStmt *block = new CompoundStmt( std::list< Label >() ); 27 std::list<Statement *> &stmts = block->get_kids(); 24 28 25 std::list<Statement *> &init = forStmt->get_initialization(); 26 if ( init.size() == 0 ) { 27 return forStmt; 29 stmts.push_back( decl ); 30 forStmt->set_initialization( 0 ); 31 stmts.push_back( forStmt ); 32 33 return block; 28 34 } // if 29 30 // create compound statement, move initializers outside, leave _for_ as-is31 CompoundStmt *block = new CompoundStmt( std::list< Label >() );32 std::list<Statement *> &stmts = block->get_kids();33 for ( std::list<Statement *>::iterator it = init.begin(); it != init.end(); ++it ) {34 stmts.push_back( *it );35 } // for36 37 // add for to the new block38 stmts.push_back( forStmt );39 forStmt->set_initialization( std::list<Statement *>() );40 return block;41 35 42 36 return forStmt;
Note:
See TracChangeset
for help on using the changeset viewer.