2 // Copyright (C) 2005-2012 Red Hat Inc.
3 // Copyright (C) 2006 Intel Corporation.
5 // This file is part of systemtap, and is free software. You can
6 // redistribute it and/or modify it under the terms of the GNU General
7 // Public License (GPL); either version 2, or (at your option) any
25 struct token
; // parse.h
26 struct systemtap_session
; // session.h
28 struct semantic_error
: public std::runtime_error
32 const semantic_error
*chain
;
34 ~semantic_error () throw () {}
35 semantic_error (const std::string
& msg
, const token
* t1
=0):
36 runtime_error (msg
), tok1 (t1
), tok2 (0), chain (0) {}
38 semantic_error (const std::string
& msg
, const token
* t1
,
40 runtime_error (msg
), tok1 (t1
), tok2 (t2
), chain (0) {}
43 // ------------------------------------------------------------------------
45 /* struct statistic_decl moved to session.h */
47 // ------------------------------------------------------------------------
53 pe_string
, // std::string
57 std::ostream
& operator << (std::ostream
& o
, const exp_type
& e
);
61 struct update_visitor
;
68 virtual ~expression ();
69 virtual void print (std::ostream
& o
) const = 0;
70 virtual void visit (visitor
* u
) = 0;
73 std::ostream
& operator << (std::ostream
& o
, const expression
& k
);
76 struct literal
: public expression
81 struct literal_string
: public literal
84 literal_string (const std::string
& v
);
85 void print (std::ostream
& o
) const;
86 void visit (visitor
* u
);
90 struct literal_number
: public literal
94 literal_number (int64_t v
, bool hex
=false);
95 void print (std::ostream
& o
) const;
96 void visit (visitor
* u
);
100 struct embedded_expr
: public expression
103 void print (std::ostream
& o
) const;
104 void visit (visitor
* u
);
108 struct binary_expression
: public expression
113 void print (std::ostream
& o
) const;
114 void visit (visitor
* u
);
118 struct unary_expression
: public expression
122 void print (std::ostream
& o
) const;
123 void visit (visitor
* u
);
127 struct pre_crement
: public unary_expression
129 void visit (visitor
* u
);
133 struct post_crement
: public unary_expression
135 void print (std::ostream
& o
) const;
136 void visit (visitor
* u
);
140 struct logical_or_expr
: public binary_expression
142 void visit (visitor
* u
);
146 struct logical_and_expr
: public binary_expression
148 void visit (visitor
* u
);
153 struct array_in
: public expression
156 void print (std::ostream
& o
) const;
157 void visit (visitor
* u
);
161 struct comparison
: public binary_expression
163 void visit (visitor
* u
);
167 struct concatenation
: public binary_expression
169 void visit (visitor
* u
);
173 struct ternary_expression
: public expression
176 expression
* truevalue
;
177 expression
* falsevalue
;
178 void print (std::ostream
& o
) const;
179 void visit (visitor
* u
);
183 struct assignment
: public binary_expression
185 void visit (visitor
* u
);
192 // This is a helper class which, type-wise, acts as a disjoint union
193 // of symbols and histograms. You can ask it whether it's a
194 // histogram or a symbol, and downcast accordingly.
195 void print_indexable (std::ostream
& o
) const;
196 void visit_indexable (visitor
* u
);
197 virtual bool is_symbol(symbol
*& sym_out
);
198 virtual bool is_hist_op(hist_op
*& hist_out
);
199 virtual bool is_const_symbol(const symbol
*& sym_out
) const;
200 virtual bool is_const_hist_op(const hist_op
*& hist_out
) const;
201 virtual const token
*get_tok() const = 0;
202 virtual ~indexable() {}
205 // Perform a downcast to one out-value and NULL the other, throwing an
206 // exception if neither downcast succeeds. This is (sadly) about the
207 // best we can accomplish in C++.
209 classify_indexable(indexable
* ix
,
211 hist_op
*& hist_out
);
214 classify_const_indexable(const indexable
* ix
,
215 symbol
const *& array_out
,
216 hist_op
const *& hist_out
);
226 void print (std::ostream
& o
) const;
227 void visit (visitor
* u
);
228 // overrides of type 'indexable'
229 const token
*get_tok() const;
230 bool is_const_symbol(const symbol
*& sym_out
) const;
231 bool is_symbol(symbol
*& sym_out
);
235 struct target_symbol
: public symbol
240 comp_literal_array_index
,
241 comp_expression_array_index
,
242 comp_pretty_print
, // must be final
249 std::string member
; // comp_struct_member, comp_pretty_print
250 int64_t num_index
; // comp_literal_array_index
251 expression
* expr_index
; // comp_expression_array_index
253 component(const token
* t
, const std::string
& m
, bool pprint
=false):
255 type(pprint
? comp_pretty_print
: comp_struct_member
),
256 member(m
), num_index(0), expr_index(0)
258 component(const token
* t
, int64_t n
):
259 tok(t
), type(comp_literal_array_index
), num_index(n
),
261 component(const token
* t
, expression
* e
):
262 tok(t
), type(comp_expression_array_index
), num_index(0),
264 void print (std::ostream
& o
) const;
268 std::string target_name
;
270 std::vector
<component
> components
;
271 semantic_error
* saved_conversion_error
; // hand-made linked list
272 target_symbol(): addressof(false), saved_conversion_error (0) {}
273 std::string
sym_name ();
274 void chain (const semantic_error
& er
);
275 void print (std::ostream
& o
) const;
276 void visit (visitor
* u
);
277 void visit_components (visitor
* u
);
278 void visit_components (update_visitor
* u
);
279 void assert_no_components(const std::string
& tapset
, bool pretty_ok
=false);
282 std::ostream
& operator << (std::ostream
& o
, const target_symbol::component
& c
);
285 struct cast_op
: public target_symbol
288 std::string type_name
, module
;
289 void print (std::ostream
& o
) const;
290 void visit (visitor
* u
);
294 struct defined_op
: public expression
296 target_symbol
*operand
;
297 void print (std::ostream
& o
) const;
298 void visit (visitor
* u
);
302 struct entry_op
: public expression
305 void print (std::ostream
& o
) const;
306 void visit (visitor
* u
);
310 struct arrayindex
: public expression
312 std::vector
<expression
*> indexes
;
315 void print (std::ostream
& o
) const;
316 void visit (visitor
* u
);
321 struct functioncall
: public expression
323 std::string function
;
324 std::vector
<expression
*> args
;
325 functiondecl
*referent
;
327 void print (std::ostream
& o
) const;
328 void visit (visitor
* u
);
332 struct print_format
: public expression
334 bool print_to_stream
;
335 bool print_with_format
;
336 bool print_with_delim
;
337 bool print_with_newline
;
340 // XXX match runtime/vsprintf.c's print_flag
341 // ... for use with number() & number_size()
344 fmt_flag_zeropad
= 1,
349 fmt_flag_special
= 32,
380 struct format_component
386 width_type widthtype
;
387 precision_type prectype
;
388 conversion_type type
;
389 std::string literal_string
;
390 bool is_empty() const
393 && widthtype
== width_unspecified
394 && prectype
== prec_unspecified
395 && type
== conv_unspecified
396 && literal_string
.empty();
401 widthtype
= width_unspecified
;
402 prectype
= prec_unspecified
;
403 type
= conv_unspecified
;
404 literal_string
.clear();
406 inline void set_flag(format_flag f
) { flags
|= f
; }
407 inline bool test_flag(format_flag f
) const { return flags
& f
; }
410 std::string raw_components
;
411 std::vector
<format_component
> components
;
412 format_component delimiter
;
413 std::vector
<expression
*> args
;
416 static std::string
components_to_string(std::vector
<format_component
> const & components
);
417 static std::vector
<format_component
> string_to_components(std::string
const & str
);
418 static print_format
* create(const token
*t
);
420 void print (std::ostream
& o
) const;
421 void visit (visitor
* u
);
424 print_format(bool stream
, bool format
, bool delim
, bool newline
, bool _char
):
425 print_to_stream(stream
), print_with_format(format
),
426 print_with_delim(delim
), print_with_newline(newline
),
427 print_char(_char
), hist(NULL
)
432 enum stat_component_type
441 struct stat_op
: public expression
443 stat_component_type ctype
;
445 void print (std::ostream
& o
) const;
446 void visit (visitor
* u
);
455 struct hist_op
: public indexable
458 histogram_type htype
;
460 std::vector
<int64_t> params
;
461 void print (std::ostream
& o
) const;
462 void visit (visitor
* u
);
463 // overrides of type 'indexable'
464 const token
*get_tok() const;
465 bool is_const_hist_op(const hist_op
*& hist_out
) const;
466 bool is_hist_op(hist_op
*& hist_out
);
469 // ------------------------------------------------------------------------
472 struct symboldecl
// unique object per (possibly implicit)
473 // symbol declaration
476 const token
* systemtap_v_conditional
; //checking systemtap compatibility
480 virtual ~symboldecl ();
481 virtual void print (std::ostream
&o
) const = 0;
482 virtual void printsig (std::ostream
&o
) const = 0;
486 std::ostream
& operator << (std::ostream
& o
, const symboldecl
& k
);
489 struct vardecl
: public symboldecl
491 void print (std::ostream
& o
) const;
492 void printsig (std::ostream
& o
) const;
494 void set_arity (int arity
, const token
* t
);
495 bool compatible_arity (int a
);
496 const token
* arity_tok
; // site where arity was first resolved
497 int arity
; // -1: unknown; 0: scalar; >0: array
498 int maxsize
; // upperbound on size for arrays
499 std::vector
<exp_type
> index_types
; // for arrays only
500 literal
*init
; // for global scalars only
501 bool skip_init
; // for probe locals only, don't init on entry
506 struct vardecl_builtin
: public vardecl
512 struct functiondecl
: public symboldecl
514 std::vector
<vardecl
*> formal_args
;
515 std::vector
<vardecl
*> locals
;
516 std::vector
<vardecl
*> unused_locals
;
520 void print (std::ostream
& o
) const;
521 void printsig (std::ostream
& o
) const;
522 void join (systemtap_session
& s
); // for synthetic functions only
526 // ------------------------------------------------------------------------
531 virtual void print (std::ostream
& o
) const = 0;
532 virtual void visit (visitor
* u
) = 0;
535 statement (const token
* tok
);
536 virtual ~statement ();
539 std::ostream
& operator << (std::ostream
& o
, const statement
& k
);
542 struct embeddedcode
: public statement
545 void print (std::ostream
& o
) const;
546 void visit (visitor
* u
);
550 struct block
: public statement
552 std::vector
<statement
*> statements
;
553 void print (std::ostream
& o
) const;
554 void visit (visitor
* u
);
556 block (statement
* car
, statement
* cdr
);
561 struct try_block
: public statement
563 statement
* try_block
; // may be 0
564 statement
* catch_block
; // may be 0
565 symbol
* catch_error_var
; // may be 0
566 void print (std::ostream
& o
) const;
567 void visit (visitor
* u
);
571 struct expr_statement
;
572 struct for_loop
: public statement
574 expr_statement
* init
; // may be 0
576 expr_statement
* incr
; // may be 0
578 void print (std::ostream
& o
) const;
579 void visit (visitor
* u
);
583 struct foreach_loop
: public statement
585 // this part is a specialization of arrayindex
586 std::vector
<symbol
*> indexes
;
588 int sort_direction
; // -1: decreasing, 0: none, 1: increasing
589 unsigned sort_column
; // 0: value, 1..N: index
590 symbol
* value
; // optional iteration value
591 expression
* limit
; // optional iteration limit
594 void print (std::ostream
& o
) const;
595 void visit (visitor
* u
);
599 struct null_statement
: public statement
601 void print (std::ostream
& o
) const;
602 void visit (visitor
* u
);
603 null_statement (const token
* tok
);
607 struct expr_statement
: public statement
609 expression
* value
; // executed for side-effects
610 void print (std::ostream
& o
) const;
611 void visit (visitor
* u
);
615 struct if_statement
: public statement
617 expression
* condition
;
618 statement
* thenblock
;
619 statement
* elseblock
; // may be 0
620 void print (std::ostream
& o
) const;
621 void visit (visitor
* u
);
625 struct return_statement
: public expr_statement
627 void print (std::ostream
& o
) const;
628 void visit (visitor
* u
);
632 struct delete_statement
: public expr_statement
634 void print (std::ostream
& o
) const;
635 void visit (visitor
* u
);
639 struct break_statement
: public statement
641 void print (std::ostream
& o
) const;
642 void visit (visitor
* u
);
646 struct continue_statement
: public statement
648 void print (std::ostream
& o
) const;
649 void visit (visitor
* u
);
653 struct next_statement
: public statement
655 void print (std::ostream
& o
) const;
656 void visit (visitor
* u
);
661 struct derived_probe
;
667 std::vector
<probe
*> probes
;
668 std::vector
<probe_alias
*> aliases
;
669 std::vector
<functiondecl
*> functions
;
670 std::vector
<vardecl
*> globals
;
671 std::vector
<embeddedcode
*> embeds
;
672 std::string file_contents
;
674 stapfile (): file_contents (""),
675 privileged (false) {}
676 void print (std::ostream
& o
) const;
682 struct component
// XXX: sort of a restricted functioncall
685 literal
* arg
; // optional
687 const token
* tok
; // points to component's functor
688 component(std::string
const & f
, literal
* a
= NULL
);
690 std::vector
<component
*> components
;
693 expression
* condition
;
694 void print (std::ostream
& o
, bool print_extras
=true) const;
696 probe_point(const probe_point
& pp
);
697 probe_point(std::vector
<component
*> const & comps
);
698 std::string
str(bool print_extras
=true) const;
701 std::ostream
& operator << (std::ostream
& o
, const probe_point
& k
);
706 std::vector
<probe_point
*> locations
;
709 const token
* systemtap_v_conditional
; //checking systemtap compatibility
710 std::vector
<vardecl
*> locals
;
711 std::vector
<vardecl
*> unused_locals
;
712 static unsigned last_probeidx
;
714 probe (const probe
& p
, probe_point
*l
);
715 void print (std::ostream
& o
) const;
716 virtual void printsig (std::ostream
&o
) const;
717 virtual void collect_derivation_chain (std::vector
<probe
*> &probes_list
);
718 virtual void collect_derivation_pp_chain (std::vector
<probe_point
*> &) {}
719 virtual const probe_alias
*get_alias () const { return 0; }
720 virtual probe
* create_alias(probe_point
* l
, probe_point
* a
);
721 virtual const probe
* basest () const { return this; }
722 virtual const probe
* almost_basest () const { return 0; }
728 struct probe_alias
: public probe
730 probe_alias(std::vector
<probe_point
*> const & aliases
);
731 std::vector
<probe_point
*> alias_names
;
732 virtual void printsig (std::ostream
&o
) const;
737 // A derived visitor instance is used to visit the entire
738 // statement/expression tree.
741 // Machinery for differentiating lvalue visits from non-lvalue.
742 std::vector
<expression
*> active_lvalues
;
743 bool is_active_lvalue(expression
*e
);
744 void push_active_lvalue(expression
*e
);
745 void pop_active_lvalue();
747 virtual ~visitor () {}
748 virtual void visit_block (block
*s
) = 0;
749 virtual void visit_try_block (try_block
*s
) = 0;
750 virtual void visit_embeddedcode (embeddedcode
*s
) = 0;
751 virtual void visit_null_statement (null_statement
*s
) = 0;
752 virtual void visit_expr_statement (expr_statement
*s
) = 0;
753 virtual void visit_if_statement (if_statement
* s
) = 0;
754 virtual void visit_for_loop (for_loop
* s
) = 0;
755 virtual void visit_foreach_loop (foreach_loop
* s
) = 0;
756 virtual void visit_return_statement (return_statement
* s
) = 0;
757 virtual void visit_delete_statement (delete_statement
* s
) = 0;
758 virtual void visit_next_statement (next_statement
* s
) = 0;
759 virtual void visit_break_statement (break_statement
* s
) = 0;
760 virtual void visit_continue_statement (continue_statement
* s
) = 0;
761 virtual void visit_literal_string (literal_string
* e
) = 0;
762 virtual void visit_literal_number (literal_number
* e
) = 0;
763 virtual void visit_embedded_expr (embedded_expr
* e
) = 0;
764 virtual void visit_binary_expression (binary_expression
* e
) = 0;
765 virtual void visit_unary_expression (unary_expression
* e
) = 0;
766 virtual void visit_pre_crement (pre_crement
* e
) = 0;
767 virtual void visit_post_crement (post_crement
* e
) = 0;
768 virtual void visit_logical_or_expr (logical_or_expr
* e
) = 0;
769 virtual void visit_logical_and_expr (logical_and_expr
* e
) = 0;
770 virtual void visit_array_in (array_in
* e
) = 0;
771 virtual void visit_comparison (comparison
* e
) = 0;
772 virtual void visit_concatenation (concatenation
* e
) = 0;
773 virtual void visit_ternary_expression (ternary_expression
* e
) = 0;
774 virtual void visit_assignment (assignment
* e
) = 0;
775 virtual void visit_symbol (symbol
* e
) = 0;
776 virtual void visit_target_symbol (target_symbol
* e
) = 0;
777 virtual void visit_arrayindex (arrayindex
* e
) = 0;
778 virtual void visit_functioncall (functioncall
* e
) = 0;
779 virtual void visit_print_format (print_format
* e
) = 0;
780 virtual void visit_stat_op (stat_op
* e
) = 0;
781 virtual void visit_hist_op (hist_op
* e
) = 0;
782 virtual void visit_cast_op (cast_op
* e
) = 0;
783 virtual void visit_defined_op (defined_op
* e
) = 0;
784 virtual void visit_entry_op (entry_op
* e
) = 0;
788 // A simple kind of visitor, which travels down to the leaves of the
789 // statement/expression tree, up to but excluding following vardecls
790 // and functioncalls.
791 struct traversing_visitor
: public visitor
793 void visit_block (block
*s
);
794 void visit_try_block (try_block
*s
);
795 void visit_embeddedcode (embeddedcode
*s
);
796 void visit_null_statement (null_statement
*s
);
797 void visit_expr_statement (expr_statement
*s
);
798 void visit_if_statement (if_statement
* s
);
799 void visit_for_loop (for_loop
* s
);
800 void visit_foreach_loop (foreach_loop
* s
);
801 void visit_return_statement (return_statement
* s
);
802 void visit_delete_statement (delete_statement
* s
);
803 void visit_next_statement (next_statement
* s
);
804 void visit_break_statement (break_statement
* s
);
805 void visit_continue_statement (continue_statement
* s
);
806 void visit_literal_string (literal_string
* e
);
807 void visit_literal_number (literal_number
* e
);
808 void visit_embedded_expr (embedded_expr
* e
);
809 void visit_binary_expression (binary_expression
* e
);
810 void visit_unary_expression (unary_expression
* e
);
811 void visit_pre_crement (pre_crement
* e
);
812 void visit_post_crement (post_crement
* e
);
813 void visit_logical_or_expr (logical_or_expr
* e
);
814 void visit_logical_and_expr (logical_and_expr
* e
);
815 void visit_array_in (array_in
* e
);
816 void visit_comparison (comparison
* e
);
817 void visit_concatenation (concatenation
* e
);
818 void visit_ternary_expression (ternary_expression
* e
);
819 void visit_assignment (assignment
* e
);
820 void visit_symbol (symbol
* e
);
821 void visit_target_symbol (target_symbol
* e
);
822 void visit_arrayindex (arrayindex
* e
);
823 void visit_functioncall (functioncall
* e
);
824 void visit_print_format (print_format
* e
);
825 void visit_stat_op (stat_op
* e
);
826 void visit_hist_op (hist_op
* e
);
827 void visit_cast_op (cast_op
* e
);
828 void visit_defined_op (defined_op
* e
);
829 void visit_entry_op (entry_op
* e
);
833 // A kind of traversing visitor, which also follows function calls.
834 // It uses an internal set object to prevent infinite recursion.
835 struct functioncall_traversing_visitor
: public traversing_visitor
837 std::set
<functiondecl
*> traversed
;
838 functiondecl
* current_function
;
839 functioncall_traversing_visitor(): current_function(0) {}
840 void visit_functioncall (functioncall
* e
);
844 // A kind of traversing visitor, which also follows function calls,
845 // and stores the vardecl* referent of each variable read and/or
846 // written and other such sundry side-effect data. It's used by
847 // the elaboration-time optimizer pass.
848 struct varuse_collecting_visitor
: public functioncall_traversing_visitor
850 systemtap_session
& session
;
851 std::set
<vardecl
*> read
;
852 std::set
<vardecl
*> written
;
853 std::set
<vardecl
*> used
;
855 bool current_lvalue_read
;
856 expression
* current_lvalue
;
857 expression
* current_lrvalue
;
858 varuse_collecting_visitor(systemtap_session
& s
):
860 embedded_seen (false),
861 current_lvalue_read (false),
863 current_lrvalue(0) {}
864 void visit_embeddedcode (embeddedcode
*s
);
865 void visit_embedded_expr (embedded_expr
*e
);
866 void visit_try_block (try_block
*s
);
867 void visit_delete_statement (delete_statement
*s
);
868 void visit_print_format (print_format
*e
);
869 void visit_assignment (assignment
*e
);
870 void visit_arrayindex (arrayindex
*e
);
871 void visit_target_symbol (target_symbol
*e
);
872 void visit_symbol (symbol
*e
);
873 void visit_pre_crement (pre_crement
*e
);
874 void visit_post_crement (post_crement
*e
);
875 void visit_foreach_loop (foreach_loop
*s
);
876 void visit_cast_op (cast_op
* e
);
877 void visit_defined_op (defined_op
* e
);
878 void visit_entry_op (entry_op
* e
);
880 bool side_effect_free ();
881 bool side_effect_free_wrt (const std::set
<vardecl
*>& vars
);
886 // A kind of visitor that throws an semantic_error exception
887 // whenever a non-overridden method is called.
888 struct throwing_visitor
: public visitor
891 throwing_visitor (const std::string
& m
);
894 virtual void throwone (const token
* t
);
896 void visit_block (block
*s
);
897 void visit_try_block (try_block
*s
);
898 void visit_embeddedcode (embeddedcode
*s
);
899 void visit_null_statement (null_statement
*s
);
900 void visit_expr_statement (expr_statement
*s
);
901 void visit_if_statement (if_statement
* s
);
902 void visit_for_loop (for_loop
* s
);
903 void visit_foreach_loop (foreach_loop
* s
);
904 void visit_return_statement (return_statement
* s
);
905 void visit_delete_statement (delete_statement
* s
);
906 void visit_next_statement (next_statement
* s
);
907 void visit_break_statement (break_statement
* s
);
908 void visit_continue_statement (continue_statement
* s
);
909 void visit_literal_string (literal_string
* e
);
910 void visit_literal_number (literal_number
* e
);
911 void visit_embedded_expr (embedded_expr
* e
);
912 void visit_binary_expression (binary_expression
* e
);
913 void visit_unary_expression (unary_expression
* e
);
914 void visit_pre_crement (pre_crement
* e
);
915 void visit_post_crement (post_crement
* e
);
916 void visit_logical_or_expr (logical_or_expr
* e
);
917 void visit_logical_and_expr (logical_and_expr
* e
);
918 void visit_array_in (array_in
* e
);
919 void visit_comparison (comparison
* e
);
920 void visit_concatenation (concatenation
* e
);
921 void visit_ternary_expression (ternary_expression
* e
);
922 void visit_assignment (assignment
* e
);
923 void visit_symbol (symbol
* e
);
924 void visit_target_symbol (target_symbol
* e
);
925 void visit_arrayindex (arrayindex
* e
);
926 void visit_functioncall (functioncall
* e
);
927 void visit_print_format (print_format
* e
);
928 void visit_stat_op (stat_op
* e
);
929 void visit_hist_op (hist_op
* e
);
930 void visit_cast_op (cast_op
* e
);
931 void visit_defined_op (defined_op
* e
);
932 void visit_entry_op (entry_op
* e
);
935 // A visitor similar to a traversing_visitor, but with the ability to rewrite
936 // parts of the tree through require/provide.
938 struct update_visitor
: public visitor
940 template <typename T
> T
* require (T
* src
, bool clearok
=false)
946 assert(!targets
.empty());
947 dst
= static_cast<T
*>(targets
.top()); // XXX: danger will robinson: not typesafe!
949 assert(clearok
|| dst
);
954 template <typename T
> void provide (T
* src
)
956 targets
.push(static_cast<void*>(src
)); // XXX: not typesafe!
959 template <typename T
> void replace (T
*& src
, bool clearok
=false)
961 src
= require(src
, clearok
);
964 virtual ~update_visitor() { assert(targets
.empty()); }
966 virtual void visit_block (block
*s
);
967 virtual void visit_try_block (try_block
*s
);
968 virtual void visit_embeddedcode (embeddedcode
*s
);
969 virtual void visit_null_statement (null_statement
*s
);
970 virtual void visit_expr_statement (expr_statement
*s
);
971 virtual void visit_if_statement (if_statement
* s
);
972 virtual void visit_for_loop (for_loop
* s
);
973 virtual void visit_foreach_loop (foreach_loop
* s
);
974 virtual void visit_return_statement (return_statement
* s
);
975 virtual void visit_delete_statement (delete_statement
* s
);
976 virtual void visit_next_statement (next_statement
* s
);
977 virtual void visit_break_statement (break_statement
* s
);
978 virtual void visit_continue_statement (continue_statement
* s
);
979 virtual void visit_literal_string (literal_string
* e
);
980 virtual void visit_literal_number (literal_number
* e
);
981 virtual void visit_embedded_expr (embedded_expr
* e
);
982 virtual void visit_binary_expression (binary_expression
* e
);
983 virtual void visit_unary_expression (unary_expression
* e
);
984 virtual void visit_pre_crement (pre_crement
* e
);
985 virtual void visit_post_crement (post_crement
* e
);
986 virtual void visit_logical_or_expr (logical_or_expr
* e
);
987 virtual void visit_logical_and_expr (logical_and_expr
* e
);
988 virtual void visit_array_in (array_in
* e
);
989 virtual void visit_comparison (comparison
* e
);
990 virtual void visit_concatenation (concatenation
* e
);
991 virtual void visit_ternary_expression (ternary_expression
* e
);
992 virtual void visit_assignment (assignment
* e
);
993 virtual void visit_symbol (symbol
* e
);
994 virtual void visit_target_symbol (target_symbol
* e
);
995 virtual void visit_arrayindex (arrayindex
* e
);
996 virtual void visit_functioncall (functioncall
* e
);
997 virtual void visit_print_format (print_format
* e
);
998 virtual void visit_stat_op (stat_op
* e
);
999 virtual void visit_hist_op (hist_op
* e
);
1000 virtual void visit_cast_op (cast_op
* e
);
1001 virtual void visit_defined_op (defined_op
* e
);
1002 virtual void visit_entry_op (entry_op
* e
);
1005 std::stack
<void *> targets
;
1008 template <> indexable
*
1009 update_visitor::require
<indexable
> (indexable
* src
, bool clearok
);
1011 // A visitor which performs a deep copy of the root node it's applied
1012 // to. NB: It does not copy any of the variable or function
1013 // declarations; those fields are set to NULL, assuming you want to
1014 // re-infer the declarations in a new context (the one you're copying
1017 struct deep_copy_visitor
: public update_visitor
1019 template <typename T
> static T
* deep_copy (T
* e
)
1021 deep_copy_visitor v
;
1022 return v
.require (e
);
1025 virtual void visit_block (block
*s
);
1026 virtual void visit_try_block (try_block
*s
);
1027 virtual void visit_embeddedcode (embeddedcode
*s
);
1028 virtual void visit_null_statement (null_statement
*s
);
1029 virtual void visit_expr_statement (expr_statement
*s
);
1030 virtual void visit_if_statement (if_statement
* s
);
1031 virtual void visit_for_loop (for_loop
* s
);
1032 virtual void visit_foreach_loop (foreach_loop
* s
);
1033 virtual void visit_return_statement (return_statement
* s
);
1034 virtual void visit_delete_statement (delete_statement
* s
);
1035 virtual void visit_next_statement (next_statement
* s
);
1036 virtual void visit_break_statement (break_statement
* s
);
1037 virtual void visit_continue_statement (continue_statement
* s
);
1038 virtual void visit_literal_string (literal_string
* e
);
1039 virtual void visit_literal_number (literal_number
* e
);
1040 virtual void visit_embedded_expr (embedded_expr
* e
);
1041 virtual void visit_binary_expression (binary_expression
* e
);
1042 virtual void visit_unary_expression (unary_expression
* e
);
1043 virtual void visit_pre_crement (pre_crement
* e
);
1044 virtual void visit_post_crement (post_crement
* e
);
1045 virtual void visit_logical_or_expr (logical_or_expr
* e
);
1046 virtual void visit_logical_and_expr (logical_and_expr
* e
);
1047 virtual void visit_array_in (array_in
* e
);
1048 virtual void visit_comparison (comparison
* e
);
1049 virtual void visit_concatenation (concatenation
* e
);
1050 virtual void visit_ternary_expression (ternary_expression
* e
);
1051 virtual void visit_assignment (assignment
* e
);
1052 virtual void visit_symbol (symbol
* e
);
1053 virtual void visit_target_symbol (target_symbol
* e
);
1054 virtual void visit_arrayindex (arrayindex
* e
);
1055 virtual void visit_functioncall (functioncall
* e
);
1056 virtual void visit_print_format (print_format
* e
);
1057 virtual void visit_stat_op (stat_op
* e
);
1058 virtual void visit_hist_op (hist_op
* e
);
1059 virtual void visit_cast_op (cast_op
* e
);
1060 virtual void visit_defined_op (defined_op
* e
);
1061 virtual void visit_entry_op (entry_op
* e
);
1064 #endif // STAPTREE_H
1066 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */