summaryrefslogtreecommitdiffstats
path: root/staptree.h
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2009-08-04 12:35:41 -0400
committerDave Brolley <brolley@redhat.com>2009-08-04 12:35:41 -0400
commitbc9077d171b8250a93a1b5a481e34913e5585dd5 (patch)
tree1fa945c76a66e297e783354ccd7a860aa65d304b /staptree.h
parent3174c3ca37371d738b86d630dc4d8b15104e57d0 (diff)
parent8b095b454b34e88c04592be6c651153f802eced6 (diff)
downloadsystemtap-steved-bc9077d171b8250a93a1b5a481e34913e5585dd5.tar.gz
systemtap-steved-bc9077d171b8250a93a1b5a481e34913e5585dd5.tar.xz
systemtap-steved-bc9077d171b8250a93a1b5a481e34913e5585dd5.zip
Merge branch 'master' of git://sources.redhat.com/git/systemtap
Conflicts: cache.cxx
Diffstat (limited to 'staptree.h')
-rw-r--r--staptree.h46
1 files changed, 38 insertions, 8 deletions
diff --git a/staptree.h b/staptree.h
index 6b62b0cb..f1d43403 100644
--- a/staptree.h
+++ b/staptree.h
@@ -60,6 +60,7 @@ std::ostream& operator << (std::ostream& o, const exp_type& e);
struct token;
struct visitor;
+struct update_visitor;
struct expression
{
@@ -229,18 +230,42 @@ struct target_symbol: public symbol
enum component_type
{
comp_struct_member,
- comp_literal_array_index
+ comp_literal_array_index,
+ comp_expression_array_index,
};
+
+ struct component
+ {
+ const token* tok;
+ component_type type;
+ std::string member; // comp_struct_member
+ int64_t num_index; // comp_literal_array_index
+ expression* expr_index; // comp_expression_array_index
+
+ component(const token* t, const std::string& m):
+ tok(t), type(comp_struct_member), member(m) {}
+ component(const token* t, int64_t n):
+ tok(t), type(comp_literal_array_index), num_index(n) {}
+ component(const token* t, expression* e):
+ tok(t), type(comp_expression_array_index), expr_index(e) {}
+ void print (std::ostream& o) const;
+ };
+
bool addressof;
std::string base_name;
- std::vector<std::pair<component_type, std::string> > components;
+ std::vector<component> components;
std::string probe_context_var;
semantic_error* saved_conversion_error;
target_symbol(): addressof(false), saved_conversion_error (0) {}
void print (std::ostream& o) const;
void visit (visitor* u);
+ void visit_components (visitor* u);
+ void visit_components (update_visitor* u);
+ void assert_no_components(const std::string& tapset);
};
+std::ostream& operator << (std::ostream& o, const target_symbol::component& c);
+
struct cast_op: public target_symbol
{
@@ -834,25 +859,30 @@ struct throwing_visitor: public visitor
struct update_visitor: public visitor
{
- template <typename T> T require (T src, bool clearok=false)
+ template <typename T> T* require (T* src, bool clearok=false)
{
- T dst = NULL;
+ T* dst = NULL;
if (src != NULL)
{
src->visit(this);
assert(!targets.empty());
- dst = static_cast<T>(targets.top());
+ dst = static_cast<T*>(targets.top());
targets.pop();
assert(clearok || dst);
}
return dst;
}
- template <typename T> void provide (T src)
+ template <typename T> void provide (T* src)
{
targets.push(static_cast<void*>(src));
}
+ template <typename T> void replace (T*& src, bool clearok=false)
+ {
+ src = require(src, clearok);
+ }
+
virtual ~update_visitor() { assert(targets.empty()); }
virtual void visit_block (block *s);
@@ -894,7 +924,7 @@ private:
};
template <> indexable*
-update_visitor::require <indexable*> (indexable* src, bool clearok);
+update_visitor::require <indexable> (indexable* src, bool clearok);
// A visitor which performs a deep copy of the root node it's applied
// to. NB: It does not copy any of the variable or function
@@ -904,7 +934,7 @@ update_visitor::require <indexable*> (indexable* src, bool clearok);
struct deep_copy_visitor: public update_visitor
{
- template <typename T> static T deep_copy (T e)
+ template <typename T> static T* deep_copy (T* e)
{
deep_copy_visitor v;
return v.require (e);