Package iota
Class Type
java.lang.Object
iota.Type
A class for representing iota types. All types are represented underneath (in the classRep field) by Java objects
of type Class.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
argTypesMatch
(Class<?>[] argTypes1, Class<?>[] argTypes2) Returns true if the argument types match, and false otherwise.boolean
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.jvmName()
Returns the JVM representation of this type's name.boolean
matchesExpected
(Type expected) Returns true if this type matches expected, and false otherwise.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.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.toString()
Returns a string representation of this type.static Type
Constructs and returns a representation for a type from its (Java) class representation, making sure there is a unique representation for each unique type.
-
Field Details
-
INT
The int type. -
BOOLEAN
The boolean type. -
VOID
The void type. -
ANY
The "any" type (denotes wild expressions).
-
-
Constructor Details
-
Type
protected Type()This constructor is to keep the compiler happy.
-
-
Method Details
-
typeFor
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
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
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
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
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
Returns the simple (unqualified) name of this type.- Returns:
- the simple (unqualified) name of this type.
-
toString
Returns a string representation of this type. -
toDescriptor
Returns the JVM descriptor of this type.- Returns:
- the JVM descriptor of this type.
-
jvmName
Returns the JVM representation of this type's name.- Returns:
- the JVM representation of this type's name.
-
methodFor
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
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
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.
-