Package daikon

Class VarInfoName

    • Method Detail

      • parse

        public static VarInfoName parse​(String name)
        Given the standard String representation of a variable name (like what appears in the normal output format), return the corresponding VarInfoName. This method can't parse all the strings that the VarInfoName name() method might produce, but it should be able to handle anything that appears in a decls file. Specifically, it can only handle a subset of the grammar of derived variables. For some values of "name", "name.equals(parse(e.name()))" might throw an exception, but if it completes normally, the result should be true.
      • name

        @Pure
        public @Interned String name​(@GuardSatisfied VarInfoName this)
        Return the String representation of this name in the default output format.
        Returns:
        the string representation (interned) of this name, in the default output format
      • name_impl

        protected abstract String name_impl​(@GuardSatisfied VarInfoName this)
        Returns the String representation of this name in the default output format. Result is not interned; the client (name()) does so, then caches the interned value.
      • esc_name

        public @Interned String esc_name()
        Return the String representation of this name in the esc style output format.
        Returns:
        the string representation (interned) of this name, in the esc style output format
      • esc_name_impl

        protected abstract String esc_name_impl()
        Returns the String representation of this name in the ESC style output format. Cached by esc_name().
      • simplify_name

        public @Interned String simplify_name()
        Returns the string representation (interned) of this name, in the Simplify tool output format in the pre-state context.
        Returns:
        the string representation (interned) of this name, in the Simplify tool output format in the pre-state context
      • simplify_name

        protected @Interned String simplify_name​(boolean prestate)
        Returns the string representation (interned) of this name, in the Simplify tool output format, in the given pre/post-state context.
        Parameters:
        prestate - if true, return the variable in a prestate context; if false, return the variable in a poststate context
        Returns:
        the string representation (interned) of this name, in the Simplify tool output format, in the given pre/post-state context
      • simplify_name_impl

        protected abstract String simplify_name_impl​(boolean prestate)
        Returns the String representation of this name in the simplify output format in either prestate or poststate context.
      • java_name

        public @Interned String java_name​(VarInfo v)
        Return the String representation of this name in the java style output format.
        Returns:
        the string representation (interned) of this name, in the java style output format
      • jml_name

        public @Interned String jml_name​(VarInfo v)
        Return the String representation of this name in the JML style output format.
      • dbc_name

        public @Interned String dbc_name​(VarInfo var)
        Return the String representation of this name in the dbc style output format.
        Parameters:
        var - the VarInfo which goes along with this VarInfoName. Used to determine the type of the variable.

        If var is null, the only repercussion is that if `this' is an "orig(x)" expression, it will be formatted in jml-style, something like "\old(x)".

        If var is not null and `this' is an "orig(x)" expressions, it will be formatted in Jtest's DBC style, as "$pre(type, x)".

        Returns:
        the string representation (interned) of this name, in the dbc style output format
      • identifier_name

        public @Interned String identifier_name()
        Return the String representation of this name using only letters, numbers, and underscores.
      • identifier_name_impl

        protected abstract String identifier_name_impl()
        Returns the name using only letters, numbers, and underscores. Cached and interned by identifier_name().
        Returns:
        the name using only letters, numbers, and underscores
      • name_using

        public String name_using​(OutputFormat format,
                                 VarInfo vi)
        Returns name of this in the specified format.
        Parameters:
        format - the format in which to return this variable name
        vi - the VarInfo for this variable name
        Returns:
        name of this in the specified format
      • repr

        public String repr​(@GuardSatisfied @UnknownSignedness VarInfoName this)
        Returns the name, in a debugging format.
        Returns:
        the name, in a debugging format
      • repr_impl

        protected abstract String repr_impl​(@GuardSatisfied @UnknownSignedness VarInfoName this)
        Returns the name in a verbose debugging format. Cached by repr().
        Returns:
        the name in a verbose debugging format
      • isLiteralConstant

        @Pure
        public boolean isLiteralConstant()
        Returns true when this is "0", "-1", "1", etc.
        Returns:
        true when this is "0", "-1", "1", etc
      • inOrderTraversal

        public Collection<VarInfoNameinOrderTraversal​(@Interned VarInfoName this)
        Returns the nodes of this, as given by an inorder traversal.
        Returns:
        the nodes of this, as given by an inorder traversal
      • hasNode

        public boolean hasNode​(VarInfoName node)
        Returns true iff the given node can be found in this. If the node has children, the whole subtree must match.
        Parameters:
        node - a variable name
        Returns:
        true iff the given node can be found in this. If the node has children, the whole subtree must match
      • hasNodeOfType

        public boolean hasNodeOfType​(Class<?> type)
        Returns true iff a node of the given type exists in this.
        Parameters:
        type - the type to search for
        Returns:
        true iff a node of the given type exists in this
      • hasTypeOf

        public boolean hasTypeOf()
        Returns true iff a TypeOf node exists in this.
        Returns:
        true iff a TypeOf node exists in this
      • isThis

        @Pure
        public boolean isThis()
        Returns whether or not this name refers to the 'this' variable of a class. True for both normal and prestate versions of the variable.
      • inPrestateContext

        public boolean inPrestateContext​(@Interned VarInfoName this,
                                         VarInfoName node)
        Returns true if the given node is in a prestate context within this tree.
        Parameters:
        node - a member of this tree
        Returns:
        true if the given node is in a prestate context within this tree
      • isAllPrestate

        @Pure
        public boolean isAllPrestate​(@Interned VarInfoName this)
        Returns true if every variable in the name is an orig(...) variable.
        Returns:
        true if every variable in the name is an orig(...) variable
      • includesSimpleName

        public boolean includesSimpleName​(@Interned VarInfoName this,
                                          String name)
        Returns true if this VarInfoName contains a simple variable whose name is NAME.
        Parameters:
        name - the name to search for in this VarInfoName
        Returns:
        true if this VarInfoName contains a simple variable whose name is NAME
      • replace

        public VarInfoName replace​(@Interned VarInfoName this,
                                   VarInfoName node,
                                   VarInfoName replacement)
        Replace the first instance of node by replacement, in the data structure rooted at this.
      • equals

        @EnsuresNonNullIf(result=true,
                          expression="#1")
        @Pure
        public boolean equals​(@GuardSatisfied VarInfoName this,
                              @GuardSatisfied @Nullable Object o)
        Overrides:
        equals in class Object
      • equalsVarInfoName

        @EnsuresNonNullIf(result=true,
                          expression="#1")
        @Pure
        public boolean equalsVarInfoName​(@GuardSatisfied @Interned VarInfoName this,
                                         @GuardSatisfied VarInfoName other)
      • hashCode

        @Pure
        public int hashCode​(@GuardSatisfied @UnknownSignedness VarInfoName this)
        Overrides:
        hashCode in class Object
      • isApplySizeSafe

        @Pure
        public boolean isApplySizeSafe()
        Returns true iff applySize will not throw an exception.
        Returns:
        true iff applySize will not throw an exception
        See Also:
        applySize()
      • applySize

        public VarInfoName applySize​(@Interned VarInfoName this)
        Returns a name for the size of this (this object should be a sequence). Form is like "size(a[])" or "a.length".
        Returns:
        a name for the size of this
      • getSliceBounds

        public @Interned VarInfoName[] getSliceBounds​(@Interned VarInfoName this)
        If this is a slice, (potentially in pre-state), return its lower and upper bounds, which can be subtracted to get one less than its size.
      • applyFunction

        public VarInfoName applyFunction​(@Interned VarInfoName this,
                                         String function)
        Returns a name for a unary function applied to this object. The result is like "sum(this)".
        Parameters:
        function - the function to apply
        Returns:
        a name for the function applied to this
      • applyFunctionOfN

        public static VarInfoName applyFunctionOfN​(String function,
                                                   List<VarInfoName> vars)
        Returns a name for a function applied to more than one argument. The result is like "sum(var1, var2)".
        Parameters:
        function - the name of the function
        vars - the arguments to the function, of type VarInfoName
        Returns:
        a name for a function applied to multiple arguments
      • applyFunctionOfN

        public static VarInfoName applyFunctionOfN​(String function,
                                                   @Interned VarInfoName[] vars)
        Returns a name for a function of more than one argument. The result is like "sum(var1, var2)".
        Parameters:
        function - the name of the function
        vars - the arguments to the function
      • applyIntersection

        public VarInfoName applyIntersection​(@Interned VarInfoName this,
                                             VarInfoName seq2)
        Returns a name for the intersection of with another sequence, like "intersect(a[], b[])".
        Parameters:
        seq2 - the variable to intersect with
        Returns:
        the name for the intersection of this and seq2
      • applyUnion

        public VarInfoName applyUnion​(@Interned VarInfoName this,
                                      VarInfoName seq2)
        Returns a name for the union of this with another sequence, like "union(a[], b[])".
        Parameters:
        seq2 - the variable to union with
        Returns:
        the name for the intersection of this and seq2
      • applyField

        public VarInfoName applyField​(@Interned VarInfoName this,
                                      String field)
        Returns a 'getter' operation for some field of this name, like a.foo if this is a.
        Parameters:
        field - the field
        Returns:
        the name for the given field of this
      • applyTypeOf

        public VarInfoName applyTypeOf​(@Interned VarInfoName this)
        Returns a name for the type of this object; form is like "this.getClass().getName()" or "\typeof(this)".
        Returns:
        the name for the type of this object
      • applyPrestate

        public VarInfoName applyPrestate​(@Interned VarInfoName this)
        Returns a name for a the prestate value of this object; form is like "orig(this)" or "\old(this)".
      • applyPoststate

        public VarInfoName applyPoststate​(@Interned VarInfoName this)
        Returns a name for a the poststate value of this object; form is like "new(this)" or "\new(this)".
        Returns:
        the name for the poststate value of this object
      • applyAdd

        public VarInfoName applyAdd​(@Interned VarInfoName this,
                                    int amount)
        Returns a name for the this term plus a constant, like "this-1" or "this+1".
      • applyDecrement

        public VarInfoName applyDecrement​(@Interned VarInfoName this)
        Returns a name for the decrement of this term, like "this-1".
      • applyIncrement

        public VarInfoName applyIncrement​(@Interned VarInfoName this)
        Returns a name for the increment of this term, like "this+1".
      • applyElements

        public VarInfoName applyElements​(@Interned VarInfoName this)
        Returns a name for the elements of a container (as opposed to the identity of the container) like "this[]" or "(elements this)".
        Returns:
        the name for the elements of this container
      • applySlice

        public VarInfoName applySlice​(@Interned VarInfoName this,
                                      @Nullable VarInfoName i,
                                      @Nullable VarInfoName j)
        Returns a name for a slice of element selected from a sequence, like "this[i..j]". If an endpoint is null, it means "from the start" or "to the end".