Class FunctionalLattice<F extends FunctionalLattice<F,​K,​V>,​K,​V extends Lattice<V>>

  • Type Parameters:
    F - the concrete FunctionalLattice type
    K - the concrete type of the keys of this function
    V - the concrete Lattice type 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.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected FunctionalLattice​(V lattice)
      Builds the lattice.
      protected FunctionalLattice​(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
      boolean equals​(java.lang.Object obj)  
      protected F functionalLift​(F other, FunctionalLattice.KeyFunctionalLift<K> keyLifter, FunctionalLattice.FunctionalLift<V> valueLifter)
      Yields the functional lift between this and other.
      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.
      V getState​(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 between k1 and k2.
      int hashCode()  
      java.util.Iterator<java.util.Map.Entry<K,​V>> iterator()  
      boolean lessOrEqualAux​(F other)
      Yields true if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.
      F lubAux​(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 between k1 and k2.
      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.
      protected java.util.Map<K,​V> mkNewFunction​(java.util.Map<K,​V> other)
      Creates a new instance of the underlying function.
      F putState​(K key, V state)
      Yields an instance of this class equal to the receiver of the call, but with key mapped to state.
      java.lang.String toString()  
      F wideningAux​(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 java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • function

        protected java.util.Map<K,​V extends Lattice<V>> function
        The function implemented by this lattice.
      • lattice

        public final V extends Lattice<V> lattice
        The underlying lattice.
    • Constructor Detail

      • FunctionalLattice

        protected FunctionalLattice​(V lattice)
        Builds the lattice.
        Parameters:
        lattice - the underlying lattice
      • FunctionalLattice

        protected FunctionalLattice​(V lattice,
                                    java.util.Map<K,​V> function)
        Builds the lattice by cloning the given function.
        Parameters:
        lattice - the underlying lattice
        function - the function to clone
    • 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 be null
        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 with key mapped to state.
        Parameters:
        key - the key
        state - 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 values
        function - the function representing the mapping contained in the new environment; can be null
        Returns:
        a new instance of this class
      • lubAux

        public F lubAux​(F other)
                 throws SemanticException
        Description copied from class: BaseLattice
        Performs 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:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        lubAux in class BaseLattice<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: BaseLattice
        Performs 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:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        wideningAux in class BaseLattice<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
      • 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 between k1 and k2.
        Parameters:
        k1 - the first key set
        k2 - the second key set
        Returns:
        the union between k1 and k2
        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 between k1 and k2.
        Parameters:
        k1 - the first key set
        k2 - the second key set
        Returns:
        the intersection between k1 and k2
        Throws:
        SemanticException - if something goes wrong while lifting the key sets
      • lessOrEqualAux

        public boolean lessOrEqualAux​(F other)
                               throws SemanticException
        Description copied from class: BaseLattice
        Yields true if 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:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        lessOrEqualAux in class BaseLattice<F extends FunctionalLattice<F,​K,​V>>
        Parameters:
        other - the other lattice element
        Returns:
        true if and only if that condition holds
        Throws:
        SemanticException - if an error occurs during the computation
      • iterator

        public java.util.Iterator<java.util.Map.Entry<K,​V>> iterator()
        Specified by:
        iterator in interface java.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
      • getMap

        public java.util.Map<K,​V> getMap()
        Yields the map associated with this functional lattice element.
        Returns:
        the map associated with this functional lattice element.