source: translator/ControlStruct/ForExprMutator.cc @ 01aeade

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 01aeade was 51587aa, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

licencing: fourth groups of files

  • Property mode set to 100644
File size: 1.3 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// XXX.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By :
12// Last Modified On :
13// Update Count     : 0
14//
15#include "SynTree/Mutator.h"
16#include "SynTree/Statement.h"
17#include "ForExprMutator.h"
18
19namespace ControlStruct {
20    Statement *ForExprMutator::mutate( ForStmt *forStmt ) {
21        // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99)
22        forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) );
23        if ( DeclStmt *decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() ) ) {
24            // create compound statement, move initializer declaration outside, leave _for_ as-is
25            CompoundStmt *block = new CompoundStmt( std::list< Label >() );
26            std::list<Statement *> &stmts = block->get_kids();
27
28            stmts.push_back( decl );
29            forStmt->set_initialization( 0 );
30            stmts.push_back( forStmt );
31
32            return block;
33        } // if
34
35        return forStmt;
36    }
37} // namespace ControlStruct
38// Local Variables: //
39// tab-width: 4 //
40// mode: c++ //
41// compile-command: "make install" //
42// End: //
Note: See TracBrowser for help on using the repository browser.