Class DaikonVariableInfo

    • Constructor Detail

      • DaikonVariableInfo

        protected DaikonVariableInfo​(String theName,
                                     String typeName,
                                     String repTypeName)
        Constructs a non-array-type DaikonVariableInfo object.
        Parameters:
        theName - the name of the variable
        typeName - the name of the type
        repTypeName - the name of the representation type
      • DaikonVariableInfo

        protected DaikonVariableInfo​(String theName,
                                     String typeName,
                                     String repTypeName,
                                     boolean arr)
        Constructs a DaikonVariableInfo object.
        Parameters:
        theName - the variable's name
        arr - true iff the variable is an array
    • Method Detail

      • getName

        public @Nullable String getName​(@GuardSatisfied DaikonVariableInfo this)
        Returns the name of this variable.
      • addChild

        protected void addChild​(DaikonVariableInfo info)
        Add a child to this node. Should only be called while the tree is being constructed.
        Parameters:
        info - the child object, must be non-null. The child's fields name, typeName, repTypeName, and compareInfoString should also be non-null.
      • toString

        @SideEffectFree
        public String toString​(@GuardSatisfied DaikonVariableInfo this)
        Returns a string representation of this node.
        Overrides:
        toString in class Object
      • treeString

        public String treeString()
        Returns a string representation of this node and its descandants.
        Returns:
        a string representation of this node and its descandants
      • iterator

        public Iterator<DaikonVariableInfoiterator()
        Returns an iterator over all the node's children. Don't modify the list of children through the iterator, as an unmodifiable list is used to generate the iterator.
        Specified by:
        iterator in interface Iterable<DaikonVariableInfo>
        Returns:
        an iterator over all the node's children
      • getMyValFromParentVal

        public abstract @Nullable Object getMyValFromParentVal​(Object parentVal)
        Given a value corresponding to the parent of this, return the value of this.

        For instance, if the variable a has a field b, then calling getMyValFromParentVal(val_of_a) will return the value of a.b .

        Parameters:
        parentVal - the parent object. Can be null for static fields.
        Returns:
        the value for this, computed from parentVal
      • getDTraceValueString

        public String getDTraceValueString​(Object val)
        Returns a String representation of this object suitable for a .dtrace file.
        Parameters:
        val - the object whose value to print
      • getValueStringOfList

        protected String getValueStringOfList​(List<Object> theValues)
        Returns a string representation of the values of a list of values as if it were an array.
        Parameters:
        theValues - the values to print out
      • addParameters

        protected void addParameters​(ClassInfo cinfo,
                                     Member method,
                                     List<String> argnames,
                                     int depth)
        Add the parameters of the given method to this node.
        Parameters:
        cinfo - the method's class
        method - the method
        argnames - the method's arguments
        depth - the remaining depth to print variables to
      • addClassVars

        @RequiresNonNull("#1.clazz")
        protected void addClassVars​(ClassInfo cinfo,
                                    boolean dontPrintInstanceVars,
                                    Class<?> type,
                                    String offset,
                                    int depth)
        Adds class variables (i.e., the fields) for the given type and attach new nodes as children of this node.
        Parameters:
        type - the class whose fields should all be added to this node
        offset - the prefix for variables -- that is, the expression whose fields are being printed
        depth - the remaining depth to print variables to
      • addParamDeclVar

        protected DaikonVariableInfo addParamDeclVar​(ClassInfo cinfo,
                                                     Class<?> type,
                                                     String name,
                                                     String offset,
                                                     int depth,
                                                     int argNum,
                                                     int param_offset)
        Adds the decl info for a single parameter as a child of this node. Also adds "derived" variables such as the runtime .class variable.
        Returns:
        the newly created DaikonVariableInfo object, whose parent is this
      • addDeclVar

        protected DaikonVariableInfo addDeclVar​(Field field,
                                                String offset,
                                                StringBuilder buf)
        Adds the decl info for a single class variable (a field) as a child of this node. Also adds "derived" variables such as the runtime .class variable.
        Returns:
        the newly created DaikonVariableInfo object, whose parent is this
      • stdClassName

        public static @BinaryName String stdClassName​(Class<?> type)
        Returns the class name of the specified class as a binary name (i.e., as the class would have been declared in Java source code, except with '$' instead of '.' separating outer and inner classes).
      • getRepName

        public static String getRepName​(Class<?> type,
                                        boolean asArray)
        Given a type, gets the representation type to be used in Daikon. For example, the representation type of a class object is "hashcode."
        Parameters:
        type - the type of the variable
        asArray - whether the variable is being output as an array (true) or as a pointer (false)
        Returns:
        the representation type as a string
      • shouldAddRuntimeClass

        protected static boolean shouldAddRuntimeClass​(Class<?> type)
        Determines if type needs a corresponding .class runtime class variable.

        The .class variable is printed for interfaces, abstract classes, and Object. For these types, the run-time class is always (or, for Object, usually) different than the declared type. An alternate, and possibly more useful, heuristic would be to print the .class variable for any type that has subtypes.

        Parameters:
        type - the variable's type
      • isFieldVisible

        public static boolean isFieldVisible​(Class<?> current,
                                             Field field)
        Returns whether or not the specified field is visible from the Class current. All fields within instrumented classes are considered visible from everywhere (to match dfej behavior).
      • checkForDerivedVariables

        protected void checkForDerivedVariables​(Class<?> type,
                                                String theName,
                                                String offset)
        Checks for "derived" Chicory variables: .class, .tostring, and java.util.List implementors and adds appropriate children to this node.
      • checkForListDecl

        protected void checkForListDecl​(Class<?> type,
                                        String theName,
                                        String offset)
        Determines if type implements list and prints associated decls, if necessary.
      • checkForRuntimeClass

        protected void checkForRuntimeClass​(Class<?> type,
                                            String theName,
                                            String offset)
        Checks the given type to see if it requires a .class addition to the decls file. If so, it adds the correct child to this node.
      • implementsList

        public static boolean implementsList​(Class<?> type)
        Returns true iff type implements the List interface.
        Returns:
        true iff type implements the List interface
      • addChildNodes

        @RequiresNonNull("#1.clazz")
        protected void addChildNodes​(ClassInfo cinfo,
                                     Class<?> type,
                                     String theName,
                                     String offset,
                                     int depthRemaining)
        Explores the tree one level deeper (see DaikonVariableInfo). This method adds child nodes to this node.

        For example: "recurse" on a hashcode array object to print the actual array of values or recurse on hashcode variable to print its fields. Also accounts for derived variables (.class, .tostring) and "recurses" on arrays (that is, adds a variable to print out the arrays's elements as opposed to just the hashcode of the array).

        Parameters:
        theName - the name of the variable currently being examined, such as "ballCount"
        offset - the representation of the variables we have previously examined. For examples, offset could be "this." in which case offset + name would be "this.ballCount.".
      • systemClass

        public static boolean systemClass​(Class<?> type)
        Returns whether or not the fields of the specified class should be included, based on whether the Class type is a system class or not. Right now, any system classes are excluded, but a better way of determining this is probably necessary.
      • getTypeName

        public String getTypeName()
        Returns the declared type name of this variable. May include auxiliary information (represented as a suffix starting with "#").
        See Also:
        getTypeNameOnly()
      • getRepTypeName

        public String getRepTypeName()
        Returns the representation type name of this variable.
      • get_const_val

        public @Nullable String get_const_val()
        Returns the constant value of the variable. If the variable is not static and final, or if the constant value is not available in the class file, returns null.
      • get_function_args

        public @Nullable String get_function_args()
        Returns the function args of the variable. If the variable is not a function, or does not have any arguments, returns null.
      • getCompareString

        public String getCompareString()
        Returns the comparability information for this variable.
      • declShouldPrint

        public boolean declShouldPrint()
        Return true iff the DeclWriter should print this node.
      • dTraceShouldPrint

        public boolean dTraceShouldPrint()
        Return true iff the DTraceWriter should print this node.
      • isArray

        public boolean isArray()
        Returns whether or not this variable is an array.
      • isHashcode

        public boolean isHashcode()
        Returns whether or not this variable has a rep type of hashcode.
      • isInt

        public boolean isInt()
        Returns whether or not the declared type of this variable is int.
      • get_var_kind

        public abstract VarKind get_var_kind()
        Returns the kind of the variable (array, field, function, etc)
      • get_relative_name

        public @Nullable String get_relative_name()
        Returns the name of this variable relative to its enclosing variable. For example the relative name for 'this.a' is 'a'.
      • get_var_flags

        public EnumSet<VarFlagsget_var_flags()
        Returns the variable flags for this variable. Subclasses should call super(), then add in any flags that they add.
      • isStatic

        @Pure
        public boolean isStatic()
        Returns true iff the variable is static. Overridden by subclasses that can be static.