Package com.tonic.analysis.ssa.transform
Class ValueRange
- java.lang.Object
-
- com.tonic.analysis.ssa.transform.ValueRange
-
public class ValueRange extends Object
An inclusive range of integer values used to track value constraints.
-
-
Field Summary
Fields Modifier and Type Field Description static ValueRangeEMPTYstatic ValueRangeFULL_INT
-
Constructor Summary
Constructors Constructor Description ValueRange(long min, long max)Creates an inclusive range; a min above max denotes the empty range.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(long value)Tests membership, always false for an empty range.booleanequals(Object o)static ValueRangeequalTo(long val)Builds the range satisfying x == val.longgetMax()longgetMin()static ValueRangegreaterOrEqual(long val)Builds the range satisfying x >= val.static ValueRangegreaterThan(long val)Builds the range satisfying x > val.inthashCode()ValueRangeintersect(ValueRange other)Intersects this range with another, narrowing the result.booleanisConstant()booleanisEmpty()static ValueRangelessOrEqual(long val)Builds the range satisfying x <= val.static ValueRangelessThan(long val)Builds the range satisfying x < val.StringtoString()
-
-
-
Field Detail
-
FULL_INT
public static final ValueRange FULL_INT
-
EMPTY
public static final ValueRange EMPTY
-
-
Method Detail
-
getMin
public long getMin()
- Returns:
- the min
-
getMax
public long getMax()
- Returns:
- the max
-
isEmpty
public boolean isEmpty()
- Returns:
- whether the range holds no values
-
isConstant
public boolean isConstant()
- Returns:
- whether the range holds exactly one value
-
contains
public boolean contains(long value)
Tests membership, always false for an empty range.- Parameters:
value- the value to test- Returns:
- whether the value lies within the bounds
-
intersect
public ValueRange intersect(ValueRange other)
Intersects this range with another, narrowing the result.- Parameters:
other- the range to intersect with- Returns:
- the overlap, or EMPTY if either side is empty or they do not overlap
-
lessThan
public static ValueRange lessThan(long val)
Builds the range satisfying x < val.- Parameters:
val- the compared value- Returns:
- the range [MIN_VALUE, val-1], or EMPTY if nothing is below it
-
lessOrEqual
public static ValueRange lessOrEqual(long val)
Builds the range satisfying x <= val.- Parameters:
val- the compared value- Returns:
- the range [MIN_VALUE, val]
-
greaterThan
public static ValueRange greaterThan(long val)
Builds the range satisfying x > val.- Parameters:
val- the compared value- Returns:
- the range [val+1, MAX_VALUE], or EMPTY if nothing is above it
-
greaterOrEqual
public static ValueRange greaterOrEqual(long val)
Builds the range satisfying x >= val.- Parameters:
val- the compared value- Returns:
- the range [val, MAX_VALUE]
-
equalTo
public static ValueRange equalTo(long val)
Builds the range satisfying x == val.- Parameters:
val- the compared value- Returns:
- the single-value range [val, val]
-
-