diff options
author | Tim King <taking@cs.nyu.edu> | 2012-05-18 23:48:38 +0000 |
---|---|---|
committer | Tim King <taking@cs.nyu.edu> | 2012-05-18 23:48:38 +0000 |
commit | ea8139dc7b727bf48bd7b7c6b169d763618a1f2a (patch) | |
tree | 95701608122c2a6e232ee22979e9da757bf4e2dd /src/util/subrange_bound.h | |
parent | 3b93d45dab9513195d5604a069423ed13e173f49 (diff) |
This commit adds TypeNode::leastCommonTypeNode(). The special case for arithmetic in TypeNode::operator==() has been removed. A number of faulty type checking checks were switched to use isSubtypeOf. The resolves bug #339
Diffstat (limited to 'src/util/subrange_bound.h')
-rw-r--r-- | src/util/subrange_bound.h | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/util/subrange_bound.h b/src/util/subrange_bound.h index 9d4d446bd..063e59a0f 100644 --- a/src/util/subrange_bound.h +++ b/src/util/subrange_bound.h @@ -57,7 +57,7 @@ public: } /** Get the finite SubrangeBound, failing an assertion if infinite. */ - Integer getBound() const throw(IllegalArgumentException) { + const Integer& getBound() const throw(IllegalArgumentException) { CheckArgument(!d_nobound, this, "SubrangeBound is infinite"); return d_bound; } @@ -130,6 +130,23 @@ public: ( hasBound() && b.hasBound() && getBound() <= b.getBound() ); } + + static SubrangeBound min(const SubrangeBound& a, const SubrangeBound& b){ + if(a.hasBound() && b.hasBound()){ + return SubrangeBound(Integer::min(a.getBound(), b.getBound())); + }else{ + return SubrangeBound(); + } + } + + static SubrangeBound max(const SubrangeBound& a, const SubrangeBound& b){ + if(a.hasBound() && b.hasBound()){ + return SubrangeBound(Integer::max(a.getBound(), b.getBound())); + }else{ + return SubrangeBound(); + } + } + };/* class SubrangeBound */ class CVC4_PUBLIC SubrangeBounds { @@ -192,6 +209,25 @@ public: return lower <= bounds.lower && upper >= bounds.upper; } + /** + * Returns true if the join of two subranges is not (- infinity, + infinity). + */ + static bool joinIsBounded(const SubrangeBounds& a, const SubrangeBounds& b){ + return (a.lower.hasBound() && b.lower.hasBound()) || + (a.upper.hasBound() && b.upper.hasBound()); + } + + /** + * Returns the join of two subranges, a and b. + * precondition: joinIsBounded(a,b) is true + */ + static SubrangeBounds join(const SubrangeBounds& a, const SubrangeBounds& b){ + Assert(joinIsBounded(a,b)); + SubrangeBound newLower = SubrangeBound::min(a.lower, b.lower); + SubrangeBound newUpper = SubrangeBound::max(a.upper, b.upper); + return SubrangeBounds(newLower, newUpper); + } + };/* class SubrangeBounds */ struct CVC4_PUBLIC SubrangeBoundsHashStrategy { |