Class ValueEnvironment<T extends NonRelationalValueDomain<T>>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<F>
-
- it.unive.lisa.analysis.lattices.FunctionalLattice<M,Identifier,T>
-
- it.unive.lisa.analysis.nonrelational.Environment<ValueEnvironment<T>,ValueExpression,T,T>
-
- it.unive.lisa.analysis.nonrelational.value.ValueEnvironment<T>
-
- Type Parameters:
T- the concrete instance of theNonRelationalValueDomainwhose instances are mapped in this environment
- All Implemented Interfaces:
Lattice<ValueEnvironment<T>>,SemanticDomain<ValueEnvironment<T>,ValueExpression,Identifier>,ValueDomain<ValueEnvironment<T>>,java.lang.Iterable<java.util.Map.Entry<Identifier,T>>
public final class ValueEnvironment<T extends NonRelationalValueDomain<T>> extends Environment<ValueEnvironment<T>,ValueExpression,T,T> implements ValueDomain<ValueEnvironment<T>>
An environment for aNonRelationalValueDomain, that mapsIdentifiers to instances of such domain. This is aFunctionalLattice, that is, it implements a function mapping keys (identifiers) to values (instances of the domain), and lattice operations are automatically lifted for individual elements of the environment if they are mapped to the same key.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
FunctionalLattice.FunctionalLift<V extends Lattice<V>>, FunctionalLattice.KeyFunctionalLift<K>
-
Nested classes/interfaces inherited from interface it.unive.lisa.analysis.SemanticDomain
SemanticDomain.Satisfiability
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
function, lattice
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description ValueEnvironment(T domain)Builds an empty environment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ValueEnvironment<T>assignAux(Identifier id, ValueExpression expression, java.util.Map<Identifier,T> function, T value, T eval, ProgramPoint pp)Auxiliary function ofEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)that is invoked after the evaluation of the expression.protected ValueEnvironment<T>assumeSatisfied(T eval)Assumes that an expression, that evaluated toeval, is always satisfied by this environment.ValueEnvironment<T>bottom()Yields the bottom element of this lattice.protected ValueEnvironment<T>copy()Copies this environment.protected org.apache.commons.lang3.tuple.Pair<T,T>eval(ValueExpression expression, ProgramPoint pp)Yields the evaluation of the given expression, happening at the given program point.protected ValueEnvironment<T>glbAux(T lattice, java.util.Map<Identifier,T> function, ValueEnvironment<T> other)Auxiliary glb operation, invoked after the result has been computed to create the concrete instance of environment.protected ValueEnvironment<T>mk(T lattice, java.util.Map<Identifier,T> function)Builds a instance of this class from the given lattice instance and the given mapping.ValueEnvironment<T>smallStepSemantics(ValueExpression expression, ProgramPoint pp)Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression.ValueEnvironment<T>top()Yields the top element of this lattice.-
Methods inherited from class it.unive.lisa.analysis.nonrelational.Environment
assign, assume, forgetIdentifier, glb, isBottom, isTop, lubKeys, popScope, pushScope, representation, satisfies
-
Methods inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
equals, functionalLift, getKeys, getMap, getState, getValues, glbKeys, hashCode, iterator, lessOrEqualAux, lubAux, mkNewFunction, putState, toString, wideningAux
-
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.SemanticDomain
assign, assume, forgetIdentifier, forgetIdentifiers, popScope, pushScope, representation, satisfies
-
Methods inherited from interface it.unive.lisa.analysis.value.ValueDomain
applySubstitution
-
-
-
-
Constructor Detail
-
ValueEnvironment
public ValueEnvironment(T domain)
Builds an empty environment.- Parameters:
domain- a singleton instance to be used during semantic operations to retrieve top and bottom values
-
-
Method Detail
-
mk
protected ValueEnvironment<T> mk(T lattice, java.util.Map<Identifier,T> function)
Description copied from class:FunctionalLatticeBuilds a instance of this class from the given lattice instance and the given mapping.- Specified by:
mkin classFunctionalLattice<ValueEnvironment<T extends NonRelationalValueDomain<T>>,Identifier,T extends NonRelationalValueDomain<T>>- Parameters:
lattice- an instance of lattice to be used during semantic operations to retrieve top and bottom valuesfunction- the function representing the mapping contained in the new environment; can benull- Returns:
- a new instance of this class
-
copy
protected ValueEnvironment<T> copy()
Description copied from class:EnvironmentCopies this environment. The function of the returned environment must be a (shallow) copy of the one of the given environment.- Specified by:
copyin classEnvironment<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,T extends NonRelationalValueDomain<T>,T extends NonRelationalValueDomain<T>>- Returns:
- a copy of the given environment
-
eval
protected org.apache.commons.lang3.tuple.Pair<T,T> eval(ValueExpression expression, ProgramPoint pp) throws SemanticException
Description copied from class:EnvironmentYields the evaluation of the given expression, happening at the given program point. The result of the evaluation is in the form of<abstract element, evaluation result>, whereevaluation resultis the true result of the evaluation, whileabstract elementis the element derived by the result that is to be stored inside the environment mapped to an identifier.- Specified by:
evalin classEnvironment<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,T extends NonRelationalValueDomain<T>,T extends NonRelationalValueDomain<T>>- Parameters:
expression- the expression to evaluatepp- the program point where the evaluation happens- Returns:
- the result of the evaluation
- Throws:
SemanticException- if something goes wrong during the evaluation
-
assignAux
protected ValueEnvironment<T> assignAux(Identifier id, ValueExpression expression, java.util.Map<Identifier,T> function, T value, T eval, ProgramPoint pp)
Description copied from class:EnvironmentAuxiliary function ofEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)that is invoked after the evaluation of the expression.- Specified by:
assignAuxin classEnvironment<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,T extends NonRelationalValueDomain<T>,T extends NonRelationalValueDomain<T>>- Parameters:
id- the identifier that has been assignedexpression- the expression that has been evaluated and assignedfunction- a copy of the current function, where theidhas been assigned toevalvalue- the final value stored forid, after considering applyingNonRelationalElement.variable(Identifier, ProgramPoint)andIdentifier.isWeak()eval- the abstract value that is the result of the evaluation ofvaluepp- the program point that where this operation is being evaluated- Returns:
- a new instance of this environment containing the given function,
obtained by assigning
idtoeval
-
smallStepSemantics
public ValueEnvironment<T> smallStepSemantics(ValueExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression.- Specified by:
smallStepSemanticsin interfaceSemanticDomain<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,Identifier>- Parameters:
expression- the expression whose semantics need to be computedpp- the program point that where this operation is being evaluated- Returns:
- a copy of this domain, modified accordingly to the semantics of
expression - Throws:
SemanticException- if an error occurs during the computation
-
assumeSatisfied
protected ValueEnvironment<T> assumeSatisfied(T eval)
Description copied from class:EnvironmentAssumes that an expression, that evaluated toeval, is always satisfied by this environment. This auxiliary method serves as a constructor for the final concrete instance of environment.- Specified by:
assumeSatisfiedin classEnvironment<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,T extends NonRelationalValueDomain<T>,T extends NonRelationalValueDomain<T>>- Parameters:
eval- the result of the evaluation of the expression that is always satisfied- Returns:
- the (possibly) updated environment
-
glbAux
protected ValueEnvironment<T> glbAux(T lattice, java.util.Map<Identifier,T> function, ValueEnvironment<T> other)
Description copied from class:EnvironmentAuxiliary glb operation, invoked after the result has been computed to create the concrete instance of environment. Note that any additional information that is instance-specific (i.e. anything but function and lattice singleton) has to be computed by this method.- Specified by:
glbAuxin classEnvironment<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,T extends NonRelationalValueDomain<T>,T extends NonRelationalValueDomain<T>>- Parameters:
lattice- the lattice that is the result of the glbfunction- the function that is the result of the glb (might benullother- the other environment- Returns:
- the final instance of the glb
-
top
public ValueEnvironment<T> 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.- Specified by:
topin interfaceLattice<T extends NonRelationalValueDomain<T>>- Returns:
- the top element
-
bottom
public ValueEnvironment<T> 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.- Specified by:
bottomin interfaceLattice<T extends NonRelationalValueDomain<T>>- Returns:
- the bottom element
-
-