Class VariableLift<M extends VariableLift<M,E,T>,E extends SymbolicExpression,T extends NonRelationalElement<T,E,M>>
- java.lang.Object
-
- it.unive.lisa.analysis.lattices.FunctionalLattice<M,Identifier,T>
-
- it.unive.lisa.analysis.nonrelational.VariableLift<M,E,T>
-
- Type Parameters:
M
- the concrete type of the liftE
- the type of expressions that this domain can evaluateT
- the concrete instance of theNonRelationalElement
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:
Environment
,InferenceSystem
public abstract class VariableLift<M extends VariableLift<M,E,T>,E extends SymbolicExpression,T extends NonRelationalElement<T,E,M>> extends FunctionalLattice<M,Identifier,T> implements SemanticDomain<M,E,Identifier>
ASemanticDomain
implemented as a lift for aNonRelationalElement
s, 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 VariableLift(T domain)
Builds an empty lift.VariableLift(T domain, java.util.Map<Identifier,T> function)
Builds a lift containing the given mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description M
forgetIdentifier(Identifier id)
Forgets anIdentifier
.M
forgetIdentifiersIf(java.util.function.Predicate<Identifier> test)
Forgets allIdentifier
s that match the given predicate.boolean
knowsIdentifier(Identifier id)
Yieldstrue
if this instance is currently tracking abstract information for the given identifier.java.util.Set<Identifier>
lubKeys(java.util.Set<Identifier> k1, java.util.Set<Identifier> k2)
Yields the union of the keys betweenk1
andk2
.M
popScope(ScopeToken scope)
Pops the scope identified by the given token from this object.M
pushScope(ScopeToken scope)
Pushes a new scope, identified by the give token, in this object.Satisfiability
satisfies(E expression, ProgramPoint pp, SemanticOracle oracle)
Checks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSatisfiability
.T
stateOfUnknown(Identifier key)
Yields the value that should be returned byFunctionalLattice.getState(Object)
whenever the given key is not present in this map.-
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
assign, assume, forgetIdentifiers, getAllDomainInstances, getDomainInstance, smallStepSemantics
-
Methods inherited from interface it.unive.lisa.util.representation.StructuredObject
representation
-
-
-
-
Constructor Detail
-
VariableLift
public VariableLift(T domain)
Builds an empty lift.- Parameters:
domain
- a singleton instance to be used during semantic operations to retrieve top and bottom values
-
VariableLift
public VariableLift(T domain, java.util.Map<Identifier,T> function)
Builds a lift containing the given mapping. If function isnull
, the new lift is the top lift iflattice.isTop()
holds, and it is the bottom lift 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 lift; can benull
-
-
Method Detail
-
satisfies
public Satisfiability satisfies(E expression, ProgramPoint pp, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Checks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSatisfiability
.- Specified by:
satisfies
in interfaceSemanticDomain<M extends VariableLift<M,E,T>,E extends SymbolicExpression,T extends NonRelationalElement<T,E,M>>
- Parameters:
expression
- the expression whose satisfiability is to be evaluatedpp
- the program point that where this operation is being evaluatedoracle
- the oracle for inter-domain communication- Returns:
Satisfiability.SATISFIED
is the expression is satisfied by the values of this domain,Satisfiability.NOT_SATISFIED
if it is not satisfied, orSatisfiability.UNKNOWN
if 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
-
pushScope
public M pushScope(ScopeToken scope) throws SemanticException
Description copied from interface:ScopedObject
Pushes a new scope, identified by the give token, in this object. This causes all variables not associated with a scope (and thus visible) to be mapped to the given scope and hidden away, until the scope is popped withScopedObject.popScope(ScopeToken)
.- Specified by:
pushScope
in interfaceScopedObject<M extends VariableLift<M,E,T>>
- Parameters:
scope
- the token identifying the scope to push- Returns:
- a copy of this object where the local unscoped variables have been hidden
- Throws:
SemanticException
- if an error occurs during the computation
-
popScope
public M popScope(ScopeToken scope) throws SemanticException
Description copied from interface:ScopedObject
Pops the scope identified by the given token from this object. This causes all the visible variables (i.e. that are not mapped to a scope) to be removed, while the local variables that were associated to the given scope token (and thus hidden) will become visible again.- Specified by:
popScope
in interfaceScopedObject<M extends VariableLift<M,E,T>>
- Parameters:
scope
- the token of the scope to be restored- Returns:
- a copy of this object where the local variables have been removed, while the variables mapped to the given scope are visible again
- Throws:
SemanticException
- if an error occurs during the computation
-
forgetIdentifier
public M forgetIdentifier(Identifier id) throws SemanticException
Description copied from interface:SemanticDomain
Forgets anIdentifier
. This means that all information regarding the givenid
will be lost. This method should be invoked whenever an identifier gets out of scope.- Specified by:
forgetIdentifier
in interfaceSemanticDomain<M extends VariableLift<M,E,T>,E extends SymbolicExpression,T extends NonRelationalElement<T,E,M>>
- Parameters:
id
- the identifier to forget- Returns:
- the semantic domain without information about the given id
- Throws:
SemanticException
- if an error occurs during the computation
-
forgetIdentifiersIf
public M forgetIdentifiersIf(java.util.function.Predicate<Identifier> test) throws SemanticException
Description copied from interface:SemanticDomain
Forgets allIdentifier
s that match the given predicate. This means that all information regarding the those identifiers will be lost. This method should be invoked whenever an identifier gets out of scope.- Specified by:
forgetIdentifiersIf
in interfaceSemanticDomain<M extends VariableLift<M,E,T>,E extends SymbolicExpression,T extends NonRelationalElement<T,E,M>>
- Parameters:
test
- the test to identify the targets of the removal- Returns:
- the semantic domain without information about the ids
- Throws:
SemanticException
- if an error occurs during the computation
-
lubKeys
public java.util.Set<Identifier> lubKeys(java.util.Set<Identifier> k1, java.util.Set<Identifier> k2) throws SemanticException
Description copied from class:FunctionalLattice
Yields the union of the keys betweenk1
andk2
.- Overrides:
lubKeys
in classFunctionalLattice<M extends VariableLift<M,E,T>,Identifier,T extends NonRelationalElement<T,E,M>>
- Parameters:
k1
- the first key setk2
- the second key set- Returns:
- the union between
k1
andk2
- Throws:
SemanticException
- if something goes wrong while lifting the keys
-
stateOfUnknown
public T stateOfUnknown(Identifier key)
Description copied from class:FunctionalLattice
Yields the value that should be returned byFunctionalLattice.getState(Object)
whenever the given key is not present in this map.- Specified by:
stateOfUnknown
in classFunctionalLattice<M extends VariableLift<M,E,T>,Identifier,T extends NonRelationalElement<T,E,M>>
- Parameters:
key
- the key that is missing- Returns:
- the lattice element for keys not in the mapping
-
knowsIdentifier
public boolean knowsIdentifier(Identifier id)
Description copied from interface:SemanticDomain
Yieldstrue
if this instance is currently tracking abstract information for the given identifier.- Specified by:
knowsIdentifier
in interfaceSemanticDomain<M extends VariableLift<M,E,T>,E extends SymbolicExpression,T extends NonRelationalElement<T,E,M>>
- Parameters:
id
- the identifier- Returns:
- whether or not this domain knows about
id
-
-