summaryrefslogtreecommitdiffstats
path: root/tapsets.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 /tapsets.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 'tapsets.cxx')
-rw-r--r--tapsets.cxx102
1 files changed, 26 insertions, 76 deletions
diff --git a/tapsets.cxx b/tapsets.cxx
index 887ddd60..2df8fc65 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1204,58 +1204,15 @@ struct
var_expanding_copy_visitor
: public deep_copy_visitor
{
- // Alas, we cannot easily mixin lvalue_aware_traversing_visitor.
- // But behold the *awesome power* of copy and paste.
-
static unsigned tick;
dwarf_query & q;
- unsigned lval_depth;
Dwarf_Addr addr;
var_expanding_copy_visitor(dwarf_query & q, Dwarf_Addr a)
- : q(q), lval_depth(0), addr(a)
+ : q(q), addr(a)
{}
-
- bool is_in_lvalue()
- {
- return lval_depth > 0;
- }
-
- void visit_pre_crement (pre_crement* e)
- {
- ++lval_depth;
- deep_copy_visitor::visit_pre_crement (e);
- --lval_depth;
- }
-
- void visit_post_crement (post_crement* e)
- {
- ++lval_depth;
- deep_copy_visitor::visit_post_crement (e);
- --lval_depth;
- }
-
- void visit_assignment (assignment* e)
- {
- assignment* n = new assignment;
- n->op = e->op;
- n->tok = e->tok;
- ++lval_depth;
- require <expression*> (this, &(n->left), e->left);
- --lval_depth;
- require <expression*> (this, &(n->right), e->right);
- provide <assignment*> (this, n);
- }
-
- void visit_delete_statement (delete_statement* s)
- {
- ++lval_depth;
- deep_copy_visitor::visit_delete_statement (s);
- --lval_depth;
- }
-
- void visit_symbol (symbol* e);
+ void visit_target_symbol (target_symbol* e);
};
@@ -1263,40 +1220,33 @@ unsigned var_expanding_copy_visitor::tick = 0;
void
-var_expanding_copy_visitor::visit_symbol (symbol *e)
+var_expanding_copy_visitor::visit_target_symbol (target_symbol *e)
{
- if (e->name.size() > 0 &&
- e->name[0] == '$')
- {
- if (is_in_lvalue())
- {
- throw semantic_error("read-only special variable "
- + e->name + " used in lvalue", e->tok);
- }
-
- string fname = "get_" + e->name.substr(1) + "_" + lex_cast<string>(tick++);
-
- // synthesize a function
- functiondecl *fdecl = new functiondecl;
- embeddedcode *ec = new embeddedcode;
- ec->code = q.dw.literal_stmt_for_local(addr, e->name.substr(1));
- fdecl->name = fname;
- fdecl->body = ec;
- fdecl->type = pe_long;
- q.sess.functions.push_back(fdecl);
-
- // synthesize a call
- functioncall* n = new functioncall;
- n->tok = e->tok;
- n->function = fname;
- n->referent = NULL;
- provide <functioncall*> (this, n);
-
- }
- else
+ assert(e->base_name.size() > 0 && e->base_name[0] == '$');
+
+ if (is_active_lvalue(e))
{
- deep_copy_visitor::visit_symbol (e);
+ throw semantic_error("read-only special variable "
+ + e->base_name + " used as lvalue", e->tok);
}
+
+ string fname = "get_" + e->base_name.substr(1) + "_" + lex_cast<string>(tick++);
+
+ // synthesize a function
+ functiondecl *fdecl = new functiondecl;
+ embeddedcode *ec = new embeddedcode;
+ ec->code = q.dw.literal_stmt_for_local(addr, e->base_name.substr(1));
+ fdecl->name = fname;
+ fdecl->body = ec;
+ fdecl->type = pe_long;
+ q.sess.functions.push_back(fdecl);
+
+ // synthesize a call
+ functioncall* n = new functioncall;
+ n->tok = e->tok;
+ n->function = fname;
+ n->referent = NULL;
+ provide <functioncall*> (this, n);
}