LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
default-visitor.hxx
Go to the documentation of this file.
1 
6 #ifndef AST_DEFAULT_VISITOR_HXX
7 # define AST_DEFAULT_VISITOR_HXX
8 
9 # include <misc/algorithm.hh>
10 # include <ast/all.hh>
11 # include <ast/default-visitor.hh>
12 
13 namespace ast
14 {
15 
16  template <template <typename> class Const>
18  GenVisitor<Const>()
19  {
20  }
21 
22  template <template <typename> class Const>
24  {
25  }
26 
27  template <template <typename> class Const>
28  void
29  GenDefaultVisitor<Const>::operator()(typename Const<Ast>::type& e)
30  {
31  super_type::operator()(e);
32  }
33 
34  template <template <typename> class Const>
35  void
36  GenDefaultVisitor<Const>::operator()(typename Const<SimpleVar>::type&)
37  {
38  }
39 
40  template <template <typename> class Const>
41  void
42  GenDefaultVisitor<Const>::operator()(typename Const<FieldVar>::type& e)
43  {
44  e.var_get().accept(*this);
45  }
46 
47  template <template <typename> class Const>
48  void
49  GenDefaultVisitor<Const>::operator()(typename Const<CastVar>::type& e)
50  {
51  e.var_get().accept(*this);
52  e.ty_get().accept(*this);
53  }
54 
55  template <template <typename> class Const>
56  void
57  GenDefaultVisitor<Const>::operator()(typename Const<SubscriptVar>::type& e)
58  {
59  e.var_get().accept(*this);
60  e.index_get().accept(*this);
61  }
62 
63  template <template <typename> class Const>
64  void
65  GenDefaultVisitor<Const>::operator()(typename Const<NilExp>::type&)
66  {
67  }
68 
69  template <template <typename> class Const>
70  void
71  GenDefaultVisitor<Const>::operator()(typename Const<IntExp>::type&)
72  {
73  }
74 
75  template <template <typename> class Const>
76  void
77  GenDefaultVisitor<Const>::operator()(typename Const<StringExp>::type&)
78  {
79  }
80 
81  template <template <typename> class Const>
82  void
83  GenDefaultVisitor<Const>::operator()(typename Const<CallExp>::type& e)
84  {
85  // FIXME: Some code was deleted here.
86  }
87 
88  template <template <typename> class Const>
89  void
90  GenDefaultVisitor<Const>::operator()(typename Const<OpExp>::type& e)
91  {
92  e.left_get().accept(*this);
93  e.right_get().accept(*this);
94  }
95 
96  template <template <typename> class Const>
97  void
98  GenDefaultVisitor<Const>::operator()(typename Const<RecordExp>::type& e)
99  {
100  // FIXME: Some code was deleted here.
101  }
102 
103  template <template <typename> class Const>
104  void
105  GenDefaultVisitor<Const>::operator()(typename Const<SeqExp>::type& e)
106  {
107  // FIXME: Some code was deleted here.
108  }
109 
110  template <template <typename> class Const>
111  void
112  GenDefaultVisitor<Const>::operator()(typename Const<AssignExp>::type& e)
113  {
114  e.var_get().accept(*this);
115  e.exp_get().accept(*this);
116  }
117 
118  template <template <typename> class Const>
119  void
120  GenDefaultVisitor<Const>::operator()(typename Const<IfExp>::type& e)
121  {
122  // FIXME: Some code was deleted here.
123  }
124 
125  template <template <typename> class Const>
126  void
127  GenDefaultVisitor<Const>::operator()(typename Const<WhileExp>::type& e)
128  {
129  e.test_get().accept(*this);
130  e.body_get().accept(*this);
131  }
132 
133  template <template <typename> class Const>
134  void
135  GenDefaultVisitor<Const>::operator()(typename Const<ForExp>::type& e)
136  {
137  e.vardec_get().accept(*this);
138  e.hi_get().accept(*this);
139  e.body_get().accept(*this);
140  }
141 
142  template <template <typename> class Const>
143  void
144  GenDefaultVisitor<Const>::operator()(typename Const<BreakExp>::type&)
145  {
146  }
147 
148  template <template <typename> class Const>
149  void
150  GenDefaultVisitor<Const>::operator()(typename Const<LetExp>::type& e)
151  {
152  e.decs_get().accept(*this);
153  e.body_get().accept(*this);
154  }
155 
156  template <template <typename> class Const>
157  void
158  GenDefaultVisitor<Const>::operator()(typename Const<ArrayExp>::type& e)
159  {
160  e.type_name_get().accept(*this);
161  e.size_get().accept(*this);
162  e.init_get().accept(*this);
163  }
164 
165  template <template <typename> class Const>
166  void
167  GenDefaultVisitor<Const>::operator()(typename Const<CastExp>::type& e)
168  {
169  e.exp_get().accept(*this);
170  e.ty_get().accept(*this);
171  }
172 
173 
174  template < template<typename> class Const >
175  void
176  GenDefaultVisitor<Const>::operator()(typename Const<FieldInit>::type& e)
177  {
178  e.init_get().accept(*this);
179  }
180 
181  template <template <typename> class Const>
182  void
183  GenDefaultVisitor<Const>::operator()(typename Const<DecsList>::type& e)
184  {
185  misc::for_each(e.decs_get(), *this);
186  }
187 
188  template <template <typename> class Const>
189  void
190  GenDefaultVisitor<Const>::operator()(typename Const<Decs>::type& e)
191  {
192  e.accept(*this);
193  }
194 
195  template <template <typename> class Const>
196  template <typename DecsType>
197  inline void
198  GenDefaultVisitor<Const>::decs_visit(typename Const<DecsType>::type& e)
199  {
200  // The compiler cannot know whether the entity `type' is a type
201  // or some other kind. We must help it by specifying `typename'.
202 
203  // The type of the argument of this function, with const preserved.
204  typedef typename Const<DecsType>::type arg_type;
205  // The type of the list contained by this argument, const preserved.
206  // We need to use Const again, because getting a typedef from
207  // a const class does not give a const typedef.
208  typedef typename Const<typename arg_type::Ds>::type elt_type;
209  // An iterator over this list, const_iterator if needed.
211  for (i = e.decs_get().begin(); i != e.decs_get().end(); ++i)
212  (*i)->accept(*this);
213  }
214 
215  template <template <typename> class Const>
216  void
217  GenDefaultVisitor<Const>::operator()(typename Const<VarDecs>::type& e)
218  {
219  decs_visit<VarDecs>(e);
220  }
221 
222  template <template <typename> class Const>
223  void
224  GenDefaultVisitor<Const>::operator()(typename Const<VarDec>::type& e)
225  {
226  // `type_name' might be omitted.
227  this->accept(e.type_name_get());
228  // `init' can be null in case of formal parameter.
229  this->accept(e.init_get());
230  }
231 
232  template <template <typename> class Const>
233  void
234  GenDefaultVisitor<Const>::operator()(typename Const<FunctionDecs>::type& e)
235  {
236  decs_visit<FunctionDecs>(e);
237  }
238 
239  template <template <typename> class Const>
240  void
241  GenDefaultVisitor<Const>::operator()(typename Const<FunctionDec>::type& e)
242  {
243  // FIXME: Some code was deleted here.
244  }
245 
246  template <template <typename> class Const>
247  void
248  GenDefaultVisitor<Const>::operator()(typename Const<TypeDecs>::type& e)
249  {
250  decs_visit<TypeDecs>(e);
251  }
252 
253  template <template <typename> class Const>
254  void
255  GenDefaultVisitor<Const>::operator()(typename Const<TypeDec>::type& e)
256  {
257  e.ty_get().accept(*this);
258  }
259 
260 
261  template <template <typename> class Const>
262  void
263  GenDefaultVisitor<Const>::operator()(typename Const<NameTy>::type&)
264  {
265  }
266 
267  template <template <typename> class Const>
268  void
269  GenDefaultVisitor<Const>::operator()(typename Const<RecordTy>::type& e)
270  {
271  // FIXME: Some code was deleted here.
272  }
273 
274  template <template <typename> class Const>
275  void
276  GenDefaultVisitor<Const>::operator()(typename Const<ArrayTy>::type& e)
277  {
278  e.base_type_get().accept(*this);
279  }
280 
281  template <template <typename> class Const>
282  void
283  GenDefaultVisitor<Const>::operator()(typename Const<Field>::type& e)
284  {
285  e.type_name_get().accept(*this);
286  }
287 
288 } // namespace ast
289 
290 #endif // !AST_DEFAULT_VISITOR_HXX