source: translator/ControlStruct/ForExprMutator.cc @ 3848e0e

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 3848e0e was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 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.