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 d4778a6 was
d4778a6,
checked in by Rob Schluntz <rschlunt@…>, 9 years ago
|
for loop initializers are hoisted properly and for loops a level of scope
|
-
Property mode set to
100644
|
File size:
768 bytes
|
Line | |
---|
1 | #include "SynTree/Mutator.h" |
---|
2 | #include "SynTree/Statement.h" |
---|
3 | #include "ForExprMutator.h" |
---|
4 | |
---|
5 | namespace ControlStruct { |
---|
6 | Statement *ForExprMutator::mutate( ForStmt *forStmt ) { |
---|
7 | forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) ); |
---|
8 | if ( DeclStmt *decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() ) ) { |
---|
9 | // create compound statement, move declaration outside, leave _for_ as-is |
---|
10 | CompoundStmt *block = new CompoundStmt( std::list< Label >() ); |
---|
11 | std::list<Statement *> &stmts = block->get_kids(); |
---|
12 | |
---|
13 | stmts.push_back( decl ); |
---|
14 | forStmt->set_initialization( 0 ); |
---|
15 | stmts.push_back( forStmt ); |
---|
16 | |
---|
17 | return block; |
---|
18 | } // if |
---|
19 | // ForStmt still needs to be fixed |
---|
20 | else |
---|
21 | return forStmt; |
---|
22 | } |
---|
23 | } // namespace ControlStruct |
---|
Note: See
TracBrowser
for help on using the repository browser.