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