source: translator/SynTree/Visitor.cc @ 134b86a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 134b86a was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 9.5 KB
Line 
1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: Visitor.cc,v 1.30 2005/08/29 20:59:27 rcbilson Exp $
5 *
6 */
7
8#include <cassert>
9#include "Visitor.h"
10#include "Initializer.h"
11#include "Statement.h"
12#include "Type.h"
13#include "Declaration.h"
14#include "Expression.h"
15#include "Constant.h"
16
17
18Visitor::Visitor()
19{
20}
21
22Visitor::~Visitor()
23{
24}
25
26void
27Visitor::visit(ObjectDecl *objectDecl)
28{
29    maybeAccept( objectDecl->get_type(), *this );
30    maybeAccept( objectDecl->get_init(), *this );
31    maybeAccept( objectDecl->get_bitfieldWidth(), *this );
32}
33
34void
35Visitor::visit(FunctionDecl *functionDecl)
36{
37    maybeAccept( functionDecl->get_functionType(), *this );
38    acceptAll( functionDecl->get_oldDecls(), *this );
39    maybeAccept( functionDecl->get_statements(), *this );
40}
41
42void
43Visitor::visit(AggregateDecl *aggregateDecl)
44{
45    acceptAll( aggregateDecl->get_parameters(), *this );
46    acceptAll( aggregateDecl->get_members(), *this );
47}
48
49void 
50Visitor::visit(StructDecl *aggregateDecl)
51{
52    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
53}
54
55void 
56Visitor::visit(UnionDecl *aggregateDecl)
57{
58    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
59}
60
61void 
62Visitor::visit(EnumDecl *aggregateDecl)
63{
64    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
65}
66
67void 
68Visitor::visit(ContextDecl *aggregateDecl)
69{
70    visit( static_cast< AggregateDecl* >( aggregateDecl ) );
71}
72
73void
74Visitor::visit(NamedTypeDecl *typeDecl)
75{
76    acceptAll( typeDecl->get_parameters(), *this );
77    acceptAll( typeDecl->get_assertions(), *this );
78    maybeAccept( typeDecl->get_base(), *this );
79}
80
81void 
82Visitor::visit(TypeDecl *typeDecl)
83{
84    visit( static_cast< NamedTypeDecl* >( typeDecl ) );
85}
86
87void 
88Visitor::visit(TypedefDecl *typeDecl)
89{
90    visit( static_cast< NamedTypeDecl* >( typeDecl ) );
91}
92
93void
94Visitor::visit(CompoundStmt *compoundStmt)
95{
96    acceptAll( compoundStmt->get_kids(), *this );
97}
98
99void
100Visitor::visit(ExprStmt *exprStmt)
101{
102    maybeAccept( exprStmt->get_expr(), *this );
103}
104
105void
106Visitor::visit(IfStmt *ifStmt)
107{
108    maybeAccept( ifStmt->get_condition(), *this );
109    maybeAccept( ifStmt->get_thenPart(), *this );
110    maybeAccept( ifStmt->get_elsePart(), *this );
111}
112
113void
114Visitor::visit(WhileStmt *whileStmt)
115{
116    maybeAccept( whileStmt->get_condition(), *this );
117    maybeAccept( whileStmt->get_body(), *this );
118}
119
120void
121Visitor::visit(ForStmt *forStmt)
122{
123    // ForStmt still needs to be fixed
124    maybeAccept( forStmt->get_initialization(), *this );
125    maybeAccept( forStmt->get_condition(), *this );
126    maybeAccept( forStmt->get_increment(), *this );
127    maybeAccept( forStmt->get_body(), *this );
128}
129
130void
131Visitor::visit(SwitchStmt *switchStmt)
132{
133    maybeAccept( switchStmt->get_condition(), *this );
134    acceptAll( switchStmt->get_branches(), *this );
135}
136
137void
138Visitor::visit(ChooseStmt *switchStmt)
139{
140    maybeAccept( switchStmt->get_condition(), *this );
141    acceptAll( switchStmt->get_branches(), *this );
142}
143
144void
145Visitor::visit(FallthruStmt *fallthruStmt){}
146
147void
148Visitor::visit(CaseStmt *caseStmt)
149{
150    maybeAccept( caseStmt->get_condition(), *this );
151    acceptAll( caseStmt->get_statements(), *this );
152}
153
154void
155Visitor::visit(BranchStmt *branchStmt)
156{
157}
158
159void
160Visitor::visit(ReturnStmt *returnStmt)
161{
162    maybeAccept( returnStmt->get_expr(), *this );
163}
164
165void
166Visitor::visit(TryStmt *tryStmt)
167{
168    maybeAccept( tryStmt->get_block(), *this );
169    acceptAll( tryStmt->get_catchers(), *this );
170}
171
172void
173Visitor::visit(CatchStmt *catchStmt)
174{
175    maybeAccept( catchStmt->get_decl(), *this );
176    maybeAccept( catchStmt->get_body(), *this );
177}
178
179void
180Visitor::visit(FinallyStmt *finalStmt)
181{
182    maybeAccept( finalStmt->get_block(), *this );
183}
184
185void
186Visitor::visit(NullStmt *nullStmt)
187{
188}
189
190void
191Visitor::visit(DeclStmt *declStmt)
192{
193    maybeAccept( declStmt->get_decl(), *this );
194}
195
196void
197Visitor::visit(ApplicationExpr *applicationExpr)
198{
199    acceptAll( applicationExpr->get_results(), *this );
200    maybeAccept( applicationExpr->get_function(), *this );
201    acceptAll( applicationExpr->get_args(), *this );
202}
203
204void
205Visitor::visit(UntypedExpr *untypedExpr)
206{
207    acceptAll( untypedExpr->get_results(), *this );
208    acceptAll( untypedExpr->get_args(), *this );
209}
210
211void
212Visitor::visit(NameExpr *nameExpr)
213{
214    acceptAll( nameExpr->get_results(), *this );
215}
216
217void
218Visitor::visit(AddressExpr *addressExpr)
219{
220    acceptAll( addressExpr->get_results(), *this );
221    maybeAccept( addressExpr->get_arg(), *this );
222}
223
224void
225Visitor::visit(LabelAddressExpr *labAddressExpr)
226{
227    acceptAll( labAddressExpr->get_results(), *this );
228    maybeAccept( labAddressExpr->get_arg(), *this );
229}
230
231void
232Visitor::visit(CastExpr *castExpr)
233{
234    acceptAll( castExpr->get_results(), *this );
235    maybeAccept( castExpr->get_arg(), *this );
236}
237
238void
239Visitor::visit(UntypedMemberExpr *memberExpr)
240{
241    acceptAll( memberExpr->get_results(), *this );
242    maybeAccept( memberExpr->get_aggregate(), *this );
243}
244
245void
246Visitor::visit(MemberExpr *memberExpr)
247{
248    acceptAll( memberExpr->get_results(), *this );
249    maybeAccept( memberExpr->get_aggregate(), *this );
250}
251
252void
253Visitor::visit(VariableExpr *variableExpr)
254{
255    acceptAll( variableExpr->get_results(), *this );
256}
257
258void
259Visitor::visit(ConstantExpr *constantExpr)
260{
261    acceptAll( constantExpr->get_results(), *this );
262    maybeAccept( constantExpr->get_constant(), *this );
263}
264
265void
266Visitor::visit(SizeofExpr *sizeofExpr)
267{
268    acceptAll( sizeofExpr->get_results(), *this );
269    if( sizeofExpr->get_isType() ) {
270        maybeAccept( sizeofExpr->get_type(), *this );
271    } else {
272        maybeAccept( sizeofExpr->get_expr(), *this );
273    }
274}
275
276void
277Visitor::visit(AttrExpr *attrExpr)
278{
279    acceptAll( attrExpr->get_results(), *this );
280    if( attrExpr->get_isType() ) {
281        maybeAccept( attrExpr->get_type(), *this );
282    } else {
283        maybeAccept( attrExpr->get_expr(), *this );
284    }
285}
286
287void
288Visitor::visit(LogicalExpr *logicalExpr)
289{
290    acceptAll( logicalExpr->get_results(), *this );
291    maybeAccept( logicalExpr->get_arg1(), *this );
292    maybeAccept( logicalExpr->get_arg2(), *this );
293}
294
295void
296Visitor::visit(ConditionalExpr *conditionalExpr)
297{
298    acceptAll( conditionalExpr->get_results(), *this );
299    maybeAccept( conditionalExpr->get_arg1(), *this );
300    maybeAccept( conditionalExpr->get_arg2(), *this );
301    maybeAccept( conditionalExpr->get_arg3(), *this );
302}
303
304void
305Visitor::visit(CommaExpr *commaExpr)
306{
307    acceptAll( commaExpr->get_results(), *this );
308    maybeAccept( commaExpr->get_arg1(), *this );
309    maybeAccept( commaExpr->get_arg2(), *this );
310}
311
312void
313Visitor::visit(TupleExpr *tupleExpr)
314{
315    acceptAll( tupleExpr->get_results(), *this );
316    acceptAll( tupleExpr->get_exprs(), *this );
317}
318
319void
320Visitor::visit(SolvedTupleExpr *tupleExpr)
321{
322    acceptAll( tupleExpr->get_results(), *this );
323    acceptAll( tupleExpr->get_exprs(), *this );
324}
325
326void
327Visitor::visit(TypeExpr *typeExpr)
328{
329    acceptAll( typeExpr->get_results(), *this );
330    maybeAccept( typeExpr->get_type(), *this );
331}
332
333void
334Visitor::visit(UntypedValofExpr *valofExpr)
335{
336    acceptAll( valofExpr->get_results(), *this );
337    maybeAccept( valofExpr->get_body(), *this );
338}
339
340void
341Visitor::visit(VoidType *voidType)
342{
343    acceptAll( voidType->get_forall(), *this );
344}
345
346void
347Visitor::visit(BasicType *basicType)
348{
349    acceptAll( basicType->get_forall(), *this );
350}
351
352void
353Visitor::visit(PointerType *pointerType)
354{
355    acceptAll( pointerType->get_forall(), *this );
356    maybeAccept( pointerType->get_base(), *this );
357}
358
359void
360Visitor::visit(ArrayType *arrayType)
361{
362    acceptAll( arrayType->get_forall(), *this );
363    maybeAccept( arrayType->get_dimension(), *this );
364    maybeAccept( arrayType->get_base(), *this );
365}
366
367void
368Visitor::visit(FunctionType *functionType)
369{
370    acceptAll( functionType->get_forall(), *this );
371    acceptAll( functionType->get_returnVals(), *this );
372    acceptAll( functionType->get_parameters(), *this );
373}
374
375void
376Visitor::visit(ReferenceToType *aggregateUseType)
377{
378    acceptAll( aggregateUseType->get_forall(), *this );
379    acceptAll( aggregateUseType->get_parameters(), *this );
380}
381
382void 
383Visitor::visit(StructInstType *aggregateUseType)
384{
385    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
386}
387
388void 
389Visitor::visit(UnionInstType *aggregateUseType)
390{
391    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
392}
393
394void 
395Visitor::visit(EnumInstType *aggregateUseType)
396{
397    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
398}
399
400void 
401Visitor::visit(ContextInstType *aggregateUseType)
402{
403    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
404    acceptAll( aggregateUseType->get_members(), *this );
405}
406
407void 
408Visitor::visit(TypeInstType *aggregateUseType)
409{
410    visit( static_cast< ReferenceToType* >( aggregateUseType ) );
411}
412
413void
414Visitor::visit(TupleType *tupleType)
415{
416    acceptAll( tupleType->get_forall(), *this );
417    acceptAll( tupleType->get_types(), *this );
418}
419
420void
421Visitor::visit(TypeofType *typeofType)
422{
423    assert( typeofType->get_expr() );
424    typeofType->get_expr()->accept( *this );
425}
426
427void
428Visitor::visit(AttrType *attrType)
429{
430    if( attrType->get_isType() ) {
431        assert( attrType->get_type() );
432        attrType->get_type()->accept( *this );
433    } else {
434        assert( attrType->get_expr() );
435        attrType->get_expr()->accept( *this );
436    }
437}
438
439void
440Visitor::visit(MemberInit *memberInit)
441{
442    memberInit->get_value()->accept( *this );
443}
444
445void
446Visitor::visit(ElementInit *elementInit)
447{
448    elementInit->get_value()->accept( *this );
449}
450
451void
452Visitor::visit(SingleInit *singleInit)
453{
454    singleInit->get_value()->accept( *this );
455}
456
457void
458Visitor::visit(ListInit *listInit)
459{
460    acceptAll( listInit->get_designators(), *this );
461    acceptAll( listInit->get_initializers(), *this );
462}
463
464void
465Visitor::visit(Subrange *subrange)
466{
467}
468
469void
470Visitor::visit(Constant *constant)
471{
472}
473
Note: See TracBrowser for help on using the repository browser.