diff options
author | Josh Stone <jistone@redhat.com> | 2009-02-18 12:53:08 -0800 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-02-18 12:53:08 -0800 |
commit | 23ad66b41ded81502948584816390c634f66c5ee (patch) | |
tree | db900ca0141a16152c3bf27395cd4975cad6a1ab /elaborate.cxx | |
parent | 2aa2ccb83142c3bf98ac8ee1558a0ee72dff3a1f (diff) | |
parent | 482fe2af17347b472232c5d7c4b26e53606e395e (diff) | |
download | systemtap-steved-23ad66b41ded81502948584816390c634f66c5ee.tar.gz systemtap-steved-23ad66b41ded81502948584816390c634f66c5ee.tar.xz systemtap-steved-23ad66b41ded81502948584816390c634f66c5ee.zip |
Enable typecasting with @cast
println(@cast(myptr, "task_struct")->pid)
println(@cast(myptr, "task_struct", "kernel")->pid)
Merge branch 'typecast', bump ChangeLog entries to push date
Diffstat (limited to 'elaborate.cxx')
-rw-r--r-- | elaborate.cxx | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/elaborate.cxx b/elaborate.cxx index ba50defb..02229fbe 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1,5 +1,5 @@ // elaboration functions -// Copyright (C) 2005-2008 Red Hat Inc. +// Copyright (C) 2005-2009 Red Hat Inc. // Copyright (C) 2008 Intel Corporation // // This file is part of systemtap, and is free software. You can @@ -701,6 +701,11 @@ struct symbol_fetcher e->base->visit_indexable (this); } + void visit_cast_op (cast_op* e) + { + sym = e; + } + void throwone (const token* t) { throw semantic_error ("Expecting symbol or array index expression", t); @@ -1087,6 +1092,9 @@ semantic_pass_symbols (systemtap_session& s) try { + for (unsigned j=0; j<s.code_filters.size(); j++) + fd->body = s.code_filters[j]->require (fd->body); + sym.current_function = fd; sym.current_probe = 0; fd->body->visit (& sym); @@ -1119,6 +1127,9 @@ semantic_pass_symbols (systemtap_session& s) try { + for (unsigned k=0; k<s.code_filters.size(); k++) + dp->body = s.code_filters[k]->require (dp->body); + sym.current_function = 0; sym.current_probe = dp; dp->body->visit (& sym); @@ -2505,6 +2516,7 @@ struct void_statement_reducer: public update_visitor void visit_concatenation (concatenation* e); void visit_functioncall (functioncall* e); void visit_print_format (print_format* e); + void visit_cast_op (cast_op* e); // these are a bit hairy to grok due to the intricacies of indexables and // stats, so I'm chickening out and skipping them... @@ -2772,6 +2784,19 @@ void_statement_reducer::visit_print_format (print_format* e) provide (e); } +void +void_statement_reducer::visit_cast_op (cast_op* e) +{ + // When the result of a cast operation isn't needed, it's just as good to + // evaluate the operand directly + + if (session.verbose>2) + clog << "Eliding unused typecast " << *e->tok << endl; + + relaxed_p = false; + e->operand->visit(this); +} + void semantic_pass_opt5 (systemtap_session& s, bool& relaxed_p) { @@ -3399,6 +3424,18 @@ typeresolution_info::visit_target_symbol (target_symbol* e) void +typeresolution_info::visit_cast_op (cast_op* e) +{ + // Like target_symbol, a cast_op shouldn't survive this far + // unless it was not resolved and its value is really needed. + if (e->saved_conversion_error) + throw (* (e->saved_conversion_error)); + else + throw semantic_error("unresolved cast expression", e->tok); +} + + +void typeresolution_info::visit_arrayindex (arrayindex* e) { |