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 theNonRelationalValueDomain
whose 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 class ValueEnvironment<T extends NonRelationalValueDomain<T>> extends Environment<ValueEnvironment<T>,ValueExpression,T,T> implements ValueDomain<ValueEnvironment<T>>
An environment for aNonRelationalValueDomain
, that mapsIdentifier
s 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. The abstract value computed for the last processed expression is exposed throughgetValueOnStack()
.
-
-
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_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description ValueEnvironment(T domain)
Builds an empty environment.ValueEnvironment(T domain, java.util.Map<Identifier,T> function, T stack)
Builds an environment containing the given mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.ValueEnvironment<T>
copy()
Copies this environment.boolean
equals(java.lang.Object obj)
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.T
getValueOnStack()
Yields the computed value of the lastSymbolicExpression
handled by this domain, either throughEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)
orsmallStepSemantics(ValueExpression, ProgramPoint)
.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.int
hashCode()
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.DomainRepresentation
representation()
Yields aDomainRepresentation
of the information contained in this domain's instance.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, forgetIdentifiersIf, glb, lubKeys, popScope, pushScope, satisfies
-
Methods inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
functionalLift, getKeys, getMap, getState, getValues, glbKeys, isBottom, isTop, 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, forgetIdentifiersIf, getDomainInstance, popScope, pushScope, 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
-
ValueEnvironment
public ValueEnvironment(T domain, java.util.Map<Identifier,T> function, T stack)
Builds an environment containing the given mapping. If function isnull
, the new environment is the top environment iflattice.isTop()
holds, and it is the bottom environment iflattice.isBottom()
holds.- Parameters:
domain
- a singleton instance to be used during semantic operations to retrieve top and bottom valuesfunction
- the function representing the mapping contained in the new environment; can benull
stack
- the abstract value for the last computed expression, that is left on the top of the stack
-
-
Method Detail
-
getValueOnStack
public T getValueOnStack()
Yields the computed value of the lastSymbolicExpression
handled by this domain, either throughEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)
orsmallStepSemantics(ValueExpression, ProgramPoint)
.- Returns:
- the value computed for the last expression
-
mk
public ValueEnvironment<T> mk(T lattice, java.util.Map<Identifier,T> function)
Description copied from class:FunctionalLattice
Builds a instance of this class from the given lattice instance and the given mapping.- Specified by:
mk
in 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
public ValueEnvironment<T> copy()
Description copied from class:Environment
Copies this environment. The function of the returned environment must be a (shallow) copy of the one of the given environment.- Specified by:
copy
in classEnvironment<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,T extends NonRelationalValueDomain<T>,T extends NonRelationalValueDomain<T>>
- Returns:
- a copy of the given environment
-
eval
public org.apache.commons.lang3.tuple.Pair<T,T> eval(ValueExpression expression, ProgramPoint pp) throws SemanticException
Description copied from class:Environment
Yields 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 result
is the true result of the evaluation, whileabstract element
is the element derived by the result that is to be stored inside the environment mapped to an identifier.- Specified by:
eval
in 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
public ValueEnvironment<T> assignAux(Identifier id, ValueExpression expression, java.util.Map<Identifier,T> function, T value, T eval, ProgramPoint pp)
Description copied from class:Environment
Auxiliary function ofEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)
that is invoked after the evaluation of the expression.- Specified by:
assignAux
in 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 theid
has been assigned toeval
value
- the final value stored forid
, after considering applyingNonRelationalElement.variable(Identifier, ProgramPoint)
andIdentifier.isWeak()
eval
- the abstract value that is the result of the evaluation ofvalue
pp
- the program point that where this operation is being evaluated- Returns:
- a new instance of this environment containing the given function,
obtained by assigning
id
toeval
-
smallStepSemantics
public ValueEnvironment<T> smallStepSemantics(ValueExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.- Specified by:
smallStepSemantics
in 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
public ValueEnvironment<T> assumeSatisfied(T eval)
Description copied from class:Environment
Assumes 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:
assumeSatisfied
in 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
public ValueEnvironment<T> glbAux(T lattice, java.util.Map<Identifier,T> function, ValueEnvironment<T> other) throws SemanticException
Description copied from class:Environment
Auxiliary 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:
glbAux
in 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 benull
other
- the other environment- Returns:
- the final instance of the glb
- Throws:
SemanticException
- if an error occurs during the computation
-
top
public ValueEnvironment<T> top()
Description copied from interface:Lattice
Yields 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:
top
in interfaceLattice<T extends NonRelationalValueDomain<T>>
- Returns:
- the top element
-
bottom
public ValueEnvironment<T> bottom()
Description copied from interface:Lattice
Yields 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:
bottom
in interfaceLattice<T extends NonRelationalValueDomain<T>>
- Returns:
- the bottom element
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classFunctionalLattice<ValueEnvironment<T extends NonRelationalValueDomain<T>>,Identifier,T extends NonRelationalValueDomain<T>>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classFunctionalLattice<ValueEnvironment<T extends NonRelationalValueDomain<T>>,Identifier,T extends NonRelationalValueDomain<T>>
-
representation
public DomainRepresentation representation()
Description copied from interface:SemanticDomain
Yields aDomainRepresentation
of the information contained in this domain's instance.- Specified by:
representation
in interfaceSemanticDomain<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,Identifier>
- Overrides:
representation
in classEnvironment<ValueEnvironment<T extends NonRelationalValueDomain<T>>,ValueExpression,T extends NonRelationalValueDomain<T>,T extends NonRelationalValueDomain<T>>
- Returns:
- the representation
-
-