source: src/SynTree/Visitor.cc@ 893256d

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 with_gc
Last change on this file since 893256d 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: 9.5 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// Visitor.cc --
8//
9// Author : Richard C. Bilson
10// Created On : Mon May 18 07:44:20 2015
11// Last Modified By : Rob Schluntz
12// Last Modified On : Tue Jul 14 12:31:03 2015
13// Update Count : 3
14//
15
16#include <cassert>
17#include "Visitor.h"
18#include "Initializer.h"
19#include "Statement.h"
20#include "Type.h"
21#include "Declaration.h"
22#include "Expression.h"
23#include "Constant.h"
24
25Visitor::Visitor() {}
26
27Visitor::~Visitor() {}
28
29void Visitor::visit( ObjectDecl *objectDecl ) {
30 maybeAccept( objectDecl->get_type(), *this );
31 maybeAccept( objectDecl->get_init(), *this );
32 maybeAccept( objectDecl->get_bitfieldWidth(), *this );
33}
34
35void Visitor::visit( FunctionDecl *functionDecl ) {
36 maybeAccept( functionDecl->get_functionType(), *this );
37 acceptAll( functionDecl->get_oldDecls(), *this );
38 maybeAccept( functionDecl->get_statements(), *this );
39}
40
41void Visitor::visit( AggregateDecl *aggregateDecl ) {
42 acceptAll( aggregateDecl->get_parameters(), *this );
43 acceptAll( aggregateDecl->get_members(), *this );
44}
45
46void Visitor::visit( StructDecl *aggregateDecl ) {
47 visit( static_cast< AggregateDecl* >( aggregateDecl ) );
48}
49
50void Visitor::visit( UnionDecl *aggregateDecl ) {
51 visit( static_cast< AggregateDecl* >( aggregateDecl ) );
52}
53
54void Visitor::visit( EnumDecl *aggregateDecl ) {
55 visit( static_cast< AggregateDecl* >( aggregateDecl ) );
56}
57
58void Visitor::visit( ContextDecl *aggregateDecl ) {
59 visit( static_cast< AggregateDecl* >( aggregateDecl ) );
60}
61
62void Visitor::visit( NamedTypeDecl *typeDecl ) {
63 acceptAll( typeDecl->get_parameters(), *this );
64 acceptAll( typeDecl->get_assertions(), *this );
65 maybeAccept( typeDecl->get_base(), *this );
66}
67
68void Visitor::visit( TypeDecl *typeDecl ) {
69 visit( static_cast< NamedTypeDecl* >( typeDecl ) );
70}
71
72void Visitor::visit( TypedefDecl *typeDecl ) {
73 visit( static_cast< NamedTypeDecl* >( typeDecl ) );
74}
75
76void Visitor::visit( CompoundStmt *compoundStmt ) {
77 acceptAll( compoundStmt->get_kids(), *this );
78}
79
80void Visitor::visit( ExprStmt *exprStmt ) {
81 maybeAccept( exprStmt->get_expr(), *this );
82}
83
84void Visitor::visit( IfStmt *ifStmt ) {
85 maybeAccept( ifStmt->get_condition(), *this );
86 maybeAccept( ifStmt->get_thenPart(), *this );
87 maybeAccept( ifStmt->get_elsePart(), *this );
88}
89
90void Visitor::visit( WhileStmt *whileStmt ) {
91 maybeAccept( whileStmt->get_condition(), *this );
92 maybeAccept( whileStmt->get_body(), *this );
93}
94
95void Visitor::visit( ForStmt *forStmt ) {
96 acceptAll( forStmt->get_initialization(), *this );
97 maybeAccept( forStmt->get_condition(), *this );
98 maybeAccept( forStmt->get_increment(), *this );
99 maybeAccept( forStmt->get_body(), *this );
100}
101
102void Visitor::visit( SwitchStmt *switchStmt ) {
103 maybeAccept( switchStmt->get_condition(), *this );
104 acceptAll( switchStmt->get_branches(), *this );
105}
106
107void Visitor::visit( ChooseStmt *switchStmt ) {
108 maybeAccept( switchStmt->get_condition(), *this );
109 acceptAll( switchStmt->get_branches(), *this );
110}
111
112void Visitor::visit( FallthruStmt *fallthruStmt ) {}
113
114void Visitor::visit( CaseStmt *caseStmt ) {
115 maybeAccept( caseStmt->get_condition(), *this );
116 acceptAll( caseStmt->get_statements(), *this );
117}
118
119void Visitor::visit( BranchStmt *branchStmt ) {
120}
121
122void Visitor::visit( ReturnStmt *returnStmt ) {
123 maybeAccept( returnStmt->get_expr(), *this );
124}
125
126void Visitor::visit( TryStmt *tryStmt ) {
127 maybeAccept( tryStmt->get_block(), *this );
128 acceptAll( tryStmt->get_catchers(), *this );
129}
130
131void Visitor::visit( CatchStmt *catchStmt ) {
132 maybeAccept( catchStmt->get_decl(), *this );
133 maybeAccept( catchStmt->get_body(), *this );
134}
135
136void Visitor::visit( FinallyStmt *finalStmt ) {
137 maybeAccept( finalStmt->get_block(), *this );
138}
139
140void Visitor::visit( NullStmt *nullStmt ) {
141}
142
143void Visitor::visit( DeclStmt *declStmt ) {
144 maybeAccept( declStmt->get_decl(), *this );
145}
146
147void Visitor::visit( ApplicationExpr *applicationExpr ) {
148 acceptAll( applicationExpr->get_results(), *this );
149 maybeAccept( applicationExpr->get_function(), *this );
150 acceptAll( applicationExpr->get_args(), *this );
151}
152
153void Visitor::visit( UntypedExpr *untypedExpr ) {
154 acceptAll( untypedExpr->get_results(), *this );
155 acceptAll( untypedExpr->get_args(), *this );
156}
157
158void Visitor::visit( NameExpr *nameExpr ) {
159 acceptAll( nameExpr->get_results(), *this );
160}
161
162void Visitor::visit( AddressExpr *addressExpr ) {
163 acceptAll( addressExpr->get_results(), *this );
164 maybeAccept( addressExpr->get_arg(), *this );
165}
166
167void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
168 acceptAll( labAddressExpr->get_results(), *this );
169 maybeAccept( labAddressExpr->get_arg(), *this );
170}
171
172void Visitor::visit( CastExpr *castExpr ) {
173 acceptAll( castExpr->get_results(), *this );
174 maybeAccept( castExpr->get_arg(), *this );
175}
176
177void Visitor::visit( UntypedMemberExpr *memberExpr ) {
178 acceptAll( memberExpr->get_results(), *this );
179 maybeAccept( memberExpr->get_aggregate(), *this );
180}
181
182void Visitor::visit( MemberExpr *memberExpr ) {
183 acceptAll( memberExpr->get_results(), *this );
184 maybeAccept( memberExpr->get_aggregate(), *this );
185}
186
187void Visitor::visit( VariableExpr *variableExpr ) {
188 acceptAll( variableExpr->get_results(), *this );
189}
190
191void Visitor::visit( ConstantExpr *constantExpr ) {
192 acceptAll( constantExpr->get_results(), *this );
193 maybeAccept( constantExpr->get_constant(), *this );
194}
195
196void Visitor::visit( SizeofExpr *sizeofExpr ) {
197 acceptAll( sizeofExpr->get_results(), *this );
198 if ( sizeofExpr->get_isType() ) {
199 maybeAccept( sizeofExpr->get_type(), *this );
200 } else {
201 maybeAccept( sizeofExpr->get_expr(), *this );
202 }
203}
204
205void Visitor::visit( AttrExpr *attrExpr ) {
206 acceptAll( attrExpr->get_results(), *this );
207 if ( attrExpr->get_isType() ) {
208 maybeAccept( attrExpr->get_type(), *this );
209 } else {
210 maybeAccept( attrExpr->get_expr(), *this );
211 }
212}
213
214void Visitor::visit( LogicalExpr *logicalExpr ) {
215 acceptAll( logicalExpr->get_results(), *this );
216 maybeAccept( logicalExpr->get_arg1(), *this );
217 maybeAccept( logicalExpr->get_arg2(), *this );
218}
219
220void Visitor::visit( ConditionalExpr *conditionalExpr ) {
221 acceptAll( conditionalExpr->get_results(), *this );
222 maybeAccept( conditionalExpr->get_arg1(), *this );
223 maybeAccept( conditionalExpr->get_arg2(), *this );
224 maybeAccept( conditionalExpr->get_arg3(), *this );
225}
226
227void Visitor::visit( CommaExpr *commaExpr ) {
228 acceptAll( commaExpr->get_results(), *this );
229 maybeAccept( commaExpr->get_arg1(), *this );
230 maybeAccept( commaExpr->get_arg2(), *this );
231}
232
233void Visitor::visit( TupleExpr *tupleExpr ) {
234 acceptAll( tupleExpr->get_results(), *this );
235 acceptAll( tupleExpr->get_exprs(), *this );
236}
237
238void Visitor::visit( SolvedTupleExpr *tupleExpr ) {
239 acceptAll( tupleExpr->get_results(), *this );
240 acceptAll( tupleExpr->get_exprs(), *this );
241}
242
243void Visitor::visit( TypeExpr *typeExpr ) {
244 acceptAll( typeExpr->get_results(), *this );
245 maybeAccept( typeExpr->get_type(), *this );
246}
247
248void Visitor::visit( UntypedValofExpr *valofExpr ) {
249 acceptAll( valofExpr->get_results(), *this );
250 maybeAccept( valofExpr->get_body(), *this );
251}
252
253void Visitor::visit( VoidType *voidType ) {
254 acceptAll( voidType->get_forall(), *this );
255}
256
257void Visitor::visit( BasicType *basicType ) {
258 acceptAll( basicType->get_forall(), *this );
259}
260
261void Visitor::visit( PointerType *pointerType ) {
262 acceptAll( pointerType->get_forall(), *this );
263 maybeAccept( pointerType->get_base(), *this );
264}
265
266void Visitor::visit( ArrayType *arrayType ) {
267 acceptAll( arrayType->get_forall(), *this );
268 maybeAccept( arrayType->get_dimension(), *this );
269 maybeAccept( arrayType->get_base(), *this );
270}
271
272void Visitor::visit( FunctionType *functionType ) {
273 acceptAll( functionType->get_forall(), *this );
274 acceptAll( functionType->get_returnVals(), *this );
275 acceptAll( functionType->get_parameters(), *this );
276}
277
278void Visitor::visit( ReferenceToType *aggregateUseType ) {
279 acceptAll( aggregateUseType->get_forall(), *this );
280 acceptAll( aggregateUseType->get_parameters(), *this );
281}
282
283void Visitor::visit( StructInstType *aggregateUseType ) {
284 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
285}
286
287void Visitor::visit( UnionInstType *aggregateUseType ) {
288 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
289}
290
291void Visitor::visit( EnumInstType *aggregateUseType ) {
292 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
293}
294
295void Visitor::visit( ContextInstType *aggregateUseType ) {
296 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
297 acceptAll( aggregateUseType->get_members(), *this );
298}
299
300void Visitor::visit( TypeInstType *aggregateUseType ) {
301 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
302}
303
304void Visitor::visit( TupleType *tupleType ) {
305 acceptAll( tupleType->get_forall(), *this );
306 acceptAll( tupleType->get_types(), *this );
307}
308
309void Visitor::visit( TypeofType *typeofType ) {
310 assert( typeofType->get_expr() );
311 typeofType->get_expr()->accept( *this );
312}
313
314void Visitor::visit( AttrType *attrType ) {
315 if ( attrType->get_isType() ) {
316 assert( attrType->get_type() );
317 attrType->get_type()->accept( *this );
318 } else {
319 assert( attrType->get_expr() );
320 attrType->get_expr()->accept( *this );
321 } // if
322}
323
324void Visitor::visit( SingleInit *singleInit ) {
325 singleInit->get_value()->accept( *this );
326}
327
328void Visitor::visit( ListInit *listInit ) {
329 acceptAll( listInit->get_designators(), *this );
330 acceptAll( listInit->get_initializers(), *this );
331}
332
333void Visitor::visit( Subrange *subrange ) {}
334
335void Visitor::visit( Constant *constant ) {}
336// Local Variables: //
337// tab-width: 4 //
338// mode: c++ //
339// compile-command: "make install" //
340// End: //
Note: See TracBrowser for help on using the repository browser.