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 b1a6d6b 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
|
Rev | Line | |
---|
[51b7345] | 1 | #include "SynTree/Mutator.h" |
---|
| 2 | #include "SynTree/Statement.h" |
---|
| 3 | #include "ForExprMutator.h" |
---|
| 4 | |
---|
| 5 | namespace ControlStruct { |
---|
[d9a0e76] | 6 | Statement *ForExprMutator::mutate( ForStmt *forStmt ) { |
---|
[d4778a6] | 7 | forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) ); |
---|
| 8 | if ( DeclStmt *decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() ) ) { |
---|
[d9a0e76] | 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(); |
---|
[51b7345] | 12 | |
---|
[d9a0e76] | 13 | stmts.push_back( decl ); |
---|
| 14 | forStmt->set_initialization( 0 ); |
---|
| 15 | stmts.push_back( forStmt ); |
---|
[51b7345] | 16 | |
---|
[d9a0e76] | 17 | return block; |
---|
| 18 | } // if |
---|
| 19 | // ForStmt still needs to be fixed |
---|
| 20 | else |
---|
| 21 | return forStmt; |
---|
| 22 | } |
---|
[51b7345] | 23 | } // namespace ControlStruct |
---|
Note: See
TracBrowser
for help on using the repository browser.