Class Parity
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<T>
-
- it.unive.lisa.analysis.nonrelational.value.BaseNonRelationalValueDomain<Parity>
-
- it.unive.lisa.analysis.impl.numeric.Parity
-
- All Implemented Interfaces:
Lattice<Parity>,NonRelationalDomain<Parity,ValueExpression,ValueEnvironment<Parity>>,NonRelationalElement<Parity,ValueExpression,ValueEnvironment<Parity>>,NonRelationalValueDomain<Parity>,SemanticEvaluator
public class Parity extends BaseNonRelationalValueDomain<Parity>
The Parity abstract domain, tracking if a numeric value is even or odd, 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 bound, 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 Parity()Builds the parity abstract domain, representing the top of the parity abstract domain.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ValueEnvironment<Parity>assumeBinaryExpression(ValueEnvironment<Parity> environment, BinaryOperator operator, ValueExpression left, ValueExpression right, ProgramPoint pp)Yields the environmentenvironmentassuming that a binary expression with operatoroperator, left argumentleft, and right argumentrightholds.Paritybottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)protected ParityevalBinaryExpression(BinaryOperator operator, Parity left, Parity right, ProgramPoint pp)Yields the evaluation of aBinaryExpressionapplyingoperatorto two expressions whose abstract value areleftandright, respectively.protected ParityevalNonNullConstant(Constant constant, ProgramPoint pp)Yields the evaluation of the given non-null constant.protected ParityevalNullConstant(ProgramPoint pp)Yields the evaluation of the null constantNullConstant.protected ParityevalUnaryExpression(UnaryOperator operator, Parity arg, ProgramPoint pp)Yields the evaluation of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg.inthashCode()protected booleanlessOrEqualAux(Parity 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 ParitylubAux(Parity 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.Paritytop()Yields the top element of this lattice.protected ParitywideningAux(Parity 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, evalPushAny, evalTernaryExpression, evalTypeCast, evalTypeConv, glb, glbAux, satisfies, satisfiesAbstractValue, satisfiesBinaryExpression, 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
isBottom, isTop, lessOrEqual, lub, widening
-
Methods inherited from interface it.unive.lisa.analysis.nonrelational.NonRelationalElement
variable
-
-
-
-
Method Detail
-
top
public Parity 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
-
bottom
public Parity 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
-
representation
public DomainRepresentation representation()
Description copied from interface:NonRelationalElementYields aDomainRepresentationof the information contained in this domain's instance.- Returns:
- the representation
-
evalNullConstant
protected Parity evalNullConstant(ProgramPoint pp)
Description copied from class:BaseNonRelationalValueDomainYields the evaluation of the null constantNullConstant.- Overrides:
evalNullConstantin classBaseNonRelationalValueDomain<Parity>- Parameters:
pp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the constant
-
evalNonNullConstant
protected Parity evalNonNullConstant(Constant constant, ProgramPoint pp)
Description copied from class:BaseNonRelationalValueDomainYields the evaluation of the given non-null constant.- Overrides:
evalNonNullConstantin classBaseNonRelationalValueDomain<Parity>- Parameters:
constant- the constant to evaluatepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the constant
-
evalUnaryExpression
protected Parity evalUnaryExpression(UnaryOperator operator, Parity 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<Parity>- 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 Parity evalBinaryExpression(BinaryOperator operator, Parity left, Parity 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<Parity>- 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 Parity lubAux(Parity 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<Parity>- Parameters:
other- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
wideningAux
protected Parity wideningAux(Parity 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<Parity>- 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(Parity 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<Parity>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<Parity>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<Parity>
-
assumeBinaryExpression
protected ValueEnvironment<Parity> assumeBinaryExpression(ValueEnvironment<Parity> 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<Parity>- 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
-
-