Class Interval
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<T>
-
- it.unive.lisa.analysis.nonrelational.value.BaseNonRelationalValueDomain<Interval>
-
- it.unive.lisa.analysis.impl.numeric.Interval
-
- All Implemented Interfaces:
Lattice<Interval>,NonRelationalDomain<Interval,ValueExpression,ValueEnvironment<Interval>>,NonRelationalElement<Interval,ValueExpression,ValueEnvironment<Interval>>,NonRelationalValueDomain<Interval>,SemanticEvaluator
public class Interval extends BaseNonRelationalValueDomain<Interval>
The interval abstract domain, approximating integer values as the minimum integer interval containing them. It is implemented as aBaseNonRelationalValueDomain, handling top and bottom values for the expression evaluation and bottom values for the expression satisfiability. Top and bottom cases for least upper bounds, widening and less or equals operations are handled byBaseLatticeinBaseLattice.lub(L),BaseLattice.widening(L)andBaseLattice.lessOrEqual(L)methods, respectively.
-
-
Field Summary
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description Interval()Builds the top interval.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ValueEnvironment<Interval>assumeBinaryExpression(ValueEnvironment<Interval> environment, BinaryOperator operator, ValueExpression left, ValueExpression right, ProgramPoint pp)Yields the environmentenvironmentassuming that a binary expression with operatoroperator, left argumentleft, and right argumentrightholds.Intervalbottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)protected IntervalevalBinaryExpression(BinaryOperator operator, Interval left, Interval right, ProgramPoint pp)Yields the evaluation of aBinaryExpressionapplyingoperatorto two expressions whose abstract value areleftandright, respectively.protected IntervalevalNonNullConstant(Constant constant, ProgramPoint pp)Yields the evaluation of the given non-null constant.protected IntervalevalUnaryExpression(UnaryOperator operator, Interval arg, ProgramPoint pp)Yields the evaluation of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg.protected IntervalglbAux(Interval other)Performs the greatest lower bound operation between this domain element andother, assuming that base cases have already been handled.inthashCode()booleanisBottom()Yieldstrueif and only if this object represents the bottom of the lattice.booleanisTop()Yieldstrueif and only if this object represents the top of the lattice.protected booleanlessOrEqualAux(Interval other)Yieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.protected IntervallubAux(Interval other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.DomainRepresentationrepresentation()Yields aDomainRepresentationof the information contained in this domain's instance.protected SemanticDomain.SatisfiabilitysatisfiesBinaryExpression(BinaryOperator operator, Interval left, Interval right, ProgramPoint pp)Yields the satisfiability of aBinaryExpressionapplyingoperatorto two expressions whose abstract values areleft, andright.Intervaltop()Yields the top element of this lattice.protected IntervalwideningAux(Interval other)Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class it.unive.lisa.analysis.nonrelational.value.BaseNonRelationalValueDomain
assume, assumeTernaryExpression, assumeUnaryExpression, canProcess, eval, evalIdentifier, evalNullConstant, evalPushAny, evalTernaryExpression, evalTypeCast, evalTypeConv, glb, satisfies, satisfiesAbstractValue, satisfiesNonNullConstant, satisfiesNullConstant, satisfiesTernaryExpression, satisfiesUnaryExpression, toString, tracksIdentifiers
-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lub, widening
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.Lattice
lessOrEqual, lub, widening
-
Methods inherited from interface it.unive.lisa.analysis.nonrelational.NonRelationalElement
variable
-
-
-
-
Method Detail
-
top
public Interval top()
Description copied from interface:LatticeYields the top element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isTop()uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isTop()accordingly to provide a coherent test.- Returns:
- the top element
-
isTop
public boolean isTop()
Description copied from interface:LatticeYieldstrueif and only if this object represents the top of the lattice. The default implementation of this method uses reference equality betweenthisand the value returned byLattice.top(), thus assuming that the top element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.- Returns:
trueif this is the top of the lattice
-
bottom
public Interval bottom()
Description copied from interface:LatticeYields the bottom element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isBottom()uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isBottom()accordingly to provide a coherent test.- Returns:
- the bottom element
-
isBottom
public boolean isBottom()
Description copied from interface:LatticeYieldstrueif and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality betweenthisand the value returned byLattice.bottom(), thus assuming that the bottom element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.- Returns:
trueif this is the bottom of the lattice
-
representation
public DomainRepresentation representation()
Description copied from interface:NonRelationalElementYields aDomainRepresentationof the information contained in this domain's instance.- Returns:
- the representation
-
evalNonNullConstant
protected Interval evalNonNullConstant(Constant constant, ProgramPoint pp)
Description copied from class:BaseNonRelationalValueDomainYields the evaluation of the given non-null constant.- Overrides:
evalNonNullConstantin classBaseNonRelationalValueDomain<Interval>- Parameters:
constant- the constant to evaluatepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the constant
-
evalUnaryExpression
protected Interval evalUnaryExpression(UnaryOperator operator, Interval arg, ProgramPoint pp)
Description copied from class:BaseNonRelationalValueDomainYields the evaluation of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg. It is guaranteed thatargis notLattice.bottom().- Overrides:
evalUnaryExpressionin classBaseNonRelationalValueDomain<Interval>- Parameters:
operator- the operator applied by the expressionarg- the instance of this domain representing the abstract value of the expresion's argumentpp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the expression
-
evalBinaryExpression
protected Interval evalBinaryExpression(BinaryOperator operator, Interval left, Interval right, ProgramPoint pp)
Description copied from class:BaseNonRelationalValueDomainYields the evaluation of aBinaryExpressionapplyingoperatorto two expressions whose abstract value areleftandright, respectively. It is guaranteed that bothleftandrightare notLattice.bottom()and thatoperatoris neitherBinaryOperator.TYPE_CASTnorBinaryOperator.TYPE_CONV.- Overrides:
evalBinaryExpressionin classBaseNonRelationalValueDomain<Interval>- Parameters:
operator- the operator applied by the expressionleft- the instance of this domain representing the abstract value of the left-hand side argumentright- the instance of this domain representing the abstract value of the right-hand side argumentpp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the expression
-
lubAux
protected Interval lubAux(Interval other) throws SemanticException
Description copied from class:BaseLatticePerforms the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lubAuxin classBaseLattice<Interval>- Parameters:
other- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
glbAux
protected Interval glbAux(Interval other)
Description copied from class:BaseNonRelationalValueDomainPerforms the greatest lower bound operation between this domain element andother, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))thisandotherare not comparable
- Overrides:
glbAuxin classBaseNonRelationalValueDomain<Interval>- Parameters:
other- the other domain element- Returns:
- the greatest lower bound between this domain element and other
-
wideningAux
protected Interval wideningAux(Interval other) throws SemanticException
Description copied from class:BaseLatticePerforms the widening operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
wideningAuxin classBaseLattice<Interval>- Parameters:
other- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
lessOrEqualAux
protected boolean lessOrEqualAux(Interval other) throws SemanticException
Description copied from class:BaseLatticeYieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lessOrEqualAuxin classBaseLattice<Interval>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
satisfiesBinaryExpression
protected SemanticDomain.Satisfiability satisfiesBinaryExpression(BinaryOperator operator, Interval left, Interval right, ProgramPoint pp)
Description copied from class:BaseNonRelationalValueDomainYields the satisfiability of aBinaryExpressionapplyingoperatorto two expressions whose abstract values areleft, andright. This method returns an instance ofSemanticDomain.Satisfiability. It is guaranteed thatoperatoris neitherBinaryOperator.LOGICAL_ANDnorBinaryOperator.LOGICAL_OR, and that bothleftandrightare notLattice.bottom().- Overrides:
satisfiesBinaryExpressionin classBaseNonRelationalValueDomain<Interval>- Parameters:
operator- the binary operator applied by the expressionleft- an instance of this abstract domain representing the argument of the left-hand side of the binary expressionright- an instance of this abstract domain representing the argument of the right-hand side of the binary expressionpp- the program point that where this operation is being evaluated- Returns:
SemanticDomain.Satisfiability.SATISFIEDif the expression is satisfied by this domain,SemanticDomain.Satisfiability.NOT_SATISFIEDif it is not satisfied, orSemanticDomain.Satisfiability.UNKNOWNif it is either impossible to determine if it satisfied, or if it is satisfied by some values and not by some others (this is equivalent to a TOP boolean value)
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<Interval>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<Interval>
-
assumeBinaryExpression
protected ValueEnvironment<Interval> assumeBinaryExpression(ValueEnvironment<Interval> environment, BinaryOperator operator, ValueExpression left, ValueExpression right, ProgramPoint pp) throws SemanticException
Description copied from class:BaseNonRelationalValueDomainYields the environmentenvironmentassuming that a binary expression with operatoroperator, left argumentleft, and right argumentrightholds. The binary expression with binary operatorBinaryOperator.LOGICAL_ANDandBinaryOperator.LOGICAL_ORare already handled byBaseNonRelationalValueDomain.assume(it.unive.lisa.analysis.nonrelational.value.ValueEnvironment<T>, it.unive.lisa.symbolic.value.ValueExpression, it.unive.lisa.program.cfg.ProgramPoint).- Overrides:
assumeBinaryExpressionin classBaseNonRelationalValueDomain<Interval>- Parameters:
environment- the environment on which the expression must be assumedoperator- the operator of the binary expressionleft- the left-hand side argument of the binary expressionright- the right-hand side argument of the binary expressionpp- the program point where the binary expression occurs- Returns:
- the environment
environmentassuming that a binary expression with operatoroperator, left argumentleft, and right argumentrightholds - Throws:
SemanticException- if something goes wrong during the assumption
-
-