edu.rice.cs.dynamicjava.interpreter
Class BaseContext

java.lang.Object
  extended by edu.rice.cs.dynamicjava.interpreter.BaseContext
All Implemented Interfaces:
TypeContext

public class BaseContext
extends Object
implements TypeContext

A non-delegating context to place and the top of a delegation chain. All methods return null, false, or an empty list, or (where none of these are valid) throw an UnsupportedOperationException.


Field Summary
static BaseContext INSTANCE
           
 
Method Summary
 Access.Module accessModule()
          Get the current access module.
 boolean fieldExists(String name, TypeSystem ts)
          Test whether name is an in-scope field
 boolean functionExists(String name, TypeSystem ts)
          Test whether name is an in-scope method or local function
 ClassLoader getClassLoader()
          Return the class loader for the current scope.
 Iterable<Type> getDeclaredThrownTypes()
          The types that are allowed to be thrown in the current context.
 Iterable<LocalFunction> getLocalFunctions(String name, TypeSystem ts)
          List all local functions that match the given name (empty if there are none)
 Iterable<LocalFunction> getLocalFunctions(String name, TypeSystem ts, Iterable<LocalFunction> partial)
          Helper for getLocalFunctions: list all matching functions, including those provided.
 LocalVariable getLocalVariable(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(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(String name, TypeSystem ts)
          Return the top-level class with the given name, or null if it does not exist.
 VariableType getTypeVariable(String name, TypeSystem ts)
          Return the type variable with the given name, or null if it does not exist.
 TypeContext importField(DJClass c, String name)
          Import the field(s) of c with the given name
 TypeContext importMemberClass(DJClass outer, 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, 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(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(String name, TypeSystem ts)
          Test whether name is an in-scope local function
 boolean localVariableExists(String name, TypeSystem ts)
          Test whether name is an in-scope local variable
 String makeAnonymousClassName()
          Return a full name for an anonymous class declared here.
 String makeClassName(String n)
          Return a full name for a class with the given name declared here.
 boolean memberClassExists(String name, TypeSystem ts)
          Test whether name is an in-scope member class
 boolean methodExists(String name, TypeSystem ts)
          Test whether name is an in-scope method
 TypeContext setPackage(String name)
          Set the current package to the given package name
 boolean topLevelClassExists(String name, TypeSystem ts)
          Test whether name is an in-scope top-level class
 ClassType typeContainingField(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(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(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(String name, TypeSystem ts)
          Test whether name is an in-scope top-level class, member class, or type variable
 boolean typeVariableExists(String name, TypeSystem ts)
          Test whether name is an in-scope type variable.
 boolean variableExists(String name, TypeSystem ts)
          Test whether name is an in-scope field or local variable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final BaseContext INSTANCE
Method Detail

fieldExists

public boolean fieldExists(String name,
                           TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope field

Specified by:
fieldExists in interface TypeContext

functionExists

public boolean functionExists(String name,
                              TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope method or local function

Specified by:
functionExists in interface TypeContext

getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: TypeContext
Return the class loader for the current scope. Allows class loaders to be defined in later scopes with the returned loader as a parent.

Specified by:
getClassLoader in interface TypeContext

getDeclaredThrownTypes

public Iterable<Type> getDeclaredThrownTypes()
Description copied from interface: TypeContext
The types that are allowed to be thrown in the current context. If there is no such declaration, the list will be empty.

Specified by:
getDeclaredThrownTypes in interface TypeContext

getLocalFunctions

public Iterable<LocalFunction> getLocalFunctions(String name,
                                                 TypeSystem ts)
Description copied from interface: TypeContext
List all local functions that match the given name (empty if there are none)

Specified by:
getLocalFunctions in interface TypeContext

getLocalFunctions

public Iterable<LocalFunction> getLocalFunctions(String name,
                                                 TypeSystem ts,
                                                 Iterable<LocalFunction> partial)
Description copied from interface: TypeContext
Helper for getLocalFunctions: list all matching functions, including those provided.

Specified by:
getLocalFunctions in interface TypeContext

getLocalVariable

public LocalVariable getLocalVariable(String name,
                                      TypeSystem ts)
Description copied from interface: TypeContext
Return the variable object for the given name, or null if it does not exist.

Specified by:
getLocalVariable in interface TypeContext

accessModule

public Access.Module accessModule()
Description copied from interface: TypeContext
Get the current access module.

Specified by:
accessModule in interface TypeContext

getReturnType

public Type getReturnType()
Description copied from interface: TypeContext
The expected type of a return statement in the given context, or null if return statements should not appear here.

Specified by:
getReturnType in interface TypeContext

getThis

public DJClass getThis()
Description copied from interface: TypeContext
Return the class of this in the current context, or null if there is no such value (for example, in a static context).

Specified by:
getThis in interface TypeContext

getThis

public DJClass getThis(String className)
Description copied from interface: TypeContext
Return the class of className.this in the current context, or null if there is no such value (for example, in a static context).

Specified by:
getThis in interface TypeContext

getThis

public DJClass getThis(Type expected,
                       TypeSystem ts)
Description copied from interface: TypeContext
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).

Specified by:
getThis in interface TypeContext

getTopLevelClass

public DJClass getTopLevelClass(String name,
                                TypeSystem ts)
                         throws AmbiguousNameException
Description copied from interface: TypeContext
Return the top-level class with the given name, or null if it does not exist.

Specified by:
getTopLevelClass in interface TypeContext
Throws:
AmbiguousNameException

getTypeVariable

public VariableType getTypeVariable(String name,
                                    TypeSystem ts)
Description copied from interface: TypeContext
Return the type variable with the given name, or null if it does not exist.

Specified by:
getTypeVariable in interface TypeContext

importField

public TypeContext importField(DJClass c,
                               String name)
Description copied from interface: TypeContext
Import the field(s) of c with the given name

Specified by:
importField in interface TypeContext

importMemberClass

public TypeContext importMemberClass(DJClass outer,
                                     String name)
Description copied from interface: TypeContext
Import the member class(es) of outer with the given name

Specified by:
importMemberClass in interface TypeContext

importMemberClasses

public TypeContext importMemberClasses(DJClass outer)
Description copied from interface: TypeContext
Import on demand all member classes of the given class

Specified by:
importMemberClasses in interface TypeContext

importMethod

public TypeContext importMethod(DJClass c,
                                String name)
Description copied from interface: TypeContext
Import the method(s) of c with the given name

Specified by:
importMethod in interface TypeContext

importStaticMembers

public TypeContext importStaticMembers(DJClass c)
Description copied from interface: TypeContext
Import on demand all static members of the given class

Specified by:
importStaticMembers in interface TypeContext

importTopLevelClass

public TypeContext importTopLevelClass(DJClass c)
Description copied from interface: TypeContext
Import the given top-level class

Specified by:
importTopLevelClass in interface TypeContext

importTopLevelClasses

public TypeContext importTopLevelClasses(String pkg)
Description copied from interface: TypeContext
Import on demand all top-level classes in the given package

Specified by:
importTopLevelClasses in interface TypeContext

initializingClass

public DJClass initializingClass()
Description copied from interface: TypeContext
Class which is being initialized (via a constructor or initialization block); null otherwise.

Specified by:
initializingClass in interface TypeContext

localFunctionExists

public boolean localFunctionExists(String name,
                                   TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope local function

Specified by:
localFunctionExists in interface TypeContext

localVariableExists

public boolean localVariableExists(String name,
                                   TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope local variable

Specified by:
localVariableExists in interface TypeContext

makeAnonymousClassName

public String makeAnonymousClassName()
Description copied from interface: TypeContext
Return a full name for an anonymous class declared here.

Specified by:
makeAnonymousClassName in interface TypeContext

makeClassName

public String makeClassName(String n)
Description copied from interface: TypeContext
Return a full name for a class with the given name declared here.

Specified by:
makeClassName in interface TypeContext

memberClassExists

public boolean memberClassExists(String name,
                                 TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope member class

Specified by:
memberClassExists in interface TypeContext

methodExists

public boolean methodExists(String name,
                            TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope method

Specified by:
methodExists in interface TypeContext

setPackage

public TypeContext setPackage(String name)
Description copied from interface: TypeContext
Set the current package to the given package name

Specified by:
setPackage in interface TypeContext

topLevelClassExists

public boolean topLevelClassExists(String name,
                                   TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope top-level class

Specified by:
topLevelClassExists in interface TypeContext

typeContainingField

public ClassType typeContainingField(String name,
                                     TypeSystem ts)
                              throws AmbiguousNameException
Description copied from interface: TypeContext
Return the most inner type containing a field with the given name, or null if there is no such type.

Specified by:
typeContainingField in interface TypeContext
Throws:
AmbiguousNameException

typeContainingMemberClass

public ClassType typeContainingMemberClass(String name,
                                           TypeSystem ts)
                                    throws AmbiguousNameException
Description copied from interface: TypeContext
Return the most inner type containing a class with the given name, or null if there is no such type.

Specified by:
typeContainingMemberClass in interface TypeContext
Throws:
AmbiguousNameException

typeContainingMethod

public Type typeContainingMethod(String name,
                                 TypeSystem ts)
Description copied from interface: TypeContext
Return the most inner type containing a method with the given name, or null if there is no such type.

Specified by:
typeContainingMethod in interface TypeContext

typeExists

public boolean typeExists(String name,
                          TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope top-level class, member class, or type variable

Specified by:
typeExists in interface TypeContext

typeVariableExists

public boolean typeVariableExists(String name,
                                  TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope type variable.

Specified by:
typeVariableExists in interface TypeContext

variableExists

public boolean variableExists(String name,
                              TypeSystem ts)
Description copied from interface: TypeContext
Test whether name is an in-scope field or local variable

Specified by:
variableExists in interface TypeContext