summaryrefslogtreecommitdiff
path: root/src/expr
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2010-02-24 21:08:15 +0000
committerTim King <taking@cs.nyu.edu>2010-02-24 21:08:15 +0000
commit3bc3eae0d3e36870b30636bd1e3eb52683e0dc17 (patch)
treee83352315485d8f08857276049969fc842fa2e93 /src/expr
parent4c1cb16059e6e484581873dfb3103851183ccc72 (diff)
Committing small changes to attribute, and theory to avoid future merge problems for Moragn. Also cleaned up theory uf and ecdata, and updated both to reflect attribute. Should be close now.
Diffstat (limited to 'src/expr')
-rw-r--r--src/expr/attribute.h17
-rw-r--r--src/expr/node.h17
-rw-r--r--src/expr/node_builder.h13
3 files changed, 34 insertions, 13 deletions
diff --git a/src/expr/attribute.h b/src/expr/attribute.h
index 95433688e..5620d7795 100644
--- a/src/expr/attribute.h
+++ b/src/expr/attribute.h
@@ -86,10 +86,10 @@ struct KindValueToTableValueMapping<bool> {
template <class T>
struct KindValueToTableValueMapping<T*> {
typedef void* table_value_type;
- inline static void* convert(const T*& t) {
- return reinterpret_cast<void*>(t);
+ inline static void* convert(const T* const& t) {
+ return reinterpret_cast<void*>(const_cast<T*>(t));
}
- inline static T* convertBack(void*& t) {
+ inline static T* convertBack(void* const& t) {
return reinterpret_cast<T*>(t);
}
};
@@ -455,6 +455,17 @@ struct getTable<const T*> {
}
};
+template <class T>
+struct getTable<T*> {
+ typedef AttrHash<void*> table_type;
+ static inline table_type& get(AttributeManager& am) {
+ return am.d_ptrs;
+ }
+ static inline const table_type& get(const AttributeManager& am) {
+ return am.d_ptrs;
+ }
+};
+
// ATTRIBUTE MANAGER IMPLEMENTATIONS ===========================================
template <class AttrKind>
diff --git a/src/expr/node.h b/src/expr/node.h
index e1085a32a..03f3e9da3 100644
--- a/src/expr/node.h
+++ b/src/expr/node.h
@@ -325,6 +325,15 @@ template<bool ref_count>
NodeTemplate uMinusNode() const;
NodeTemplate multNode(const NodeTemplate& right) const;
+ /**
+ * Sets the given attribute of this node to the given value.
+ * @param attKind the kind of the atribute
+ * @param value the value to set the attribute to
+ */
+ template<class AttrKind>
+ inline void setAttribute(const AttrKind& attKind,
+ const typename AttrKind::value_type& value);
+
private:
/**
@@ -334,14 +343,6 @@ template<bool ref_count>
*/
void debugPrint();
- /**
- * Sets the given attribute of this node to the given value.
- * @param attKind the kind of the atribute
- * @param value the value to set the attribute to
- */
- template<class AttrKind>
- inline void setAttribute(const AttrKind& attKind,
- const typename AttrKind::value_type& value);
/**
* Indents the given stream a given amount of spaces.
diff --git a/src/expr/node_builder.h b/src/expr/node_builder.h
index 61b048a5b..d79d5ad54 100644
--- a/src/expr/node_builder.h
+++ b/src/expr/node_builder.h
@@ -47,6 +47,7 @@ class MultNodeBuilder;
template <unsigned nchild_thresh>
class NodeBuilder {
+
unsigned d_size;
uint64_t d_hash;
@@ -129,14 +130,17 @@ public:
}
Kind getKind() const {
+ Assert(!d_used, "NodeBuilder is one-shot only; tried to access it after conversion");
return d_nv->getKind();
}
unsigned getNumChildren() const {
+ Assert(!d_used, "NodeBuilder is one-shot only; tried to access it after conversion");
return d_nv->getNumChildren();
}
Node operator[](int i) const {
+ Assert(!d_used, "NodeBuilder is one-shot only; tried to access it after conversion");
Assert(i >= 0 && i < d_nv->getNumChildren());
return Node(d_nv->d_children[i]);
}
@@ -225,6 +229,11 @@ public:
friend class PlusNodeBuilder;
friend class MultNodeBuilder;
*/
+
+ //Yet 1 more example of how terrifying C++ is as a language
+ //This is needed for copy constructors of different sizes to access private fields
+ template <unsigned N> friend class NodeBuilder;
+
};/* class NodeBuilder */
#if 0
@@ -439,9 +448,9 @@ inline NodeBuilder<nchild_thresh>::NodeBuilder(const NodeBuilder<N>& nb) :
if(nb.d_nv->d_nchildren > nchild_thresh) {
realloc(nb.d_size, false);
- std::copy(nb.d_nv->ev_begin(), nb.d_nv->end(), d_nv->nv_begin());
+ std::copy(nb.d_nv->ev_begin(), nb.d_nv->ev_end(), d_nv->nv_begin());
} else {
- std::copy(nb.d_nv->ev_begin(), nb.d_nv->end(), d_inlineNv.nv_begin());
+ std::copy(nb.d_nv->ev_begin(), nb.d_nv->ev_end(), d_inlineNv.nv_begin());
}
d_nv->d_kind = nb.d_nv->d_kind;
d_nv->d_nchildren = nb.d_nv->d_nchildren;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback