source: src/SynTree/Visitor.cc@ 334163c

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 334163c 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
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
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Mon May 18 11:14:51 2015
13// Update Count : 2
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 ) {
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 );
[51b73452]101}
102
[0dd3a2f]103void Visitor::visit( SwitchStmt *switchStmt ) {
104 maybeAccept( switchStmt->get_condition(), *this );
105 acceptAll( switchStmt->get_branches(), *this );
[51b73452]106}
107
[0dd3a2f]108void Visitor::visit( ChooseStmt *switchStmt ) {
109 maybeAccept( switchStmt->get_condition(), *this );
110 acceptAll( switchStmt->get_branches(), *this );
[51b73452]111}
112
[a08ba92]113void Visitor::visit( FallthruStmt *fallthruStmt ) {}
[51b73452]114
[0dd3a2f]115void Visitor::visit( CaseStmt *caseStmt ) {
116 maybeAccept( caseStmt->get_condition(), *this );
117 acceptAll( caseStmt->get_statements(), *this );
[51b73452]118}
119
[0dd3a2f]120void Visitor::visit( BranchStmt *branchStmt ) {
[51b73452]121}
122
[0dd3a2f]123void Visitor::visit( ReturnStmt *returnStmt ) {
124 maybeAccept( returnStmt->get_expr(), *this );
[51b73452]125}
126
[0dd3a2f]127void Visitor::visit( TryStmt *tryStmt ) {
128 maybeAccept( tryStmt->get_block(), *this );
129 acceptAll( tryStmt->get_catchers(), *this );
[51b73452]130}
131
[0dd3a2f]132void Visitor::visit( CatchStmt *catchStmt ) {
133 maybeAccept( catchStmt->get_decl(), *this );
134 maybeAccept( catchStmt->get_body(), *this );
[51b73452]135}
136
[0dd3a2f]137void Visitor::visit( FinallyStmt *finalStmt ) {
138 maybeAccept( finalStmt->get_block(), *this );
[51b73452]139}
140
[0dd3a2f]141void Visitor::visit( NullStmt *nullStmt ) {
[51b73452]142}
143
[0dd3a2f]144void Visitor::visit( DeclStmt *declStmt ) {
145 maybeAccept( declStmt->get_decl(), *this );
[51b73452]146}
147
[0dd3a2f]148void Visitor::visit( ApplicationExpr *applicationExpr ) {
149 acceptAll( applicationExpr->get_results(), *this );
150 maybeAccept( applicationExpr->get_function(), *this );
151 acceptAll( applicationExpr->get_args(), *this );
[51b73452]152}
153
[0dd3a2f]154void Visitor::visit( UntypedExpr *untypedExpr ) {
155 acceptAll( untypedExpr->get_results(), *this );
156 acceptAll( untypedExpr->get_args(), *this );
[51b73452]157}
158
[0dd3a2f]159void Visitor::visit( NameExpr *nameExpr ) {
160 acceptAll( nameExpr->get_results(), *this );
[51b73452]161}
162
[0dd3a2f]163void Visitor::visit( AddressExpr *addressExpr ) {
164 acceptAll( addressExpr->get_results(), *this );
165 maybeAccept( addressExpr->get_arg(), *this );
[51b73452]166}
167
[0dd3a2f]168void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
169 acceptAll( labAddressExpr->get_results(), *this );
170 maybeAccept( labAddressExpr->get_arg(), *this );
[51b73452]171}
172
[0dd3a2f]173void Visitor::visit( CastExpr *castExpr ) {
174 acceptAll( castExpr->get_results(), *this );
175 maybeAccept( castExpr->get_arg(), *this );
[51b73452]176}
177
[0dd3a2f]178void Visitor::visit( UntypedMemberExpr *memberExpr ) {
179 acceptAll( memberExpr->get_results(), *this );
180 maybeAccept( memberExpr->get_aggregate(), *this );
[51b73452]181}
182
[0dd3a2f]183void Visitor::visit( MemberExpr *memberExpr ) {
184 acceptAll( memberExpr->get_results(), *this );
185 maybeAccept( memberExpr->get_aggregate(), *this );
[51b73452]186}
187
[0dd3a2f]188void Visitor::visit( VariableExpr *variableExpr ) {
189 acceptAll( variableExpr->get_results(), *this );
[51b73452]190}
191
[0dd3a2f]192void Visitor::visit( ConstantExpr *constantExpr ) {
193 acceptAll( constantExpr->get_results(), *this );
194 maybeAccept( constantExpr->get_constant(), *this );
[51b73452]195}
196
[0dd3a2f]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 }
[51b73452]204}
205
[0dd3a2f]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 }
[51b73452]213}
214
[0dd3a2f]215void Visitor::visit( LogicalExpr *logicalExpr ) {
216 acceptAll( logicalExpr->get_results(), *this );
217 maybeAccept( logicalExpr->get_arg1(), *this );
218 maybeAccept( logicalExpr->get_arg2(), *this );
[51b73452]219}
220
[0dd3a2f]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 );
[51b73452]226}
227
[0dd3a2f]228void Visitor::visit( CommaExpr *commaExpr ) {
229 acceptAll( commaExpr->get_results(), *this );
230 maybeAccept( commaExpr->get_arg1(), *this );
231 maybeAccept( commaExpr->get_arg2(), *this );
[51b73452]232}
233
[0dd3a2f]234void Visitor::visit( TupleExpr *tupleExpr ) {
235 acceptAll( tupleExpr->get_results(), *this );
236 acceptAll( tupleExpr->get_exprs(), *this );
[51b73452]237}
238
[0dd3a2f]239void Visitor::visit( SolvedTupleExpr *tupleExpr ) {
240 acceptAll( tupleExpr->get_results(), *this );
241 acceptAll( tupleExpr->get_exprs(), *this );
[51b73452]242}
243
[0dd3a2f]244void Visitor::visit( TypeExpr *typeExpr ) {
245 acceptAll( typeExpr->get_results(), *this );
246 maybeAccept( typeExpr->get_type(), *this );
[51b73452]247}
248
[0dd3a2f]249void Visitor::visit( UntypedValofExpr *valofExpr ) {
250 acceptAll( valofExpr->get_results(), *this );
251 maybeAccept( valofExpr->get_body(), *this );
[51b73452]252}
253
[0dd3a2f]254void Visitor::visit( VoidType *voidType ) {
255 acceptAll( voidType->get_forall(), *this );
[51b73452]256}
257
[0dd3a2f]258void Visitor::visit( BasicType *basicType ) {
259 acceptAll( basicType->get_forall(), *this );
[51b73452]260}
261
[0dd3a2f]262void Visitor::visit( PointerType *pointerType ) {
263 acceptAll( pointerType->get_forall(), *this );
264 maybeAccept( pointerType->get_base(), *this );
[51b73452]265}
266
[0dd3a2f]267void Visitor::visit( ArrayType *arrayType ) {
268 acceptAll( arrayType->get_forall(), *this );
269 maybeAccept( arrayType->get_dimension(), *this );
270 maybeAccept( arrayType->get_base(), *this );
[51b73452]271}
272
[0dd3a2f]273void Visitor::visit( FunctionType *functionType ) {
274 acceptAll( functionType->get_forall(), *this );
275 acceptAll( functionType->get_returnVals(), *this );
276 acceptAll( functionType->get_parameters(), *this );
[51b73452]277}
278
[0dd3a2f]279void Visitor::visit( ReferenceToType *aggregateUseType ) {
280 acceptAll( aggregateUseType->get_forall(), *this );
281 acceptAll( aggregateUseType->get_parameters(), *this );
[51b73452]282}
283
[0dd3a2f]284void Visitor::visit( StructInstType *aggregateUseType ) {
285 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
[51b73452]286}
287
[0dd3a2f]288void Visitor::visit( UnionInstType *aggregateUseType ) {
289 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
[51b73452]290}
291
[0dd3a2f]292void Visitor::visit( EnumInstType *aggregateUseType ) {
293 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
[51b73452]294}
295
[0dd3a2f]296void Visitor::visit( ContextInstType *aggregateUseType ) {
297 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
298 acceptAll( aggregateUseType->get_members(), *this );
[51b73452]299}
300
[0dd3a2f]301void Visitor::visit( TypeInstType *aggregateUseType ) {
302 visit( static_cast< ReferenceToType* >( aggregateUseType ) );
[51b73452]303}
304
[0dd3a2f]305void Visitor::visit( TupleType *tupleType ) {
306 acceptAll( tupleType->get_forall(), *this );
307 acceptAll( tupleType->get_types(), *this );
[51b73452]308}
309
[0dd3a2f]310void Visitor::visit( TypeofType *typeofType ) {
311 assert( typeofType->get_expr() );
312 typeofType->get_expr()->accept( *this );
[51b73452]313}
314
[0dd3a2f]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
[51b73452]323}
324
[0dd3a2f]325void Visitor::visit( SingleInit *singleInit ) {
326 singleInit->get_value()->accept( *this );
[51b73452]327}
328
[0dd3a2f]329void Visitor::visit( ListInit *listInit ) {
330 acceptAll( listInit->get_designators(), *this );
331 acceptAll( listInit->get_initializers(), *this );
[51b73452]332}
333
[0dd3a2f]334void Visitor::visit( Subrange *subrange ) {}
[51b73452]335
[0dd3a2f]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.