source: translator/ControlStruct/ForExprMutator.cc@ b87a5ed

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since b87a5ed was c11e31c, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago

add inline and attribute qualifiers, cfa.y comment formatting, fix error message in isIntegralType

  • Property mode set to 100644
File size: 844 bytes
Line 
1#include "SynTree/Mutator.h"
2#include "SynTree/Statement.h"
3#include "ForExprMutator.h"
4
5namespace ControlStruct {
6 Statement *ForExprMutator::mutate( ForStmt *forStmt ) {
7 // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99)
8 forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) );
9 if ( DeclStmt *decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() ) ) {
10 // create compound statement, move initializer declaration outside, leave _for_ as-is
11 CompoundStmt *block = new CompoundStmt( std::list< Label >() );
12 std::list<Statement *> &stmts = block->get_kids();
13
14 stmts.push_back( decl );
15 forStmt->set_initialization( 0 );
16 stmts.push_back( forStmt );
17
18 return block;
19 } // if
20
21 return forStmt;
22 }
23} // namespace ControlStruct
Note: See TracBrowser for help on using the repository browser.