source: src/SynTree/Visitor.cc@ 2bae7307

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 2bae7307 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

licencing: seventh groups of files

  • 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 : Peter A. Buhr
12// Last Modified On : Mon May 18 11:14:51 2015
13// Update Count : 2
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 // ForStmt still needs to be fixed
97 maybeAccept( forStmt->get_initialization(), *this );
98 maybeAccept( forStmt->get_condition(), *this );
99 maybeAccept( forStmt->get_increment(), *this );
100 maybeAccept( forStmt->get_body(), *this );
101}
102
103void Visitor::visit( SwitchStmt *switchStmt ) {
104 maybeAccept( switchStmt->get_condition(), *this );
105 acceptAll( switchStmt->get_branches(), *this );
106}
107
108void Visitor::visit( ChooseStmt *switchStmt ) {
109 maybeAccept( switchStmt->get_condition(), *this );
110 acceptAll( switchStmt->get_branches(), *this );
111}
112
113void Visitor::visit( FallthruStmt *fallthruStmt ) {}
114
115void Visitor::visit( CaseStmt *caseStmt ) {
116 maybeAccept( caseStmt->get_condition(), *this );
117 acceptAll( caseStmt->get_statements(), *this );
118}
119
120void Visitor::visit( BranchStmt *branchStmt ) {
121}
122
123void Visitor::visit( ReturnStmt *returnStmt ) {
124 maybeAccept( returnStmt->get_expr(), *this );
125}
126
127void Visitor::visit( TryStmt *tryStmt ) {
128 maybeAccept( tryStmt->get_block(), *this );
129 acceptAll( tryStmt->get_catchers(), *this );
130}
131
132void Visitor::visit( CatchStmt *catchStmt ) {
133 maybeAccept( catchStmt->get_decl(), *this );
134 maybeAccept( catchStmt->get_body(), *this );
135}
136
137void Visitor::visit( FinallyStmt *finalStmt ) {
138 maybeAccept( finalStmt->get_block(), *this );
139}
140
141void Visitor::visit( NullStmt *nullStmt ) {
142}
143
144void Visitor::visit( DeclStmt *declStmt ) {
145 maybeAccept( declStmt->get_decl(), *this );
146}
147
148void Visitor::visit( ApplicationExpr *applicationExpr ) {
149 acceptAll( applicationExpr->get_results(), *this );
150 maybeAccept( applicationExpr->get_function(), *this );
151 acceptAll( applicationExpr->get_args(), *this );
152}
153
154void Visitor::visit( UntypedExpr *untypedExpr ) {
155 acceptAll( untypedExpr->get_results(), *this );
156 acceptAll( untypedExpr->get_args(), *this );
157}
158
159void Visitor::visit( NameExpr *nameExpr ) {
160 acceptAll( nameExpr->get_results(), *this );
161}
162
163void Visitor::visit( AddressExpr *addressExpr ) {
164 acceptAll( addressExpr->get_results(), *this );
165 maybeAccept( addressExpr->get_arg(), *this );
166}
167
168void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
169 acceptAll( labAddressExpr->get_results(), *this );
170 maybeAccept( labAddressExpr->get_arg(), *this );
171}
172
173void Visitor::visit( CastExpr *castExpr ) {
174 acceptAll( castExpr->get_results(), *this );
175 maybeAccept( castExpr->get_arg(), *this );
176}
177
178void Visitor::visit( UntypedMemberExpr *memberExpr ) {
179 acceptAll( memberExpr->get_results(), *this );
180 maybeAccept( memberExpr->get_aggregate(), *this );
181}
182
183void Visitor::visit( MemberExpr *memberExpr ) {
184 acceptAll( memberExpr->get_results(), *this );
185 maybeAccept( memberExpr->get_aggregate(), *this );
186}
187
188void Visitor::visit( VariableExpr *variableExpr ) {
189 acceptAll( variableExpr->get_results(), *this );
190}
191
192void Visitor::visit( ConstantExpr *constantExpr ) {
193 acceptAll( constantExpr->get_results(), *this );
194 maybeAccept( constantExpr->get_constant(), *this );
195}
196
197void Visitor::visit( SizeofExpr *sizeofExpr ) {
198 acceptAll( sizeofExpr->get_results(), *this );
199 if ( sizeofExpr->get_isType() ) {
200 maybeAccept( sizeofExpr->get_type(), *this );
201 } else {
202 maybeAccept( sizeofExpr->get_expr(), *this );
203 }
204}
205
206void Visitor::visit( AttrExpr *attrExpr ) {
207 acceptAll( attrExpr->get_results(), *this );
208 if ( attrExpr->get_isType() ) {
209 maybeAccept( attrExpr->get_type(), *this );
210 } else {
211 maybeAccept( attrExpr->get_expr(), *this );
212 }
213}
214
215void Visitor::visit( LogicalExpr *logicalExpr ) {
216 acceptAll( logicalExpr->get_results(), *this );
217 maybeAccept( logicalExpr->get_arg1(), *this );
218 maybeAccept( logicalExpr->get_arg2(), *this );
219}
220
221void Visitor::visit( ConditionalExpr *conditionalExpr ) {
222 acceptAll( conditionalExpr->get_results(), *this );
223 maybeAccept( conditionalExpr->get_arg1(), *this );
224 maybeAccept( conditionalExpr->get_arg2(), *this );
225 maybeAccept( conditionalExpr->get_arg3(), *this );
226}
227
228void Visitor::visit( CommaExpr *commaExpr ) {
229 acceptAll( commaExpr->get_results(), *this );
230 maybeAccept( commaExpr->get_arg1(), *this );
231 maybeAccept( commaExpr->get_arg2(), *this );
232}
233
234void Visitor::visit( TupleExpr *tupleExpr ) {
235 acceptAll( tupleExpr->get_results(), *this );
236 acceptAll( tupleExpr->get_exprs(), *this );
237}
238
239void Visitor::visit( SolvedTupleExpr *tupleExpr ) {
240 acceptAll( tupleExpr->get_results(), *this );
241 acceptAll( tupleExpr->get_exprs(), *this );
242}
243
244void Visitor::visit( TypeExpr *typeExpr ) {
245 acceptAll( typeExpr->get_results(), *this );
246 maybeAccept( typeExpr->get_type(), *this );
247}
248
249void Visitor::visit( UntypedValofExpr *valofExpr ) {
250 acceptAll( valofExpr->get_results(), *this );
251 maybeAccept( valofExpr->get_body(), *this );
252}
253
254void Visitor::visit( VoidType *voidType ) {
255 acceptAll( voidType->get_forall(), *this );
256}
257
258void Visitor::visit( BasicType *basicType ) {
259 acceptAll( basicType->get_forall(), *this );
260}
261
262void Visitor::visit( PointerType *pointerType ) {
263 acceptAll( pointerType->get_forall(), *this );
264 maybeAccept( pointerType->get_base(), *this );
265}
266
267void Visitor::visit( ArrayType *arrayType ) {
268 acceptAll( arrayType->get_forall(), *this );
269 maybeAccept( arrayType->get_dimension(), *this );
270 maybeAccept( arrayType->get_base(), *this );
271}
272
273void Visitor::visit( FunctionType *functionType ) {
274 acceptAll( functionType->get_forall(), *this );
275 acceptAll( functionType->get_returnVals(), *this );
276 acceptAll( functionType->get_parameters(), *this );
277}
278
279void Visitor::visit( ReferenceToType *aggregateUseType ) {
280 acceptAll( aggregateUseType->get_forall(), *this );
281 acceptAll( aggregateUseType->get_parameters(), *this );
282}
283
284void Visitor::visit( StructInstType *aggregateUseType ) {
285 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
286}
287
288void Visitor::visit( UnionInstType *aggregateUseType ) {
289 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
290}
291
292void Visitor::visit( EnumInstType *aggregateUseType ) {
293 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
294}
295
296void Visitor::visit( ContextInstType *aggregateUseType ) {
297 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
298 acceptAll( aggregateUseType->get_members(), *this );
299}
300
301void Visitor::visit( TypeInstType *aggregateUseType ) {
302 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
303}
304
305void Visitor::visit( TupleType *tupleType ) {
306 acceptAll( tupleType->get_forall(), *this );
307 acceptAll( tupleType->get_types(), *this );
308}
309
310void Visitor::visit( TypeofType *typeofType ) {
311 assert( typeofType->get_expr() );
312 typeofType->get_expr()->accept( *this );
313}
314
315void Visitor::visit( AttrType *attrType ) {
316 if ( attrType->get_isType() ) {
317 assert( attrType->get_type() );
318 attrType->get_type()->accept( *this );
319 } else {
320 assert( attrType->get_expr() );
321 attrType->get_expr()->accept( *this );
322 } // if
323}
324
325void Visitor::visit( SingleInit *singleInit ) {
326 singleInit->get_value()->accept( *this );
327}
328
329void Visitor::visit( ListInit *listInit ) {
330 acceptAll( listInit->get_designators(), *this );
331 acceptAll( listInit->get_initializers(), *this );
332}
333
334void Visitor::visit( Subrange *subrange ) {}
335
336void Visitor::visit( Constant *constant ) {}
337// Local Variables: //
338// tab-width: 4 //
339// mode: c++ //
340// compile-command: "make install" //
341// End: //
Note: See TracBrowser for help on using the repository browser.