Package daikon

Class ProglangType

  • All Implemented Interfaces:
    Serializable

    @Interned
    public final class ProglangType
    extends Object
    implements Serializable
    Represents the type of a variable, for its declared type, dtrace file representation, and internal representations. ProgLangTypes are interned, so they can be == compared.
    See Also:
    Serialized Form
    • Method Detail

      • dimensions

        public int dimensions()
        Return the number of dimensions (zero for a non-array).
        Returns:
        the number of dimensions
      • isArray

        @Pure
        public boolean isArray()
      • parse

        public static ProglangType parse​(String rep)
        This can't be a constructor because it returns a canonical representation (that can be compared with ==), not necessarily a new object.
        Parameters:
        rep - the name of the type, optionally suffixed by (possibly multiple) "[]"
      • rep_parse

        public static ProglangType rep_parse​(String rep)
        Like parse, but normalizes representation types (such as converting "float" to "double"), in order to return real file representation types even if the file contains something slightly different than the prescribed format.
      • readResolve

        public Object readResolve()
                           throws ObjectStreamException
        For serialization; indicates which object to return instead of the one that was just read from the file. This obviates the need to write a readObject method that interns the interned fields (just "base").
        Throws:
        ObjectStreamException
      • elementType

        public ProglangType elementType​(@GuardSatisfied ProglangType this)
        Returns the type of elements of this. They may themselves be arrays if this is multidimensional.
      • parse_value

        public final @Nullable @Interned Object parse_value​(String value,
                                                            LineNumberReader reader,
                                                            String filename)
        Given a string representation of a value (of the type represented by this ProglangType), return the (canonicalized) interpretation of that value.

        This ProglangType (the method receiver) is assumed to be a representation type, not an arbitrary type in the underlying programming language.

        If the type is an array and there are any nonsensical elements in the array, the entire array is considered to be nonsensical (indicated by returning null). This is not really correct, but it is a reasonable path to take for now. (jhp, Feb 12, 2005)

      • isIndex

        @Pure
        public boolean isIndex()
      • isScalar

        @Pure
        public boolean isScalar()
      • isFloat

        @Pure
        public boolean isFloat()
      • isObject

        @Pure
        public boolean isObject()
        Return true if this is java.lang.Object.
        Returns:
        true if this is java.lang.Object
      • baseIsObject

        public boolean baseIsObject()
        Return true if the base (the final element type) is a reference type rather than integer, float, or boolean.
        Returns:
        true if the base is Object
      • isString

        @Pure
        public boolean isString()
      • isPointerFileRep

        @Pure
        public boolean isPointerFileRep()
        Does this type represent a pointer? Should only be applied to file_rep types.
      • comparableOrSuperclassEitherWay

        public boolean comparableOrSuperclassEitherWay​(ProglangType other)
        Return true if these two types can be sensibly compared to one another, or if one can be cast to the other. For instance, int is castable to long, but boolean is not castable to float, and int is not castable to int[]. This is a reflexive relationship, but not a transitive one because it might not be true for two children of a superclass, even though it's true for the superclass.
      • comparableOrSuperclassOf

        public boolean comparableOrSuperclassOf​(ProglangType other)
        Return true if these two types can be sensibly compared to one another, and if non-integral, whether this could be a superclass of other. A List is comparableOrSuperclassOf to a ArrayList, but not the other way around. This is a transitive method, but not reflexive.
      • format

        @SideEffectFree
        public String format​(@GuardSatisfied ProglangType this)
      • is_function_pointer

        @Pure
        public boolean is_function_pointer()
        Returns whether or not this declared type is a function pointer Only valid if the front end marks the function pointer with the name '*func'.