|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.dynamicjava.symbol.TypeSystem
public abstract class TypeSystem
A type system allows for variance in the typing rules of the system, while maintaining
a standard type checker. It separates the type checker from most of the details of type
implementations. For simplicity, it is also defined independently of most type-checker implementation
issues, such as syntax. To enforce these relationships, the type checker should minimize
references to specific subtypes of Type; and the type system should minimize references
to specific subtypes of Expression.
| Nested Class Summary | |
|---|---|
static class |
TypeSystem.AmbiguousFunctionLookupException
A function lookup that failed because all of the given candidates equally matched the provided arguments. |
static class |
TypeSystem.ConstructorInvocation
The result of a constructor lookup |
static class |
TypeSystem.FieldReference
Abstraction of the result of a static or non-static field lookup |
static class |
TypeSystem.FunctionInvocation
Abstraction of the result of a method or constructor lookup |
static class |
TypeSystem.InvalidTypeArgumentException
|
static class |
TypeSystem.MethodInvocation
Abstraction of the result of a static or non-static method lookup |
static class |
TypeSystem.ObjectFieldReference
The result of a non-static field lookup |
static class |
TypeSystem.ObjectMethodInvocation
The result of a non-static method lookup |
static class |
TypeSystem.StaticFieldReference
The result of a static field lookup |
static class |
TypeSystem.StaticMethodInvocation
The result of a static method lookup |
static interface |
TypeSystem.TypePrinter
|
static class |
TypeSystem.TypeSystemException
|
class |
TypeSystem.TypeWrapper
A wrapper for types that provides an alternate toString() and equals() implementation:
toString() is defined in terms of #userRepresentation; equals() is defined
in terms of isEqual(edu.rice.cs.dynamicjava.symbol.type.Type, edu.rice.cs.dynamicjava.symbol.type.Type). |
static class |
TypeSystem.UnmatchedFunctionLookupException
A function lookup that failed because none of the given candidates matched the provided arguments. |
static class |
TypeSystem.UnmatchedLookupException
|
static class |
TypeSystem.UnsupportedConversionException
|
| Constructor Summary | |
|---|---|
TypeSystem()
|
|
| Method Summary | |
|---|---|
abstract Type |
arrayElementType(Type t)
Determine the element type of the given array type. |
abstract Expression |
assign(Type target,
Expression e)
Prepare the given expression for assignment, wrapping it in any necessary conversions. |
abstract Pair<Expression,Expression> |
binaryPromote(Expression e1,
Expression e2)
Perform binary numeric promotion on a pair of expressions. |
abstract Type |
capture(Type t)
Compute the capture of t. |
abstract Expression |
cast(Type target,
Expression e)
Perform a cast on the given expression. |
abstract boolean |
containsClass(Type t,
String name,
Access.Module accessModule)
|
abstract boolean |
containsField(Type t,
String name,
Access.Module accessModule)
|
abstract boolean |
containsMethod(Type t,
String name,
Access.Module accessModule)
|
abstract boolean |
containsStaticClass(Type t,
String name,
Access.Module accessModule)
|
abstract boolean |
containsStaticField(Type t,
String name,
Access.Module accessModule)
|
abstract boolean |
containsStaticMethod(Type t,
String name,
Access.Module accessModule)
|
abstract Option<Type> |
dynamicallyEnclosingType(Type t)
Get the type of the object, if any, that dynamically encloses instances of t. |
abstract Type |
erase(Type t)
Compute the erased type of t. |
abstract Thunk<Class<?>> |
erasedClass(Type t)
Determine the class corresponding to the erasure of t. |
abstract boolean |
isArray(Type t)
Determine if t is an array. |
abstract boolean |
isAssignable(Type target,
Type expT)
Determine if assign(edu.rice.cs.dynamicjava.symbol.type.Type, koala.dynamicjava.tree.Expression) would succeed given a non-constant expression of the given type |
abstract boolean |
isAssignable(Type target,
Type expT,
Object expValue)
Determine if assign(edu.rice.cs.dynamicjava.symbol.type.Type, koala.dynamicjava.tree.Expression) would succeed given a constant expression of the given type and value |
abstract boolean |
isConcrete(Type t)
Determine if there exist values whose most specific type is t (ignoring
constructor-accessibility issues). |
abstract boolean |
isDisjoint(Type t1,
Type t2)
Whether two types are known to be disjoint. |
abstract boolean |
isEnum(Type t)
Determine if an object with type t is enumerable (and so can be used as the selector of a
switch statement) |
abstract boolean |
isEqual(Type t1,
Type t2)
Determine if the given types may be treated as equal. |
abstract boolean |
isExtendable(Type t)
Determine if t is valid in the extends clause of a class definition |
abstract boolean |
isImplementable(Type t)
Determine if t is valid in the implements clause of a class definition |
abstract boolean |
isIterable(Type t)
Determine if the type can be used in an enhanced for loop. |
abstract boolean |
isPrimitive(Type t)
Determine if t is a primitive. |
abstract boolean |
isPrimitiveConvertible(Type t)
Determine if makePrimitive(koala.dynamicjava.tree.Expression) would succeed given an expression of the given type |
abstract boolean |
isReference(Type t)
Determine if t is a reference. |
abstract boolean |
isReferenceConvertible(Type t)
Determine if makeReference(koala.dynamicjava.tree.Expression) would succeed given an expression of the given type |
abstract boolean |
isReifiable(Type t)
Determine if the type is available at runtime (via a Class object) |
abstract boolean |
isSubtype(Type subT,
Type superT)
Determine if subT is a subtype of superT. |
abstract boolean |
isWellFormed(Type t)
Determine if the type is well-formed. |
abstract Type |
join(Iterable<? extends Type> ts)
Compute a common supertype of the given list of types. |
Type |
join(Type t1,
Type t2)
Compute a common supertype of the given pair of types. |
abstract ClassType |
lookupClass(Expression object,
String name,
Iterable<? extends Type> typeArgs,
Access.Module accessModule)
Lookup the class with the given name in the given object. |
abstract ClassType |
lookupClass(Type t,
String name,
Iterable<? extends Type> typeArgs,
Access.Module accessModule)
Lookup the class with the given name in the given type. |
abstract TypeSystem.ConstructorInvocation |
lookupConstructor(Type t,
Iterable<? extends Type> typeArgs,
Iterable<? extends Expression> args,
Option<Type> expected,
Access.Module accessModule)
Lookup the constructor corresponding the the given invocation. |
abstract TypeSystem.ObjectFieldReference |
lookupField(Expression object,
String name,
Access.Module accessModule)
Lookup the field with the given name in the given object. |
abstract TypeSystem.ObjectMethodInvocation |
lookupMethod(Expression object,
String name,
Iterable<? extends Type> typeArgs,
Iterable<? extends Expression> args,
Option<Type> expected,
Access.Module accessModule)
Lookup the method corresponding the the given invocation. |
abstract ClassType |
lookupStaticClass(Type t,
String name,
Iterable<? extends Type> typeArgs,
Access.Module accessModule)
Lookup the static class with the given name. |
abstract TypeSystem.StaticFieldReference |
lookupStaticField(Type t,
String name,
Access.Module accessModule)
Lookup the static field with the given name. |
abstract TypeSystem.StaticMethodInvocation |
lookupStaticMethod(Type t,
String name,
Iterable<? extends Type> typeArgs,
Iterable<? extends Expression> args,
Option<Type> expected,
Access.Module accessModule)
Lookup the static method corresponding the the given invocation. |
abstract ClassType |
makeClassType(DJClass c)
Create a SimpleClassType or RawClassType corresponding to the given class. |
abstract ClassType |
makeClassType(DJClass c,
Iterable<? extends Type> args)
Create a SimpleClassType, RawClassType, or ParameterizedClassType
corresponding to the given class with given type arguments. |
abstract Expression |
makePrimitive(Expression e)
Convert the expression to a primitive. |
abstract Expression |
makeReference(Expression e)
Convert the expression to a reference. |
abstract Type |
meet(Iterable<? extends Type> ts)
Compute a common subtype of the given list of types. |
Type |
meet(Type t1,
Type t2)
Compute a common supertype of the given pair of types. |
abstract Pair<Expression,Expression> |
mergeConditional(Expression e1,
Expression e2)
Perform a join (as defined for the ? : operator) on a pair of expressions. |
abstract Type |
reflectionClassOf(Type t)
Determine the type of the class object associated with t (for example, (informally) classOf(Integer) = Class<Integer>). |
abstract TypeSystem.TypePrinter |
typePrinter()
|
abstract Expression |
unaryPromote(Expression e)
Perform unary numeric promotion on an expression. |
Iterable<TypeSystem.TypeWrapper> |
wrap(Iterable<? extends Type> ts)
|
Option<TypeSystem.TypeWrapper> |
wrap(Option<Type> t)
|
TypeSystem.TypeWrapper |
wrap(Type t)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final BooleanType BOOLEAN
public static final CharType CHAR
public static final ByteType BYTE
public static final ShortType SHORT
public static final IntType INT
public static final LongType LONG
public static final FloatType FLOAT
public static final DoubleType DOUBLE
public static final NullType NULL
public static final VoidType VOID
public static final TopType TOP
public static final BottomType BOTTOM
public static final SimpleClassType OBJECT
public static final SimpleClassType STRING
public static final SimpleClassType CLONEABLE
public static final SimpleClassType SERIALIZABLE
public static final SimpleClassType THROWABLE
public static final SimpleClassType EXCEPTION
public static final SimpleClassType RUNTIME_EXCEPTION
public static final SimpleClassType BOOLEAN_CLASS
public static final SimpleClassType CHARACTER_CLASS
public static final SimpleClassType BYTE_CLASS
public static final SimpleClassType SHORT_CLASS
public static final SimpleClassType INTEGER_CLASS
public static final SimpleClassType LONG_CLASS
public static final SimpleClassType FLOAT_CLASS
public static final SimpleClassType DOUBLE_CLASS
public static final SimpleClassType VOID_CLASS
protected static final Type[] EMPTY_TYPE_ARRAY
protected static final Iterable<Type> EMPTY_TYPE_ITERABLE
protected static final Iterable<Expression> EMPTY_EXPRESSION_ITERABLE
protected static final Option<Type> NONE_TYPE_OPTION
| Constructor Detail |
|---|
public TypeSystem()
| Method Detail |
|---|
public TypeSystem.TypeWrapper wrap(Type t)
public Iterable<TypeSystem.TypeWrapper> wrap(Iterable<? extends Type> ts)
public Option<TypeSystem.TypeWrapper> wrap(Option<Type> t)
public abstract TypeSystem.TypePrinter typePrinter()
public abstract boolean isPrimitive(Type t)
t is a primitive.
public abstract boolean isReference(Type t)
t is a reference.
public abstract boolean isArray(Type t)
t is an array.
public abstract boolean isWellFormed(Type t)
public abstract boolean isIterable(Type t)
true implies that an object of
type t has member iterator(), which returns a Iterator.
public abstract boolean isEnum(Type t)
t is enumerable (and so can be used as the selector of a
switch statement)
public abstract boolean isReifiable(Type t)
Class object)
public abstract boolean isConcrete(Type t)
t (ignoring
constructor-accessibility issues). (Note that this implies that t is captured.)
public abstract boolean isExtendable(Type t)
t is valid in the extends clause of a class definition
public abstract boolean isImplementable(Type t)
t is valid in the implements clause of a class definition
public abstract boolean isEqual(Type t1,
Type t2)
public abstract boolean isSubtype(Type subT,
Type superT)
subT is a subtype of superT. This is a recursive
(in terms of isEqual(edu.rice.cs.dynamicjava.symbol.type.Type, edu.rice.cs.dynamicjava.symbol.type.Type)), transitive relation.
public abstract boolean isDisjoint(Type t1,
Type t2)
public abstract boolean isAssignable(Type target,
Type expT)
assign(edu.rice.cs.dynamicjava.symbol.type.Type, koala.dynamicjava.tree.Expression) would succeed given a non-constant expression of the given type
public abstract boolean isAssignable(Type target,
Type expT,
Object expValue)
assign(edu.rice.cs.dynamicjava.symbol.type.Type, koala.dynamicjava.tree.Expression) would succeed given a constant expression of the given type and value
public abstract boolean isPrimitiveConvertible(Type t)
makePrimitive(koala.dynamicjava.tree.Expression) would succeed given an expression of the given type
public abstract boolean isReferenceConvertible(Type t)
makeReference(koala.dynamicjava.tree.Expression) would succeed given an expression of the given type
public abstract Type join(Iterable<? extends Type> ts)
public Type join(Type t1,
Type t2)
public abstract Type meet(Iterable<? extends Type> ts)
public Type meet(Type t1,
Type t2)
public abstract Type capture(Type t)
t. Capture eliminates wildcards in a ParameterizedClassType
and converts VarargArrayTypes to StandardArrayTypes.
public abstract Type erase(Type t)
t. The result is guaranteed to be reifiable (according
to isReifiable(edu.rice.cs.dynamicjava.symbol.type.Type)) and a supertype of t.
public abstract Thunk<Class<?>> erasedClass(Type t)
t. To prevent over-eager loading of
user-defined classes, computation of the result is delayed by wrapping it in a thunk. (A DJClass
return type would be incorrect, as there's no such thing (for example) as an array DJClass.)
public abstract Type reflectionClassOf(Type t)
classOf(Integer) = Class<Integer>).
public abstract Type arrayElementType(Type t)
t is an array type (according to
isArray(edu.rice.cs.dynamicjava.symbol.type.Type)).
public abstract Option<Type> dynamicallyEnclosingType(Type t)
t.
public abstract ClassType makeClassType(DJClass c)
SimpleClassType or RawClassType corresponding to the given class.
public abstract ClassType makeClassType(DJClass c,
Iterable<? extends Type> args)
throws TypeSystem.InvalidTypeArgumentException
SimpleClassType, RawClassType, or ParameterizedClassType
corresponding to the given class with given type arguments. If args is nonempty,
the result must be a ParameterizedClassType (or an error must occur).
c - The class to be instantiatedargs - The type arguments for c
TypeSystem.InvalidTypeArgumentException - If the arguments do not correspond to the formal parameters of
c (bounds are not checked, so the result may not be
well-formed).
public abstract Expression makePrimitive(Expression e)
throws TypeSystem.UnsupportedConversionException
isPrimitive(edu.rice.cs.dynamicjava.symbol.type.Type)).
e - A typed expression
e that has a primitive type
TypeSystem.UnsupportedConversionException - If the expression cannot be converted to a primitive
public abstract Expression makeReference(Expression e)
throws TypeSystem.UnsupportedConversionException
isReference(edu.rice.cs.dynamicjava.symbol.type.Type)).
e - A typed expression
e that has a reference type
TypeSystem.UnsupportedConversionException - If the expression cannot be converted to a reference
public abstract Expression unaryPromote(Expression e)
throws TypeSystem.UnsupportedConversionException
e - A typed expression with a primitive type
e with the promoted type
TypeSystem.UnsupportedConversionException - If the expression cannot be used for numeric promotion
public abstract Pair<Expression,Expression> binaryPromote(Expression e1,
Expression e2)
throws TypeSystem.UnsupportedConversionException
e1 - A typed expression with a primitive typee2 - A typed expression with a primitive type
e1 and e2 with the promoted type
TypeSystem.UnsupportedConversionException - If either expression cannot be used for numeric promotion
public abstract Pair<Expression,Expression> mergeConditional(Expression e1,
Expression e2)
throws TypeSystem.UnsupportedConversionException
e1 - A typed expressione2 - A typed expression
e1 and e2 with the joined type
TypeSystem.UnsupportedConversionException - If the two types are incompatible.
public abstract Expression cast(Type target,
Expression e)
throws TypeSystem.UnsupportedConversionException
CHECKED_TYPE and CONVERTED_TYPE properties are set on the result.
e, wrapped in any necessary conversions
TypeSystem.UnsupportedConversionException - If the cast is to an incompatible type.
public abstract Expression assign(Type target,
Expression e)
throws TypeSystem.UnsupportedConversionException
e, wrapped in any necessary conversions
TypeSystem.UnsupportedConversionException - If assignment to the given type is incorrect.
public abstract TypeSystem.ConstructorInvocation lookupConstructor(Type t,
Iterable<? extends Type> typeArgs,
Iterable<? extends Expression> args,
Option<Type> expected,
Access.Module accessModule)
throws TypeSystem.InvalidTypeArgumentException,
TypeSystem.UnmatchedLookupException
t - The type of the object to be constructed.typeArgs - The type arguments for the constructor's type parameters.args - A list of typed expressions corresponding to the constructor's parameters.expected - The type expected in the invocation's calling context, if any.
TypeSystem.ConstructorInvocation object representing the matched constructor.
TypeSystem.InvalidTypeArgumentException - If the type arguments are invalid (for example, a primitive type).
TypeSystem.UnmatchedLookupException - If 0 or more than 1 constructor matches the given arguments and type
arguments.
public abstract boolean containsMethod(Type t,
String name,
Access.Module accessModule)
public abstract boolean containsStaticMethod(Type t,
String name,
Access.Module accessModule)
public abstract TypeSystem.ObjectMethodInvocation lookupMethod(Expression object,
String name,
Iterable<? extends Type> typeArgs,
Iterable<? extends Expression> args,
Option<Type> expected,
Access.Module accessModule)
throws TypeSystem.InvalidTypeArgumentException,
TypeSystem.UnmatchedLookupException
object - A typed expression representing the object whose method is to be invoked.name - The name of the method.typeArgs - The type arguments for the method's type parameters.args - A list of typed expressions corresponding to the method's parameters.expected - The type expected in the invocation's calling context, if any.
TypeSystem.ObjectMethodInvocation object representing the matched method.
TypeSystem.InvalidTypeArgumentException - If the type arguments are invalid (for example, a primitive type).
TypeSystem.UnmatchedLookupException - If 0 or more than 1 method matches the given name, arguments, and type
arguments.
public abstract TypeSystem.StaticMethodInvocation lookupStaticMethod(Type t,
String name,
Iterable<? extends Type> typeArgs,
Iterable<? extends Expression> args,
Option<Type> expected,
Access.Module accessModule)
throws TypeSystem.InvalidTypeArgumentException,
TypeSystem.UnmatchedLookupException
t - The type in which to search for a static method.name - The name of the method.typeArgs - The type arguments for the method's type parameters.args - A list of typed expressions corresponding to the method's parameters.expected - The type expected in the invocation's calling context, if any.
TypeSystem.StaticMethodInvocation object representing the matched method.
TypeSystem.InvalidTypeArgumentException - If the type arguments are invalid (for example, a primitive type).
TypeSystem.UnmatchedLookupException - If 0 or more than 1 method matches the given name, arguments, and type
arguments.
public abstract boolean containsField(Type t,
String name,
Access.Module accessModule)
public abstract boolean containsStaticField(Type t,
String name,
Access.Module accessModule)
public abstract TypeSystem.ObjectFieldReference lookupField(Expression object,
String name,
Access.Module accessModule)
throws TypeSystem.UnmatchedLookupException
object - A typed expression representing the object whose field is to be accessed.name - The name of the field.
TypeSystem.ObjectFieldReference object representing the matched field.
TypeSystem.UnmatchedLookupException - If 0 or more than 1 field matches the given name.
public abstract TypeSystem.StaticFieldReference lookupStaticField(Type t,
String name,
Access.Module accessModule)
throws TypeSystem.UnmatchedLookupException
t - The type in which to search for a static field.name - The name of the field.
TypeSystem.StaticFieldReference object representing the matched field.
TypeSystem.UnmatchedLookupException - If 0 or more than 1 field matches the given name.
public abstract boolean containsClass(Type t,
String name,
Access.Module accessModule)
public abstract boolean containsStaticClass(Type t,
String name,
Access.Module accessModule)
public abstract ClassType lookupClass(Expression object,
String name,
Iterable<? extends Type> typeArgs,
Access.Module accessModule)
throws TypeSystem.InvalidTypeArgumentException,
TypeSystem.UnmatchedLookupException
object - A typed expression representing the object whose class is to be accessed.name - The name of the class.typeArgs - The type arguments for the class
TypeSystem.InvalidTypeArgumentException - If the type arguments are invalid or do not correspond to the
class's formal parameters (bounds are not checked, so the result
may not be well-formed).
TypeSystem.UnmatchedLookupException - If 0 or more than 1 class matches the given name.
public abstract ClassType lookupClass(Type t,
String name,
Iterable<? extends Type> typeArgs,
Access.Module accessModule)
throws TypeSystem.InvalidTypeArgumentException,
TypeSystem.UnmatchedLookupException
t - The type in which to search for a static class.name - The name of the class.typeArgs - The type arguments for the class
TypeSystem.InvalidTypeArgumentException - If the type arguments are invalid or do not correspond to the
class's formal parameters (bounds are not checked, so the
result may not be well-formed).
TypeSystem.UnmatchedLookupException - If 0 or more than 1 class matches the given name.
public abstract ClassType lookupStaticClass(Type t,
String name,
Iterable<? extends Type> typeArgs,
Access.Module accessModule)
throws TypeSystem.InvalidTypeArgumentException,
TypeSystem.UnmatchedLookupException
t - The type in which to search for a static class.name - The name of the class.typeArgs - The type arguments for the class
TypeSystem.InvalidTypeArgumentException - If the type arguments are invalid or do not correspond to the
class's formal parameters (bounds are not checked, so the result
may not be well-formed).
TypeSystem.UnmatchedLookupException - If 0 or more than 1 class matches the given name.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||