edu.rice.cs.dynamicjava.interpreter
Class ClassContext

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

public class ClassContext
extends DelegatingContext

The context of a class body, including all members of the class (both declared and inherited).


Constructor Summary
ClassContext(TypeContext next, DJClass c)
           
 
Method Summary
protected  ClassContext duplicate(TypeContext next)
          Create a copy of this context with the given context enclosing it.
 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.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, 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.
 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 n)
          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
 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
 
Methods inherited from class edu.rice.cs.dynamicjava.interpreter.DelegatingContext
accessModule, getClassLoader, getLocalFunctions, importField, importMemberClass, importMemberClasses, importMethod, importStaticMembers, importTopLevelClass, importTopLevelClasses, setPackage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassContext

public ClassContext(TypeContext next,
                    DJClass c)
Method Detail

duplicate

protected ClassContext duplicate(TypeContext next)
Description copied from class: DelegatingContext
Create a copy of this context with the given context enclosing it.

Specified by:
duplicate in class DelegatingContext

typeExists

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

Specified by:
typeExists in interface TypeContext
Overrides:
typeExists in class DelegatingContext

memberClassExists

public boolean memberClassExists(java.lang.String name,
                                 TypeSystem ts)
Description copied from class: DelegatingContext
Test whether name is an in-scope member class

Specified by:
memberClassExists in interface TypeContext
Overrides:
memberClassExists in class DelegatingContext

typeContainingMemberClass

public ClassType typeContainingMemberClass(java.lang.String name,
                                           TypeSystem ts)
                                    throws AmbiguousNameException
Description copied from class: DelegatingContext
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
Overrides:
typeContainingMemberClass in class DelegatingContext
Throws:
AmbiguousNameException

topLevelClassExists

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

Specified by:
topLevelClassExists in interface TypeContext
Overrides:
topLevelClassExists in class DelegatingContext

getTopLevelClass

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

Specified by:
getTopLevelClass in interface TypeContext
Overrides:
getTopLevelClass in class DelegatingContext
Throws:
AmbiguousNameException

typeVariableExists

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

Specified by:
typeVariableExists in interface TypeContext
Overrides:
typeVariableExists in class DelegatingContext

getTypeVariable

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

Specified by:
getTypeVariable in interface TypeContext
Overrides:
getTypeVariable in class DelegatingContext

variableExists

public boolean variableExists(java.lang.String name,
                              TypeSystem ts)
Description copied from class: DelegatingContext
Test whether name is an in-scope field or local variable

Specified by:
variableExists in interface TypeContext
Overrides:
variableExists in class DelegatingContext

fieldExists

public boolean fieldExists(java.lang.String name,
                           TypeSystem ts)
Description copied from class: DelegatingContext
Test whether name is an in-scope field

Specified by:
fieldExists in interface TypeContext
Overrides:
fieldExists in class DelegatingContext

typeContainingField

public ClassType typeContainingField(java.lang.String name,
                                     TypeSystem ts)
                              throws AmbiguousNameException
Description copied from class: DelegatingContext
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
Overrides:
typeContainingField in class DelegatingContext
Throws:
AmbiguousNameException

localVariableExists

public boolean localVariableExists(java.lang.String name,
                                   TypeSystem ts)
Description copied from class: DelegatingContext
Test whether name is an in-scope local variable

Specified by:
localVariableExists in interface TypeContext
Overrides:
localVariableExists in class DelegatingContext

getLocalVariable

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

Specified by:
getLocalVariable in interface TypeContext
Overrides:
getLocalVariable in class DelegatingContext

functionExists

public boolean functionExists(java.lang.String name,
                              TypeSystem ts)
Description copied from class: DelegatingContext
Test whether name is an in-scope method or local function

Specified by:
functionExists in interface TypeContext
Overrides:
functionExists in class DelegatingContext

methodExists

public boolean methodExists(java.lang.String name,
                            TypeSystem ts)
Description copied from class: DelegatingContext
Test whether name is an in-scope method

Specified by:
methodExists in interface TypeContext
Overrides:
methodExists in class DelegatingContext

typeContainingMethod

public Type typeContainingMethod(java.lang.String name,
                                 TypeSystem ts)
Description copied from class: DelegatingContext
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
Overrides:
typeContainingMethod in class DelegatingContext

localFunctionExists

public boolean localFunctionExists(java.lang.String name,
                                   TypeSystem ts)
Description copied from class: DelegatingContext
Test whether name is an in-scope local function

Specified by:
localFunctionExists in interface TypeContext
Overrides:
localFunctionExists in class DelegatingContext

getLocalFunctions

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

Specified by:
getLocalFunctions in interface TypeContext
Overrides:
getLocalFunctions in class DelegatingContext

makeClassName

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

Specified by:
makeClassName in interface TypeContext
Overrides:
makeClassName in class DelegatingContext

makeAnonymousClassName

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

Specified by:
makeAnonymousClassName in interface TypeContext
Overrides:
makeAnonymousClassName in class DelegatingContext

getThis

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

Specified by:
getThis in interface TypeContext
Overrides:
getThis in class DelegatingContext

getThis

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

Specified by:
getThis in interface TypeContext
Overrides:
getThis in class DelegatingContext

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
Overrides:
getThis in class DelegatingContext

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
Overrides:
initializingClass in class DelegatingContext

getReturnType

public Type getReturnType()
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
Overrides:
getReturnType in class DelegatingContext

getDeclaredThrownTypes

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

Specified by:
getDeclaredThrownTypes in interface TypeContext
Overrides:
getDeclaredThrownTypes in class DelegatingContext