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 Aug 17 15:39:38 2017 |
---|
13 | // Update Count : 29 |
---|
14 | // |
---|
15 | |
---|
16 | #include <cassert> // for assert |
---|
17 | #include <list> // for list |
---|
18 | |
---|
19 | #include "Attribute.h" // for Attribute |
---|
20 | #include "Constant.h" // for Constant |
---|
21 | #include "Declaration.h" // for DeclarationWithType, ObjectDecl, Declaration |
---|
22 | #include "Expression.h" // for Expression, ConstantExpr, ImplicitCopyCtorExpr |
---|
23 | #include "Initializer.h" // for Initializer, Designation, ConstructorInit |
---|
24 | #include "Statement.h" // for Statement, CatchStmt, AsmStmt, CompoundStmt |
---|
25 | #include "Type.h" // for Type, Type::ForallList, AttrType, FunctionType |
---|
26 | #include "Visitor.h" |
---|
27 | |
---|
28 | class Subrange; |
---|
29 | |
---|
30 | Visitor::Visitor() {} |
---|
31 | |
---|
32 | Visitor::~Visitor() {} |
---|
33 | |
---|
34 | void Visitor::visit( TupleType *tupleType ) { |
---|
35 | acceptAll( tupleType->get_forall(), *this ); |
---|
36 | acceptAll( tupleType->get_types(), *this ); |
---|
37 | acceptAll( tupleType->get_members(), *this ); |
---|
38 | } |
---|
39 | |
---|
40 | void Visitor::visit( TypeofType *typeofType ) { |
---|
41 | assert( typeofType->get_expr() ); |
---|
42 | typeofType->get_expr()->accept( *this ); |
---|
43 | } |
---|
44 | |
---|
45 | void Visitor::visit( AttrType *attrType ) { |
---|
46 | if ( attrType->get_isType() ) { |
---|
47 | assert( attrType->get_type() ); |
---|
48 | attrType->get_type()->accept( *this ); |
---|
49 | } else { |
---|
50 | assert( attrType->get_expr() ); |
---|
51 | attrType->get_expr()->accept( *this ); |
---|
52 | } // if |
---|
53 | } |
---|
54 | |
---|
55 | void Visitor::visit( VarArgsType *varArgsType ) { |
---|
56 | acceptAll( varArgsType->get_forall(), *this ); |
---|
57 | } |
---|
58 | |
---|
59 | void Visitor::visit( ZeroType *zeroType ) { |
---|
60 | acceptAll( zeroType->get_forall(), *this ); |
---|
61 | } |
---|
62 | |
---|
63 | void Visitor::visit( OneType *oneType ) { |
---|
64 | acceptAll( oneType->get_forall(), *this ); |
---|
65 | } |
---|
66 | |
---|
67 | void Visitor::visit( Designation * designation ) { |
---|
68 | acceptAll( designation->get_designators(), *this ); |
---|
69 | } |
---|
70 | |
---|
71 | void Visitor::visit( SingleInit *singleInit ) { |
---|
72 | singleInit->get_value()->accept( *this ); |
---|
73 | } |
---|
74 | |
---|
75 | void Visitor::visit( ListInit *listInit ) { |
---|
76 | acceptAll( listInit->get_designations(), *this ); |
---|
77 | acceptAll( listInit->get_initializers(), *this ); |
---|
78 | } |
---|
79 | |
---|
80 | void Visitor::visit( ConstructorInit *ctorInit ) { |
---|
81 | maybeAccept( ctorInit->get_ctor(), *this ); |
---|
82 | maybeAccept( ctorInit->get_dtor(), *this ); |
---|
83 | maybeAccept( ctorInit->get_init(), *this ); |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | void Visitor::visit( Subrange * ) {} |
---|
88 | |
---|
89 | |
---|
90 | void Visitor::visit( Constant * ) {} |
---|
91 | |
---|
92 | void Visitor::visit( Attribute * attribute ) { |
---|
93 | acceptAll( attribute->parameters, *this ); |
---|
94 | } |
---|
95 | |
---|
96 | // Local Variables: // |
---|
97 | // tab-width: 4 // |
---|
98 | // mode: c++ // |
---|
99 | // compile-command: "make install" // |
---|
100 | // End: // |
---|