source: src/SymTab/AddVisit.h@ 2ee5426

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
Last change on this file since 2ee5426 was 8688ce1, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

move case-list management into parser

  • Property mode set to 100644
File size: 1.9 KB
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// AddVisit.h --
8//
9// Author : Richard C. Bilson
10// Created On : Sun May 17 16:14:32 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Aug 4 11:22:01 2016
13// Update Count : 9
14//
15
16namespace SymTab {
17 void addDecls( std::list< Declaration* > &declsToAdd, std::list< Statement* > &statements, std::list< Statement* >::iterator i );
18
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() );
26 }
27
28 template< typename Visitor >
29 inline void addVisit(CompoundStmt *compoundStmt, Visitor &visitor) {
30 addVisitStatementList( compoundStmt->get_kids(), visitor );
31 }
32
33 template< typename Visitor >
34 inline void addVisit(SwitchStmt *switchStmt, Visitor &visitor) {
35 addVisitStatementList( switchStmt->get_statements(), visitor );
36 maybeAccept( switchStmt->get_condition(), visitor );
37 }
38
39 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
51 }
52
53} // namespace SymTab
54
55// Local Variables: //
56// tab-width: 4 //
57// mode: c++ //
58// compile-command: "make install" //
59// End: //
Note: See TracBrowser for help on using the repository browser.