source: src/ControlStruct/ForExprMutator.cc@ 8f6dfe7

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 8f6dfe7 was d180746, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Big header cleaning pass - commit 2

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[51587aa]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//
[0db6fc0]7// ForExprMutator.cc --
[51587aa]8//
[843054c2]9// Author : Rodolfo G. Esteves
[51587aa]10// Created On : Mon May 18 07:44:20 2015
[145f1fc]11// Last Modified By : Rob Schluntz
12// Last Modified On : Tue Jul 14 12:14:44 2015
13// Update Count : 10
[51587aa]14//
[a08ba92]15
[d180746]16#include <list> // for list, _List_iterator, list<>::iterator
17
[51b73452]18#include "ForExprMutator.h"
[d180746]19#include "SynTree/Label.h" // for Label
20#include "SynTree/Statement.h" // for Statement (ptr only), ForStmt, Compou...
[51b73452]21
22namespace ControlStruct {
[0db6fc0]23 Statement *ForExprMutator::postmutate( ForStmt *forStmt ) {
24 // hoist any initializer declarations to make them C89 (rather than C99)
25 std::list<Statement *> &init = forStmt->get_initialization();
[145f1fc]26 if ( init.size() == 0 ) {
27 return forStmt;
[a08ba92]28 } // if
[c11e31c]29
[145f1fc]30 // create compound statement, move initializers outside, leave _for_ as-is
31 CompoundStmt *block = new CompoundStmt( std::list< Label >() );
32 std::list<Statement *> &stmts = block->get_kids();
33 for ( std::list<Statement *>::iterator it = init.begin(); it != init.end(); ++it ) {
34 stmts.push_back( *it );
35 } // for
36
37 // add for to the new block
38 stmts.push_back( forStmt );
39 forStmt->set_initialization( std::list<Statement *>() );
40 return block;
[a08ba92]41 }
[51b73452]42} // namespace ControlStruct
[a08ba92]43
[51587aa]44// Local Variables: //
45// tab-width: 4 //
46// mode: c++ //
47// compile-command: "make install" //
48// End: //
Note: See TracBrowser for help on using the repository browser.