Class BaseNonRelationalValueDomain<T extends BaseNonRelationalValueDomain<T>>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<T>
-
- it.unive.lisa.analysis.nonrelational.value.BaseNonRelationalValueDomain<T>
-
- Type Parameters:
T- the concrete type of this domain
- All Implemented Interfaces:
Lattice<T>,NonRelationalDomain<T,ValueExpression,ValueEnvironment<T>>,NonRelationalElement<T,ValueExpression,ValueEnvironment<T>>,NonRelationalValueDomain<T>,SemanticEvaluator
public abstract class BaseNonRelationalValueDomain<T extends BaseNonRelationalValueDomain<T>> extends BaseLattice<T> implements NonRelationalValueDomain<T>
Base implementation forNonRelationalValueDomains. This class extendsBaseLatticeand implementsNonRelationalDomain.eval(it.unive.lisa.symbolic.SymbolicExpression, it.unive.lisa.analysis.lattices.FunctionalLattice, ProgramPoint)by taking care of the recursive computation of inner expressions evaluation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBaseNonRelationalValueDomain.EvaluationVisitorAExpressionVisitorforBaseNonRelationalValueDomaininstances.
-
Field Summary
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description BaseNonRelationalValueDomain()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueEnvironment<T>assume(ValueEnvironment<T> environment, ValueExpression expression, ProgramPoint pp)Yields the environmentenvironmenton which the expressionexpressionis assumed to hold by this domain.ValueEnvironment<T>assumeBinaryExpression(ValueEnvironment<T> environment, BinaryOperator operator, ValueExpression left, ValueExpression right, ProgramPoint pp)Yields the environmentenvironmentassuming that a binary expression with operatoroperator, left argumentleft, and right argumentrightholds.ValueEnvironment<T>assumeTernaryExpression(ValueEnvironment<T> environment, TernaryOperator operator, ValueExpression left, ValueExpression middle, ValueExpression right, ProgramPoint pp)Yields the environmentenvironmentassuming that a ternary expression with operatoroperator, left argumentleft, middle argumentmiddle,and right argumentrightholds.ValueEnvironment<T>assumeUnaryExpression(ValueEnvironment<T> environment, UnaryOperator operator, ValueExpression expression, ProgramPoint pp)Yields the environmentenvironmentassuming that an unary expression with operatoroperatorand argumentexpressionholds.booleancanProcess(SymbolicExpression expression)Yieldstrueif the domain can processexpression,falseotherwise.Teval(ValueExpression expression, ValueEnvironment<T> environment, ProgramPoint pp)Evaluates aSymbolicExpression, assuming that the values of program variables are the ones stored inenvironment.TevalBinaryExpression(BinaryOperator operator, T left, T right, ProgramPoint pp)Yields the evaluation of aBinaryExpressionapplyingoperatorto two expressions whose abstract value areleftandright, respectively.TevalIdentifier(Identifier id, ValueEnvironment<T> environment, ProgramPoint pp)Yields the evaluation of an identifier in a given environment.TevalNonNullConstant(Constant constant, ProgramPoint pp)Yields the evaluation of the given non-null constant.TevalNullConstant(ProgramPoint pp)Yields the evaluation of the null constantNullConstant.TevalPushAny(PushAny pushAny, ProgramPoint pp)Yields the evaluation of a push-any expression.TevalTernaryExpression(TernaryOperator operator, T left, T middle, T right, ProgramPoint pp)Yields the evaluation of aTernaryExpressionapplyingoperatorto two expressions whose abstract value areleft,middleandright, respectively.TevalTypeCast(BinaryExpression cast, T left, T right, ProgramPoint pp)Yields the evaluation of a type cast expression.TevalTypeConv(BinaryExpression conv, T left, T right, ProgramPoint pp)Yields the evaluation of a type conversion expression.TevalUnaryExpression(UnaryOperator operator, T arg, ProgramPoint pp)Yields the evaluation of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg.Tglb(T other)Performs the greatest lower bound operation between this domain element andother.TglbAux(T other)Performs the greatest lower bound operation between this domain element andother, assuming that base cases have already been handled.SemanticDomain.Satisfiabilitysatisfies(ValueExpression expression, ValueEnvironment<T> environment, ProgramPoint pp)Checks whetherexpressionis satisfied inenvironment, assuming that the values of program variables are the ones stored inenvironmentand returning an instance ofSemanticDomain.Satisfiability.SemanticDomain.SatisfiabilitysatisfiesAbstractValue(T value, ProgramPoint pp)Yields the satisfiability of an abstract value of type<T>.SemanticDomain.SatisfiabilitysatisfiesBinaryExpression(BinaryOperator operator, T left, T right, ProgramPoint pp)Yields the satisfiability of aBinaryExpressionapplyingoperatorto two expressions whose abstract values areleft, andright.SemanticDomain.SatisfiabilitysatisfiesNonNullConstant(Constant constant, ProgramPoint pp)Yields the satisfiability of the given non-null constant on this abstract domain.SemanticDomain.SatisfiabilitysatisfiesNullConstant(ProgramPoint pp)Yields the satisfiability of the null constantNullConstanton this abstract domain.SemanticDomain.SatisfiabilitysatisfiesTernaryExpression(TernaryOperator operator, T left, T middle, T right, ProgramPoint pp)Yields the satisfiability of aTernaryExpressionapplyingoperatorto three expressions whose abstract values areleft,middleandright.SemanticDomain.SatisfiabilitysatisfiesUnaryExpression(UnaryOperator operator, T arg, ProgramPoint pp)Yields the satisfiability of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg, returning an instance ofSemanticDomain.Satisfiability.java.lang.StringtoString()booleantracksIdentifiers(Identifier id)Yieldstrueif the domain tracks information on the identifierid,falseotherwise.-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
equals, hashCode, lessOrEqual, lessOrEqualAux, lub, lubAux, widening, wideningAux
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.Lattice
bottom, isBottom, isTop, lessOrEqual, lub, top, widening
-
Methods inherited from interface it.unive.lisa.analysis.nonrelational.NonRelationalElement
representation, variable
-
-
-
-
Method Detail
-
satisfies
public SemanticDomain.Satisfiability satisfies(ValueExpression expression, ValueEnvironment<T> environment, ProgramPoint pp) throws SemanticException
Description copied from interface:NonRelationalElementChecks whetherexpressionis satisfied inenvironment, assuming that the values of program variables are the ones stored inenvironmentand returning an instance ofSemanticDomain.Satisfiability.- Specified by:
satisfiesin interfaceNonRelationalElement<T extends BaseNonRelationalValueDomain<T>,ValueExpression,ValueEnvironment<T extends BaseNonRelationalValueDomain<T>>>- Parameters:
expression- the expression whose satisfiability is to be evaluatedenvironment- the environment containing the values of program variables for the satisfiabilitypp- the program point that where this operation is being evaluated- Returns:
SemanticDomain.Satisfiability.SATISFIEDif the expression is satisfied by the environment,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)- Throws:
SemanticException- if something goes wrong during the computation
-
eval
public T eval(ValueExpression expression, ValueEnvironment<T> environment, ProgramPoint pp) throws SemanticException
Description copied from interface:NonRelationalDomainEvaluates aSymbolicExpression, assuming that the values of program variables are the ones stored inenvironment.- Specified by:
evalin interfaceNonRelationalDomain<T extends BaseNonRelationalValueDomain<T>,ValueExpression,ValueEnvironment<T extends BaseNonRelationalValueDomain<T>>>- Parameters:
expression- the expression to evaluateenvironment- the environment containing the values of program variables for the evaluationpp- the program point that where this operation is being evaluated- Returns:
- an new instance of this domain, representing the abstract result
of
expressionwhen evaluated onenvironment - Throws:
SemanticException- if something goes wrong during the computation
-
tracksIdentifiers
public boolean tracksIdentifiers(Identifier id)
Description copied from interface:SemanticEvaluatorYieldstrueif the domain tracks information on the identifierid,falseotherwise.- Specified by:
tracksIdentifiersin interfaceSemanticEvaluator- Parameters:
id- the identifier- Returns:
trueif the domain tracks information on the identifierid,falseotherwise
-
canProcess
public boolean canProcess(SymbolicExpression expression)
Description copied from interface:SemanticEvaluatorYieldstrueif the domain can processexpression,falseotherwise.- Specified by:
canProcessin interfaceSemanticEvaluator- Parameters:
expression- the expression- Returns:
trueif the domain can processexpression,falseotherwise.
-
evalIdentifier
public T evalIdentifier(Identifier id, ValueEnvironment<T> environment, ProgramPoint pp) throws SemanticException
Yields the evaluation of an identifier in a given environment.- Parameters:
id- the identifier to be evaluatedenvironment- the environment where the identifier must be evaluatedpp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the identifier
- Throws:
SemanticException- if an error occurs during the computation
-
evalPushAny
public T evalPushAny(PushAny pushAny, ProgramPoint pp) throws SemanticException
Yields the evaluation of a push-any expression.- Parameters:
pushAny- the push-any expression to be evaluatedpp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the push-any expression
- Throws:
SemanticException- if an error occurs during the computation
-
evalTypeConv
public T evalTypeConv(BinaryExpression conv, T left, T right, ProgramPoint pp) throws SemanticException
Yields the evaluation of a type conversion expression.- Parameters:
conv- the type conversion expressionleft- the left expression, namely the expression to be convertedright- the right expression, namely the types to which left should be convertedpp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the type conversion expression
- Throws:
SemanticException- if an error occurs during the computation
-
evalTypeCast
public T evalTypeCast(BinaryExpression cast, T left, T right, ProgramPoint pp) throws SemanticException
Yields the evaluation of a type cast expression.- Parameters:
cast- the type casted expressionleft- the left expression, namely the expression to be castedright- the right expression, namely the types to which left should be castedpp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the type cast expression
- Throws:
SemanticException- if an error occurs during the computation
-
evalNullConstant
public T evalNullConstant(ProgramPoint pp) throws SemanticException
Yields the evaluation of the null constantNullConstant.- Parameters:
pp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the constant
- Throws:
SemanticException- if an error occurs during the computation
-
evalNonNullConstant
public T evalNonNullConstant(Constant constant, ProgramPoint pp) throws SemanticException
Yields the evaluation of the given non-null constant.- Parameters:
constant- the constant to evaluatepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the constant
- Throws:
SemanticException- if an error occurs during the computation
-
evalUnaryExpression
public T evalUnaryExpression(UnaryOperator operator, T arg, ProgramPoint pp) throws SemanticException
Yields the evaluation of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg. It is guaranteed thatargis notLattice.bottom().- 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
- Throws:
SemanticException- if an error occurs during the computation
-
evalBinaryExpression
public T evalBinaryExpression(BinaryOperator operator, T left, T right, ProgramPoint pp) throws SemanticException
Yields the evaluation of aBinaryExpressionapplyingoperatorto two expressions whose abstract value areleftandright, respectively. It is guaranteed that bothleftandrightare notLattice.bottom()and thatoperatoris neitherTypeCastnorTypeConv.- 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
- Throws:
SemanticException- if an error occurs during the computation
-
evalTernaryExpression
public T evalTernaryExpression(TernaryOperator operator, T left, T middle, T right, ProgramPoint pp) throws SemanticException
Yields the evaluation of aTernaryExpressionapplyingoperatorto two expressions whose abstract value areleft,middleandright, respectively. It is guaranteed that bothleftandrightare notLattice.bottom().- Parameters:
operator- the operator applied by the expressionleft- the instance of this domain representing the abstract value of the left-hand side argumentmiddle- the instance of this domain representing the abstract value of the middle 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
- Throws:
SemanticException- if an error occurs during the computation
-
satisfiesAbstractValue
public SemanticDomain.Satisfiability satisfiesAbstractValue(T value, ProgramPoint pp) throws SemanticException
Yields the satisfiability of an abstract value of type<T>.- Parameters:
value- the abstract value whose satisfiability is to be evaluatedpp- 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)- Throws:
SemanticException- if an error occurs during the computation
-
satisfiesNullConstant
public SemanticDomain.Satisfiability satisfiesNullConstant(ProgramPoint pp) throws SemanticException
Yields the satisfiability of the null constantNullConstanton this abstract domain.- Parameters:
pp- 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)- Throws:
SemanticException- if an error occurs during the computation
-
satisfiesNonNullConstant
public SemanticDomain.Satisfiability satisfiesNonNullConstant(Constant constant, ProgramPoint pp) throws SemanticException
Yields the satisfiability of the given non-null constant on this abstract domain.- Parameters:
constant- the constant to satisfiedpp- the program point that where this operation is being evaluated- Returns:
SemanticDomain.Satisfiability.SATISFIEDis the constant 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)- Throws:
SemanticException- if an error occurs during the computation
-
satisfiesUnaryExpression
public SemanticDomain.Satisfiability satisfiesUnaryExpression(UnaryOperator operator, T arg, ProgramPoint pp) throws SemanticException
Yields the satisfiability of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg, returning an instance ofSemanticDomain.Satisfiability. It is guaranteed thatoperatoris notLogicalNegationandargis notLattice.bottom().- Parameters:
operator- the unary operator applied by the expressionarg- an instance of this abstract domain representing the argument of the unary 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)- Throws:
SemanticException- if an error occurs during the computation
-
satisfiesBinaryExpression
public SemanticDomain.Satisfiability satisfiesBinaryExpression(BinaryOperator operator, T left, T right, ProgramPoint pp) throws SemanticException
Yields the satisfiability of aBinaryExpressionapplyingoperatorto two expressions whose abstract values areleft, andright. This method returns an instance ofSemanticDomain.Satisfiability. It is guaranteed thatoperatoris neitherLogicalAndnorLogicalOr, and that bothleftandrightare notLattice.bottom().- 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)- Throws:
SemanticException- if an error occurs during the computation
-
satisfiesTernaryExpression
public SemanticDomain.Satisfiability satisfiesTernaryExpression(TernaryOperator operator, T left, T middle, T right, ProgramPoint pp) throws SemanticException
Yields the satisfiability of aTernaryExpressionapplyingoperatorto three expressions whose abstract values areleft,middleandright. This method returns an instance ofSemanticDomain.Satisfiability. It is guaranteed thatleft,middleandrightare notLattice.bottom().- Parameters:
operator- the ternary operator applied by the expressionleft- an instance of this abstract domain representing the argument of the left-most side of the ternary expressionmiddle- an instance of this abstract domain representing the argument in the middle of the ternary expressionright- an instance of this abstract domain representing the argument of the right-most side of the ternary 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)- Throws:
SemanticException- if an error occurs during the computation
-
toString
public final java.lang.String toString()
- Specified by:
toStringin classBaseLattice<T extends BaseNonRelationalValueDomain<T>>
-
assume
public ValueEnvironment<T> assume(ValueEnvironment<T> environment, ValueExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:NonRelationalElementYields the environmentenvironmenton which the expressionexpressionis assumed to hold by this domain.- Specified by:
assumein interfaceNonRelationalElement<T extends BaseNonRelationalValueDomain<T>,ValueExpression,ValueEnvironment<T extends BaseNonRelationalValueDomain<T>>>- Parameters:
environment- the environmentexpression- the expression to be assumedpp- the program point whereexpressionoccurs.- Returns:
- the environment
environmentwhereexpressionis assumed to hold - Throws:
SemanticException- if an error occurs during the computation
-
assumeTernaryExpression
public ValueEnvironment<T> assumeTernaryExpression(ValueEnvironment<T> environment, TernaryOperator operator, ValueExpression left, ValueExpression middle, ValueExpression right, ProgramPoint pp) throws SemanticException
Yields the environmentenvironmentassuming that a ternary expression with operatoroperator, left argumentleft, middle argumentmiddle,and right argumentrightholds.- Parameters:
environment- the environment on which the expression must be assumedoperator- the operator of the ternary expressionleft- the left-hand side argument of the ternary expressionmiddle- the middle-hand side argument of the ternary expressionright- the right-hand side argument of the ternary expressionpp- the program point where the ternary expression occurs- Returns:
- the environment
environmentassuming that a ternary expression with operatoroperator, left argumentleft, middle argumentmiddle,and right argumentrightholds - Throws:
SemanticException- if something goes wrong during the assumption
-
assumeBinaryExpression
public ValueEnvironment<T> assumeBinaryExpression(ValueEnvironment<T> environment, BinaryOperator operator, ValueExpression left, ValueExpression right, ProgramPoint pp) throws SemanticException
Yields the environmentenvironmentassuming that a binary expression with operatoroperator, left argumentleft, and right argumentrightholds. The binary expression with binary operatorLogicalAndandLogicalOrare already handled byassume(it.unive.lisa.analysis.nonrelational.value.ValueEnvironment<T>, it.unive.lisa.symbolic.value.ValueExpression, it.unive.lisa.program.cfg.ProgramPoint).- 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
-
assumeUnaryExpression
public ValueEnvironment<T> assumeUnaryExpression(ValueEnvironment<T> environment, UnaryOperator operator, ValueExpression expression, ProgramPoint pp) throws SemanticException
Yields the environmentenvironmentassuming that an unary expression with operatoroperatorand argumentexpressionholds.- Parameters:
environment- the environment on which the expression must be assumedoperator- the operator of the unary expressionexpression- the argument of the unary expressionpp- the program point where the unary expression occurs- Returns:
- the environment
environmentassuming that an unary expression with operatoroperatorand argumentexpressionholds. - Throws:
SemanticException- if something goes wrong during the assumption
-
glb
public T glb(T other) throws SemanticException
Description copied from interface:NonRelationalElementPerforms the greatest lower bound operation between this domain element andother.- Specified by:
glbin interfaceNonRelationalElement<T extends BaseNonRelationalValueDomain<T>,ValueExpression,ValueEnvironment<T extends BaseNonRelationalValueDomain<T>>>- Parameters:
other- the other domain element- Returns:
- the greatest lowe bound between
thisandother - Throws:
SemanticException- if an error occurs during the computation
-
glbAux
public T glbAux(T other) throws SemanticException
Performs 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
- Parameters:
other- the other domain element- Returns:
- the greatest lower bound between this domain element and other
- Throws:
SemanticException- if an error occurs during the computation
-
-