edu.rice.cs.dynamicjava.symbol
Class StandardTypeSystem

java.lang.Object
  extended by edu.rice.cs.dynamicjava.symbol.TypeSystem
      extended by edu.rice.cs.dynamicjava.symbol.StandardTypeSystem
Direct Known Subclasses:
ExtendedTypeSystem, JLSTypeSystem

public abstract class StandardTypeSystem
extends TypeSystem

Abstract parent class for TypeSystems that stick to the standard Java notions of types, conversions, class members, etc. Subclasses are responsible for providing core type operations: subtyping, inference, well-formedness checking, etc.


Nested Class Summary
protected static class StandardTypeSystem.SubstitutionMap
           
 
Nested classes/interfaces inherited from class edu.rice.cs.dynamicjava.symbol.TypeSystem
TypeSystem.AmbiguousFunctionLookupException, TypeSystem.ConstructorInvocation, TypeSystem.FieldReference, TypeSystem.FunctionInvocation, TypeSystem.InvalidTypeArgumentException, TypeSystem.MethodInvocation, TypeSystem.ObjectFieldReference, TypeSystem.ObjectMethodInvocation, TypeSystem.StaticFieldReference, TypeSystem.StaticMethodInvocation, TypeSystem.TypePrinter, TypeSystem.TypeSystemException, TypeSystem.TypeWrapper, TypeSystem.UnmatchedFunctionLookupException, TypeSystem.UnmatchedLookupException, TypeSystem.UnsupportedConversionException
 
Field Summary
protected static Type CLONEABLE_AND_SERIALIZABLE
           
protected static TypeVisitorLambda<java.lang.Boolean> IS_ARRAY
           
protected static TypeVisitorLambda<java.lang.Boolean> IS_PRIMITIVE
           
protected static TypeVisitorLambda<java.lang.Boolean> IS_REFERENCE
           
 
Fields inherited from class edu.rice.cs.dynamicjava.symbol.TypeSystem
BOOLEAN, BOOLEAN_CLASS, BOTTOM, BYTE, BYTE_CLASS, CHAR, CHARACTER_CLASS, CLONEABLE, DOUBLE, DOUBLE_CLASS, EMPTY_EXPRESSION_ITERABLE, EMPTY_TYPE_ARRAY, EMPTY_TYPE_ITERABLE, EXCEPTION, FLOAT, FLOAT_CLASS, INT, INTEGER_CLASS, LONG, LONG_CLASS, NONE_TYPE_OPTION, NULL, OBJECT, RUNTIME_EXCEPTION, SERIALIZABLE, SHORT, SHORT_CLASS, STRING, THROWABLE, TOP, VOID, VOID_CLASS
 
Constructor Summary
protected StandardTypeSystem(Options opt, boolean boxingInMostSpecific, boolean useExplicitTypeArgs, boolean strictClassEquality)
           
 
Method Summary
 Type arrayElementType(Type t)
          Determine the element type of the given array type.
 Expression assign(Type target, Expression exp)
          Prepare the given expression for assignment, wrapping it in any necessary conversions.
 Pair<Expression,Expression> binaryPromote(Expression e1, Expression e2)
          Perform binary numeric promotion on a pair of expressions.
protected  ParameterizedClassType capture(ParameterizedClassType t)
           
 Type capture(Type t)
          Compute the capture of t.
protected abstract  java.lang.Iterable<Type> captureTypeArgs(java.lang.Iterable<? extends Type> targs, java.lang.Iterable<? extends VariableType> params)
          Produce types that are bounded by the corresponding type argument and parameter.
 Expression cast(Type target, Expression e)
          Perform a cast on the given expression.
protected  boolean containsAnyVar(Type t, java.util.Set<? extends VariableType> vars)
          Test whether any of the given variables is reachable from a type.
 boolean containsClass(Type t, java.lang.String name, Access.Module accessModule)
           
 boolean containsField(Type t, java.lang.String name, Access.Module accessModule)
           
 boolean containsMethod(Type t, java.lang.String name, Access.Module accessModule)
           
 boolean containsStaticClass(Type t, java.lang.String name, Access.Module accessModule)
           
 boolean containsStaticField(Type t, java.lang.String name, Access.Module accessModule)
           
 boolean containsStaticMethod(Type t, java.lang.String name, Access.Module accessModule)
           
protected  boolean containsVar(Type t, VariableType var)
          Test whether a variable is reachable from a type.
 Option<Type> dynamicallyEnclosingType(Type t)
          Get the type of the object, if any, that dynamically encloses instances of t.
 Type erase(Type t)
          Compute the erased type of t.
 Thunk<java.lang.Class<?>> erasedClass(Type t)
          Determine the class corresponding to the erasure of t, or null if no such class object exists.
 Type immediateSuperclass(Type t)
           
protected  Type immediateSupertype(ClassType t)
          Get a class type's immediate supertype.
protected  boolean inBounds(java.lang.Iterable<? extends VariableType> params, java.lang.Iterable<? extends Type> args)
          Test whether the given arguments are within the bounds of the corresponding parameters.
protected abstract  java.lang.Iterable<Type> inferTypeArguments(java.lang.Iterable<? extends VariableType> tparams, java.lang.Iterable<? extends Type> params, Type returned, java.lang.Iterable<? extends Type> args, Option<Type> expected)
          Top-level entry point for type inference.
 boolean isArray(Type t)
          Determine if t is an array.
 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
 boolean isAssignable(Type target, Type expT, java.lang.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
 boolean isConcrete(Type t)
          Determine if there exist values whose most specific type is t (ignoring constructor-accessibility issues).
 boolean isDisjoint(Type s, Type t)
          Whether two types are known to be disjoint.
 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.
 boolean isExtendable(Type t)
          Determine if t is valid in the extends clause of a class definition
 boolean isImplementable(Type t)
          Determine if t is valid in the implements clause of a class definition
 boolean isIterable(Type t)
          Determine if the type can be used in an enhanced for loop.
 boolean isPrimitive(Type t)
          Determine if t is a primitive.
 boolean isPrimitiveConvertible(Type t)
          Determine if TypeSystem.makePrimitive(koala.dynamicjava.tree.Expression) would succeed given an expression of the given type
 boolean isReference(Type t)
          Determine if t is a reference.
 boolean isReferenceConvertible(Type t)
          Determine if TypeSystem.makeReference(koala.dynamicjava.tree.Expression) would succeed given an expression of the given type
 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(java.lang.Iterable<? extends Type> ts)
          Compute a common supertype of the given list of types.
 ClassType lookupClass(Expression object, java.lang.String name, java.lang.Iterable<? extends Type> typeArgs, Access.Module accessModule)
          Lookup the class with the given name in the given object.
 ClassType lookupClass(Type t, java.lang.String name, java.lang.Iterable<? extends Type> typeArgs, Access.Module accessModule)
          Lookup the class with the given name in the given type.
 TypeSystem.ConstructorInvocation lookupConstructor(Type t, java.lang.Iterable<? extends Type> typeArgs, java.lang.Iterable<? extends Expression> args, Option<Type> expected, Access.Module accessModule)
          Lookup the constructor corresponding the the given invocation.
 TypeSystem.ObjectFieldReference lookupField(Expression object, java.lang.String name, Access.Module accessModule)
          Lookup the field with the given name in the given object.
 TypeSystem.ObjectMethodInvocation lookupMethod(Expression object, java.lang.String name, java.lang.Iterable<? extends Type> typeArgs, java.lang.Iterable<? extends Expression> args, Option<Type> expected, Access.Module accessModule)
          Lookup the method corresponding the the given invocation.
 ClassType lookupStaticClass(Type t, java.lang.String name, java.lang.Iterable<? extends Type> typeArgs, Access.Module accessModule)
          Lookup the static class with the given name.
 TypeSystem.StaticFieldReference lookupStaticField(Type t, java.lang.String name, Access.Module accessModule)
          Lookup the static field with the given name.
 TypeSystem.StaticMethodInvocation lookupStaticMethod(Type t, java.lang.String name, java.lang.Iterable<? extends Type> typeArgs, java.lang.Iterable<? extends Expression> args, Option<Type> expected, Access.Module accessModule)
          Lookup the static method corresponding the the given invocation.
 ClassType makeClassType(DJClass c)
          Create a SimpleClassType or RawClassType corresponding to the given class.
 ClassType makeClassType(DJClass c, java.lang.Iterable<? extends Type> args)
          Create a SimpleClassType, RawClassType, or ParameterizedClassType corresponding to the given class with given type arguments.
 Expression makePrimitive(Expression e)
          Convert the expression to a primitive.
 Expression makeReference(Expression e)
          Convert the expression to a reference.
abstract  Type meet(java.lang.Iterable<? extends Type> ts)
          Compute a common subtype of the given list of types.
 Pair<Expression,Expression> mergeConditional(Expression e1, Expression e2)
          Perform a join (as defined for the ? : operator) on a pair of expressions.
protected  ParameterizedClassType parameterize(RawClassType t)
          Convert a raw class type to its wildcard-parameterized equivalent.
 Type reflectionClassOf(Type t)
          Determine the type of the class object associated with t (for example, (informally) classOf(Integer) = Class<Integer>).
protected  boolean sameClass(ClassType c1, ClassType c2)
           
protected  Type substitute(Type t, java.lang.Iterable<? extends VariableType> params, java.lang.Iterable<? extends Type> args)
          Assumes each paramater is a unique variable, and that the length of params is consistent with the length of args.
protected  Type substitute(Type t, java.util.Map<? extends VariableType,? extends Type> map)
           
protected  Type substitute(Type t, StandardTypeSystem.SubstitutionMap sigma)
           
 TypeSystem.TypePrinter typePrinter()
           
 Expression unaryPromote(Expression e)
          Perform unary numeric promotion on an expression.
 
Methods inherited from class edu.rice.cs.dynamicjava.symbol.TypeSystem
join, meet, wrap, wrap, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLONEABLE_AND_SERIALIZABLE

protected static final Type CLONEABLE_AND_SERIALIZABLE

IS_PRIMITIVE

protected static final TypeVisitorLambda<java.lang.Boolean> IS_PRIMITIVE

IS_REFERENCE

protected static final TypeVisitorLambda<java.lang.Boolean> IS_REFERENCE

IS_ARRAY

protected static final TypeVisitorLambda<java.lang.Boolean> IS_ARRAY
Constructor Detail

StandardTypeSystem

protected StandardTypeSystem(Options opt,
                             boolean boxingInMostSpecific,
                             boolean useExplicitTypeArgs,
                             boolean strictClassEquality)
Method Detail

isWellFormed

public abstract boolean isWellFormed(Type t)
Determine if the type is well-formed.

Specified by:
isWellFormed in class TypeSystem

isEqual

public abstract boolean isEqual(Type t1,
                                Type t2)
Determine if the given types may be treated as equal. This is recursive, transitive, and symmetric.

Specified by:
isEqual in class TypeSystem

isSubtype

public abstract boolean isSubtype(Type subT,
                                  Type superT)
Determine if 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.

Specified by:
isSubtype in class TypeSystem

join

public abstract Type join(java.lang.Iterable<? extends Type> ts)
Compute a common supertype of the given list of types.

Specified by:
join in class TypeSystem

meet

public abstract Type meet(java.lang.Iterable<? extends Type> ts)
Compute a common subtype of the given list of types.

Specified by:
meet in class TypeSystem

captureTypeArgs

protected abstract java.lang.Iterable<Type> captureTypeArgs(java.lang.Iterable<? extends Type> targs,
                                                            java.lang.Iterable<? extends VariableType> params)
Produce types that are bounded by the corresponding type argument and parameter.


inferTypeArguments

protected abstract java.lang.Iterable<Type> inferTypeArguments(java.lang.Iterable<? extends VariableType> tparams,
                                                               java.lang.Iterable<? extends Type> params,
                                                               Type returned,
                                                               java.lang.Iterable<? extends Type> args,
                                                               Option<Type> expected)
Top-level entry point for type inference. Produces the set of types corresponding to the given type parameters, given that args were provided where params were expected (args and params are assumed to have the same length), and returned will be returned where expected is expected.

Returns:
A set of inferred type arguments for tparams, or null if the parameters are overconstrained

sameClass

protected boolean sameClass(ClassType c1,
                            ClassType c2)

typePrinter

public TypeSystem.TypePrinter typePrinter()
Specified by:
typePrinter in class TypeSystem

isPrimitive

public boolean isPrimitive(Type t)
Determine if t is a primitive.

Specified by:
isPrimitive in class TypeSystem

isReference

public boolean isReference(Type t)
Determine if t is a reference.

Specified by:
isReference in class TypeSystem

isArray

public boolean isArray(Type t)
Determine if t is an array.

Specified by:
isArray in class TypeSystem

isIterable

public boolean isIterable(Type t)
Determine if the type can be used in an enhanced for loop. true implies that an object of type t has member iterator(), which returns a Iterator.

Specified by:
isIterable in class TypeSystem

isEnum

public 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)

Specified by:
isEnum in class TypeSystem

isReifiable

public boolean isReifiable(Type t)
Determine if the type is available at runtime (via a Class object)

Specified by:
isReifiable in class TypeSystem

isConcrete

public boolean isConcrete(Type t)
Determine if there exist values whose most specific type is t (ignoring constructor-accessibility issues). (Note that this implies that t is captured.)

Specified by:
isConcrete in class TypeSystem

dynamicallyEnclosingType

public Option<Type> dynamicallyEnclosingType(Type t)
Description copied from class: TypeSystem
Get the type of the object, if any, that dynamically encloses instances of t.

Specified by:
dynamicallyEnclosingType in class TypeSystem

isExtendable

public boolean isExtendable(Type t)
Determine if t is valid in the extends clause of a class definition

Specified by:
isExtendable in class TypeSystem

isImplementable

public boolean isImplementable(Type t)
Determine if t is valid in the implements clause of a class definition

Specified by:
isImplementable in class TypeSystem

containsVar

protected boolean containsVar(Type t,
                              VariableType var)
Test whether a variable is reachable from a type.


containsAnyVar

protected boolean containsAnyVar(Type t,
                                 java.util.Set<? extends VariableType> vars)
Test whether any of the given variables is reachable from a type.


isDisjoint

public boolean isDisjoint(Type s,
                          Type t)
Whether two types are known to be disjoint. (Standard version is implicitly defined in JLS 5.5.)

Specified by:
isDisjoint in class TypeSystem

isAssignable

public 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

Specified by:
isAssignable in class TypeSystem

isAssignable

public boolean isAssignable(Type target,
                            Type expT,
                            java.lang.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

Specified by:
isAssignable in class TypeSystem

isPrimitiveConvertible

public boolean isPrimitiveConvertible(Type t)
Description copied from class: TypeSystem
Determine if TypeSystem.makePrimitive(koala.dynamicjava.tree.Expression) would succeed given an expression of the given type

Specified by:
isPrimitiveConvertible in class TypeSystem

isReferenceConvertible

public boolean isReferenceConvertible(Type t)
Description copied from class: TypeSystem
Determine if TypeSystem.makeReference(koala.dynamicjava.tree.Expression) would succeed given an expression of the given type

Specified by:
isReferenceConvertible in class TypeSystem

immediateSuperclass

public Type immediateSuperclass(Type t)

capture

public Type capture(Type t)
Description copied from class: TypeSystem
Compute the capture of t. Capture eliminates wildcards in a ParameterizedClassType and converts VarargArrayTypes to StandardArrayTypes.

Specified by:
capture in class TypeSystem

capture

protected ParameterizedClassType capture(ParameterizedClassType t)

erase

public Type erase(Type t)
Compute the erased type of t. The result is guaranteed to be reifiable (according to isReifiable(edu.rice.cs.dynamicjava.symbol.type.Type)) and a supertype of t.

Specified by:
erase in class TypeSystem

erasedClass

public Thunk<java.lang.Class<?>> erasedClass(Type t)
Determine the class corresponding to the erasure of t, or null if no such class object exists. 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.)

Specified by:
erasedClass in class TypeSystem

parameterize

protected ParameterizedClassType parameterize(RawClassType t)
Convert a raw class type to its wildcard-parameterized equivalent.


reflectionClassOf

public Type reflectionClassOf(Type t)
Description copied from class: TypeSystem
Determine the type of the class object associated with t (for example, (informally) classOf(Integer) = Class<Integer>).

Specified by:
reflectionClassOf in class TypeSystem
Returns:
The type of the Class object associated with t (for example, (informally) reflectionClassOf(java.lang.Integer) = Class<Integer>).

arrayElementType

public Type arrayElementType(Type t)
Determine the element type of the given array type. Assumes t is an array type (according to isArray(edu.rice.cs.dynamicjava.symbol.type.Type)).

Specified by:
arrayElementType in class TypeSystem

substitute

protected Type substitute(Type t,
                          java.lang.Iterable<? extends VariableType> params,
                          java.lang.Iterable<? extends Type> args)
Assumes each paramater is a unique variable, and that the length of params is consistent with the length of args.


substitute

protected Type substitute(Type t,
                          java.util.Map<? extends VariableType,? extends Type> map)

substitute

protected Type substitute(Type t,
                          StandardTypeSystem.SubstitutionMap sigma)

makeClassType

public ClassType makeClassType(DJClass c)
Create a SimpleClassType or RawClassType corresponding to the given class.

Specified by:
makeClassType in class TypeSystem

makeClassType

public ClassType makeClassType(DJClass c,
                               java.lang.Iterable<? extends Type> args)
                        throws TypeSystem.InvalidTypeArgumentException
Create a 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).

Specified by:
makeClassType in class TypeSystem
Parameters:
c - The class to be instantiated
args - The type arguments for c
Throws:
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).
TypeSystem.InvalidTypeArgumentException

makePrimitive

public Expression makePrimitive(Expression e)
                         throws TypeSystem.UnsupportedConversionException
Convert the expression to a primitive. The result is guaranteed to have a primitive type as its TYPE property (according to isPrimitive(edu.rice.cs.dynamicjava.symbol.type.Type)).

Specified by:
makePrimitive in class TypeSystem
Parameters:
e - A typed expression
Returns:
A typed expression equivalent to e that has a primitive type
Throws:
UnsupportedConversionException - If the expression cannot be converted to a primitive
TypeSystem.UnsupportedConversionException

makeReference

public Expression makeReference(Expression e)
                         throws TypeSystem.UnsupportedConversionException
Convert the expression to a reference. The result is guaranteed to have a reference type as its TYPE property (according to isReference(edu.rice.cs.dynamicjava.symbol.type.Type)).

Specified by:
makeReference in class TypeSystem
Parameters:
e - A typed expression
Returns:
A typed expression equivalent to e that has a reference type
Throws:
UnsupportedConversionException - If the expression cannot be converted to a reference
TypeSystem.UnsupportedConversionException

unaryPromote

public Expression unaryPromote(Expression e)
                        throws TypeSystem.UnsupportedConversionException
Perform unary numeric promotion on an expression.

Specified by:
unaryPromote in class TypeSystem
Parameters:
e - A typed expression with a primitive type
Returns:
A typed expression equivalent to e with the promoted type
Throws:
UnsupportedConversionException - If the expression cannot be used for numeric promotion
TypeSystem.UnsupportedConversionException

binaryPromote

public Pair<Expression,Expression> binaryPromote(Expression e1,
                                                 Expression e2)
                                          throws TypeSystem.UnsupportedConversionException
Perform binary numeric promotion on a pair of expressions. The resulting pair of expressions are guaranteed to have the same type.

Specified by:
binaryPromote in class TypeSystem
Parameters:
e1 - A typed expression with a primitive type
e2 - A typed expression with a primitive type
Returns:
Two typed expressions equivalent to e1 and e2 with the promoted type
Throws:
UnsupportedConversionException - If either expression cannot be used for numeric promotion
TypeSystem.UnsupportedConversionException

mergeConditional

public Pair<Expression,Expression> mergeConditional(Expression e1,
                                                    Expression e2)
                                             throws TypeSystem.UnsupportedConversionException
Perform a join (as defined for the ? : operator) on a pair of expressions. The resulting pair of expressions are guaranteed to have the same type. That type may contain non-captured wildcards.

Specified by:
mergeConditional in class TypeSystem
Parameters:
e1 - A typed expression
e2 - A typed expression
Returns:
Two typed expressions equivalent to e1 and e2 with the joined type
Throws:
UnsupportedConversionException - If the two types are incompatible.
TypeSystem.UnsupportedConversionException

cast

public Expression cast(Type target,
                       Expression e)
                throws TypeSystem.UnsupportedConversionException
Perform a cast on the given expression. Any necessary conversions are performed. One of CHECKED_TYPE, CONVERTED_TYPE, or ASSERTED_TYPE is set on the result.

Specified by:
cast in class TypeSystem
Returns:
An expression equivalent to e, wrapped in any necessary conversions
Throws:
UnsupportedConversionException - If the cast is to an incompatible type.
TypeSystem.UnsupportedConversionException

assign

public Expression assign(Type target,
                         Expression exp)
                  throws TypeSystem.UnsupportedConversionException
Prepare the given expression for assignment, wrapping it in any necessary conversions.

Specified by:
assign in class TypeSystem
Returns:
An expression equivalent to e, wrapped in any necessary conversions
Throws:
UnsupportedConversionException - If assignment to the given type is incorrect.
TypeSystem.UnsupportedConversionException

immediateSupertype

protected Type immediateSupertype(ClassType t)
Get a class type's immediate supertype. The result may be null.


lookupConstructor

public TypeSystem.ConstructorInvocation lookupConstructor(Type t,
                                                          java.lang.Iterable<? extends Type> typeArgs,
                                                          java.lang.Iterable<? extends Expression> args,
                                                          Option<Type> expected,
                                                          Access.Module accessModule)
                                                   throws TypeSystem.InvalidTypeArgumentException,
                                                          TypeSystem.UnmatchedLookupException
Lookup the constructor corresponding the the given invocation.

Specified by:
lookupConstructor in class TypeSystem
Parameters:
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.
Returns:
A TypeSystem.ConstructorInvocation object representing the matched constructor.
Throws:
InvalidTypeArgumentException - If the type arguments are invalid (for example, a primitive type).
UnmatchedLookupException - If 0 or more than 1 constructor matches the given arguments and type arguments.
TypeSystem.InvalidTypeArgumentException
TypeSystem.UnmatchedLookupException

containsMethod

public boolean containsMethod(Type t,
                              java.lang.String name,
                              Access.Module accessModule)
Specified by:
containsMethod in class TypeSystem

containsStaticMethod

public boolean containsStaticMethod(Type t,
                                    java.lang.String name,
                                    Access.Module accessModule)
Specified by:
containsStaticMethod in class TypeSystem

lookupMethod

public TypeSystem.ObjectMethodInvocation lookupMethod(Expression object,
                                                      java.lang.String name,
                                                      java.lang.Iterable<? extends Type> typeArgs,
                                                      java.lang.Iterable<? extends Expression> args,
                                                      Option<Type> expected,
                                                      Access.Module accessModule)
                                               throws TypeSystem.InvalidTypeArgumentException,
                                                      TypeSystem.UnmatchedLookupException
Description copied from class: TypeSystem
Lookup the method corresponding the the given invocation.

Specified by:
lookupMethod in class TypeSystem
Parameters:
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.
Returns:
An TypeSystem.ObjectMethodInvocation object representing the matched method.
Throws:
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.

lookupStaticMethod

public TypeSystem.StaticMethodInvocation lookupStaticMethod(Type t,
                                                            java.lang.String name,
                                                            java.lang.Iterable<? extends Type> typeArgs,
                                                            java.lang.Iterable<? extends Expression> args,
                                                            Option<Type> expected,
                                                            Access.Module accessModule)
                                                     throws TypeSystem.InvalidTypeArgumentException,
                                                            TypeSystem.UnmatchedLookupException
Description copied from class: TypeSystem
Lookup the static method corresponding the the given invocation.

Specified by:
lookupStaticMethod in class TypeSystem
Parameters:
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.
Returns:
A TypeSystem.StaticMethodInvocation object representing the matched method.
Throws:
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.

containsField

public boolean containsField(Type t,
                             java.lang.String name,
                             Access.Module accessModule)
Specified by:
containsField in class TypeSystem

containsStaticField

public boolean containsStaticField(Type t,
                                   java.lang.String name,
                                   Access.Module accessModule)
Specified by:
containsStaticField in class TypeSystem

lookupField

public TypeSystem.ObjectFieldReference lookupField(Expression object,
                                                   java.lang.String name,
                                                   Access.Module accessModule)
                                            throws TypeSystem.UnmatchedLookupException
Description copied from class: TypeSystem
Lookup the field with the given name in the given object.

Specified by:
lookupField in class TypeSystem
Parameters:
object - A typed expression representing the object whose field is to be accessed.
name - The name of the field.
Returns:
An TypeSystem.ObjectFieldReference object representing the matched field.
Throws:
TypeSystem.UnmatchedLookupException - If 0 or more than 1 field matches the given name.

lookupStaticField

public TypeSystem.StaticFieldReference lookupStaticField(Type t,
                                                         java.lang.String name,
                                                         Access.Module accessModule)
                                                  throws TypeSystem.UnmatchedLookupException
Description copied from class: TypeSystem
Lookup the static field with the given name.

Specified by:
lookupStaticField in class TypeSystem
Parameters:
t - The type in which to search for a static field.
name - The name of the field.
Returns:
A TypeSystem.StaticFieldReference object representing the matched field.
Throws:
TypeSystem.UnmatchedLookupException - If 0 or more than 1 field matches the given name.

containsClass

public boolean containsClass(Type t,
                             java.lang.String name,
                             Access.Module accessModule)
Specified by:
containsClass in class TypeSystem

containsStaticClass

public boolean containsStaticClass(Type t,
                                   java.lang.String name,
                                   Access.Module accessModule)
Specified by:
containsStaticClass in class TypeSystem

lookupClass

public ClassType lookupClass(Expression object,
                             java.lang.String name,
                             java.lang.Iterable<? extends Type> typeArgs,
                             Access.Module accessModule)
                      throws TypeSystem.InvalidTypeArgumentException,
                             TypeSystem.UnmatchedLookupException
Description copied from class: TypeSystem
Lookup the class with the given name in the given object.

Specified by:
lookupClass in class TypeSystem
Parameters:
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
Returns:
A type representing the named class.
Throws:
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.

lookupClass

public ClassType lookupClass(Type t,
                             java.lang.String name,
                             java.lang.Iterable<? extends Type> typeArgs,
                             Access.Module accessModule)
                      throws TypeSystem.InvalidTypeArgumentException,
                             TypeSystem.UnmatchedLookupException
Description copied from class: TypeSystem
Lookup the class with the given name in the given type.

Specified by:
lookupClass in class TypeSystem
Parameters:
t - The type in which to search for a static class.
name - The name of the class.
typeArgs - The type arguments for the class
Returns:
A type representing the named class.
Throws:
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.

lookupStaticClass

public ClassType lookupStaticClass(Type t,
                                   java.lang.String name,
                                   java.lang.Iterable<? extends Type> typeArgs,
                                   Access.Module accessModule)
                            throws TypeSystem.InvalidTypeArgumentException,
                                   TypeSystem.UnmatchedLookupException
Description copied from class: TypeSystem
Lookup the static class with the given name.

Specified by:
lookupStaticClass in class TypeSystem
Parameters:
t - The type in which to search for a static class.
name - The name of the class.
typeArgs - The type arguments for the class
Returns:
A type representing the named class.
Throws:
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.

inBounds

protected boolean inBounds(java.lang.Iterable<? extends VariableType> params,
                           java.lang.Iterable<? extends Type> args)
Test whether the given arguments are within the bounds of the corresponding parameters. Assumes that params and args have matching arity.

Returns:
true iff the given arguments are within the bounds of the given parameters