diff options
author | Josh Stone <jistone@redhat.com> | 2009-02-11 14:34:32 -0800 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-02-18 12:47:25 -0800 |
commit | 9b5af2958a35174a67076c0f27cff0ed5950736d (patch) | |
tree | edd1da26e8e47d033c6ad29fc2e797243b7ba1d0 /staptree.h | |
parent | bbc46bf643491173b9086907cf0820b3fd2c1fe3 (diff) | |
download | systemtap-steved-9b5af2958a35174a67076c0f27cff0ed5950736d.tar.gz systemtap-steved-9b5af2958a35174a67076c0f27cff0ed5950736d.tar.xz systemtap-steved-9b5af2958a35174a67076c0f27cff0ed5950736d.zip |
Add high-level support for @cast()ing
This handles all of the parsing, traversal, and optimization. It
doesn't actually resolve the cast yet though.
* staptree.h (struct cast_op, visitor::visit_cast_op): New.
* staptree.cxx (cast_op::print/visit, various visitor::visit_cast_op's):
Incorporate cast_op into the basic tree operations.
* parse.cxx (parser::parse_symbol): Parse @cast operator with an
expression operand, type string, and optional module string.
* translate.cxx (c_unparser::visit_cast_op): Error out if a @cast
survives to translation.
* elaborate.cxx (typeresolution_info::visit_cast_op): Error out if a
@cast survives to type resolution.
(symbol_fetcher::visit_cast_op): treat @casts as a symbol target
(void_statement_reducer::visit_cast_op): unused @casts can be discarded,
but the operand should still be evaluated.
Diffstat (limited to 'staptree.h')
-rw-r--r-- | staptree.h | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -238,6 +238,15 @@ struct target_symbol: public symbol }; +struct cast_op: public target_symbol +{ + expression *operand; + std::string type, module; + void print (std::ostream& o) const; + void visit (visitor* u); +}; + + struct arrayindex: public expression { std::vector<expression*> indexes; @@ -680,6 +689,7 @@ struct visitor virtual void visit_print_format (print_format* e) = 0; virtual void visit_stat_op (stat_op* e) = 0; virtual void visit_hist_op (hist_op* e) = 0; + virtual void visit_cast_op (cast_op* e) = 0; }; @@ -720,6 +730,7 @@ struct traversing_visitor: public visitor void visit_print_format (print_format* e); void visit_stat_op (stat_op* e); void visit_hist_op (hist_op* e); + void visit_cast_op (cast_op* e); }; @@ -759,6 +770,7 @@ struct varuse_collecting_visitor: public functioncall_traversing_visitor void visit_pre_crement (pre_crement *e); void visit_post_crement (post_crement *e); void visit_foreach_loop (foreach_loop *s); + void visit_cast_op (cast_op* e); bool side_effect_free (); bool side_effect_free_wrt (const std::set<vardecl*>& vars); @@ -808,6 +820,7 @@ struct throwing_visitor: public visitor void visit_print_format (print_format* e); void visit_stat_op (stat_op* e); void visit_hist_op (hist_op* e); + void visit_cast_op (cast_op* e); }; // A visitor similar to a traversing_visitor, but with the ability to rewrite @@ -868,6 +881,7 @@ struct update_visitor: public visitor virtual void visit_print_format (print_format* e); virtual void visit_stat_op (stat_op* e); virtual void visit_hist_op (hist_op* e); + virtual void visit_cast_op (cast_op* e); private: std::stack<void *> targets; @@ -922,6 +936,7 @@ struct deep_copy_visitor: public update_visitor virtual void visit_print_format (print_format* e); virtual void visit_stat_op (stat_op* e); virtual void visit_hist_op (hist_op* e); + virtual void visit_cast_op (cast_op* e); }; #endif // STAPTREE_H |