source: src/SynTree/Visitor.cc@ ed50f0ba

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 ed50f0ba was e994912, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

code generation for external asm statement (declaration)

  • Property mode set to 100644
File size: 13.1 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 : Thu Feb 9 14:19:22 2017
13// Update Count : 22
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::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
42 acceptAll( aggregateDecl->get_parameters(), *this );
43 acceptAll( aggregateDecl->get_members(), *this );
44}
45
46void Visitor::visit( StructDecl *aggregateDecl ) {
47 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
48}
49
50void Visitor::visit( UnionDecl *aggregateDecl ) {
51 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
52}
53
54void Visitor::visit( EnumDecl *aggregateDecl ) {
55 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
56}
57
58void Visitor::visit( TraitDecl *aggregateDecl ) {
59 handleAggregateDecl( static_cast< AggregateDecl* >( aggregateDecl ) );
60}
61
62void Visitor::handleNamedTypeDecl( 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 handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) );
70}
71
72void Visitor::visit( TypedefDecl *typeDecl ) {
73 handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) );
74}
75
76void Visitor::visit( AsmDecl *asmDecl ) {
77 maybeAccept( asmDecl->get_stmt(), *this );
78}
79
80
81void Visitor::visit( CompoundStmt *compoundStmt ) {
82 acceptAll( compoundStmt->get_kids(), *this );
83}
84
85void Visitor::visit( ExprStmt *exprStmt ) {
86 maybeAccept( exprStmt->get_expr(), *this );
87}
88
89void Visitor::visit( AsmStmt *asmStmt ) {
90 maybeAccept( asmStmt->get_instruction(), *this );
91 acceptAll( asmStmt->get_output(), *this );
92 acceptAll( asmStmt->get_input(), *this );
93 acceptAll( asmStmt->get_clobber(), *this );
94}
95
96void Visitor::visit( IfStmt *ifStmt ) {
97 maybeAccept( ifStmt->get_condition(), *this );
98 maybeAccept( ifStmt->get_thenPart(), *this );
99 maybeAccept( ifStmt->get_elsePart(), *this );
100}
101
102void Visitor::visit( WhileStmt *whileStmt ) {
103 maybeAccept( whileStmt->get_condition(), *this );
104 maybeAccept( whileStmt->get_body(), *this );
105}
106
107void Visitor::visit( ForStmt *forStmt ) {
108 acceptAll( forStmt->get_initialization(), *this );
109 maybeAccept( forStmt->get_condition(), *this );
110 maybeAccept( forStmt->get_increment(), *this );
111 maybeAccept( forStmt->get_body(), *this );
112}
113
114void Visitor::visit( SwitchStmt *switchStmt ) {
115 maybeAccept( switchStmt->get_condition(), *this );
116 acceptAll( switchStmt->get_statements(), *this );
117}
118
119void Visitor::visit( CaseStmt *caseStmt ) {
120 maybeAccept( caseStmt->get_condition(), *this );
121 acceptAll( caseStmt->get_statements(), *this );
122}
123
124void Visitor::visit( BranchStmt *branchStmt ) {
125}
126
127void Visitor::visit( ReturnStmt *returnStmt ) {
128 maybeAccept( returnStmt->get_expr(), *this );
129}
130
131void Visitor::visit( TryStmt *tryStmt ) {
132 maybeAccept( tryStmt->get_block(), *this );
133 acceptAll( tryStmt->get_catchers(), *this );
134}
135
136void Visitor::visit( CatchStmt *catchStmt ) {
137 maybeAccept( catchStmt->get_decl(), *this );
138 maybeAccept( catchStmt->get_body(), *this );
139}
140
141void Visitor::visit( FinallyStmt *finalStmt ) {
142 maybeAccept( finalStmt->get_block(), *this );
143}
144
145void Visitor::visit( NullStmt *nullStmt ) {
146}
147
148void Visitor::visit( DeclStmt *declStmt ) {
149 maybeAccept( declStmt->get_decl(), *this );
150}
151
152void Visitor::visit( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
153 maybeAccept( impCtorDtorStmt->get_callStmt(), *this );
154}
155
156
157void Visitor::visit( ApplicationExpr *applicationExpr ) {
158 maybeAccept( applicationExpr->get_result(), *this );
159 maybeAccept( applicationExpr->get_function(), *this );
160 acceptAll( applicationExpr->get_args(), *this );
161}
162
163void Visitor::visit( UntypedExpr *untypedExpr ) {
164 maybeAccept( untypedExpr->get_result(), *this );
165 acceptAll( untypedExpr->get_args(), *this );
166}
167
168void Visitor::visit( NameExpr *nameExpr ) {
169 maybeAccept( nameExpr->get_result(), *this );
170}
171
172void Visitor::visit( AddressExpr *addressExpr ) {
173 maybeAccept( addressExpr->get_result(), *this );
174 maybeAccept( addressExpr->get_arg(), *this );
175}
176
177void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
178 maybeAccept( labAddressExpr->get_result(), *this );
179 maybeAccept( labAddressExpr->get_arg(), *this );
180}
181
182void Visitor::visit( CastExpr *castExpr ) {
183 maybeAccept( castExpr->get_result(), *this );
184 maybeAccept( castExpr->get_arg(), *this );
185}
186
187void Visitor::visit( UntypedMemberExpr *memberExpr ) {
188 maybeAccept( memberExpr->get_result(), *this );
189 maybeAccept( memberExpr->get_aggregate(), *this );
190 maybeAccept( memberExpr->get_member(), *this );
191}
192
193void Visitor::visit( MemberExpr *memberExpr ) {
194 maybeAccept( memberExpr->get_result(), *this );
195 maybeAccept( memberExpr->get_aggregate(), *this );
196}
197
198void Visitor::visit( VariableExpr *variableExpr ) {
199 maybeAccept( variableExpr->get_result(), *this );
200}
201
202void Visitor::visit( ConstantExpr *constantExpr ) {
203 maybeAccept( constantExpr->get_result(), *this );
204 maybeAccept( constantExpr->get_constant(), *this );
205}
206
207void Visitor::visit( SizeofExpr *sizeofExpr ) {
208 maybeAccept( sizeofExpr->get_result(), *this );
209 if ( sizeofExpr->get_isType() ) {
210 maybeAccept( sizeofExpr->get_type(), *this );
211 } else {
212 maybeAccept( sizeofExpr->get_expr(), *this );
213 }
214}
215
216void Visitor::visit( AlignofExpr *alignofExpr ) {
217 maybeAccept( alignofExpr->get_result(), *this );
218 if ( alignofExpr->get_isType() ) {
219 maybeAccept( alignofExpr->get_type(), *this );
220 } else {
221 maybeAccept( alignofExpr->get_expr(), *this );
222 }
223}
224
225void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
226 maybeAccept( offsetofExpr->get_result(), *this );
227 maybeAccept( offsetofExpr->get_type(), *this );
228}
229
230void Visitor::visit( OffsetofExpr *offsetofExpr ) {
231 maybeAccept( offsetofExpr->get_result(), *this );
232 maybeAccept( offsetofExpr->get_type(), *this );
233 maybeAccept( offsetofExpr->get_member(), *this );
234}
235
236void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
237 maybeAccept( offsetPackExpr->get_result(), *this );
238 maybeAccept( offsetPackExpr->get_type(), *this );
239}
240
241void Visitor::visit( AttrExpr *attrExpr ) {
242 maybeAccept( attrExpr->get_result(), *this );
243 if ( attrExpr->get_isType() ) {
244 maybeAccept( attrExpr->get_type(), *this );
245 } else {
246 maybeAccept( attrExpr->get_expr(), *this );
247 }
248}
249
250void Visitor::visit( LogicalExpr *logicalExpr ) {
251 maybeAccept( logicalExpr->get_result(), *this );
252 maybeAccept( logicalExpr->get_arg1(), *this );
253 maybeAccept( logicalExpr->get_arg2(), *this );
254}
255
256void Visitor::visit( ConditionalExpr *conditionalExpr ) {
257 maybeAccept( conditionalExpr->get_result(), *this );
258 maybeAccept( conditionalExpr->get_arg1(), *this );
259 maybeAccept( conditionalExpr->get_arg2(), *this );
260 maybeAccept( conditionalExpr->get_arg3(), *this );
261}
262
263void Visitor::visit( CommaExpr *commaExpr ) {
264 maybeAccept( commaExpr->get_result(), *this );
265 maybeAccept( commaExpr->get_arg1(), *this );
266 maybeAccept( commaExpr->get_arg2(), *this );
267}
268
269void Visitor::visit( TypeExpr *typeExpr ) {
270 maybeAccept( typeExpr->get_result(), *this );
271 maybeAccept( typeExpr->get_type(), *this );
272}
273
274void Visitor::visit( AsmExpr *asmExpr ) {
275 maybeAccept( asmExpr->get_inout(), *this );
276 maybeAccept( asmExpr->get_constraint(), *this );
277 maybeAccept( asmExpr->get_operand(), *this );
278}
279
280void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
281 maybeAccept( impCpCtorExpr->get_result(), *this );
282 maybeAccept( impCpCtorExpr->get_callExpr(), *this );
283 acceptAll( impCpCtorExpr->get_tempDecls(), *this );
284 acceptAll( impCpCtorExpr->get_returnDecls(), *this );
285 acceptAll( impCpCtorExpr->get_dtors(), *this );
286}
287
288void Visitor::visit( ConstructorExpr * ctorExpr ) {
289 maybeAccept( ctorExpr->get_result(), *this );
290 maybeAccept( ctorExpr->get_callExpr(), *this );
291}
292
293void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
294 maybeAccept( compLitExpr->get_result(), *this );
295 maybeAccept( compLitExpr->get_type(), *this );
296 maybeAccept( compLitExpr->get_initializer(), *this );
297}
298
299void Visitor::visit( UntypedValofExpr *valofExpr ) {
300 maybeAccept( valofExpr->get_result(), *this );
301 maybeAccept( valofExpr->get_body(), *this );
302}
303
304void Visitor::visit( RangeExpr *rangeExpr ) {
305 maybeAccept( rangeExpr->get_low(), *this );
306 maybeAccept( rangeExpr->get_high(), *this );
307}
308
309void Visitor::visit( UntypedTupleExpr *tupleExpr ) {
310 maybeAccept( tupleExpr->get_result(), *this );
311 acceptAll( tupleExpr->get_exprs(), *this );
312}
313
314void Visitor::visit( TupleExpr *tupleExpr ) {
315 maybeAccept( tupleExpr->get_result(), *this );
316 acceptAll( tupleExpr->get_exprs(), *this );
317}
318
319void Visitor::visit( TupleIndexExpr *tupleExpr ) {
320 maybeAccept( tupleExpr->get_result(), *this );
321 maybeAccept( tupleExpr->get_tuple(), *this );
322}
323
324void Visitor::visit( MemberTupleExpr *tupleExpr ) {
325 maybeAccept( tupleExpr->get_result(), *this );
326 maybeAccept( tupleExpr->get_member(), *this );
327 maybeAccept( tupleExpr->get_aggregate(), *this );
328}
329
330void Visitor::visit( TupleAssignExpr *assignExpr ) {
331 maybeAccept( assignExpr->get_result(), *this );
332 maybeAccept( assignExpr->get_stmtExpr(), *this );
333}
334
335void Visitor::visit( StmtExpr *stmtExpr ) {
336 maybeAccept( stmtExpr->get_result(), *this );
337 maybeAccept( stmtExpr->get_statements(), *this );
338 acceptAll( stmtExpr->get_returnDecls(), *this );
339 acceptAll( stmtExpr->get_dtors(), *this );
340}
341
342void Visitor::visit( UniqueExpr *uniqueExpr ) {
343 maybeAccept( uniqueExpr->get_result(), *this );
344 maybeAccept( uniqueExpr->get_expr(), *this );
345}
346
347
348void Visitor::visit( VoidType *voidType ) {
349 acceptAll( voidType->get_forall(), *this );
350}
351
352void Visitor::visit( BasicType *basicType ) {
353 acceptAll( basicType->get_forall(), *this );
354}
355
356void Visitor::visit( PointerType *pointerType ) {
357 acceptAll( pointerType->get_forall(), *this );
358 maybeAccept( pointerType->get_base(), *this );
359}
360
361void Visitor::visit( ArrayType *arrayType ) {
362 acceptAll( arrayType->get_forall(), *this );
363 maybeAccept( arrayType->get_dimension(), *this );
364 maybeAccept( arrayType->get_base(), *this );
365}
366
367void Visitor::visit( FunctionType *functionType ) {
368 acceptAll( functionType->get_forall(), *this );
369 acceptAll( functionType->get_returnVals(), *this );
370 acceptAll( functionType->get_parameters(), *this );
371}
372
373void Visitor::handleReferenceToType( ReferenceToType *aggregateUseType ) {
374 acceptAll( aggregateUseType->get_forall(), *this );
375 acceptAll( aggregateUseType->get_parameters(), *this );
376}
377
378void Visitor::visit( StructInstType *aggregateUseType ) {
379 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
380}
381
382void Visitor::visit( UnionInstType *aggregateUseType ) {
383 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
384}
385
386void Visitor::visit( EnumInstType *aggregateUseType ) {
387 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
388}
389
390void Visitor::visit( TraitInstType *aggregateUseType ) {
391 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
392 acceptAll( aggregateUseType->get_members(), *this );
393}
394
395void Visitor::visit( TypeInstType *aggregateUseType ) {
396 handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
397}
398
399void Visitor::visit( TupleType *tupleType ) {
400 acceptAll( tupleType->get_forall(), *this );
401 acceptAll( tupleType->get_types(), *this );
402}
403
404void Visitor::visit( TypeofType *typeofType ) {
405 assert( typeofType->get_expr() );
406 typeofType->get_expr()->accept( *this );
407}
408
409void Visitor::visit( AttrType *attrType ) {
410 if ( attrType->get_isType() ) {
411 assert( attrType->get_type() );
412 attrType->get_type()->accept( *this );
413 } else {
414 assert( attrType->get_expr() );
415 attrType->get_expr()->accept( *this );
416 } // if
417}
418
419void Visitor::visit( VarArgsType *varArgsType ) {
420 acceptAll( varArgsType->get_forall(), *this );
421}
422
423void Visitor::visit( ZeroType *zeroType ) {
424 acceptAll( zeroType->get_forall(), *this );
425}
426
427void Visitor::visit( OneType *oneType ) {
428 acceptAll( oneType->get_forall(), *this );
429}
430
431
432void Visitor::visit( SingleInit *singleInit ) {
433 singleInit->get_value()->accept( *this );
434}
435
436void Visitor::visit( ListInit *listInit ) {
437 acceptAll( listInit->get_designators(), *this );
438 acceptAll( listInit->get_initializers(), *this );
439}
440
441void Visitor::visit( ConstructorInit *ctorInit ) {
442 maybeAccept( ctorInit->get_ctor(), *this );
443 maybeAccept( ctorInit->get_dtor(), *this );
444 maybeAccept( ctorInit->get_init(), *this );
445}
446
447
448void Visitor::visit( Subrange *subrange ) {}
449
450
451void Visitor::visit( Constant *constant ) {}
452// Local Variables: //
453// tab-width: 4 //
454// mode: c++ //
455// compile-command: "make install" //
456// End: //
Note: See TracBrowser for help on using the repository browser.