]>
Commit | Line | Data |
---|---|---|
56099f08 | 1 | // parse tree functions |
69c68955 FCE |
2 | // Copyright (C) 2005 Red Hat Inc. |
3 | // | |
4 | // This file is part of systemtap, and is free software. You can | |
5 | // redistribute it and/or modify it under the terms of the GNU General | |
6 | // Public License (GPL); either version 2, or (at your option) any | |
7 | // later version. | |
2f1a1aea | 8 | |
2b066ec1 | 9 | #include "config.h" |
2f1a1aea FCE |
10 | #include "staptree.h" |
11 | #include "parse.h" | |
12 | #include <iostream> | |
56099f08 FCE |
13 | #include <typeinfo> |
14 | #include <cassert> | |
2f1a1aea | 15 | |
2b066ec1 FCE |
16 | using namespace std; |
17 | ||
2f1a1aea | 18 | |
56099f08 FCE |
19 | expression::expression (): |
20 | type (pe_unknown), tok (0) | |
21 | { | |
22 | } | |
23 | ||
24 | ||
25 | expression::~expression () | |
26 | { | |
27 | } | |
28 | ||
29 | ||
30 | statement::statement (): | |
31 | tok (0) | |
32 | { | |
33 | } | |
34 | ||
35 | ||
36 | statement::~statement () | |
37 | { | |
38 | } | |
39 | ||
40 | ||
41 | symbol::symbol (): | |
42 | referent (0) | |
43 | { | |
44 | } | |
45 | ||
46 | ||
47 | arrayindex::arrayindex (): | |
48 | referent (0) | |
49 | { | |
50 | } | |
51 | ||
52 | ||
53 | functioncall::functioncall (): | |
54 | referent (0) | |
55 | { | |
56 | } | |
57 | ||
58 | ||
59 | symboldecl::symboldecl (): | |
60 | tok (0), | |
61 | type (pe_unknown) | |
62 | { | |
63 | } | |
64 | ||
65 | ||
66 | symboldecl::~symboldecl () | |
67 | { | |
68 | } | |
69 | ||
a229fcd7 GH |
70 | probe_point::probe_point (std::vector<component*> const & comps, |
71 | const token * t): | |
72 | components(comps), tok(t) | |
73 | { | |
74 | } | |
56099f08 | 75 | |
9c0c0e46 | 76 | probe_point::probe_point (): |
82919855 FCE |
77 | tok (0) |
78 | { | |
79 | } | |
80 | ||
81 | ||
82 | probe::probe (): | |
83 | body (0), tok (0) | |
9c0c0e46 FCE |
84 | { |
85 | } | |
86 | ||
87 | ||
88 | probe_point::component::component (): | |
89 | arg (0) | |
90 | { | |
91 | } | |
92 | ||
93 | ||
a229fcd7 GH |
94 | probe_point::component::component (std::string const & f, literal * a): |
95 | functor(f), arg(a) | |
96 | { | |
97 | } | |
98 | ||
99 | ||
2b066ec1 FCE |
100 | vardecl::vardecl (): |
101 | arity (-1) | |
56099f08 FCE |
102 | { |
103 | } | |
104 | ||
105 | ||
2b066ec1 FCE |
106 | void |
107 | vardecl::set_arity (int a) | |
56099f08 | 108 | { |
d98d459c GH |
109 | if (a < 0) |
110 | return; | |
8846477c FCE |
111 | |
112 | if (arity != a && arity >= 0) | |
113 | throw semantic_error ("inconsistent arity", tok); | |
114 | ||
115 | if (arity != a) | |
116 | { | |
117 | arity = a; | |
118 | index_types.resize (arity); | |
119 | for (int i=0; i<arity; i++) | |
120 | index_types[i] = pe_unknown; | |
121 | } | |
56099f08 FCE |
122 | } |
123 | ||
313b2f74 GH |
124 | bool |
125 | vardecl::compatible_arity (int a) | |
126 | { | |
d98d459c | 127 | if (arity == -1 || a == -1) |
313b2f74 GH |
128 | return true; |
129 | return arity == a; | |
130 | } | |
131 | ||
56099f08 FCE |
132 | |
133 | functiondecl::functiondecl (): | |
134 | body (0) | |
135 | { | |
136 | } | |
137 | ||
138 | ||
3a20432b | 139 | literal_number::literal_number (int64_t v) |
56099f08 FCE |
140 | { |
141 | value = v; | |
142 | type = pe_long; | |
143 | } | |
144 | ||
2f1a1aea | 145 | |
56099f08 FCE |
146 | literal_string::literal_string (const string& v) |
147 | { | |
148 | value = v; | |
149 | type = pe_string; | |
150 | } | |
151 | ||
152 | ||
153 | ostream& | |
154 | operator << (ostream& o, const exp_type& e) | |
155 | { | |
156 | switch (e) | |
157 | { | |
158 | case pe_unknown: o << "unknown"; break; | |
159 | case pe_long: o << "long"; break; | |
160 | case pe_string: o << "string"; break; | |
161 | case pe_stats: o << "stats"; break; | |
162 | default: o << "???"; break; | |
163 | } | |
164 | return o; | |
165 | } | |
166 | ||
167 | ||
168 | // ------------------------------------------------------------------------ | |
169 | // parse tree printing | |
170 | ||
171 | ostream& operator << (ostream& o, expression& k) | |
172 | { | |
173 | k.print (o); | |
174 | return o; | |
175 | } | |
176 | ||
177 | ||
178 | void literal_string::print (ostream& o) | |
179 | { | |
2b066ec1 | 180 | // XXX: quote special chars |
56099f08 FCE |
181 | o << '"' << value << '"'; |
182 | } | |
183 | ||
f3c26ea5 | 184 | |
56099f08 FCE |
185 | void literal_number::print (ostream& o) |
186 | { | |
187 | o << value; | |
188 | } | |
189 | ||
190 | ||
191 | void binary_expression::print (ostream& o) | |
192 | { | |
193 | o << '(' << *left << ")" | |
194 | << op | |
195 | << '(' << *right << ")"; | |
196 | } | |
2f1a1aea FCE |
197 | |
198 | ||
56099f08 | 199 | void unary_expression::print (ostream& o) |
2f1a1aea | 200 | { |
56099f08 FCE |
201 | o << op << '(' << *operand << ")"; |
202 | } | |
203 | ||
69c68955 FCE |
204 | void array_in::print (ostream& o) |
205 | { | |
206 | o << "["; | |
207 | for (unsigned i=0; i<operand->indexes.size(); i++) | |
208 | { | |
209 | if (i > 0) o << ", "; | |
210 | operand->indexes[i]->print (o); | |
211 | } | |
212 | o << "] in " << operand->base; | |
213 | } | |
56099f08 FCE |
214 | |
215 | void post_crement::print (ostream& o) | |
216 | { | |
217 | o << '(' << *operand << ")" << op; | |
218 | } | |
219 | ||
220 | ||
221 | void ternary_expression::print (ostream& o) | |
222 | { | |
223 | o << "(" << *cond << ") ? (" | |
224 | << *truevalue << ") : (" | |
225 | << *falsevalue << ")"; | |
226 | } | |
227 | ||
228 | ||
229 | void symbol::print (ostream& o) | |
230 | { | |
231 | o << name; | |
232 | } | |
233 | ||
234 | ||
d7f3e0c5 GH |
235 | void target_symbol::print (std::ostream& o) |
236 | { | |
237 | o << base_name; | |
238 | for (unsigned i = 0; i < components.size(); ++i) | |
239 | { | |
240 | switch (components[i].first) | |
241 | { | |
242 | case comp_literal_array_index: | |
243 | o << '[' << components[i].second << ']'; | |
244 | break; | |
245 | case comp_struct_pointer_member: | |
246 | o << "->" << components[i].second; | |
247 | break; | |
248 | case comp_struct_member: | |
249 | o << "." << components[i].second; | |
250 | } | |
251 | } | |
252 | } | |
253 | ||
254 | ||
56099f08 FCE |
255 | void vardecl::print (ostream& o) |
256 | { | |
257 | o << name; | |
bed7c0af | 258 | if (arity > 0 || index_types.size() > 0) |
56099f08 FCE |
259 | o << "[...]"; |
260 | } | |
261 | ||
2f1a1aea | 262 | |
56099f08 FCE |
263 | void vardecl::printsig (ostream& o) |
264 | { | |
265 | o << name << ":" << type; | |
266 | if (index_types.size() > 0) | |
2f1a1aea | 267 | { |
56099f08 FCE |
268 | o << " ["; |
269 | for (unsigned i=0; i<index_types.size(); i++) | |
270 | o << (i>0 ? ", " : "") << index_types[i]; | |
271 | o << "]"; | |
272 | } | |
273 | } | |
274 | ||
275 | ||
276 | void functiondecl::print (ostream& o) | |
277 | { | |
278 | o << "function " << name << " ("; | |
279 | for (unsigned i=0; i<formal_args.size(); i++) | |
280 | o << (i>0 ? ", " : "") << *formal_args[i]; | |
281 | o << ")" << endl; | |
282 | body->print(o); | |
283 | } | |
284 | ||
285 | ||
286 | void functiondecl::printsig (ostream& o) | |
287 | { | |
288 | o << name << ":" << type << " ("; | |
289 | for (unsigned i=0; i<formal_args.size(); i++) | |
290 | o << (i>0 ? ", " : "") | |
291 | << *formal_args[i] | |
292 | << ":" | |
293 | << formal_args[i]->type; | |
294 | o << ")"; | |
295 | } | |
296 | ||
297 | ||
298 | void arrayindex::print (ostream& o) | |
299 | { | |
300 | o << base << "["; | |
301 | for (unsigned i=0; i<indexes.size(); i++) | |
302 | o << (i>0 ? ", " : "") << *indexes[i]; | |
303 | o << "]"; | |
304 | } | |
305 | ||
306 | ||
307 | void functioncall::print (ostream& o) | |
308 | { | |
309 | o << function << "("; | |
310 | for (unsigned i=0; i<args.size(); i++) | |
311 | o << (i>0 ? ", " : "") << *args[i]; | |
312 | o << ")"; | |
313 | } | |
314 | ||
315 | ||
316 | ostream& operator << (ostream& o, statement& k) | |
317 | { | |
318 | k.print (o); | |
319 | return o; | |
320 | } | |
321 | ||
322 | ||
54dfabe9 FCE |
323 | void embeddedcode::print (ostream &o) |
324 | { | |
325 | o << "%{"; | |
326 | o << code; | |
327 | o << "%}"; | |
328 | } | |
329 | ||
56099f08 FCE |
330 | void block::print (ostream& o) |
331 | { | |
332 | o << "{" << endl; | |
333 | for (unsigned i=0; i<statements.size(); i++) | |
69c68955 | 334 | o << *statements [i] << endl; |
bb2e3076 | 335 | o << "}"; |
56099f08 FCE |
336 | } |
337 | ||
338 | ||
339 | void for_loop::print (ostream& o) | |
340 | { | |
f3c26ea5 FCE |
341 | o << "for ("; |
342 | init->print (o); | |
343 | o << "; "; | |
344 | cond->print (o); | |
345 | o << "; "; | |
346 | incr->print (o); | |
bb2e3076 | 347 | o << ") "; |
f3c26ea5 | 348 | block->print (o); |
56099f08 FCE |
349 | } |
350 | ||
351 | ||
69c68955 FCE |
352 | void foreach_loop::print (ostream& o) |
353 | { | |
354 | o << "foreach (["; | |
355 | for (unsigned i=0; i<indexes.size(); i++) | |
356 | { | |
357 | if (i > 0) o << ", "; | |
358 | indexes[i]->print (o); | |
359 | } | |
bb2e3076 | 360 | o << "] in " << base << ") "; |
69c68955 FCE |
361 | block->print (o); |
362 | } | |
363 | ||
364 | ||
56099f08 FCE |
365 | void null_statement::print (ostream& o) |
366 | { | |
367 | o << ";"; | |
368 | } | |
369 | ||
370 | ||
371 | void expr_statement::print (ostream& o) | |
372 | { | |
373 | o << *value; | |
374 | } | |
375 | ||
376 | ||
377 | void return_statement::print (ostream& o) | |
378 | { | |
379 | o << "return " << *value; | |
380 | } | |
381 | ||
382 | ||
383 | void delete_statement::print (ostream& o) | |
384 | { | |
385 | o << "delete " << *value; | |
386 | } | |
387 | ||
f3c26ea5 FCE |
388 | void next_statement::print (ostream& o) |
389 | { | |
390 | o << "next"; | |
391 | } | |
392 | ||
393 | void break_statement::print (ostream& o) | |
394 | { | |
395 | o << "break"; | |
396 | } | |
397 | ||
398 | void continue_statement::print (ostream& o) | |
399 | { | |
400 | o << "continue"; | |
401 | } | |
56099f08 FCE |
402 | |
403 | void if_statement::print (ostream& o) | |
404 | { | |
bb2e3076 | 405 | o << "if (" << *condition << ") " |
56099f08 FCE |
406 | << *thenblock << endl; |
407 | if (elseblock) | |
408 | o << "else " << *elseblock << endl; | |
409 | } | |
410 | ||
411 | ||
412 | void stapfile::print (ostream& o) | |
413 | { | |
414 | o << "# file " << name << endl; | |
415 | ||
54dfabe9 FCE |
416 | for (unsigned i=0; i<embeds.size(); i++) |
417 | embeds[i]->print (o); | |
418 | ||
bed7c0af FCE |
419 | for (unsigned i=0; i<globals.size(); i++) |
420 | { | |
421 | o << "global "; | |
422 | globals[i]->print (o); | |
423 | o << endl; | |
424 | } | |
425 | ||
20c6c071 GH |
426 | for (unsigned i=0; i<aliases.size(); i++) |
427 | { | |
428 | aliases[i]->print (o); | |
429 | o << endl; | |
430 | } | |
431 | ||
bed7c0af | 432 | for (unsigned i=0; i<probes.size(); i++) |
56099f08 FCE |
433 | { |
434 | probes[i]->print (o); | |
435 | o << endl; | |
436 | } | |
437 | ||
438 | for (unsigned j = 0; j < functions.size(); j++) | |
439 | { | |
440 | functions[j]->print (o); | |
441 | o << endl; | |
442 | } | |
443 | } | |
444 | ||
445 | ||
446 | void probe::print (ostream& o) | |
447 | { | |
448 | o << "probe "; | |
40a1cb62 FCE |
449 | printsig (o); |
450 | o << *body; | |
451 | } | |
452 | ||
453 | ||
454 | void probe::printsig (ostream& o) | |
455 | { | |
9c0c0e46 | 456 | for (unsigned i=0; i<locations.size(); i++) |
56099f08 | 457 | { |
9c0c0e46 FCE |
458 | o << (i>0 ? ", " : ""); |
459 | locations[i]->print (o); | |
56099f08 | 460 | } |
56099f08 FCE |
461 | } |
462 | ||
463 | ||
9c0c0e46 | 464 | void probe_point::print (ostream& o) |
56099f08 | 465 | { |
9c0c0e46 FCE |
466 | for (unsigned i=0; i<components.size(); i++) |
467 | { | |
468 | if (i>0) o << "."; | |
469 | probe_point::component* c = components[i]; | |
470 | o << c->functor; | |
471 | if (c->arg) | |
472 | o << "(" << *c->arg << ")"; | |
473 | } | |
56099f08 FCE |
474 | } |
475 | ||
20c6c071 GH |
476 | probe_alias::probe_alias(std::vector<probe_point*> const & aliases): |
477 | probe (), alias_names (aliases) | |
478 | { | |
479 | } | |
480 | ||
481 | void probe_alias::printsig (ostream& o) | |
482 | { | |
483 | for (unsigned i=0; i<alias_names.size(); i++) | |
484 | { | |
485 | o << (i>0 ? " = " : ""); | |
486 | alias_names[i]->print (o); | |
487 | } | |
5227f1ea | 488 | o << " = "; |
20c6c071 GH |
489 | for (unsigned i=0; i<locations.size(); i++) |
490 | { | |
491 | o << (i>0 ? ", " : ""); | |
492 | locations[i]->print (o); | |
493 | } | |
494 | } | |
495 | ||
56099f08 | 496 | |
82919855 FCE |
497 | ostream& operator << (ostream& o, probe_point& k) |
498 | { | |
499 | k.print (o); | |
500 | return o; | |
501 | } | |
502 | ||
503 | ||
56099f08 FCE |
504 | ostream& operator << (ostream& o, symboldecl& k) |
505 | { | |
506 | k.print (o); | |
507 | return o; | |
508 | } | |
509 | ||
510 | ||
82919855 FCE |
511 | |
512 | // ------------------------------------------------------------------------ | |
513 | // visitors | |
514 | ||
515 | ||
516 | void | |
517 | block::visit (visitor* u) | |
518 | { | |
519 | u->visit_block (this); | |
520 | } | |
521 | ||
54dfabe9 FCE |
522 | |
523 | void | |
524 | embeddedcode::visit (visitor* u) | |
525 | { | |
526 | u->visit_embeddedcode (this); | |
527 | } | |
528 | ||
529 | ||
82919855 FCE |
530 | void |
531 | for_loop::visit (visitor* u) | |
532 | { | |
533 | u->visit_for_loop (this); | |
534 | } | |
535 | ||
69c68955 FCE |
536 | void |
537 | foreach_loop::visit (visitor* u) | |
538 | { | |
539 | u->visit_foreach_loop (this); | |
540 | } | |
541 | ||
82919855 FCE |
542 | void |
543 | null_statement::visit (visitor* u) | |
544 | { | |
545 | u->visit_null_statement (this); | |
546 | } | |
547 | ||
548 | void | |
549 | expr_statement::visit (visitor* u) | |
550 | { | |
551 | u->visit_expr_statement (this); | |
552 | } | |
553 | ||
554 | void | |
555 | return_statement::visit (visitor* u) | |
556 | { | |
557 | u->visit_return_statement (this); | |
558 | } | |
559 | ||
560 | void | |
561 | delete_statement::visit (visitor* u) | |
562 | { | |
d7f3e0c5 | 563 | u->push_active_lvalue (this->value); |
82919855 | 564 | u->visit_delete_statement (this); |
d7f3e0c5 | 565 | u->pop_active_lvalue (); |
82919855 FCE |
566 | } |
567 | ||
568 | void | |
569 | if_statement::visit (visitor* u) | |
570 | { | |
571 | u->visit_if_statement (this); | |
572 | } | |
573 | ||
f3c26ea5 FCE |
574 | void |
575 | next_statement::visit (visitor* u) | |
576 | { | |
577 | u->visit_next_statement (this); | |
578 | } | |
579 | ||
580 | void | |
581 | break_statement::visit (visitor* u) | |
582 | { | |
583 | u->visit_break_statement (this); | |
584 | } | |
585 | ||
586 | void | |
587 | continue_statement::visit (visitor* u) | |
588 | { | |
589 | u->visit_continue_statement (this); | |
590 | } | |
591 | ||
82919855 FCE |
592 | void |
593 | literal_string::visit(visitor* u) | |
594 | { | |
595 | u->visit_literal_string (this); | |
596 | } | |
597 | ||
598 | void | |
599 | literal_number::visit(visitor* u) | |
600 | { | |
601 | u->visit_literal_number (this); | |
602 | } | |
603 | ||
604 | void | |
605 | binary_expression::visit (visitor* u) | |
606 | { | |
607 | u->visit_binary_expression (this); | |
608 | } | |
609 | ||
610 | void | |
611 | unary_expression::visit (visitor* u) | |
612 | { | |
613 | u->visit_unary_expression (this); | |
614 | } | |
615 | ||
616 | void | |
617 | pre_crement::visit (visitor* u) | |
618 | { | |
d7f3e0c5 | 619 | u->push_active_lvalue (this->operand); |
82919855 | 620 | u->visit_pre_crement (this); |
d7f3e0c5 | 621 | u->pop_active_lvalue (); |
82919855 FCE |
622 | } |
623 | ||
624 | void | |
625 | post_crement::visit (visitor* u) | |
626 | { | |
d7f3e0c5 | 627 | u->push_active_lvalue (this->operand); |
82919855 | 628 | u->visit_post_crement (this); |
d7f3e0c5 | 629 | u->pop_active_lvalue (); |
82919855 FCE |
630 | } |
631 | ||
632 | void | |
633 | logical_or_expr::visit (visitor* u) | |
634 | { | |
635 | u->visit_logical_or_expr (this); | |
636 | } | |
637 | ||
638 | void | |
639 | logical_and_expr::visit (visitor* u) | |
640 | { | |
641 | u->visit_logical_and_expr (this); | |
642 | } | |
643 | ||
644 | void | |
645 | array_in::visit (visitor* u) | |
646 | { | |
647 | u->visit_array_in (this); | |
648 | } | |
649 | ||
650 | void | |
651 | comparison::visit (visitor* u) | |
652 | { | |
653 | u->visit_comparison (this); | |
654 | } | |
655 | ||
656 | void | |
657 | concatenation::visit (visitor* u) | |
658 | { | |
659 | u->visit_concatenation (this); | |
660 | } | |
661 | ||
82919855 FCE |
662 | void |
663 | ternary_expression::visit (visitor* u) | |
664 | { | |
665 | u->visit_ternary_expression (this); | |
666 | } | |
667 | ||
668 | void | |
669 | assignment::visit (visitor* u) | |
670 | { | |
d7f3e0c5 | 671 | u->push_active_lvalue (this->left); |
82919855 | 672 | u->visit_assignment (this); |
d7f3e0c5 | 673 | u->pop_active_lvalue (); |
82919855 FCE |
674 | } |
675 | ||
676 | void | |
677 | symbol::visit (visitor* u) | |
678 | { | |
679 | u->visit_symbol (this); | |
680 | } | |
681 | ||
d7f3e0c5 GH |
682 | void |
683 | target_symbol::visit (visitor* u) | |
684 | { | |
685 | u->visit_target_symbol(this); | |
686 | } | |
687 | ||
82919855 FCE |
688 | void |
689 | arrayindex::visit (visitor* u) | |
690 | { | |
691 | u->visit_arrayindex (this); | |
692 | } | |
693 | ||
694 | void | |
695 | functioncall::visit (visitor* u) | |
696 | { | |
697 | u->visit_functioncall (this); | |
698 | } | |
699 | ||
d7f3e0c5 GH |
700 | // ------------------------------------------------------------------------ |
701 | ||
702 | bool | |
703 | visitor::is_active_lvalue(expression *e) | |
704 | { | |
705 | for (unsigned i = 0; i < active_lvalues.size(); ++i) | |
706 | { | |
707 | if (active_lvalues[i] == e) | |
708 | return true; | |
709 | } | |
710 | return false; | |
711 | } | |
712 | ||
713 | void | |
714 | visitor::push_active_lvalue(expression *e) | |
715 | { | |
716 | active_lvalues.push_back(e); | |
717 | } | |
718 | ||
719 | void | |
720 | visitor::pop_active_lvalue() | |
721 | { | |
722 | assert(!active_lvalues.empty()); | |
723 | active_lvalues.pop_back(); | |
724 | } | |
725 | ||
726 | ||
82919855 FCE |
727 | |
728 | // ------------------------------------------------------------------------ | |
729 | ||
730 | void | |
54dfabe9 | 731 | traversing_visitor::visit_block (block* s) |
82919855 FCE |
732 | { |
733 | for (unsigned i=0; i<s->statements.size(); i++) | |
734 | s->statements[i]->visit (this); | |
735 | } | |
736 | ||
737 | void | |
54dfabe9 FCE |
738 | traversing_visitor::visit_embeddedcode (embeddedcode* s) |
739 | { | |
740 | } | |
741 | ||
742 | void | |
743 | traversing_visitor::visit_null_statement (null_statement* s) | |
82919855 FCE |
744 | { |
745 | } | |
746 | ||
747 | void | |
54dfabe9 | 748 | traversing_visitor::visit_expr_statement (expr_statement* s) |
82919855 FCE |
749 | { |
750 | s->value->visit (this); | |
751 | } | |
752 | ||
753 | void | |
754 | traversing_visitor::visit_if_statement (if_statement* s) | |
755 | { | |
756 | s->condition->visit (this); | |
757 | s->thenblock->visit (this); | |
2b066ec1 FCE |
758 | if (s->elseblock) |
759 | s->elseblock->visit (this); | |
82919855 FCE |
760 | } |
761 | ||
762 | void | |
763 | traversing_visitor::visit_for_loop (for_loop* s) | |
764 | { | |
765 | s->init->visit (this); | |
766 | s->cond->visit (this); | |
767 | s->incr->visit (this); | |
768 | s->block->visit (this); | |
769 | } | |
770 | ||
69c68955 FCE |
771 | void |
772 | traversing_visitor::visit_foreach_loop (foreach_loop* s) | |
773 | { | |
774 | for (unsigned i=0; i<s->indexes.size(); i++) | |
775 | s->indexes[i]->visit (this); | |
776 | s->block->visit (this); | |
777 | } | |
778 | ||
82919855 FCE |
779 | void |
780 | traversing_visitor::visit_return_statement (return_statement* s) | |
781 | { | |
782 | s->value->visit (this); | |
783 | } | |
784 | ||
785 | void | |
786 | traversing_visitor::visit_delete_statement (delete_statement* s) | |
787 | { | |
788 | s->value->visit (this); | |
789 | } | |
790 | ||
f3c26ea5 FCE |
791 | void |
792 | traversing_visitor::visit_next_statement (next_statement* s) | |
793 | { | |
794 | } | |
795 | ||
796 | void | |
797 | traversing_visitor::visit_break_statement (break_statement* s) | |
798 | { | |
799 | } | |
800 | ||
801 | void | |
802 | traversing_visitor::visit_continue_statement (continue_statement* s) | |
803 | { | |
804 | } | |
805 | ||
82919855 FCE |
806 | void |
807 | traversing_visitor::visit_literal_string (literal_string* e) | |
808 | { | |
809 | } | |
810 | ||
811 | void | |
812 | traversing_visitor::visit_literal_number (literal_number* e) | |
813 | { | |
814 | } | |
815 | ||
816 | void | |
817 | traversing_visitor::visit_binary_expression (binary_expression* e) | |
818 | { | |
819 | e->left->visit (this); | |
820 | e->right->visit (this); | |
821 | } | |
822 | ||
823 | void | |
824 | traversing_visitor::visit_unary_expression (unary_expression* e) | |
825 | { | |
826 | e->operand->visit (this); | |
827 | } | |
828 | ||
829 | void | |
830 | traversing_visitor::visit_pre_crement (pre_crement* e) | |
831 | { | |
832 | e->operand->visit (this); | |
833 | } | |
834 | ||
835 | void | |
836 | traversing_visitor::visit_post_crement (post_crement* e) | |
837 | { | |
838 | e->operand->visit (this); | |
839 | } | |
840 | ||
841 | ||
842 | void | |
843 | traversing_visitor::visit_logical_or_expr (logical_or_expr* e) | |
844 | { | |
845 | e->left->visit (this); | |
846 | e->right->visit (this); | |
847 | } | |
848 | ||
849 | void | |
850 | traversing_visitor::visit_logical_and_expr (logical_and_expr* e) | |
851 | { | |
852 | e->left->visit (this); | |
853 | e->right->visit (this); | |
854 | } | |
855 | ||
856 | void | |
857 | traversing_visitor::visit_array_in (array_in* e) | |
858 | { | |
ce10591c | 859 | e->operand->visit (this); |
82919855 FCE |
860 | } |
861 | ||
862 | void | |
863 | traversing_visitor::visit_comparison (comparison* e) | |
864 | { | |
865 | e->left->visit (this); | |
866 | e->right->visit (this); | |
867 | } | |
868 | ||
869 | void | |
870 | traversing_visitor::visit_concatenation (concatenation* e) | |
871 | { | |
872 | e->left->visit (this); | |
873 | e->right->visit (this); | |
874 | } | |
875 | ||
82919855 FCE |
876 | void |
877 | traversing_visitor::visit_ternary_expression (ternary_expression* e) | |
878 | { | |
879 | e->cond->visit (this); | |
880 | e->truevalue->visit (this); | |
881 | e->falsevalue->visit (this); | |
882 | } | |
883 | ||
884 | void | |
885 | traversing_visitor::visit_assignment (assignment* e) | |
886 | { | |
887 | e->left->visit (this); | |
888 | e->right->visit (this); | |
889 | } | |
890 | ||
891 | void | |
892 | traversing_visitor::visit_symbol (symbol* e) | |
893 | { | |
894 | } | |
895 | ||
d7f3e0c5 GH |
896 | void |
897 | traversing_visitor::visit_target_symbol (target_symbol* e) | |
898 | { | |
899 | } | |
900 | ||
82919855 FCE |
901 | void |
902 | traversing_visitor::visit_arrayindex (arrayindex* e) | |
903 | { | |
904 | for (unsigned i=0; i<e->indexes.size(); i++) | |
905 | e->indexes[i]->visit (this); | |
906 | } | |
907 | ||
908 | void | |
909 | traversing_visitor::visit_functioncall (functioncall* e) | |
910 | { | |
911 | for (unsigned i=0; i<e->args.size(); i++) | |
912 | e->args[i]->visit (this); | |
913 | } | |
914 | ||
915 | ||
916 | // ------------------------------------------------------------------------ | |
917 | ||
918 | ||
919 | throwing_visitor::throwing_visitor (const std::string& m): msg (m) {} | |
920 | throwing_visitor::throwing_visitor (): msg ("invalid element") {} | |
921 | ||
922 | ||
923 | void | |
924 | throwing_visitor::throwone (const token* t) | |
925 | { | |
926 | throw semantic_error (msg, t); | |
927 | } | |
928 | ||
929 | void | |
54dfabe9 FCE |
930 | throwing_visitor::visit_block (block* s) |
931 | { | |
932 | throwone (s->tok); | |
933 | } | |
934 | ||
935 | void | |
936 | throwing_visitor::visit_embeddedcode (embeddedcode* s) | |
82919855 FCE |
937 | { |
938 | throwone (s->tok); | |
939 | } | |
940 | ||
941 | void | |
54dfabe9 | 942 | throwing_visitor::visit_null_statement (null_statement* s) |
82919855 FCE |
943 | { |
944 | throwone (s->tok); | |
945 | } | |
946 | ||
947 | void | |
54dfabe9 | 948 | throwing_visitor::visit_expr_statement (expr_statement* s) |
82919855 FCE |
949 | { |
950 | throwone (s->tok); | |
951 | } | |
952 | ||
953 | void | |
954 | throwing_visitor::visit_if_statement (if_statement* s) | |
955 | { | |
956 | throwone (s->tok); | |
957 | } | |
958 | ||
959 | void | |
960 | throwing_visitor::visit_for_loop (for_loop* s) | |
961 | { | |
962 | throwone (s->tok); | |
963 | } | |
964 | ||
69c68955 FCE |
965 | void |
966 | throwing_visitor::visit_foreach_loop (foreach_loop* s) | |
967 | { | |
968 | throwone (s->tok); | |
969 | } | |
970 | ||
82919855 FCE |
971 | void |
972 | throwing_visitor::visit_return_statement (return_statement* s) | |
973 | { | |
974 | throwone (s->tok); | |
975 | } | |
976 | ||
977 | void | |
978 | throwing_visitor::visit_delete_statement (delete_statement* s) | |
979 | { | |
980 | throwone (s->tok); | |
981 | } | |
982 | ||
f3c26ea5 FCE |
983 | void |
984 | throwing_visitor::visit_next_statement (next_statement* s) | |
985 | { | |
986 | throwone (s->tok); | |
987 | } | |
988 | ||
989 | void | |
990 | throwing_visitor::visit_break_statement (break_statement* s) | |
991 | { | |
992 | throwone (s->tok); | |
993 | } | |
994 | ||
995 | void | |
996 | throwing_visitor::visit_continue_statement (continue_statement* s) | |
997 | { | |
998 | throwone (s->tok); | |
999 | } | |
1000 | ||
82919855 FCE |
1001 | void |
1002 | throwing_visitor::visit_literal_string (literal_string* e) | |
1003 | { | |
1004 | throwone (e->tok); | |
1005 | } | |
1006 | ||
1007 | void | |
1008 | throwing_visitor::visit_literal_number (literal_number* e) | |
1009 | { | |
1010 | throwone (e->tok); | |
1011 | } | |
1012 | ||
1013 | void | |
1014 | throwing_visitor::visit_binary_expression (binary_expression* e) | |
1015 | { | |
1016 | throwone (e->tok); | |
1017 | } | |
1018 | ||
1019 | void | |
1020 | throwing_visitor::visit_unary_expression (unary_expression* e) | |
1021 | { | |
1022 | throwone (e->tok); | |
1023 | } | |
1024 | ||
1025 | void | |
1026 | throwing_visitor::visit_pre_crement (pre_crement* e) | |
1027 | { | |
1028 | throwone (e->tok); | |
1029 | } | |
1030 | ||
1031 | void | |
1032 | throwing_visitor::visit_post_crement (post_crement* e) | |
1033 | { | |
1034 | throwone (e->tok); | |
0054a7ea FCE |
1035 | } |
1036 | ||
1037 | ||
82919855 FCE |
1038 | void |
1039 | throwing_visitor::visit_logical_or_expr (logical_or_expr* e) | |
1040 | { | |
1041 | throwone (e->tok); | |
1042 | } | |
1043 | ||
1044 | void | |
1045 | throwing_visitor::visit_logical_and_expr (logical_and_expr* e) | |
1046 | { | |
1047 | throwone (e->tok); | |
1048 | } | |
1049 | ||
1050 | void | |
1051 | throwing_visitor::visit_array_in (array_in* e) | |
1052 | { | |
1053 | throwone (e->tok); | |
1054 | } | |
1055 | ||
1056 | void | |
1057 | throwing_visitor::visit_comparison (comparison* e) | |
1058 | { | |
1059 | throwone (e->tok); | |
1060 | } | |
1061 | ||
1062 | void | |
1063 | throwing_visitor::visit_concatenation (concatenation* e) | |
1064 | { | |
1065 | throwone (e->tok); | |
1066 | } | |
1067 | ||
82919855 FCE |
1068 | void |
1069 | throwing_visitor::visit_ternary_expression (ternary_expression* e) | |
1070 | { | |
1071 | throwone (e->tok); | |
1072 | } | |
1073 | ||
1074 | void | |
1075 | throwing_visitor::visit_assignment (assignment* e) | |
1076 | { | |
1077 | throwone (e->tok); | |
1078 | } | |
1079 | ||
1080 | void | |
1081 | throwing_visitor::visit_symbol (symbol* e) | |
1082 | { | |
1083 | throwone (e->tok); | |
1084 | } | |
1085 | ||
d7f3e0c5 GH |
1086 | void |
1087 | throwing_visitor::visit_target_symbol (target_symbol* e) | |
1088 | { | |
1089 | throwone (e->tok); | |
1090 | } | |
1091 | ||
82919855 FCE |
1092 | void |
1093 | throwing_visitor::visit_arrayindex (arrayindex* e) | |
1094 | { | |
1095 | throwone (e->tok); | |
1096 | } | |
1097 | ||
1098 | void | |
1099 | throwing_visitor::visit_functioncall (functioncall* e) | |
1100 | { | |
1101 | throwone (e->tok); | |
1102 | } | |
85365d1b GH |
1103 | |
1104 | ||
1105 | // ------------------------------------------------------------------------ | |
1106 | ||
85365d1b GH |
1107 | |
1108 | void | |
54dfabe9 | 1109 | deep_copy_visitor::visit_block (block* s) |
85365d1b | 1110 | { |
54dfabe9 | 1111 | block* n = new block; |
67c0a579 | 1112 | n->tok = s->tok; |
85365d1b GH |
1113 | for (unsigned i = 0; i < s->statements.size(); ++i) |
1114 | { | |
54dfabe9 | 1115 | statement* ns; |
85365d1b GH |
1116 | require <statement*> (this, &ns, s->statements[i]); |
1117 | n->statements.push_back(ns); | |
1118 | } | |
1119 | provide <block*> (this, n); | |
1120 | } | |
1121 | ||
1122 | void | |
54dfabe9 FCE |
1123 | deep_copy_visitor::visit_embeddedcode (embeddedcode* s) |
1124 | { | |
1125 | embeddedcode* n = new embeddedcode; | |
1126 | n->tok = s->tok; | |
1127 | n->code = s->code; | |
1128 | provide <embeddedcode*> (this, n); | |
1129 | } | |
1130 | ||
1131 | void | |
1132 | deep_copy_visitor::visit_null_statement (null_statement* s) | |
85365d1b | 1133 | { |
54dfabe9 | 1134 | null_statement* n = new null_statement; |
67c0a579 GH |
1135 | n->tok = s->tok; |
1136 | provide <null_statement*> (this, n); | |
85365d1b GH |
1137 | } |
1138 | ||
1139 | void | |
54dfabe9 | 1140 | deep_copy_visitor::visit_expr_statement (expr_statement* s) |
85365d1b | 1141 | { |
54dfabe9 | 1142 | expr_statement* n = new expr_statement; |
67c0a579 | 1143 | n->tok = s->tok; |
85365d1b GH |
1144 | require <expression*> (this, &(n->value), s->value); |
1145 | provide <expr_statement*> (this, n); | |
1146 | } | |
1147 | ||
1148 | void | |
1149 | deep_copy_visitor::visit_if_statement (if_statement* s) | |
1150 | { | |
54dfabe9 | 1151 | if_statement* n = new if_statement; |
67c0a579 | 1152 | n->tok = s->tok; |
85365d1b GH |
1153 | require <expression*> (this, &(n->condition), s->condition); |
1154 | require <statement*> (this, &(n->thenblock), s->thenblock); | |
c37f6b36 | 1155 | require <statement*> (this, &(n->elseblock), s->elseblock); |
85365d1b GH |
1156 | provide <if_statement*> (this, n); |
1157 | } | |
1158 | ||
1159 | void | |
1160 | deep_copy_visitor::visit_for_loop (for_loop* s) | |
1161 | { | |
54dfabe9 | 1162 | for_loop* n = new for_loop; |
67c0a579 | 1163 | n->tok = s->tok; |
85365d1b GH |
1164 | require <expr_statement*> (this, &(n->init), s->init); |
1165 | require <expression*> (this, &(n->cond), s->cond); | |
1166 | require <expr_statement*> (this, &(n->incr), s->incr); | |
1167 | require <statement*> (this, &(n->block), s->block); | |
1168 | provide <for_loop*> (this, n); | |
1169 | } | |
1170 | ||
1171 | void | |
1172 | deep_copy_visitor::visit_foreach_loop (foreach_loop* s) | |
1173 | { | |
54dfabe9 | 1174 | foreach_loop* n = new foreach_loop; |
67c0a579 | 1175 | n->tok = s->tok; |
85365d1b GH |
1176 | for (unsigned i = 0; i < s->indexes.size(); ++i) |
1177 | { | |
54dfabe9 | 1178 | symbol* sym; |
85365d1b GH |
1179 | require <symbol*> (this, &sym, s->indexes[i]); |
1180 | n->indexes.push_back(sym); | |
1181 | } | |
1182 | n->base = s->base; | |
1183 | n->base_referent = NULL; | |
1184 | require <statement*> (this, &(n->block), s->block); | |
1185 | provide <foreach_loop*> (this, n); | |
1186 | } | |
1187 | ||
1188 | void | |
1189 | deep_copy_visitor::visit_return_statement (return_statement* s) | |
1190 | { | |
54dfabe9 | 1191 | return_statement* n = new return_statement; |
67c0a579 | 1192 | n->tok = s->tok; |
85365d1b GH |
1193 | require <expression*> (this, &(n->value), s->value); |
1194 | provide <return_statement*> (this, n); | |
1195 | } | |
1196 | ||
1197 | void | |
1198 | deep_copy_visitor::visit_delete_statement (delete_statement* s) | |
1199 | { | |
54dfabe9 | 1200 | delete_statement* n = new delete_statement; |
67c0a579 | 1201 | n->tok = s->tok; |
85365d1b GH |
1202 | require <expression*> (this, &(n->value), s->value); |
1203 | provide <delete_statement*> (this, n); | |
1204 | } | |
1205 | ||
1206 | void | |
1207 | deep_copy_visitor::visit_next_statement (next_statement* s) | |
1208 | { | |
54dfabe9 | 1209 | next_statement* n = new next_statement; |
67c0a579 GH |
1210 | n->tok = s->tok; |
1211 | provide <next_statement*> (this, n); | |
85365d1b GH |
1212 | } |
1213 | ||
1214 | void | |
1215 | deep_copy_visitor::visit_break_statement (break_statement* s) | |
1216 | { | |
54dfabe9 | 1217 | break_statement* n = new break_statement; |
67c0a579 GH |
1218 | n->tok = s->tok; |
1219 | provide <break_statement*> (this, n); | |
85365d1b GH |
1220 | } |
1221 | ||
1222 | void | |
1223 | deep_copy_visitor::visit_continue_statement (continue_statement* s) | |
1224 | { | |
54dfabe9 | 1225 | continue_statement* n = new continue_statement; |
67c0a579 GH |
1226 | n->tok = s->tok; |
1227 | provide <continue_statement*> (this, n); | |
85365d1b GH |
1228 | } |
1229 | ||
1230 | void | |
1231 | deep_copy_visitor::visit_literal_string (literal_string* e) | |
1232 | { | |
54dfabe9 | 1233 | literal_string* n = new literal_string(e->value); |
67c0a579 GH |
1234 | n->tok = e->tok; |
1235 | provide <literal_string*> (this, n); | |
85365d1b GH |
1236 | } |
1237 | ||
1238 | void | |
1239 | deep_copy_visitor::visit_literal_number (literal_number* e) | |
1240 | { | |
54dfabe9 | 1241 | literal_number* n = new literal_number(e->value); |
67c0a579 GH |
1242 | n->tok = e->tok; |
1243 | provide <literal_number*> (this, n); | |
85365d1b GH |
1244 | } |
1245 | ||
1246 | void | |
1247 | deep_copy_visitor::visit_binary_expression (binary_expression* e) | |
1248 | { | |
54dfabe9 | 1249 | binary_expression* n = new binary_expression; |
85365d1b | 1250 | n->op = e->op; |
67c0a579 | 1251 | n->tok = e->tok; |
85365d1b GH |
1252 | require <expression*> (this, &(n->left), e->left); |
1253 | require <expression*> (this, &(n->right), e->right); | |
1254 | provide <binary_expression*> (this, n); | |
1255 | } | |
1256 | ||
1257 | void | |
1258 | deep_copy_visitor::visit_unary_expression (unary_expression* e) | |
1259 | { | |
54dfabe9 | 1260 | unary_expression* n = new unary_expression; |
85365d1b | 1261 | n->op = e->op; |
67c0a579 | 1262 | n->tok = e->tok; |
85365d1b GH |
1263 | require <expression*> (this, &(n->operand), e->operand); |
1264 | provide <unary_expression*> (this, n); | |
1265 | } | |
1266 | ||
1267 | void | |
1268 | deep_copy_visitor::visit_pre_crement (pre_crement* e) | |
1269 | { | |
54dfabe9 | 1270 | pre_crement* n = new pre_crement; |
85365d1b | 1271 | n->op = e->op; |
67c0a579 | 1272 | n->tok = e->tok; |
85365d1b GH |
1273 | require <expression*> (this, &(n->operand), e->operand); |
1274 | provide <pre_crement*> (this, n); | |
1275 | } | |
1276 | ||
1277 | void | |
1278 | deep_copy_visitor::visit_post_crement (post_crement* e) | |
1279 | { | |
54dfabe9 | 1280 | post_crement* n = new post_crement; |
85365d1b | 1281 | n->op = e->op; |
67c0a579 | 1282 | n->tok = e->tok; |
85365d1b GH |
1283 | require <expression*> (this, &(n->operand), e->operand); |
1284 | provide <post_crement*> (this, n); | |
1285 | } | |
1286 | ||
1287 | ||
1288 | void | |
1289 | deep_copy_visitor::visit_logical_or_expr (logical_or_expr* e) | |
1290 | { | |
54dfabe9 | 1291 | logical_or_expr* n = new logical_or_expr; |
85365d1b | 1292 | n->op = e->op; |
67c0a579 | 1293 | n->tok = e->tok; |
85365d1b GH |
1294 | require <expression*> (this, &(n->left), e->left); |
1295 | require <expression*> (this, &(n->right), e->right); | |
1296 | provide <logical_or_expr*> (this, n); | |
1297 | } | |
1298 | ||
1299 | void | |
1300 | deep_copy_visitor::visit_logical_and_expr (logical_and_expr* e) | |
1301 | { | |
54dfabe9 | 1302 | logical_and_expr* n = new logical_and_expr; |
85365d1b | 1303 | n->op = e->op; |
67c0a579 | 1304 | n->tok = e->tok; |
85365d1b GH |
1305 | require <expression*> (this, &(n->left), e->left); |
1306 | require <expression*> (this, &(n->right), e->right); | |
1307 | provide <logical_and_expr*> (this, n); | |
1308 | } | |
1309 | ||
1310 | void | |
1311 | deep_copy_visitor::visit_array_in (array_in* e) | |
1312 | { | |
54dfabe9 | 1313 | array_in* n = new array_in; |
67c0a579 | 1314 | n->tok = e->tok; |
85365d1b GH |
1315 | require <arrayindex*> (this, &(n->operand), e->operand); |
1316 | provide <array_in*> (this, n); | |
1317 | } | |
1318 | ||
1319 | void | |
1320 | deep_copy_visitor::visit_comparison (comparison* e) | |
1321 | { | |
54dfabe9 | 1322 | comparison* n = new comparison; |
85365d1b | 1323 | n->op = e->op; |
67c0a579 | 1324 | n->tok = e->tok; |
85365d1b GH |
1325 | require <expression*> (this, &(n->left), e->left); |
1326 | require <expression*> (this, &(n->right), e->right); | |
1327 | provide <comparison*> (this, n); | |
1328 | } | |
1329 | ||
1330 | void | |
1331 | deep_copy_visitor::visit_concatenation (concatenation* e) | |
1332 | { | |
54dfabe9 | 1333 | concatenation* n = new concatenation; |
85365d1b | 1334 | n->op = e->op; |
67c0a579 | 1335 | n->tok = e->tok; |
85365d1b GH |
1336 | require <expression*> (this, &(n->left), e->left); |
1337 | require <expression*> (this, &(n->right), e->right); | |
1338 | provide <concatenation*> (this, n); | |
1339 | } | |
1340 | ||
1341 | void | |
1342 | deep_copy_visitor::visit_ternary_expression (ternary_expression* e) | |
1343 | { | |
54dfabe9 | 1344 | ternary_expression* n = new ternary_expression; |
67c0a579 | 1345 | n->tok = e->tok; |
85365d1b GH |
1346 | require <expression*> (this, &(n->cond), e->cond); |
1347 | require <expression*> (this, &(n->truevalue), e->truevalue); | |
1348 | require <expression*> (this, &(n->falsevalue), e->falsevalue); | |
1349 | provide <ternary_expression*> (this, n); | |
1350 | } | |
1351 | ||
1352 | void | |
1353 | deep_copy_visitor::visit_assignment (assignment* e) | |
1354 | { | |
54dfabe9 | 1355 | assignment* n = new assignment; |
85365d1b | 1356 | n->op = e->op; |
67c0a579 | 1357 | n->tok = e->tok; |
85365d1b GH |
1358 | require <expression*> (this, &(n->left), e->left); |
1359 | require <expression*> (this, &(n->right), e->right); | |
1360 | provide <assignment*> (this, n); | |
1361 | } | |
1362 | ||
1363 | void | |
1364 | deep_copy_visitor::visit_symbol (symbol* e) | |
1365 | { | |
54dfabe9 | 1366 | symbol* n = new symbol; |
67c0a579 | 1367 | n->tok = e->tok; |
85365d1b GH |
1368 | n->name = e->name; |
1369 | n->referent = NULL; | |
1370 | provide <symbol*> (this, n); | |
d7f3e0c5 GH |
1371 | } |
1372 | ||
1373 | void | |
1374 | deep_copy_visitor::visit_target_symbol (target_symbol* e) | |
1375 | { | |
1376 | target_symbol* n = new target_symbol; | |
1377 | n->tok = e->tok; | |
1378 | n->base_name = e->base_name; | |
1379 | n->components = e->components; | |
1380 | provide <target_symbol*> (this, n); | |
85365d1b GH |
1381 | } |
1382 | ||
1383 | void | |
1384 | deep_copy_visitor::visit_arrayindex (arrayindex* e) | |
1385 | { | |
54dfabe9 | 1386 | arrayindex* n = new arrayindex; |
67c0a579 | 1387 | n->tok = e->tok; |
85365d1b GH |
1388 | n->base = e->base; |
1389 | n->referent = NULL; | |
1390 | for (unsigned i = 0; i < e->indexes.size(); ++i) | |
1391 | { | |
54dfabe9 | 1392 | expression* ne; |
85365d1b GH |
1393 | require <expression*> (this, &ne, e->indexes[i]); |
1394 | n->indexes.push_back(ne); | |
1395 | } | |
1396 | provide <arrayindex*> (this, n); | |
1397 | } | |
1398 | ||
1399 | void | |
1400 | deep_copy_visitor::visit_functioncall (functioncall* e) | |
1401 | { | |
54dfabe9 | 1402 | functioncall* n = new functioncall; |
67c0a579 | 1403 | n->tok = e->tok; |
85365d1b GH |
1404 | n->function = e->function; |
1405 | n->referent = NULL; | |
1406 | for (unsigned i = 0; i < e->args.size(); ++i) | |
1407 | { | |
54dfabe9 | 1408 | expression* na; |
85365d1b GH |
1409 | require <expression*> (this, &na, e->args[i]); |
1410 | n->args.push_back(na); | |
1411 | } | |
1412 | provide <functioncall*> (this, n); | |
1413 | } | |
1414 | ||
54dfabe9 FCE |
1415 | block* |
1416 | deep_copy_visitor::deep_copy (block* b) | |
85365d1b | 1417 | { |
54dfabe9 | 1418 | block* n; |
85365d1b GH |
1419 | deep_copy_visitor v; |
1420 | require <block*> (&v, &n, b); | |
1421 | return n; | |
1422 | } | |
1423 | ||
54dfabe9 FCE |
1424 | statement* |
1425 | deep_copy_visitor::deep_copy (statement* s) | |
85365d1b | 1426 | { |
54dfabe9 | 1427 | statement* n; |
85365d1b GH |
1428 | deep_copy_visitor v; |
1429 | require <statement*> (&v, &n, s); | |
1430 | return n; | |
1431 | } |