cetus.hir
Class RangeExpression

java.lang.Object
  extended by cetus.hir.Expression
      extended by cetus.hir.RangeExpression
All Implemented Interfaces:
Printable, Traversable, java.lang.Cloneable, java.lang.Comparable<Expression>

public class RangeExpression
extends Expression

RangeExpression represents a symbolic range with a lower bound expression and an upper bound expression. RangeAnalysis uses RangeExpression to compute a valid value ranges of variables at program points.


Field Summary
 
Fields inherited from class cetus.hir.Expression
children, needs_parens, object_print_method, parent
 
Constructor Summary
RangeExpression(Expression lb, Expression ub)
          Constructs a range expression with the given lower and upper bounds.
 
Method Summary
 int compareTo(Expression e)
          Compares the given expression with this range expression.
static void defaultPrint(RangeExpression range, java.io.OutputStream stream)
          Default print method
 boolean equals(java.lang.Object o)
          Checks if the given object is equal to this range expression.
 Expression getLB()
          Returns the lower bound of this range expression.
static Expression getOmega()
          Returns a new instanceof omega expression which is [-inf:inf].
 Expression getUB()
          Returns the upper bound of this range expression.
 boolean isBounded()
          Returns true if neither lb nor ub is infinity.
 boolean isEmpty()
          Checks if this range expression has a lower bound greater than the upper bound.
 boolean isOmega()
          Checks if this range expression does not have any closed bounds.
 void setLB(Expression lb)
          Sets the lower bound with the given expression.
 void setUB(Expression ub)
          Sets the upper bound with the given expression.
 Expression toExpression()
          Converts this range expression to a non-range expression if the lower bound is equal to the upper bound.
static RangeExpression toRange(Expression e)
          Converts an arbitrary expression to a range expression by setting the same lower bound and upper bound.
 java.lang.String toString()
          Returns the string representation of the range expression.
 
Methods inherited from class cetus.hir.Expression
clone, equals2, findExpression, getChildren, getParent, getStatement, needsParens, print, printSelf, removeChild, setChild, setParens, setParent, setPrintMethod, swapWith, verify
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RangeExpression

public RangeExpression(Expression lb,
                       Expression ub)
Constructs a range expression with the given lower and upper bounds.

Parameters:
lb - the lower bound expression.
ub - the upper bound expression.
Method Detail

defaultPrint

public static void defaultPrint(RangeExpression range,
                                java.io.OutputStream stream)
Default print method


toString

public java.lang.String toString()
Returns the string representation of the range expression.

Overrides:
toString in class Expression

equals

public boolean equals(java.lang.Object o)
Checks if the given object is equal to this range expression.

Overrides:
equals in class Expression
Parameters:
o - the object to be compared.

compareTo

public int compareTo(Expression e)
Compares the given expression with this range expression.

Specified by:
compareTo in interface java.lang.Comparable<Expression>
Overrides:
compareTo in class Expression
Returns:
0 if they are equal, -1 otherwise.

setLB

public void setLB(Expression lb)
Sets the lower bound with the given expression.

Parameters:
lb - the new lower bound.

setUB

public void setUB(Expression ub)
Sets the upper bound with the given expression.

Parameters:
ub - the new upper bound

getLB

public Expression getLB()
Returns the lower bound of this range expression.


getUB

public Expression getUB()
Returns the upper bound of this range expression.


isEmpty

public boolean isEmpty()
Checks if this range expression has a lower bound greater than the upper bound. The comparison is possible only for literals and infinity expression.


isOmega

public boolean isOmega()
Checks if this range expression does not have any closed bounds.


isBounded

public boolean isBounded()
Returns true if neither lb nor ub is infinity.


toRange

public static RangeExpression toRange(Expression e)
Converts an arbitrary expression to a range expression by setting the same lower bound and upper bound.


toExpression

public Expression toExpression()
Converts this range expression to a non-range expression if the lower bound is equal to the upper bound.


getOmega

public static Expression getOmega()
Returns a new instanceof omega expression which is [-inf:inf].

Returns:
a new omega expression.