source: src/SymTab/AddVisit.h@ 4389966

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since 4389966 was 145f1fc, checked in by Rob Schluntz <rschlunt@…>, 10 years ago

modified ForStmt to have a list of statements for the initialization portion, and reverted to hoisting the initialization

  • Property mode set to 100644
File size: 3.2 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 : Rob Schluntz
12// Last Modified On : Tue Jul 14 12:26:17 2015
13// Update Count : 4
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 addVisitStatement( Statement *stmt, Visitor &visitor ) {
30 maybeAccept( stmt, visitor );
31/// if ( ! declsToAdd.empty() ) {
32/// CompoundStmt *compound = new CompoundStmt( noLabels );
33/// compound->get_kids().push_back( stmt );
34/// addDecls( declsToAdd, compound->get_kids(), compound->get_kids().end() );
35/// }
36 }
37
38 template< typename Visitor >
39 inline void addVisit(CompoundStmt *compoundStmt, Visitor &visitor) {
40 addVisitStatementList( compoundStmt->get_kids(), visitor );
41 }
42
43 template< typename Visitor >
44 inline void addVisit(IfStmt *ifStmt, Visitor &visitor) {
45 addVisitStatement( ifStmt->get_thenPart(), visitor );
46 addVisitStatement( ifStmt->get_elsePart(), visitor );
47 maybeAccept( ifStmt->get_condition(), visitor );
48 }
49
50 template< typename Visitor >
51 inline void addVisit(WhileStmt *whileStmt, Visitor &visitor) {
52 addVisitStatement( whileStmt->get_body(), visitor );
53 maybeAccept( whileStmt->get_condition(), visitor );
54 }
55
56 template< typename Visitor >
57 inline void addVisit(ForStmt *forStmt, Visitor &visitor) {
58 addVisitStatement( forStmt->get_body(), visitor );
59 acceptAll( forStmt->get_initialization(), visitor );
60 maybeAccept( forStmt->get_condition(), visitor );
61 maybeAccept( forStmt->get_increment(), visitor );
62 }
63
64 template< typename Visitor >
65 inline void addVisit(SwitchStmt *switchStmt, Visitor &visitor) {
66 addVisitStatementList( switchStmt->get_branches(), visitor );
67 maybeAccept( switchStmt->get_condition(), visitor );
68 }
69
70 template< typename Visitor >
71 inline void addVisit(ChooseStmt *switchStmt, Visitor &visitor) {
72 addVisitStatementList( switchStmt->get_branches(), visitor );
73 maybeAccept( switchStmt->get_condition(), visitor );
74 }
75
76 template< typename Visitor >
77 inline void addVisit(CaseStmt *caseStmt, Visitor &visitor) {
78 addVisitStatementList( caseStmt->get_statements(), visitor );
79 maybeAccept( caseStmt->get_condition(), visitor );
80 }
81
82 template< typename Visitor >
83 inline void addVisit(CatchStmt *cathStmt, Visitor &visitor) {
84 addVisitStatement( cathStmt->get_body(), visitor );
85 maybeAccept( cathStmt->get_decl(), visitor );
86 }
87} // namespace SymTab
88
89// Local Variables: //
90// tab-width: 4 //
91// mode: c++ //
92// compile-command: "make install" //
93// End: //
Note: See TracBrowser for help on using the repository browser.