Changeset a08ba92 for translator/ControlStruct/ForExprMutator.cc
- Timestamp:
- May 19, 2015, 4:58:14 PM (11 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 843054c2
- Parents:
- 01aeade
- File:
-
- 1 edited
-
translator/ControlStruct/ForExprMutator.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
translator/ControlStruct/ForExprMutator.cc
r01aeade ra08ba92 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // XXX.cc --7 // ForExprMutator.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : 12 // Last Modified On : 13 // Update Count : 011 // 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 16 #include "SynTree/Mutator.h" 16 17 #include "SynTree/Statement.h" … … 18 19 19 20 namespace ControlStruct { 20 Statement *ForExprMutator::mutate( ForStmt *forStmt ) {21 // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99)22 forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) );23 if ( DeclStmt *decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() ) ) {24 // create compound statement, move initializer declaration outside, leave _for_ as-is25 CompoundStmt *block = new CompoundStmt( std::list< Label >() );26 std::list<Statement *> &stmts = block->get_kids();21 Statement *ForExprMutator::mutate( ForStmt *forStmt ) { 22 // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99) 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(); 27 28 28 stmts.push_back( decl );29 forStmt->set_initialization( 0 );30 stmts.push_back( forStmt );29 stmts.push_back( decl ); 30 forStmt->set_initialization( 0 ); 31 stmts.push_back( forStmt ); 31 32 32 return block;33 } // if33 return block; 34 } // if 34 35 35 return forStmt;36 }36 return forStmt; 37 } 37 38 } // namespace ControlStruct 39 38 40 // Local Variables: // 39 41 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.