edu.rice.cs.dynamicjava.symbol
Class SymbolUtil

java.lang.Object
  extended by edu.rice.cs.dynamicjava.symbol.SymbolUtil

public class SymbolUtil
extends java.lang.Object


Constructor Summary
SymbolUtil()
           
 
Method Summary
static java.lang.Iterable<VariableType> allTypeParameters(DJClass c)
          Determine all the in-scope type parameters of c, ordered outermost to innermost.
static Thunk<java.lang.Class<?>> arrayClassThunk(Thunk<java.lang.Class<?>> element)
           
static Library classLibrary(java.lang.ClassLoader loader)
          Create an appropriate Library for the given ClassLoader, based on the available reflection APIs.
static boolean dynamicallyEncloses(DJClass outer, DJClass inner)
          Determine whether inner is non-statically nested within outer.
static DJClass dynamicOuterClass(DJClass c)
          Determine the most deeply-nested dynamically-enclosing class of c.
static ClassType dynamicOuterClassType(ClassType t)
          Determine the type of an enclosing object of a value of the given type.
static java.lang.Object initialValue(java.lang.Class<?> c)
          Get the initial (zero) value of a field with the given class.
static boolean isVararg(Function f)
          Test whether the function's last parameter has a VarargArrayType type.
static java.lang.Iterable<DJClass> outerClassChain(DJClass c)
          Produces a list of classes enclosing the given class, from the most outer to the most inner.
static DJClass outermostClass(DJClass c)
          Produce the first element of the class's outerClassChain().
static java.lang.Iterable<Type> parameterTypes(Function f)
           
static java.lang.String shortName(DJClass c)
          Produce a short name for the given class -- including all outer class names, but excluding the package name.
static ClassType thisType(DJClass c)
          Create the type corresponding to this within the body of c
static Type typeOfGeneralClass(java.lang.Class<?> c, TypeSystem ts)
          Create a type corresponding to an arbitrary reflection class, which may represent a primitive, an array, or a class/interface.
static Type typeOfPrimitiveClass(java.lang.Class<?> c)
          Convert a Class object representing a primitive type to the corresponding Type.
static DJClass wrapClass(java.lang.Class<?> c)
          Create an appropriate DJClass for the given Class, based on the available reflection APIs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymbolUtil

public SymbolUtil()
Method Detail

outerClassChain

public static java.lang.Iterable<DJClass> outerClassChain(DJClass c)
Produces a list of classes enclosing the given class, from the most outer to the most inner. The length of the list is at least 1 (the last element of the list is always c). Note that classes that indirectly enclose this class, such as a class containing a method that declares this class, are not included in the result.


outermostClass

public static DJClass outermostClass(DJClass c)
Produce the first element of the class's outerClassChain().


dynamicallyEncloses

public static boolean dynamicallyEncloses(DJClass outer,
                                          DJClass inner)
Determine whether inner is non-statically nested within outer. This is the case iff outer appears in inner's outer class chain, and the next class in the chain is not declared static, or outer equals inner.


dynamicOuterClass

public static DJClass dynamicOuterClass(DJClass c)
Determine the most deeply-nested dynamically-enclosing class of c. The result is null if {code c} is a top-level class or is declared in a strictly static context. On the other hand, for generality, if class A has non-static inner class B, which in turn declares static class C, the result for C is A, not null or B (such declarations are not allowed in Java, and have limited syntactic support).


dynamicOuterClassType

public static ClassType dynamicOuterClassType(ClassType t)
Determine the type of an enclosing object of a value of the given type. The result is a parameterization of dynamicOuterClass(t.ofClass()), where the parameters are drawn from t, or null if there is no such class.


allTypeParameters

public static java.lang.Iterable<VariableType> allTypeParameters(DJClass c)
Determine all the in-scope type parameters of c, ordered outermost to innermost. A type parameter is in scope if it belongs to a dynamically enclosing class of c.


shortName

public static java.lang.String shortName(DJClass c)
Produce a short name for the given class -- including all outer class names, but excluding the package name. Anonymous classes are written "(anonymous Foo)", where Foo is the shortName of the extended type.


thisType

public static ClassType thisType(DJClass c)
Create the type corresponding to this within the body of c


wrapClass

public static DJClass wrapClass(java.lang.Class<?> c)
Create an appropriate DJClass for the given Class, based on the available reflection APIs. If Java 5 is available, returns a Java5Class. Otherwise, returns a JavaClass.


classLibrary

public static Library classLibrary(java.lang.ClassLoader loader)
Create an appropriate Library for the given ClassLoader, based on the available reflection APIs. If Java 5 is available, returns a Java5Library. Otherwise, returns a JavaLibrary.


typeOfPrimitiveClass

public static Type typeOfPrimitiveClass(java.lang.Class<?> c)
Convert a Class object representing a primitive type to the corresponding Type. The class void.class is also handled.

Throws:
java.lang.IllegalArgumentException - If !c.isPrimitive().

typeOfGeneralClass

public static Type typeOfGeneralClass(java.lang.Class<?> c,
                                      TypeSystem ts)
Create a type corresponding to an arbitrary reflection class, which may represent a primitive, an array, or a class/interface. Class types are created by invoking wrapClass(java.lang.Class) and passing the result to TypeSystem.makeClassType(edu.rice.cs.dynamicjava.symbol.DJClass).


arrayClassThunk

public static Thunk<java.lang.Class<?>> arrayClassThunk(Thunk<java.lang.Class<?>> element)

initialValue

public static java.lang.Object initialValue(java.lang.Class<?> c)
Get the initial (zero) value of a field with the given class. May be an array or primitive; if void, the result is null.


parameterTypes

public static java.lang.Iterable<Type> parameterTypes(Function f)

isVararg

public static boolean isVararg(Function f)
Test whether the function's last parameter has a VarargArrayType type.