Class Environment<M extends Environment<M,E,T>,E extends SymbolicExpression,T extends NonRelationalDomain<T,E,M>>
- java.lang.Object
-
- it.unive.lisa.analysis.lattices.FunctionalLattice<M,Identifier,T>
-
- it.unive.lisa.analysis.nonrelational.VariableLift<M,E,T>
-
- it.unive.lisa.analysis.nonrelational.Environment<M,E,T>
-
- Type Parameters:
M
- the concrete type of environmentE
- the type of expressions that this domain can evaluateT
- the concrete instance of theNonRelationalDomain
whose instances are mapped in this environment
- All Implemented Interfaces:
BaseLattice<M>
,Lattice<M>
,ScopedObject<M>
,SemanticDomain<M,E,Identifier>
,StructuredObject
,java.lang.Iterable<java.util.Map.Entry<Identifier,T>>
- Direct Known Subclasses:
HeapEnvironment
,TypeEnvironment
,ValueEnvironment
public abstract class Environment<M extends Environment<M,E,T>,E extends SymbolicExpression,T extends NonRelationalDomain<T,E,M>> extends VariableLift<M,E,T>
An environment for aNonRelationalDomain
, 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
FunctionalLattice.FunctionalLift<V extends Lattice<V>>, FunctionalLattice.KeyFunctionalLift<K>
-
-
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 Environment(T domain)
Builds an empty environment.Environment(T domain, java.util.Map<Identifier,T> function)
Builds an environment containing the given mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description M
assign(Identifier id, E expression, ProgramPoint pp, SemanticOracle oracle)
Yields a copy of this domain, whereid
has been assigned tovalue
.M
assume(E expression, ProgramPoint src, ProgramPoint dest, SemanticOracle oracle)
Yields a copy of this domain, modified by assuming that the given expression holds.T
eval(E expression, ProgramPoint pp, SemanticOracle oracle)
Evaluates the given expression to an abstract value.M
smallStepSemantics(E expression, ProgramPoint pp, SemanticOracle oracle)
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.-
Methods inherited from class it.unive.lisa.analysis.nonrelational.VariableLift
forgetIdentifier, forgetIdentifiersIf, knowsIdentifier, lubKeys, popScope, pushScope, satisfies, stateOfUnknown
-
Methods inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
equals, functionalLift, getKeys, getMap, getOtDefault, getState, getValues, glbAux, glbKeys, hashCode, isBottom, isTop, iterator, lessOrEqualAux, lubAux, mk, mkNewFunction, narrowingAux, putState, representation, toString, wideningAux
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.BaseLattice
glb, lessOrEqual, lub, narrowing, widening
-
Methods inherited from interface it.unive.lisa.analysis.SemanticDomain
forgetIdentifiers, getAllDomainInstances, getDomainInstance
-
Methods inherited from interface it.unive.lisa.util.representation.StructuredObject
representation
-
-
-
-
Constructor Detail
-
Environment
public Environment(T domain)
Builds an empty environment.- Parameters:
domain
- a singleton instance to be used during semantic operations to retrieve top and bottom values
-
Environment
public Environment(T domain, java.util.Map<Identifier,T> function)
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
-
-
Method Detail
-
assign
public M assign(Identifier id, E expression, ProgramPoint pp, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, whereid
has been assigned tovalue
.- Parameters:
id
- the identifier to assign the value toexpression
- the expression to assignpp
- the program point that where this operation is being evaluatedoracle
- the oracle for inter-domain communication- Returns:
- a copy of this domain, modified by the assignment
- Throws:
SemanticException
- if an error occurs during the computation
-
smallStepSemantics
public M smallStepSemantics(E expression, ProgramPoint pp, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.- Parameters:
expression
- the expression whose semantics need to be computedpp
- the program point that where this operation is being evaluatedoracle
- the oracle for inter-domain communication- Returns:
- a copy of this domain, modified accordingly to the semantics of
expression
- Throws:
SemanticException
- if an error occurs during the computation
-
eval
public T eval(E expression, ProgramPoint pp, SemanticOracle oracle) throws SemanticException
Evaluates the given expression to an abstract value.- Parameters:
expression
- the expression to evaluatepp
- the program point where the evaluation happensoracle
- the oracle for inter-domain communication- Returns:
- the abstract result of the evaluation
- Throws:
SemanticException
- if an error happens during the evaluation
-
assume
public M assume(E expression, ProgramPoint src, ProgramPoint dest, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, modified by assuming that the given expression holds. It is required that the returned domain is in relation with this one. A safe (but imprecise) implementation of this method can always returnthis
.- Parameters:
expression
- the expression to assume to hold.src
- the program point that where this operation is being evaluated, corresponding to the one that generated the given expressiondest
- the program point where the execution will move after the expression has been assumedoracle
- the oracle for inter-domain communication- Returns:
- the (optionally) modified copy of this domain
- Throws:
SemanticException
- if an error occurs during the computation
-
-