Package it.unive.lisa.analysis.lattices
Class FunctionalLattice<F extends FunctionalLattice<F,K,V>,K,V extends Lattice<V>>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<F>
-
- it.unive.lisa.analysis.lattices.FunctionalLattice<F,K,V>
-
- Type Parameters:
F- the concreteFunctionalLatticetypeK- the concrete type of the keys of this functionV- the concreteLatticetype of the values of this function
- All Implemented Interfaces:
Lattice<F>,java.lang.Iterable<java.util.Map.Entry<K,V>>
- Direct Known Subclasses:
CFGResults,Environment,FixpointResults,StatementStore
public abstract class FunctionalLattice<F extends FunctionalLattice<F,K,V>,K,V extends Lattice<V>> extends BaseLattice<F> implements java.lang.Iterable<java.util.Map.Entry<K,V>>
A generic functional abstract domain that performs the functional lifting of the lattice on the elements of the co-domain.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceFunctionalLattice.FunctionalLift<V extends Lattice<V>>Interface for the lift of lattice elements.protected static interfaceFunctionalLattice.KeyFunctionalLift<K>Interface for the left of key sets.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<K,V>functionThe function implemented by this lattice.VlatticeThe underlying lattice.-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFunctionalLattice(V lattice)Builds the lattice.protectedFunctionalLattice(V lattice, java.util.Map<K,V> function)Builds the lattice by cloning the given function.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)protected FfunctionalLift(F other, FunctionalLattice.KeyFunctionalLift<K> keyLifter, FunctionalLattice.FunctionalLift<V> valueLifter)Yields the functional lift betweenthisandother.java.util.Set<K>getKeys()Yields the set of keys currently in this lattice.java.util.Map<K,V>getMap()Yields the map associated with this functional lattice element.VgetState(K key)Yields the state associated to the given key.java.util.Collection<V>getValues()Yields the values of this functional lattice.protected java.util.Set<K>glbKeys(java.util.Set<K> k1, java.util.Set<K> k2)Yields the intersection of the keys betweenk1andk2.inthashCode()java.util.Iterator<java.util.Map.Entry<K,V>>iterator()booleanlessOrEqualAux(F other)Yieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.FlubAux(F other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.protected java.util.Set<K>lubKeys(java.util.Set<K> k1, java.util.Set<K> k2)Yields the union of the keys betweenk1andk2.protected abstract Fmk(V lattice, java.util.Map<K,V> function)Builds a instance of this class from the given lattice instance and the given mapping.protected java.util.Map<K,V>mkNewFunction(java.util.Map<K,V> other)Creates a new instance of the underlying function.FputState(K key, V state)Yields an instance of this class equal to the receiver of the call, but withkeymapped tostate.java.lang.StringtoString()FwideningAux(F other)Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lub, widening
-
-
-
-
Constructor Detail
-
FunctionalLattice
protected FunctionalLattice(V lattice)
Builds the lattice.- Parameters:
lattice- the underlying lattice
-
-
Method Detail
-
mkNewFunction
protected java.util.Map<K,V> mkNewFunction(java.util.Map<K,V> other)
Creates a new instance of the underlying function. The purpose of this method is to provide a common function implementation to every subclass that does not have implementation-specific requirements.- Parameters:
other- an optional function to copy, can benull- Returns:
- a new function, either empty or containing the same data of the given one
-
getKeys
public final java.util.Set<K> getKeys()
Yields the set of keys currently in this lattice.- Returns:
- the set of keys
-
getState
public final V getState(K key)
Yields the state associated to the given key.- Parameters:
key- the key- Returns:
- the state
-
putState
public final F putState(K key, V state)
Yields an instance of this class equal to the receiver of the call, but withkeymapped tostate.- Parameters:
key- the keystate- the state- Returns:
- the new instance of this class with the updated mapping
-
mk
protected abstract F mk(V lattice, java.util.Map<K,V> function)
Builds a instance of this class from the given lattice instance and the given mapping.- 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
-
lubAux
public F lubAux(F other) throws SemanticException
Description copied from class:BaseLatticePerforms the least upper bound operation between this lattice element and the given one, 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))
- Specified by:
lubAuxin classBaseLattice<F extends FunctionalLattice<F,K,V>>- Parameters:
other- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
wideningAux
public F wideningAux(F other) throws SemanticException
Description copied from class:BaseLatticePerforms the widening operation between this lattice element and the given one, 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))
- Specified by:
wideningAuxin classBaseLattice<F extends FunctionalLattice<F,K,V>>- Parameters:
other- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
functionalLift
protected final F functionalLift(F other, FunctionalLattice.KeyFunctionalLift<K> keyLifter, FunctionalLattice.FunctionalLift<V> valueLifter) throws SemanticException
Yields the functional lift betweenthisandother.- Parameters:
other- the other functional latticekeyLifter- the key liftervalueLifter- the value lifter- Returns:
- the intersection between
k1andk2 - Throws:
SemanticException- if something goes wrong while lifting the lattice elements
-
lubKeys
protected java.util.Set<K> lubKeys(java.util.Set<K> k1, java.util.Set<K> k2) throws SemanticException
Yields the union of the keys betweenk1andk2.- Parameters:
k1- the first key setk2- the second key set- Returns:
- the union between
k1andk2 - Throws:
SemanticException- if something goes wrong while lifting the keys
-
glbKeys
protected java.util.Set<K> glbKeys(java.util.Set<K> k1, java.util.Set<K> k2) throws SemanticException
Yields the intersection of the keys betweenk1andk2.- Parameters:
k1- the first key setk2- the second key set- Returns:
- the intersection between
k1andk2 - Throws:
SemanticException- if something goes wrong while lifting the key sets
-
lessOrEqualAux
public boolean lessOrEqualAux(F other) throws SemanticException
Description copied from class:BaseLatticeYieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, 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))
- Specified by:
lessOrEqualAuxin classBaseLattice<F extends FunctionalLattice<F,K,V>>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<F extends FunctionalLattice<F,K,V>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<F extends FunctionalLattice<F,K,V>>
-
toString
public java.lang.String toString()
- Specified by:
toStringin classBaseLattice<F extends FunctionalLattice<F,K,V>>
-
iterator
public java.util.Iterator<java.util.Map.Entry<K,V>> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<F extends FunctionalLattice<F,K,V>>
-
getValues
public java.util.Collection<V> getValues()
Yields the values of this functional lattice.- Returns:
- the values of this functional lattice
-
-