source: translator/ControlStruct/ForExprMutator.cc@ 91b216b4

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 91b216b4 was 51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago

initial commit

  • Property mode set to 100644
File size: 698 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 {
8 DeclStmt *decl;
9 if (( decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() )) != 0 )
10 {
11 // create compound statement, move declaration outside, leave _for_ as-is
12 CompoundStmt *block = new CompoundStmt( std::list< Label >() );
13 std::list<Statement *> &stmts = block->get_kids();
14
15 stmts.push_back( decl );
16 forStmt->set_initialization( 0 );
17 stmts.push_back( forStmt );
18
19 return block;
20 }
21 // ForStmt still needs to be fixed
22 else
23 return forStmt;
24 }
25
26} // namespace ControlStruct
Note: See TracBrowser for help on using the repository browser.