Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ForExprMutator.cc

    r6d49ea3 rd180746  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 17 15:32:46 2017
    13 // Update Count     : 11
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Jul 14 12:14:44 2015
     13// Update Count     : 10
    1414//
    1515
     
    2121
    2222namespace ControlStruct {
    23         Statement *ForExprMutator::postmutate( IfStmt *ifStmt ) {
    24                 std::list<Statement *> &init = ifStmt->get_initialization();
    25                 if ( init.size() == 0 ) {
    26                         return ifStmt;
    27                 } // if
    28 
    29                 // create compound statement, move initializers outside, leave _for_ as-is
    30                 CompoundStmt *block = new CompoundStmt( std::list< Label >() );
    31                 std::list<Statement *> &stmts = block->get_kids();
    32                 stmts.splice( stmts.end(), init );
    33 
    34                 // add for to the new block
    35                 stmts.push_back( ifStmt );
    36                 return block;
    37         }
    38 
    3923        Statement *ForExprMutator::postmutate( ForStmt *forStmt ) {
    4024                // hoist any initializer declarations to make them C89 (rather than C99)
     
    4731                CompoundStmt *block = new CompoundStmt( std::list< Label >() );
    4832                std::list<Statement *> &stmts = block->get_kids();
    49                 stmts.splice( stmts.end(), init );
     33                for ( std::list<Statement *>::iterator it = init.begin(); it != init.end(); ++it ) {
     34                        stmts.push_back( *it );
     35                }       // for
    5036
    5137                // add for to the new block
    5238                stmts.push_back( forStmt );
     39                forStmt->set_initialization( std::list<Statement *>() );
    5340                return block;
    5441        }
Note: See TracChangeset for help on using the changeset viewer.