summaryrefslogtreecommitdiffstats
path: root/staptree.cxx
diff options
context:
space:
mode:
authorgraydon <graydon>2005-08-10 03:15:21 +0000
committergraydon <graydon>2005-08-10 03:15:21 +0000
commitd7f3e0c5d0b0af0dcb5f8168e1184f15a0554a4e (patch)
tree905bbe1cff9ae08a6cf9f314fd4d5bc8976215fa /staptree.cxx
parent0110f903329ab531bcbe9d555d5b6f6dc77d8a54 (diff)
downloadsystemtap-steved-d7f3e0c5d0b0af0dcb5f8168e1184f15a0554a4e.tar.gz
systemtap-steved-d7f3e0c5d0b0af0dcb5f8168e1184f15a0554a4e.tar.xz
systemtap-steved-d7f3e0c5d0b0af0dcb5f8168e1184f15a0554a4e.zip
2005-08-09 Graydon Hoare <graydon@redhat.com>
* 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.
Diffstat (limited to 'staptree.cxx')
-rw-r--r--staptree.cxx82
1 files changed, 82 insertions, 0 deletions
diff --git a/staptree.cxx b/staptree.cxx
index 31330017..811605ca 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -232,6 +232,26 @@ void symbol::print (ostream& o)
}
+void target_symbol::print (std::ostream& o)
+{
+ o << base_name;
+ for (unsigned i = 0; i < components.size(); ++i)
+ {
+ switch (components[i].first)
+ {
+ case comp_literal_array_index:
+ o << '[' << components[i].second << ']';
+ break;
+ case comp_struct_pointer_member:
+ o << "->" << components[i].second;
+ break;
+ case comp_struct_member:
+ o << "." << components[i].second;
+ }
+ }
+}
+
+
void vardecl::print (ostream& o)
{
o << name;
@@ -540,7 +560,9 @@ return_statement::visit (visitor* u)
void
delete_statement::visit (visitor* u)
{
+ u->push_active_lvalue (this->value);
u->visit_delete_statement (this);
+ u->pop_active_lvalue ();
}
void
@@ -594,13 +616,17 @@ unary_expression::visit (visitor* u)
void
pre_crement::visit (visitor* u)
{
+ u->push_active_lvalue (this->operand);
u->visit_pre_crement (this);
+ u->pop_active_lvalue ();
}
void
post_crement::visit (visitor* u)
{
+ u->push_active_lvalue (this->operand);
u->visit_post_crement (this);
+ u->pop_active_lvalue ();
}
void
@@ -642,7 +668,9 @@ ternary_expression::visit (visitor* u)
void
assignment::visit (visitor* u)
{
+ u->push_active_lvalue (this->left);
u->visit_assignment (this);
+ u->pop_active_lvalue ();
}
void
@@ -651,6 +679,12 @@ symbol::visit (visitor* u)
u->visit_symbol (this);
}
+void
+target_symbol::visit (visitor* u)
+{
+ u->visit_target_symbol(this);
+}
+
void
arrayindex::visit (visitor* u)
{
@@ -663,6 +697,33 @@ functioncall::visit (visitor* u)
u->visit_functioncall (this);
}
+// ------------------------------------------------------------------------
+
+bool
+visitor::is_active_lvalue(expression *e)
+{
+ for (unsigned i = 0; i < active_lvalues.size(); ++i)
+ {
+ if (active_lvalues[i] == e)
+ return true;
+ }
+ return false;
+}
+
+void
+visitor::push_active_lvalue(expression *e)
+{
+ active_lvalues.push_back(e);
+}
+
+void
+visitor::pop_active_lvalue()
+{
+ assert(!active_lvalues.empty());
+ active_lvalues.pop_back();
+}
+
+
// ------------------------------------------------------------------------
@@ -833,6 +894,11 @@ traversing_visitor::visit_symbol (symbol* e)
}
void
+traversing_visitor::visit_target_symbol (target_symbol* e)
+{
+}
+
+void
traversing_visitor::visit_arrayindex (arrayindex* e)
{
for (unsigned i=0; i<e->indexes.size(); i++)
@@ -1018,6 +1084,12 @@ throwing_visitor::visit_symbol (symbol* e)
}
void
+throwing_visitor::visit_target_symbol (target_symbol* e)
+{
+ throwone (e->tok);
+}
+
+void
throwing_visitor::visit_arrayindex (arrayindex* e)
{
throwone (e->tok);
@@ -1299,6 +1371,16 @@ deep_copy_visitor::visit_symbol (symbol* e)
}
void
+deep_copy_visitor::visit_target_symbol (target_symbol* e)
+{
+ target_symbol* n = new target_symbol;
+ n->tok = e->tok;
+ n->base_name = e->base_name;
+ n->components = e->components;
+ provide <target_symbol*> (this, n);
+}
+
+void
deep_copy_visitor::visit_arrayindex (arrayindex* e)
{
arrayindex* n = new arrayindex;