Changeset c3f551b for src/InitTweak
- Timestamp:
- Nov 30, 2017, 6:06:46 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:
- 0a6aad4
- Parents:
- ef3d798
- git-author:
- Rob Schluntz <rschlunt@…> (11/30/17 17:40:16)
- git-committer:
- Rob Schluntz <rschlunt@…> (11/30/17 18:06:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/InitTweak.cc
ref3d798 rc3f551b 67 67 }; 68 68 69 class InitFlattener : public Visitor { 70 public: 71 virtual void visit( SingleInit * singleInit ); 72 virtual void visit( ListInit * listInit ); 69 struct InitFlattener : public WithShortCircuiting { 70 void previsit( SingleInit * singleInit ) { 71 visit_children = false; 72 argList.push_back( singleInit->value->clone() ); 73 } 73 74 std::list< Expression * > argList; 74 75 }; 75 76 76 void InitFlattener::visit( SingleInit * singleInit ) {77 argList.push_back( singleInit->get_value()->clone() );78 }79 80 void InitFlattener::visit( ListInit * listInit ) {81 // flatten nested list inits82 std::list<Initializer*>::iterator it = listInit->begin();83 for ( ; it != listInit->end(); ++it ) {84 (*it)->accept( *this );85 }86 }87 77 } 88 78 89 79 std::list< Expression * > makeInitList( Initializer * init ) { 90 InitFlattenerflattener;80 PassVisitor<InitFlattener> flattener; 91 81 maybeAccept( init, flattener ); 92 return flattener. argList;82 return flattener.pass.argList; 93 83 } 94 84
Note: See TracChangeset
for help on using the changeset viewer.