source: src/SynTree/Visitor.cc@ 1ab4ce2

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 1ab4ce2 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
RevLine 
[0dd3a2f]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
[145f1fc]11// Last Modified By : Rob Schluntz
12// Last Modified On : Tue Jul 14 12:31:03 2015
13// Update Count : 3
[0dd3a2f]14//
15
[51b73452]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
[d9a0e76]25Visitor::Visitor() {}
[51b73452]26
[d9a0e76]27Visitor::~Visitor() {}
[51b73452]28
[0dd3a2f]29void Visitor::visit( ObjectDecl *objectDecl ) {
30 maybeAccept( objectDecl->get_type(), *this );
31 maybeAccept( objectDecl->get_init(), *this );
32 maybeAccept( objectDecl->get_bitfieldWidth(), *this );
[51b73452]33}
34
[0dd3a2f]35void Visitor::visit( FunctionDecl *functionDecl ) {
36 maybeAccept( functionDecl->get_functionType(), *this );
37 acceptAll( functionDecl->get_oldDecls(), *this );
38 maybeAccept( functionDecl->get_statements(), *this );
[51b73452]39}
40
[0dd3a2f]41void Visitor::visit( AggregateDecl *aggregateDecl ) {
42 acceptAll( aggregateDecl->get_parameters(), *this );
43 acceptAll( aggregateDecl->get_members(), *this );
[51b73452]44}
45
[0dd3a2f]46void Visitor::visit( StructDecl *aggregateDecl ) {
47 visit( static_cast< AggregateDecl* >( aggregateDecl ) );
[51b73452]48}
49
[0dd3a2f]50void Visitor::visit( UnionDecl *aggregateDecl ) {
51 visit( static_cast< AggregateDecl* >( aggregateDecl ) );
[51b73452]52}
53
[0dd3a2f]54void Visitor::visit( EnumDecl *aggregateDecl ) {
55 visit( static_cast< AggregateDecl* >( aggregateDecl ) );
[51b73452]56}
57
[0dd3a2f]58void Visitor::visit( ContextDecl *aggregateDecl ) {
59 visit( static_cast< AggregateDecl* >( aggregateDecl ) );
[51b73452]60}
61
[0dd3a2f]62void Visitor::visit( NamedTypeDecl *typeDecl ) {
63 acceptAll( typeDecl->get_parameters(), *this );
64 acceptAll( typeDecl->get_assertions(), *this );
65 maybeAccept( typeDecl->get_base(), *this );
[51b73452]66}
67
[0dd3a2f]68void Visitor::visit( TypeDecl *typeDecl ) {
69 visit( static_cast< NamedTypeDecl* >( typeDecl ) );
[51b73452]70}
71
[0dd3a2f]72void Visitor::visit( TypedefDecl *typeDecl ) {
73 visit( static_cast< NamedTypeDecl* >( typeDecl ) );
[51b73452]74}
75
[0dd3a2f]76void Visitor::visit( CompoundStmt *compoundStmt ) {
77 acceptAll( compoundStmt->get_kids(), *this );
[51b73452]78}
79
[0dd3a2f]80void Visitor::visit( ExprStmt *exprStmt ) {
81 maybeAccept( exprStmt->get_expr(), *this );
[51b73452]82}
83
[0dd3a2f]84void Visitor::visit( IfStmt *ifStmt ) {
85 maybeAccept( ifStmt->get_condition(), *this );
86 maybeAccept( ifStmt->get_thenPart(), *this );
87 maybeAccept( ifStmt->get_elsePart(), *this );
[51b73452]88}
89
[0dd3a2f]90void Visitor::visit( WhileStmt *whileStmt ) {
91 maybeAccept( whileStmt->get_condition(), *this );
92 maybeAccept( whileStmt->get_body(), *this );
[51b73452]93}
94
[0dd3a2f]95void Visitor::visit( ForStmt *forStmt ) {
[145f1fc]96 acceptAll( forStmt->get_initialization(), *this );
[0dd3a2f]97 maybeAccept( forStmt->get_condition(), *this );
98 maybeAccept( forStmt->get_increment(), *this );
99 maybeAccept( forStmt->get_body(), *this );
[51b73452]100}
101
[0dd3a2f]102void Visitor::visit( SwitchStmt *switchStmt ) {
103 maybeAccept( switchStmt->get_condition(), *this );
104 acceptAll( switchStmt->get_branches(), *this );
[51b73452]105}
106
[0dd3a2f]107void Visitor::visit( ChooseStmt *switchStmt ) {
108 maybeAccept( switchStmt->get_condition(), *this );
109 acceptAll( switchStmt->get_branches(), *this );
[51b73452]110}
111
[a08ba92]112void Visitor::visit( FallthruStmt *fallthruStmt ) {}
[51b73452]113
[0dd3a2f]114void Visitor::visit( CaseStmt *caseStmt ) {
115 maybeAccept( caseStmt->get_condition(), *this );
116 acceptAll( caseStmt->get_statements(), *this );
[51b73452]117}
118
[0dd3a2f]119void Visitor::visit( BranchStmt *branchStmt ) {
[51b73452]120}
121
[0dd3a2f]122void Visitor::visit( ReturnStmt *returnStmt ) {
123 maybeAccept( returnStmt->get_expr(), *this );
[51b73452]124}
125
[0dd3a2f]126void Visitor::visit( TryStmt *tryStmt ) {
127 maybeAccept( tryStmt->get_block(), *this );
128 acceptAll( tryStmt->get_catchers(), *this );
[51b73452]129}
130
[0dd3a2f]131void Visitor::visit( CatchStmt *catchStmt ) {
132 maybeAccept( catchStmt->get_decl(), *this );
133 maybeAccept( catchStmt->get_body(), *this );
[51b73452]134}
135
[0dd3a2f]136void Visitor::visit( FinallyStmt *finalStmt ) {
137 maybeAccept( finalStmt->get_block(), *this );
[51b73452]138}
139
[0dd3a2f]140void Visitor::visit( NullStmt *nullStmt ) {
[51b73452]141}
142
[0dd3a2f]143void Visitor::visit( DeclStmt *declStmt ) {
144 maybeAccept( declStmt->get_decl(), *this );
[51b73452]145}
146
[0dd3a2f]147void Visitor::visit( ApplicationExpr *applicationExpr ) {
148 acceptAll( applicationExpr->get_results(), *this );
149 maybeAccept( applicationExpr->get_function(), *this );
150 acceptAll( applicationExpr->get_args(), *this );
[51b73452]151}
152
[0dd3a2f]153void Visitor::visit( UntypedExpr *untypedExpr ) {
154 acceptAll( untypedExpr->get_results(), *this );
155 acceptAll( untypedExpr->get_args(), *this );
[51b73452]156}
157
[0dd3a2f]158void Visitor::visit( NameExpr *nameExpr ) {
159 acceptAll( nameExpr->get_results(), *this );
[51b73452]160}
161
[0dd3a2f]162void Visitor::visit( AddressExpr *addressExpr ) {
163 acceptAll( addressExpr->get_results(), *this );
164 maybeAccept( addressExpr->get_arg(), *this );
[51b73452]165}
166
[0dd3a2f]167void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
168 acceptAll( labAddressExpr->get_results(), *this );
169 maybeAccept( labAddressExpr->get_arg(), *this );
[51b73452]170}
171
[0dd3a2f]172void Visitor::visit( CastExpr *castExpr ) {
173 acceptAll( castExpr->get_results(), *this );
174 maybeAccept( castExpr->get_arg(), *this );
[51b73452]175}
176
[0dd3a2f]177void Visitor::visit( UntypedMemberExpr *memberExpr ) {
178 acceptAll( memberExpr->get_results(), *this );
179 maybeAccept( memberExpr->get_aggregate(), *this );
[51b73452]180}
181
[0dd3a2f]182void Visitor::visit( MemberExpr *memberExpr ) {
183 acceptAll( memberExpr->get_results(), *this );
184 maybeAccept( memberExpr->get_aggregate(), *this );
[51b73452]185}
186
[0dd3a2f]187void Visitor::visit( VariableExpr *variableExpr ) {
188 acceptAll( variableExpr->get_results(), *this );
[51b73452]189}
190
[0dd3a2f]191void Visitor::visit( ConstantExpr *constantExpr ) {
192 acceptAll( constantExpr->get_results(), *this );
193 maybeAccept( constantExpr->get_constant(), *this );
[51b73452]194}
195
[0dd3a2f]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 }
[51b73452]203}
204
[0dd3a2f]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 }
[51b73452]212}
213
[0dd3a2f]214void Visitor::visit( LogicalExpr *logicalExpr ) {
215 acceptAll( logicalExpr->get_results(), *this );
216 maybeAccept( logicalExpr->get_arg1(), *this );
217 maybeAccept( logicalExpr->get_arg2(), *this );
[51b73452]218}
219
[0dd3a2f]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 );
[51b73452]225}
226
[0dd3a2f]227void Visitor::visit( CommaExpr *commaExpr ) {
228 acceptAll( commaExpr->get_results(), *this );
229 maybeAccept( commaExpr->get_arg1(), *this );
230 maybeAccept( commaExpr->get_arg2(), *this );
[51b73452]231}
232
[0dd3a2f]233void Visitor::visit( TupleExpr *tupleExpr ) {
234 acceptAll( tupleExpr->get_results(), *this );
235 acceptAll( tupleExpr->get_exprs(), *this );
[51b73452]236}
237
[0dd3a2f]238void Visitor::visit( SolvedTupleExpr *tupleExpr ) {
239 acceptAll( tupleExpr->get_results(), *this );
240 acceptAll( tupleExpr->get_exprs(), *this );
[51b73452]241}
242
[0dd3a2f]243void Visitor::visit( TypeExpr *typeExpr ) {
244 acceptAll( typeExpr->get_results(), *this );
245 maybeAccept( typeExpr->get_type(), *this );
[51b73452]246}
247
[0dd3a2f]248void Visitor::visit( UntypedValofExpr *valofExpr ) {
249 acceptAll( valofExpr->get_results(), *this );
250 maybeAccept( valofExpr->get_body(), *this );
[51b73452]251}
252
[0dd3a2f]253void Visitor::visit( VoidType *voidType ) {
254 acceptAll( voidType->get_forall(), *this );
[51b73452]255}
256
[0dd3a2f]257void Visitor::visit( BasicType *basicType ) {
258 acceptAll( basicType->get_forall(), *this );
[51b73452]259}
260
[0dd3a2f]261void Visitor::visit( PointerType *pointerType ) {
262 acceptAll( pointerType->get_forall(), *this );
263 maybeAccept( pointerType->get_base(), *this );
[51b73452]264}
265
[0dd3a2f]266void Visitor::visit( ArrayType *arrayType ) {
267 acceptAll( arrayType->get_forall(), *this );
268 maybeAccept( arrayType->get_dimension(), *this );
269 maybeAccept( arrayType->get_base(), *this );
[51b73452]270}
271
[0dd3a2f]272void Visitor::visit( FunctionType *functionType ) {
273 acceptAll( functionType->get_forall(), *this );
274 acceptAll( functionType->get_returnVals(), *this );
275 acceptAll( functionType->get_parameters(), *this );
[51b73452]276}
277
[0dd3a2f]278void Visitor::visit( ReferenceToType *aggregateUseType ) {
279 acceptAll( aggregateUseType->get_forall(), *this );
280 acceptAll( aggregateUseType->get_parameters(), *this );
[51b73452]281}
282
[0dd3a2f]283void Visitor::visit( StructInstType *aggregateUseType ) {
284 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
[51b73452]285}
286
[0dd3a2f]287void Visitor::visit( UnionInstType *aggregateUseType ) {
288 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
[51b73452]289}
290
[0dd3a2f]291void Visitor::visit( EnumInstType *aggregateUseType ) {
292 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
[51b73452]293}
294
[0dd3a2f]295void Visitor::visit( ContextInstType *aggregateUseType ) {
296 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
297 acceptAll( aggregateUseType->get_members(), *this );
[51b73452]298}
299
[0dd3a2f]300void Visitor::visit( TypeInstType *aggregateUseType ) {
301 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
[51b73452]302}
303
[0dd3a2f]304void Visitor::visit( TupleType *tupleType ) {
305 acceptAll( tupleType->get_forall(), *this );
306 acceptAll( tupleType->get_types(), *this );
[51b73452]307}
308
[0dd3a2f]309void Visitor::visit( TypeofType *typeofType ) {
310 assert( typeofType->get_expr() );
311 typeofType->get_expr()->accept( *this );
[51b73452]312}
313
[0dd3a2f]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
[51b73452]322}
323
[0dd3a2f]324void Visitor::visit( SingleInit *singleInit ) {
325 singleInit->get_value()->accept( *this );
[51b73452]326}
327
[0dd3a2f]328void Visitor::visit( ListInit *listInit ) {
329 acceptAll( listInit->get_designators(), *this );
330 acceptAll( listInit->get_initializers(), *this );
[51b73452]331}
332
[0dd3a2f]333void Visitor::visit( Subrange *subrange ) {}
[51b73452]334
[0dd3a2f]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.