diff options
author | Morgan Deters <mdeters@gmail.com> | 2010-07-10 05:46:41 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2010-07-10 05:46:41 +0000 |
commit | ff090033353d68144edf619c19b7911a33e8c5b2 (patch) | |
tree | a557d5e5899c663fcc229ab0f4e0a0926fbfe325 /src/expr/node.h | |
parent | 9f4784e950f295d45cf6b0bdb1def1b83bb11b1a (diff) |
add >, <=, and >= comparisons for Exprs and Nodes
Diffstat (limited to 'src/expr/node.h')
-rw-r--r-- | src/expr/node.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/expr/node.h b/src/expr/node.h index 09a1ad8bc..218b9a3ea 100644 --- a/src/expr/node.h +++ b/src/expr/node.h @@ -245,6 +245,39 @@ public: } /** + * We compare by expression ids so, keeping things deterministic and having + * that subexpressions have to be smaller than the enclosing expressions. + * @param node the node to compare to + * @return true if this expression is greater + */ + template <bool ref_count_1> + inline bool operator>(const NodeTemplate<ref_count_1>& node) const { + return d_nv->d_id > node.d_nv->d_id; + } + + /** + * We compare by expression ids so, keeping things deterministic and having + * that subexpressions have to be smaller than the enclosing expressions. + * @param node the node to compare to + * @return true if this expression is smaller than or equal to + */ + template <bool ref_count_1> + inline bool operator<=(const NodeTemplate<ref_count_1>& node) const { + return d_nv->d_id <= node.d_nv->d_id; + } + + /** + * We compare by expression ids so, keeping things deterministic and having + * that subexpressions have to be smaller than the enclosing expressions. + * @param node the node to compare to + * @return true if this expression is greater than or equal to + */ + template <bool ref_count_1> + inline bool operator>=(const NodeTemplate<ref_count_1>& node) const { + return d_nv->d_id >= node.d_nv->d_id; + } + + /** * Returns the i-th child of this node. * @param i the index of the child * @return the node representing the i-th child |