Package iota

Class Type

java.lang.Object
iota.Type

class Type extends Object
A class for representing iota types. All types are represented underneath (in the classRep field) by Java objects of type Class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Type
    The "any" type (denotes wild expressions).
    static final Type
    The boolean type.
    static final Type
    The int type.
    static final Type
    The void type.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    This constructor is to keep the compiler happy.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    argTypesMatch(Class<?>[] argTypes1, Class<?>[] argTypes2)
    Returns true if the argument types match, and false otherwise.
    boolean
    equals(Type other)
    Returns true if this type has the same descriptor as other, and false otherwise.
    boolean
    Returns true if this is a primitive type, and false otherwise.
    Returns the JVM representation of this type's name.
    boolean
    Returns true if this type matches expected, and false otherwise.
    methodFor(String name, Type[] argTypes)
    Finds and returns a method in this type having the given name and argument types, or null.
    void
    mustMatchExpected(int line, Type expectedType)
    An assertion that this type matches the specified type.
    resolve(Context context)
    Resolves this type in the given context and returns the resolved type.
    static String
    signatureFor(String name, Type[] argTypes)
    Returns a signature for reporting unfound methods.
    Returns the simple (unqualified) name of this type.
    Returns the JVM descriptor of this type.
    Returns a string representation of this type.
    static Type
    typeFor(Class<?> classRep)
    Constructs and returns a representation for a type from its (Java) class representation, making sure there is a unique representation for each unique type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • INT

      public static final Type INT
      The int type.
    • BOOLEAN

      public static final Type BOOLEAN
      The boolean type.
    • VOID

      public static final Type VOID
      The void type.
    • ANY

      public static final Type ANY
      The "any" type (denotes wild expressions).
  • Constructor Details

    • Type

      protected Type()
      This constructor is to keep the compiler happy.
  • Method Details

    • typeFor

      public static Type typeFor(Class<?> classRep)
      Constructs and returns a representation for a type from its (Java) class representation, making sure there is a unique representation for each unique type.
      Parameters:
      classRep - the Java class representation.
      Returns:
      a type representation of classRep.
    • equals

      public boolean equals(Type other)
      Returns true if this type has the same descriptor as other, and false otherwise.
      Parameters:
      other - the other type.
      Returns:
      true if this type has the same descriptor as other, and false otherwise.
    • isPrimitive

      public boolean isPrimitive()
      Returns true if this is a primitive type, and false otherwise.
      Returns:
      true if this is a primitive type, and false otherwise.
    • mustMatchExpected

      public void mustMatchExpected(int line, Type expectedType)
      An assertion that this type matches the specified type. If there is no match, an error is reported.
      Parameters:
      line - the line near which the mismatch occurs.
      expectedType - type with which to match.
    • matchesExpected

      public boolean matchesExpected(Type expected)
      Returns true if this type matches expected, and false otherwise.
      Parameters:
      expected - the type that this might match.
      Returns:
      true if this type matches expected, and false otherwise.
    • argTypesMatch

      public static boolean argTypesMatch(Class<?>[] argTypes1, Class<?>[] argTypes2)
      Returns true if the argument types match, and false otherwise.
      Parameters:
      argTypes1 - arguments (classReps) of one method.
      argTypes2 - arguments (classReps) of another method.
      Returns:
      true if the argument types match, and false otherwise.
    • simpleName

      public String simpleName()
      Returns the simple (unqualified) name of this type.
      Returns:
      the simple (unqualified) name of this type.
    • toString

      public String toString()
      Returns a string representation of this type.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this type.
    • toDescriptor

      public String toDescriptor()
      Returns the JVM descriptor of this type.
      Returns:
      the JVM descriptor of this type.
    • jvmName

      public String jvmName()
      Returns the JVM representation of this type's name.
      Returns:
      the JVM representation of this type's name.
    • methodFor

      public Method methodFor(String name, Type[] argTypes)
      Finds and returns a method in this type having the given name and argument types, or null.
      Parameters:
      name - the method name.
      argTypes - the argument types.
      Returns:
      a method in this type having the given name and argument types, or null.
    • resolve

      public Type resolve(Context context)
      Resolves this type in the given context and returns the resolved type.
      Parameters:
      context - context in which the names are resolved.
      Returns:
      the resolved type.
    • signatureFor

      public static String signatureFor(String name, Type[] argTypes)
      Returns a signature for reporting unfound methods.
      Parameters:
      name - the message or type name.
      argTypes - the actual argument types.
      Returns:
      a signature for reporting unfound methods.