Changeset 6d49ea3 for src/ControlStruct
- Timestamp:
- Aug 17, 2017, 5:37:20 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 274ce8c
- Parents:
- 936e9f4
- Location:
- src/ControlStruct
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ForExprMutator.cc
r936e9f4 r6d49ea3 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T ue Jul 14 12:14:44 201513 // Update Count : 1 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 17 15:32:46 2017 13 // Update Count : 11 14 14 // 15 15 … … 21 21 22 22 namespace 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 23 39 Statement *ForExprMutator::postmutate( ForStmt *forStmt ) { 24 40 // hoist any initializer declarations to make them C89 (rather than C99) … … 31 47 CompoundStmt *block = new CompoundStmt( std::list< Label >() ); 32 48 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 49 stmts.splice( stmts.end(), init ); 36 50 37 51 // add for to the new block 38 52 stmts.push_back( forStmt ); 39 forStmt->set_initialization( std::list<Statement *>() );40 53 return block; 41 54 } -
src/ControlStruct/ForExprMutator.h
r936e9f4 r6d49ea3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:17:08 201713 // Update Count : 412 // Last Modified On : Thu Aug 17 15:32:48 2017 13 // Update Count : 5 14 14 // 15 15 16 16 #pragma once 17 17 18 class IfStmt; 18 19 class ForStmt; 19 20 class Statement; … … 22 23 class ForExprMutator { 23 24 public: 25 Statement *postmutate( IfStmt * ); 24 26 Statement *postmutate( ForStmt * ); 25 27 };
Note: See TracChangeset
for help on using the changeset viewer.