Class SymbolicExpression

    • Constructor Detail

      • SymbolicExpression

        protected SymbolicExpression​(Type staticType,
                                     CodeLocation location)
        Builds the symbolic expression.
        Parameters:
        staticType - the static type of this expression
        location - the code location of the statement that has generated this expression
    • Method Detail

      • getStaticType

        public Type getStaticType()
        Yields the static type of this expression.
        Returns:
        the static type
      • getRuntimeTypes

        public final java.util.Set<Type> getRuntimeTypes​(TypeSystem types)
        Yields the runtime types of this expression. If setRuntimeTypes(Set) has never been called before, this method will return all instances of the static type.
        Parameters:
        types - the type system that knows about the types of the program point where this method is called. If hasRuntimeTypes() returns true, this parameter can be null
        Returns:
        the runtime types
      • setRuntimeTypes

        public void setRuntimeTypes​(java.util.Set<Type> types)
        Sets the runtime types to the given set of types.
        Parameters:
        types - the runtime types
      • hasRuntimeTypes

        public boolean hasRuntimeTypes()
        Yields true if this expression's runtime types have been set (even to the empty set). If this method returns false, then getDynamicType() will yield the same as getStaticType(), and getRuntimeTypes(TypeSystem) returns all possible instances of the static type.
        Returns:
        whether or not runtime types are set for this expression
      • getDynamicType

        public final Type getDynamicType()
        Yields the dynamic type of this expression, that is, the most specific common supertype of all its runtime types (available through getRuntimeTypes(TypeSystem). If setRuntimeTypes(Set) has never been called before, this method will return the static type.
        Returns:
        the dynamic type of this expression
      • pushScope

        public abstract SymbolicExpression pushScope​(ScopeToken token)
                                              throws SemanticException
        Pushes a new scope, identified by the give token, in the expression. This causes all Variables to become OutOfScopeIdentifiers associated with the given token.
        Parameters:
        token - the token identifying the scope to push
        Returns:
        a copy of this expression where the local variables have gone out of scope
        Throws:
        SemanticException - if an error occurs during the computation
      • popScope

        public abstract SymbolicExpression popScope​(ScopeToken token)
                                             throws SemanticException
        Pops the scope identified by the given token from the expression. This causes all the invisible variables (i.e. OutOfScopeIdentifiers) mapped to the given scope to become visible (i.e. Variables) again.
        Parameters:
        token - the token of the scope to be restored
        Returns:
        a copy of this expression where the local variables associated with the given scope are visible again
        Throws:
        SemanticException - if an error occurs during the computation
      • accept

        public abstract <T> T accept​(ExpressionVisitor<T> visitor,
                                     java.lang.Object... params)
                              throws SemanticException
        Accepts an ExpressionVisitor, visiting this expression recursively.
        Type Parameters:
        T - the type of value produced by the visiting callbacks
        Parameters:
        visitor - the visitor
        params - additional optional parameters to pass to each visiting callback
        Returns:
        the value produced by the visiting operation
        Throws:
        SemanticException - if an error occurs during the visiting
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getCodeLocation

        public CodeLocation getCodeLocation()
        Yields the code location of the statement that has generated this symbolic expression. The code location is not used for the equality between two symbolic expressions.
        Returns:
        the code location of the statement that has generated this symbolic expression
      • toString

        public abstract java.lang.String toString()
        Overrides:
        toString in class java.lang.Object