Class Environment<M extends Environment<M,​E,​T,​V>,​E extends SymbolicExpression,​T extends NonRelationalElement<T,​E,​M>,​V extends Lattice<V>>

    • 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 is null, the new environment is the top environment if lattice.isTop() holds, and it is the bottom environment if lattice.isBottom() holds.
        Parameters:
        domain - a singleton instance 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
    • Method Detail

      • copy

        public abstract M copy()
        Copies this environment. The function of the returned environment must be a (shallow) copy of the one of the given environment.
        Returns:
        a copy of the given environment
      • eval

        public abstract org.apache.commons.lang3.tuple.Pair<T,​V> eval​(E expression,
                                                                            ProgramPoint pp)
                                                                     throws SemanticException
        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>, where evaluation result is the true result of the evaluation, while abstract element is the element derived by the result that is to be stored inside the environment mapped to an identifier.
        Parameters:
        expression - the expression to evaluate
        pp - the program point where the evaluation happens
        Returns:
        the result of the evaluation
        Throws:
        SemanticException - if something goes wrong during the evaluation
      • assume

        public M assume​(E expression,
                        ProgramPoint pp)
                 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 return this.
        Specified by:
        assume in interface SemanticDomain<M extends Environment<M,​E,​T,​V>,​E extends SymbolicExpression,​T extends NonRelationalElement<T,​E,​M>>
        Parameters:
        expression - the expression to assume to hold.
        pp - the program point that where this operation is being evaluated
        Returns:
        the (optionally) modified copy of this domain
        Throws:
        SemanticException - if an error occurs during the computation
      • assumeSatisfied

        public abstract M assumeSatisfied​(V eval)
                                   throws SemanticException
        Assumes that an expression, that evaluated to eval, is always satisfied by this environment. This auxiliary method serves as a constructor for the final concrete instance of environment.
        Parameters:
        eval - the result of the evaluation of the expression that is always satisfied
        Returns:
        the (possibly) updated environment
        Throws:
        SemanticException - if an error occurs during the computation
      • glb

        public M glb​(M other)
              throws SemanticException
        Performs the greatest lower bound between this environment and other.
        Parameters:
        other - the other environment
        Returns:
        the greatest lower bound between this environment and other
        Throws:
        SemanticException - if something goes wrong during the computation
      • glbAux

        public abstract M glbAux​(T lattice,
                                 java.util.Map<Identifier,​T> function,
                                 M other)
                          throws SemanticException
        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.
        Parameters:
        lattice - the lattice that is the result of the glb
        function - the function that is the result of the glb (might be null
        other - the other environment
        Returns:
        the final instance of the glb
        Throws:
        SemanticException - if an error occurs during the computation
      • popScope

        public M popScope​(ScopeToken scope)
                   throws SemanticException
        Description copied from interface: SemanticDomain
        Pops the scope identified by the given token from the domain. This causes all the visible variables (i.e. that are not mapped to a scope) to be removed from the domain, while the local variables that were associated to the given scope token (and thus hidden) will become visible again.
        Specified by:
        popScope in interface SemanticDomain<M extends Environment<M,​E,​T,​V>,​E extends SymbolicExpression,​T extends NonRelationalElement<T,​E,​M>>
        Parameters:
        scope - the token of the scope to be restored
        Returns:
        a copy of this domain 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