edu.rice.cs.dynamicjava.interpreter
Interface TypeContext

All Known Implementing Classes:
BaseContext, ClassContext, ClassSignatureContext, DelegatingContext, FunctionContext, FunctionSignatureContext, ImportContext, InitializerContext, LibraryContext, LocalContext, TryBlockContext

public interface TypeContext

A context for type checking. Contexts are immutable, and provide the necessary contextual information for static analysis. To separate concerns, a context has no knowledge of the type system, and requires a TypeSystem to be passed as an argument wherever it may be useful.


Method Summary
 Access.Module accessModule()
          Get the current access module.
 boolean fieldExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope field
 boolean functionExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope method or local function
 java.lang.ClassLoader getClassLoader()
          Return the class loader for the current scope.
 java.lang.Iterable<Type> getDeclaredThrownTypes()
          The types that are allowed to be thrown in the current context.
 java.lang.Iterable<LocalFunction> getLocalFunctions(java.lang.String name, TypeSystem ts)
          List all local functions that match the given name (empty if there are none)
 java.lang.Iterable<LocalFunction> getLocalFunctions(java.lang.String name, TypeSystem ts, java.lang.Iterable<LocalFunction> partial)
          Helper for getLocalFunctions: list all matching functions, including those provided.
 LocalVariable getLocalVariable(java.lang.String name, TypeSystem ts)
          Return the variable object for the given name, or null if it does not exist.
 Type getReturnType()
          The expected type of a return statement in the given context, or null if return statements should not appear here.
 DJClass getThis()
          Return the class of this in the current context, or null if there is no such value (for example, in a static context).
 DJClass getThis(java.lang.String className)
          Return the class of className.this in the current context, or null if there is no such value (for example, in a static context).
 DJClass getThis(Type expected, TypeSystem ts)
          Return the innermost "this" class with the given type in the current context, or null if there is no such value (for example, in a static context).
 DJClass getTopLevelClass(java.lang.String name, TypeSystem ts)
          Return the top-level class with the given name, or null if it does not exist.
 VariableType getTypeVariable(java.lang.String name, TypeSystem ts)
          Return the type variable with the given name, or null if it does not exist.
 TypeContext importField(DJClass c, java.lang.String name)
          Import the field(s) of c with the given name
 TypeContext importMemberClass(DJClass outer, java.lang.String name)
          Import the member class(es) of outer with the given name
 TypeContext importMemberClasses(DJClass outer)
          Import on demand all member classes of the given class
 TypeContext importMethod(DJClass c, java.lang.String name)
          Import the method(s) of c with the given name
 TypeContext importStaticMembers(DJClass c)
          Import on demand all static members of the given class
 TypeContext importTopLevelClass(DJClass c)
          Import the given top-level class
 TypeContext importTopLevelClasses(java.lang.String pkg)
          Import on demand all top-level classes in the given package
 DJClass initializingClass()
          Class which is being initialized (via a constructor or initialization block); null otherwise.
 boolean localFunctionExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope local function
 boolean localVariableExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope local variable
 java.lang.String makeAnonymousClassName()
          Return a full name for an anonymous class declared here.
 java.lang.String makeClassName(java.lang.String declaredName)
          Return a full name for a class with the given name declared here.
 boolean memberClassExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope member class
 boolean methodExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope method
 TypeContext setPackage(java.lang.String name)
          Set the current package to the given package name
 boolean topLevelClassExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope top-level class
 ClassType typeContainingField(java.lang.String name, TypeSystem ts)
          Return the most inner type containing a field with the given name, or null if there is no such type.
 ClassType typeContainingMemberClass(java.lang.String name, TypeSystem ts)
          Return the most inner type containing a class with the given name, or null if there is no such type.
 Type typeContainingMethod(java.lang.String name, TypeSystem ts)
          Return the most inner type containing a method with the given name, or null if there is no such type.
 boolean typeExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope top-level class, member class, or type variable
 boolean typeVariableExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope type variable.
 boolean variableExists(java.lang.String name, TypeSystem ts)
          Test whether name is an in-scope field or local variable
 

Method Detail

setPackage

TypeContext setPackage(java.lang.String name)
Set the current package to the given package name


importTopLevelClasses

TypeContext importTopLevelClasses(java.lang.String pkg)
Import on demand all top-level classes in the given package


importMemberClasses

TypeContext importMemberClasses(DJClass outer)
Import on demand all member classes of the given class


importStaticMembers

TypeContext importStaticMembers(DJClass c)
Import on demand all static members of the given class


importTopLevelClass

TypeContext importTopLevelClass(DJClass c)
Import the given top-level class


importMemberClass

TypeContext importMemberClass(DJClass outer,
                              java.lang.String name)
Import the member class(es) of outer with the given name


importField

TypeContext importField(DJClass c,
                        java.lang.String name)
Import the field(s) of c with the given name


importMethod

TypeContext importMethod(DJClass c,
                         java.lang.String name)
Import the method(s) of c with the given name


typeExists

boolean typeExists(java.lang.String name,
                   TypeSystem ts)
Test whether name is an in-scope top-level class, member class, or type variable


topLevelClassExists

boolean topLevelClassExists(java.lang.String name,
                            TypeSystem ts)
Test whether name is an in-scope top-level class


getTopLevelClass

DJClass getTopLevelClass(java.lang.String name,
                         TypeSystem ts)
                         throws AmbiguousNameException
Return the top-level class with the given name, or null if it does not exist.

Throws:
AmbiguousNameException

memberClassExists

boolean memberClassExists(java.lang.String name,
                          TypeSystem ts)
Test whether name is an in-scope member class


typeContainingMemberClass

ClassType typeContainingMemberClass(java.lang.String name,
                                    TypeSystem ts)
                                    throws AmbiguousNameException
Return the most inner type containing a class with the given name, or null if there is no such type.

Throws:
AmbiguousNameException

typeVariableExists

boolean typeVariableExists(java.lang.String name,
                           TypeSystem ts)
Test whether name is an in-scope type variable.


getTypeVariable

VariableType getTypeVariable(java.lang.String name,
                             TypeSystem ts)
Return the type variable with the given name, or null if it does not exist.


variableExists

boolean variableExists(java.lang.String name,
                       TypeSystem ts)
Test whether name is an in-scope field or local variable


fieldExists

boolean fieldExists(java.lang.String name,
                    TypeSystem ts)
Test whether name is an in-scope field


typeContainingField

ClassType typeContainingField(java.lang.String name,
                              TypeSystem ts)
                              throws AmbiguousNameException
Return the most inner type containing a field with the given name, or null if there is no such type.

Throws:
AmbiguousNameException

localVariableExists

boolean localVariableExists(java.lang.String name,
                            TypeSystem ts)
Test whether name is an in-scope local variable


getLocalVariable

LocalVariable getLocalVariable(java.lang.String name,
                               TypeSystem ts)
Return the variable object for the given name, or null if it does not exist.


functionExists

boolean functionExists(java.lang.String name,
                       TypeSystem ts)
Test whether name is an in-scope method or local function


methodExists

boolean methodExists(java.lang.String name,
                     TypeSystem ts)
Test whether name is an in-scope method


typeContainingMethod

Type typeContainingMethod(java.lang.String name,
                          TypeSystem ts)
Return the most inner type containing a method with the given name, or null if there is no such type.


localFunctionExists

boolean localFunctionExists(java.lang.String name,
                            TypeSystem ts)
Test whether name is an in-scope local function


getLocalFunctions

java.lang.Iterable<LocalFunction> getLocalFunctions(java.lang.String name,
                                                    TypeSystem ts)
List all local functions that match the given name (empty if there are none)


getLocalFunctions

java.lang.Iterable<LocalFunction> getLocalFunctions(java.lang.String name,
                                                    TypeSystem ts,
                                                    java.lang.Iterable<LocalFunction> partial)
Helper for getLocalFunctions: list all matching functions, including those provided.


accessModule

Access.Module accessModule()
Get the current access module.


makeClassName

java.lang.String makeClassName(java.lang.String declaredName)
Return a full name for a class with the given name declared here.


makeAnonymousClassName

java.lang.String makeAnonymousClassName()
Return a full name for an anonymous class declared here.


getThis

DJClass getThis()
Return the class of this in the current context, or null if there is no such value (for example, in a static context).


getThis

DJClass getThis(java.lang.String className)
Return the class of className.this in the current context, or null if there is no such value (for example, in a static context).


getThis

DJClass getThis(Type expected,
                TypeSystem ts)
Return the innermost "this" class with the given type in the current context, or null if there is no such value (for example, in a static context).


initializingClass

DJClass initializingClass()
Class which is being initialized (via a constructor or initialization block); null otherwise.


getReturnType

Type getReturnType()
The expected type of a return statement in the given context, or null if return statements should not appear here.


getDeclaredThrownTypes

java.lang.Iterable<Type> getDeclaredThrownTypes()
The types that are allowed to be thrown in the current context. If there is no such declaration, the list will be empty.


getClassLoader

java.lang.ClassLoader getClassLoader()
Return the class loader for the current scope. Allows class loaders to be defined in later scopes with the returned loader as a parent.