edu.rice.cs.dynamicjava.interpreter
Class FunctionContext

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

public class FunctionContext
extends DelegatingContext

The context of a function's (method, constructor, or local function) body, introducing the function's parameters.


Constructor Summary
FunctionContext(TypeContext next, Function f)
           
 
Method Summary
protected  FunctionContext duplicate(TypeContext next)
          Create a copy of this context with the given context enclosing it.
 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
 Iterable<Type> getDeclaredThrownTypes()
          The types that are allowed to be thrown in the current context.
 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 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 makeClassName(String n)
          Return a full name for a class with the given name declared here.
 boolean methodExists(String name, TypeSystem ts)
          Test whether name is an in-scope method
 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.
 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 variableExists(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, getTopLevelClass, getTypeVariable, importField, importMemberClass, importMemberClasses, importMethod, importStaticMembers, importTopLevelClass, importTopLevelClasses, makeAnonymousClassName, memberClassExists, setPackage, topLevelClassExists, typeContainingMemberClass, typeExists, typeVariableExists
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionContext

public FunctionContext(TypeContext next,
                       Function f)
Method Detail

duplicate

protected FunctionContext 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

variableExists

public boolean variableExists(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

localVariableExists

public boolean localVariableExists(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(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

fieldExists

public boolean fieldExists(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(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

functionExists

public boolean functionExists(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

localFunctionExists

public boolean localFunctionExists(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 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
Overrides:
getLocalFunctions in class DelegatingContext

methodExists

public boolean methodExists(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(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

makeClassName

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

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

getThis

public DJClass getThis()
Description copied from class: DelegatingContext
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(String className)
Description copied from class: DelegatingContext
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()
Description copied from class: DelegatingContext
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 Iterable<Type> getDeclaredThrownTypes()
Description copied from class: DelegatingContext
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