Changeset c0aa336 for src/SymTab/AddVisit.h
- Timestamp:
- Feb 6, 2017, 4:19:41 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:
- b4d65c7
- Parents:
- a362f97
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/AddVisit.h
ra362f97 rc0aa336 10 10 // Created On : Sun May 17 16:14:32 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 11:22:01 201613 // Update Count : 912 // Last Modified On : Thu Feb 2 16:36:02 2017 13 // Update Count : 14 14 14 // 15 15 … … 18 18 19 19 template< typename Visitor > 20 inline void addVisitStatementList( std::list< Statement* > &statements, Visitor &visitor ) { 21 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 22 addDecls( visitor.get_declsToAdd(), statements, i ); 23 (*i)->accept( visitor ); 24 } // for 25 addDecls( visitor.get_declsToAdd(), statements, statements.end() ); 20 inline void addVisitStatementList( std::list< Statement* > &stmts, Visitor &visitor ) { 21 for ( std::list< Statement* >::iterator stmt = stmts.begin(); ; ++stmt ) { 22 // add any new declarations after the previous statement 23 for ( std::list< Declaration* >::iterator decl = visitor.declsToAddAfter.begin(); decl != visitor.declsToAddAfter.end(); ++decl ) { 24 DeclStmt *declStmt = new DeclStmt( noLabels, *decl ); 25 stmts.insert( stmt, declStmt ); 26 } 27 visitor.declsToAddAfter.clear(); 28 29 if ( stmt == stmts.end() ) break; 30 31 // run mutator on statement 32 maybeAccept( *stmt, visitor ); 33 34 // add any new declarations before the statement 35 for ( std::list< Declaration* >::iterator decl = visitor.declsToAdd.begin(); decl != visitor.declsToAdd.end(); ++decl ) { 36 DeclStmt *declStmt = new DeclStmt( noLabels, *decl ); 37 stmts.insert( stmt, declStmt ); 38 } 39 visitor.declsToAdd.clear(); 40 } 26 41 } 27 42 … … 38 53 39 54 template< typename Visitor > 40 void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor, bool addBefore ) { 41 std::list< Declaration * >::iterator i = translationUnit.begin(); 42 while ( i != translationUnit.end() ) { 43 (*i)->accept( visitor ); 44 std::list< Declaration * >::iterator next = i; 45 next++; 46 if ( ! visitor.get_declsToAdd().empty() ) { 47 translationUnit.splice( addBefore ? i : next, visitor.get_declsToAdd() ); 48 } // if 49 i = next; 50 } // while 55 void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor ) { 56 for ( std::list< Declaration* >::iterator decl = translationUnit.begin(); ; ++decl ) { 57 // splice in new declarations after previous decl 58 translationUnit.splice( decl, visitor.declsToAddAfter ); 59 60 if ( decl == translationUnit.end() ) break; 61 62 // run mutator on declaration 63 maybeAccept( *decl, visitor ); 64 65 // splice in new declarations before current decl 66 translationUnit.splice( decl, visitor.declsToAdd ); 67 } 51 68 } 52 69
Note: See TracChangeset
for help on using the changeset viewer.