source: src/SynTree/Visitor.cc@ 908cc83

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox 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 908cc83 was add7117, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

Merge branch 'master' into tuples

Conflicts:

src/ResolvExpr/AlternativeFinder.cc
src/ResolvExpr/AlternativeFinder.h

  • Property mode set to 100644
File size: 12.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//
[71f4e4f]7// Visitor.cc --
[0dd3a2f]8//
9// Author : Richard C. Bilson
10// Created On : Mon May 18 07:44:20 2015
[4e06c1e]11// Last Modified By : Peter A. Buhr
[8688ce1]12// Last Modified On : Thu Aug 4 11:24:25 2016
13// Update Count : 21
[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
[1e1e15b]41void Visitor::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
[0dd3a2f]42 acceptAll( aggregateDecl->get_parameters(), *this );
43 acceptAll( aggregateDecl->get_members(), *this );
[51b73452]44}
45
[0dd3a2f]46void Visitor::visit( StructDecl *aggregateDecl ) {
[1e1e15b]47 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
[51b73452]48}
49
[0dd3a2f]50void Visitor::visit( UnionDecl *aggregateDecl ) {
[1e1e15b]51 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
[51b73452]52}
53
[0dd3a2f]54void Visitor::visit( EnumDecl *aggregateDecl ) {
[1e1e15b]55 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
[51b73452]56}
57
[4040425]58void Visitor::visit( TraitDecl *aggregateDecl ) {
[1e1e15b]59 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
[51b73452]60}
61
[1e1e15b]62void Visitor::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {
[0dd3a2f]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 ) {
[1e1e15b]69 handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) );
[51b73452]70}
71
[0dd3a2f]72void Visitor::visit( TypedefDecl *typeDecl ) {
[1e1e15b]73 handleNamedTypeDecl( 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
[7f5566b]84void Visitor::visit( AsmStmt *asmStmt ) {
85 maybeAccept( asmStmt->get_instruction(), *this );
86 acceptAll( asmStmt->get_output(), *this );
87 acceptAll( asmStmt->get_input(), *this );
88 acceptAll( asmStmt->get_clobber(), *this );
89}
90
[0dd3a2f]91void Visitor::visit( IfStmt *ifStmt ) {
92 maybeAccept( ifStmt->get_condition(), *this );
93 maybeAccept( ifStmt->get_thenPart(), *this );
94 maybeAccept( ifStmt->get_elsePart(), *this );
[51b73452]95}
96
[0dd3a2f]97void Visitor::visit( WhileStmt *whileStmt ) {
98 maybeAccept( whileStmt->get_condition(), *this );
99 maybeAccept( whileStmt->get_body(), *this );
[51b73452]100}
101
[0dd3a2f]102void Visitor::visit( ForStmt *forStmt ) {
[145f1fc]103 acceptAll( forStmt->get_initialization(), *this );
[0dd3a2f]104 maybeAccept( forStmt->get_condition(), *this );
105 maybeAccept( forStmt->get_increment(), *this );
106 maybeAccept( forStmt->get_body(), *this );
[51b73452]107}
108
[0dd3a2f]109void Visitor::visit( SwitchStmt *switchStmt ) {
110 maybeAccept( switchStmt->get_condition(), *this );
[8688ce1]111 acceptAll( switchStmt->get_statements(), *this );
[51b73452]112}
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
[f1b1e4c]147void Visitor::visit( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
148 maybeAccept( impCtorDtorStmt->get_callStmt(), *this );
149}
150
[0dd3a2f]151void Visitor::visit( ApplicationExpr *applicationExpr ) {
152 acceptAll( applicationExpr->get_results(), *this );
153 maybeAccept( applicationExpr->get_function(), *this );
154 acceptAll( applicationExpr->get_args(), *this );
[51b73452]155}
156
[0dd3a2f]157void Visitor::visit( UntypedExpr *untypedExpr ) {
158 acceptAll( untypedExpr->get_results(), *this );
159 acceptAll( untypedExpr->get_args(), *this );
[51b73452]160}
161
[0dd3a2f]162void Visitor::visit( NameExpr *nameExpr ) {
163 acceptAll( nameExpr->get_results(), *this );
[51b73452]164}
165
[0dd3a2f]166void Visitor::visit( AddressExpr *addressExpr ) {
167 acceptAll( addressExpr->get_results(), *this );
168 maybeAccept( addressExpr->get_arg(), *this );
[51b73452]169}
170
[0dd3a2f]171void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
172 acceptAll( labAddressExpr->get_results(), *this );
173 maybeAccept( labAddressExpr->get_arg(), *this );
[51b73452]174}
175
[0dd3a2f]176void Visitor::visit( CastExpr *castExpr ) {
177 acceptAll( castExpr->get_results(), *this );
178 maybeAccept( castExpr->get_arg(), *this );
[51b73452]179}
180
[0dd3a2f]181void Visitor::visit( UntypedMemberExpr *memberExpr ) {
182 acceptAll( memberExpr->get_results(), *this );
183 maybeAccept( memberExpr->get_aggregate(), *this );
[3b58d91]184 maybeAccept( memberExpr->get_member(), *this );
[51b73452]185}
186
[0dd3a2f]187void Visitor::visit( MemberExpr *memberExpr ) {
188 acceptAll( memberExpr->get_results(), *this );
189 maybeAccept( memberExpr->get_aggregate(), *this );
[51b73452]190}
191
[0dd3a2f]192void Visitor::visit( VariableExpr *variableExpr ) {
193 acceptAll( variableExpr->get_results(), *this );
[51b73452]194}
195
[0dd3a2f]196void Visitor::visit( ConstantExpr *constantExpr ) {
197 acceptAll( constantExpr->get_results(), *this );
198 maybeAccept( constantExpr->get_constant(), *this );
[51b73452]199}
200
[0dd3a2f]201void Visitor::visit( SizeofExpr *sizeofExpr ) {
202 acceptAll( sizeofExpr->get_results(), *this );
203 if ( sizeofExpr->get_isType() ) {
204 maybeAccept( sizeofExpr->get_type(), *this );
205 } else {
206 maybeAccept( sizeofExpr->get_expr(), *this );
207 }
[51b73452]208}
209
[47534159]210void Visitor::visit( AlignofExpr *alignofExpr ) {
211 acceptAll( alignofExpr->get_results(), *this );
212 if ( alignofExpr->get_isType() ) {
213 maybeAccept( alignofExpr->get_type(), *this );
214 } else {
215 maybeAccept( alignofExpr->get_expr(), *this );
216 }
217}
218
[2a4b088]219void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
220 acceptAll( offsetofExpr->get_results(), *this );
221 maybeAccept( offsetofExpr->get_type(), *this );
222}
223
[25a054f]224void Visitor::visit( OffsetofExpr *offsetofExpr ) {
225 acceptAll( offsetofExpr->get_results(), *this );
226 maybeAccept( offsetofExpr->get_type(), *this );
227 maybeAccept( offsetofExpr->get_member(), *this );
228}
229
[afc1045]230void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
231 acceptAll( offsetPackExpr->get_results(), *this );
232 maybeAccept( offsetPackExpr->get_type(), *this );
233}
234
[0dd3a2f]235void Visitor::visit( AttrExpr *attrExpr ) {
236 acceptAll( attrExpr->get_results(), *this );
237 if ( attrExpr->get_isType() ) {
238 maybeAccept( attrExpr->get_type(), *this );
239 } else {
240 maybeAccept( attrExpr->get_expr(), *this );
241 }
[51b73452]242}
243
[0dd3a2f]244void Visitor::visit( LogicalExpr *logicalExpr ) {
245 acceptAll( logicalExpr->get_results(), *this );
246 maybeAccept( logicalExpr->get_arg1(), *this );
247 maybeAccept( logicalExpr->get_arg2(), *this );
[51b73452]248}
249
[0dd3a2f]250void Visitor::visit( ConditionalExpr *conditionalExpr ) {
251 acceptAll( conditionalExpr->get_results(), *this );
252 maybeAccept( conditionalExpr->get_arg1(), *this );
253 maybeAccept( conditionalExpr->get_arg2(), *this );
254 maybeAccept( conditionalExpr->get_arg3(), *this );
[51b73452]255}
256
[0dd3a2f]257void Visitor::visit( CommaExpr *commaExpr ) {
258 acceptAll( commaExpr->get_results(), *this );
259 maybeAccept( commaExpr->get_arg1(), *this );
260 maybeAccept( commaExpr->get_arg2(), *this );
[51b73452]261}
262
[0dd3a2f]263void Visitor::visit( TupleExpr *tupleExpr ) {
264 acceptAll( tupleExpr->get_results(), *this );
265 acceptAll( tupleExpr->get_exprs(), *this );
[51b73452]266}
267
[0dd3a2f]268void Visitor::visit( SolvedTupleExpr *tupleExpr ) {
269 acceptAll( tupleExpr->get_results(), *this );
270 acceptAll( tupleExpr->get_exprs(), *this );
[51b73452]271}
272
[0dd3a2f]273void Visitor::visit( TypeExpr *typeExpr ) {
274 acceptAll( typeExpr->get_results(), *this );
275 maybeAccept( typeExpr->get_type(), *this );
[51b73452]276}
277
[7f5566b]278void Visitor::visit( AsmExpr *asmExpr ) {
279 maybeAccept( asmExpr->get_inout(), *this );
280 maybeAccept( asmExpr->get_constraint(), *this );
281 maybeAccept( asmExpr->get_operand(), *this );
282}
283
[db4ecc5]284void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
285 maybeAccept( impCpCtorExpr->get_callExpr(), *this );
286 acceptAll( impCpCtorExpr->get_tempDecls(), *this );
[dc2e7e0]287 acceptAll( impCpCtorExpr->get_returnDecls(), *this );
[db4ecc5]288}
289
[b6fe7e6]290void Visitor::visit( ConstructorExpr * ctorExpr ) {
291 acceptAll( ctorExpr->get_results(), *this );
292 maybeAccept( ctorExpr->get_callExpr(), *this );
[51b73452]293}
294
[630a82a]295void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
296 acceptAll( compLitExpr->get_results(), *this );
297 maybeAccept( compLitExpr->get_type(), *this );
298 maybeAccept( compLitExpr->get_initializer(), *this );
299}
300
[b6fe7e6]301void Visitor::visit( UntypedValofExpr *valofExpr ) {
302 acceptAll( valofExpr->get_results(), *this );
303 maybeAccept( valofExpr->get_body(), *this );
304}
305
[8688ce1]306void Visitor::visit( RangeExpr *rangeExpr ) {
307 maybeAccept( rangeExpr->get_low(), *this );
308 maybeAccept( rangeExpr->get_high(), *this );
309}
310
[3b58d91]311void Visitor::visit( TupleIndexExpr *tupleExpr ) {
312 acceptAll( tupleExpr->get_results(), *this );
313 maybeAccept( tupleExpr->get_tuple(), *this );
314}
315
316void Visitor::visit( MemberTupleExpr *tupleExpr ) {
317 acceptAll( tupleExpr->get_results(), *this );
318 maybeAccept( tupleExpr->get_member(), *this );
319 maybeAccept( tupleExpr->get_aggregate(), *this );
320}
321
322void Visitor::visit( MultipleAssignExpr *assignExpr ) {
323 acceptAll( assignExpr->get_results(), *this );
324 maybeAccept( assignExpr->get_lhs(), *this );
325 maybeAccept( assignExpr->get_rhs(), *this );
326}
327
328void Visitor::visit( MassAssignExpr *assignExpr ) {
329 acceptAll( assignExpr->get_results(), *this );
330 maybeAccept( assignExpr->get_lhs(), *this );
331 maybeAccept( assignExpr->get_rhs(), *this );
332}
333
[0dd3a2f]334void Visitor::visit( VoidType *voidType ) {
335 acceptAll( voidType->get_forall(), *this );
[51b73452]336}
337
[0dd3a2f]338void Visitor::visit( BasicType *basicType ) {
339 acceptAll( basicType->get_forall(), *this );
[51b73452]340}
341
[0dd3a2f]342void Visitor::visit( PointerType *pointerType ) {
343 acceptAll( pointerType->get_forall(), *this );
344 maybeAccept( pointerType->get_base(), *this );
[51b73452]345}
346
[0dd3a2f]347void Visitor::visit( ArrayType *arrayType ) {
348 acceptAll( arrayType->get_forall(), *this );
349 maybeAccept( arrayType->get_dimension(), *this );
350 maybeAccept( arrayType->get_base(), *this );
[51b73452]351}
352
[0dd3a2f]353void Visitor::visit( FunctionType *functionType ) {
354 acceptAll( functionType->get_forall(), *this );
355 acceptAll( functionType->get_returnVals(), *this );
356 acceptAll( functionType->get_parameters(), *this );
[51b73452]357}
358
[1e1e15b]359void Visitor::handleReferenceToType( ReferenceToType *aggregateUseType ) {
[0dd3a2f]360 acceptAll( aggregateUseType->get_forall(), *this );
361 acceptAll( aggregateUseType->get_parameters(), *this );
[51b73452]362}
363
[0dd3a2f]364void Visitor::visit( StructInstType *aggregateUseType ) {
[1e1e15b]365 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
[51b73452]366}
367
[0dd3a2f]368void Visitor::visit( UnionInstType *aggregateUseType ) {
[1e1e15b]369 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
[51b73452]370}
371
[0dd3a2f]372void Visitor::visit( EnumInstType *aggregateUseType ) {
[1e1e15b]373 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
[51b73452]374}
375
[4040425]376void Visitor::visit( TraitInstType *aggregateUseType ) {
[1e1e15b]377 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
[0dd3a2f]378 acceptAll( aggregateUseType->get_members(), *this );
[51b73452]379}
380
[0dd3a2f]381void Visitor::visit( TypeInstType *aggregateUseType ) {
[1e1e15b]382 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
[51b73452]383}
384
[0dd3a2f]385void Visitor::visit( TupleType *tupleType ) {
386 acceptAll( tupleType->get_forall(), *this );
387 acceptAll( tupleType->get_types(), *this );
[51b73452]388}
389
[0dd3a2f]390void Visitor::visit( TypeofType *typeofType ) {
391 assert( typeofType->get_expr() );
392 typeofType->get_expr()->accept( *this );
[51b73452]393}
394
[0dd3a2f]395void Visitor::visit( AttrType *attrType ) {
396 if ( attrType->get_isType() ) {
397 assert( attrType->get_type() );
398 attrType->get_type()->accept( *this );
399 } else {
400 assert( attrType->get_expr() );
401 attrType->get_expr()->accept( *this );
402 } // if
[51b73452]403}
404
[44b7088]405void Visitor::visit( VarArgsType *varArgsType ) {
406 acceptAll( varArgsType->get_forall(), *this );
407}
408
[0dd3a2f]409void Visitor::visit( SingleInit *singleInit ) {
410 singleInit->get_value()->accept( *this );
[51b73452]411}
412
[0dd3a2f]413void Visitor::visit( ListInit *listInit ) {
414 acceptAll( listInit->get_designators(), *this );
415 acceptAll( listInit->get_initializers(), *this );
[51b73452]416}
417
[71f4e4f]418void Visitor::visit( ConstructorInit *ctorInit ) {
419 maybeAccept( ctorInit->get_ctor(), *this );
420 maybeAccept( ctorInit->get_init(), *this );
421}
422
[0dd3a2f]423void Visitor::visit( Subrange *subrange ) {}
[51b73452]424
[0dd3a2f]425void Visitor::visit( Constant *constant ) {}
426// Local Variables: //
427// tab-width: 4 //
428// mode: c++ //
429// compile-command: "make install" //
430// End: //
Note: See TracBrowser for help on using the repository browser.