From d7f3e0c5d0b0af0dcb5f8168e1184f15a0554a4e Mon Sep 17 00:00:00 2001 From: graydon Date: Wed, 10 Aug 2005 03:15:21 +0000 Subject: 2005-08-09 Graydon Hoare * staptree.{cxx,h} (target_symbol): New struct. (*_visitor::visit_target_symbol): Support it. (visitor::active_lvalues) (visitor::is_active_lvalue) (visitor::push_active_lvalue) (visitor::pop_active_lvalue): Support lvalue-detection. (delete_statement::visit) (pre_crement::visit) (post_crement::visit) (assignment::visit): Push and pop lvalue expressions. * elaborate.{cxx,h} (lvalule_aware_traversing_visitor): Remove class. (no_map_mutation_during_iteration_check) (mutated_map_collector): Update lvalue logic. (typeresolution_info::visit_target_symbol): Add, throw error. * parse.{cxx,h} (tt2str) (tok_is) (parser::expect_*) (parser::peek_*): New helpers. (parser::parse_symbol): Rewrite, support target_symbols. * translate.cxx (c_unparser::visit_target_symbol): Implement. * tapsets.cxx (var_expanding_copy_visitor): Update lvalue logic, change visit_symbol to visit_target_symbol. --- elaborate.cxx | 60 +++++++++++------------------------------------------------ 1 file changed, 11 insertions(+), 49 deletions(-) (limited to 'elaborate.cxx') diff --git a/elaborate.cxx b/elaborate.cxx index c9f1fcd1..0cecab7e 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -396,53 +396,9 @@ symresolution_info::derive_probes (match_node * root, // Map usage checks // -class lvalue_aware_traversing_visitor - : public traversing_visitor -{ - unsigned lval_depth; -public: - - lvalue_aware_traversing_visitor() : lval_depth(0) {} - - bool is_in_lvalue() - { - return lval_depth > 0; - } - - virtual void visit_pre_crement (pre_crement* e) - { - ++lval_depth; - e->operand->visit (this); - --lval_depth; - } - - virtual void visit_post_crement (post_crement* e) - { - ++lval_depth; - e->operand->visit (this); - --lval_depth; - } - - virtual void visit_assignment (assignment* e) - { - ++lval_depth; - e->left->visit (this); - --lval_depth; - e->right->visit (this); - } - - virtual void visit_delete_statement (delete_statement* s) - { - ++lval_depth; - s->value->visit (this); - --lval_depth; - } - -}; - struct mutated_map_collector - : public lvalue_aware_traversing_visitor + : public traversing_visitor { set * mutated_maps; @@ -452,14 +408,14 @@ struct mutated_map_collector void visit_arrayindex (arrayindex *e) { - if (is_in_lvalue()) + if (is_active_lvalue(e)) mutated_maps->insert(e->referent); } }; struct no_map_mutation_during_iteration_check - : public lvalue_aware_traversing_visitor + : public traversing_visitor { systemtap_session & session; map *> & function_mutates_maps; @@ -473,7 +429,7 @@ struct no_map_mutation_during_iteration_check void visit_arrayindex (arrayindex *e) { - if (is_in_lvalue()) + if (is_active_lvalue(e)) { for (unsigned i = 0; i < maps_being_iterated.size(); ++i) { @@ -1346,12 +1302,18 @@ typeresolution_info::visit_symbol (symbol* e) if (e->referent->arity > 0) unresolved (e->tok); // symbol resolution should not permit this - // XXX: but consider "delete ;" and similar constructs else resolve_2types (e, e->referent, this, t); } +void +typeresolution_info::visit_target_symbol (target_symbol* e) +{ + throw semantic_error("unresolved target-symbol expression", e->tok); +} + + void typeresolution_info::visit_arrayindex (arrayindex* e) { -- cgit