source: translator/ControlStruct/ForExprMutator.cc @ 4bf5298

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 4bf5298 was c11e31c, checked in by Peter A. Buhr <pabuhr@…>, 9 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
RevLine 
[51b7345]1#include "SynTree/Mutator.h"
2#include "SynTree/Statement.h"
3#include "ForExprMutator.h"
4
5namespace ControlStruct {
[d9a0e76]6    Statement *ForExprMutator::mutate( ForStmt *forStmt ) {
[c11e31c]7        // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99)
[d4778a6]8        forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) );
9        if ( DeclStmt *decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() ) ) {
[c11e31c]10            // create compound statement, move initializer declaration outside, leave _for_ as-is
[d9a0e76]11            CompoundStmt *block = new CompoundStmt( std::list< Label >() );
12            std::list<Statement *> &stmts = block->get_kids();
[51b7345]13
[d9a0e76]14            stmts.push_back( decl );
15            forStmt->set_initialization( 0 );
16            stmts.push_back( forStmt );
[51b7345]17
[d9a0e76]18            return block;
19        } // if
[c11e31c]20
21        return forStmt;
[d9a0e76]22    }
[51b7345]23} // namespace ControlStruct
Note: See TracBrowser for help on using the repository browser.