koala.dynamicjava.interpreter.context
Interface Context

All Superinterfaces:
SimpleContext
All Known Implementing Classes:
GlobalContext

public interface Context
extends SimpleContext

The classes that implements this interface represent contexts of execution


Method Summary
 boolean classExists(java.lang.String name)
          Whether a simple identifier is a class
 Expression createName(Node node, IdentifierToken name)
          Creates the tree that is associated with the given name
 void declareClassImport(java.lang.String cname)
          Declares a new single-type-import clause
 void declarePackageImport(java.lang.String pkg)
          Declares a new import-on-demand clause
 void defineClass(TypeDeclaration node)
          Defines a class from its syntax tree
 void defineFunction(MethodDeclaration node)
          Defines a MethodDeclaration as a function
 boolean exists(java.lang.String name)
          Whether a simple identifier represents an existing variable or field in this context
 boolean getAccessible()
          Returns the accessibility state of this context.
 java.lang.String getCurrentPackage()
          Returns the current package
 Node getDefaultQualifier(Node node)
          Returns the default qualifier for this context
 Node getDefaultQualifier(Node node, java.lang.String tname)
          Returns the default qualifier for this context
 java.lang.reflect.Field getField(java.lang.Class fc, java.lang.String fn)
          Looks for a field
 java.util.List getFunctions()
          Returns the defined functions
 java.lang.Object getHiddenArgument()
          Returns the default argument to pass to methods in this context
 ImportationManager getImportationManager()
          Returns the importation manager
 Interpreter getInterpreter()
          Returns the current interpreter
 LeftHandSideModifier getModifier(ObjectFieldAccess node)
          Returns the modifier that match the given node
 LeftHandSideModifier getModifier(QualifiedName node)
          Returns the modifier that match the given node
 LeftHandSideModifier getModifier(StaticFieldAccess node)
          Returns the modifier that match the given node
 LeftHandSideModifier getModifier(SuperFieldAccess node)
          Returns the modifier that match the given node
 java.lang.reflect.Field getSuperField(Node node, java.lang.String fn)
          Looks for a field in the super class
 java.lang.Object invokeConstructor(ClassAllocation node, java.lang.Object[] args)
          Invokes a constructor
 java.lang.Object invokeConstructor(SimpleAllocation node, java.lang.Object[] args)
          Invokes a constructor
 boolean isDefined(java.lang.String name)
          Tests whether a variable or a field is defined in this context
 java.lang.Class lookupClass(java.lang.String cname)
          Looks for a class
 java.lang.Class lookupClass(java.lang.String cname, java.lang.String ccname)
          Looks for a class (context-free lookup)
 java.lang.reflect.Constructor lookupConstructor(java.lang.Class c, java.lang.Class[] params)
          Looks for a constructor
 MethodDeclaration lookupFunction(java.lang.String mname, java.lang.Class[] params)
          Looks for a function
 java.lang.reflect.Method lookupMethod(Node prefix, java.lang.String mname, java.lang.Class[] params)
          Looks for a method
 java.lang.reflect.Method lookupSuperMethod(Node node, java.lang.String mname, java.lang.Class[] params)
          Looks for a super method
 void setAccessible(boolean accessible)
          Allows the scripts to access private fields.
 void setAdditionalClassLoaderContainer(ClassLoaderContainer clc)
          Sets the additional class loader container
 void setCurrentPackage(java.lang.String pkg)
          Sets the current package
 void setFunctions(java.util.List l)
          Sets the defined functions
 void setImportationManager(ImportationManager im)
          Sets the importation manager
 java.lang.Class setProperties(ClassAllocation node, java.lang.Class c, java.lang.Class[] args, java.util.List memb)
          Sets the properties of a ClassAllocation node
 java.lang.Class setProperties(SimpleAllocation node, java.lang.Class c, java.lang.Class[] args)
          Sets the properties of a SimpleAllocation node
 
Methods inherited from interface koala.dynamicjava.interpreter.context.SimpleContext
define, defineConstant, defineVariables, enterScope, enterScope, get, getConstants, getCurrentScopeVariableNames, getCurrentScopeVariables, isDefinedVariable, isFinal, leaveScope, set, setConstant, setVariable
 

Method Detail

setAdditionalClassLoaderContainer

public void setAdditionalClassLoaderContainer(ClassLoaderContainer clc)
Sets the additional class loader container


setAccessible

public void setAccessible(boolean accessible)
Allows the scripts to access private fields.


getAccessible

public boolean getAccessible()
Returns the accessibility state of this context.


setFunctions

public void setFunctions(java.util.List l)
Sets the defined functions


getFunctions

public java.util.List getFunctions()
Returns the defined functions


getInterpreter

public Interpreter getInterpreter()
Returns the current interpreter


getImportationManager

public ImportationManager getImportationManager()
Returns the importation manager


setImportationManager

public void setImportationManager(ImportationManager im)
Sets the importation manager


exists

public boolean exists(java.lang.String name)
Whether a simple identifier represents an existing variable or field in this context

Parameters:
name - the identifier

classExists

public boolean classExists(java.lang.String name)
Whether a simple identifier is a class

Parameters:
name - the identifier

isDefined

public boolean isDefined(java.lang.String name)
Tests whether a variable or a field is defined in this context

Parameters:
name - the name of the entry
Returns:
false if the variable is undefined

setCurrentPackage

public void setCurrentPackage(java.lang.String pkg)
Sets the current package

Parameters:
pkg - the package name

getCurrentPackage

public java.lang.String getCurrentPackage()
Returns the current package


declarePackageImport

public void declarePackageImport(java.lang.String pkg)
Declares a new import-on-demand clause

Parameters:
pkg - the package name

declareClassImport

public void declareClassImport(java.lang.String cname)
                        throws java.lang.ClassNotFoundException
Declares a new single-type-import clause

Parameters:
cname - the fully qualified class name
Throws:
java.lang.ClassNotFoundException - if the class cannot be found

getDefaultQualifier

public Node getDefaultQualifier(Node node)
Returns the default qualifier for this context

Parameters:
node - the current node

getDefaultQualifier

public Node getDefaultQualifier(Node node,
                                java.lang.String tname)
Returns the default qualifier for this context

Parameters:
node - the current node
tname - the qualifier of 'this'

getModifier

public LeftHandSideModifier getModifier(QualifiedName node)
Returns the modifier that match the given node

Parameters:
node - a tree node

getModifier

public LeftHandSideModifier getModifier(StaticFieldAccess node)
Returns the modifier that match the given node

Parameters:
node - a tree node

getModifier

public LeftHandSideModifier getModifier(ObjectFieldAccess node)
Returns the modifier that match the given node

Parameters:
node - a tree node

getModifier

public LeftHandSideModifier getModifier(SuperFieldAccess node)
Returns the modifier that match the given node

Parameters:
node - a tree node

getHiddenArgument

public java.lang.Object getHiddenArgument()
Returns the default argument to pass to methods in this context


createName

public Expression createName(Node node,
                             IdentifierToken name)
Creates the tree that is associated with the given name

Parameters:
node - the current node
name - the variable name
Throws:
java.lang.IllegalStateException - if the variable is not defined

defineFunction

public void defineFunction(MethodDeclaration node)
Defines a MethodDeclaration as a function

Parameters:
node - the function declaration

defineClass

public void defineClass(TypeDeclaration node)
Defines a class from its syntax tree

Parameters:
node - the class declaration

lookupClass

public java.lang.Class lookupClass(java.lang.String cname)
                            throws java.lang.ClassNotFoundException
Looks for a class

Parameters:
cname - the class name
Throws:
java.lang.ClassNotFoundException - if the class cannot be found

lookupClass

public java.lang.Class lookupClass(java.lang.String cname,
                                   java.lang.String ccname)
                            throws java.lang.ClassNotFoundException
Looks for a class (context-free lookup)

Parameters:
cname - the class name
ccname - the fully qualified name of the context class
Throws:
java.lang.ClassNotFoundException - if the class cannot be found

setProperties

public java.lang.Class setProperties(SimpleAllocation node,
                                     java.lang.Class c,
                                     java.lang.Class[] args)
Sets the properties of a SimpleAllocation node

Parameters:
node - the allocation node
c - the class of the constructor
args - the classes of the arguments of the constructor

setProperties

public java.lang.Class setProperties(ClassAllocation node,
                                     java.lang.Class c,
                                     java.lang.Class[] args,
                                     java.util.List memb)
Sets the properties of a ClassAllocation node

Parameters:
node - the allocation node
c - the class of the constructor
args - the classes of the arguments of the constructor
memb - the class members

lookupConstructor

public java.lang.reflect.Constructor lookupConstructor(java.lang.Class c,
                                                       java.lang.Class[] params)
                                                throws java.lang.NoSuchMethodException
Looks for a constructor

Parameters:
c - the class of the constructor
params - the parameter types
Throws:
java.lang.NoSuchMethodException - if the constructor cannot be found

invokeConstructor

public java.lang.Object invokeConstructor(SimpleAllocation node,
                                          java.lang.Object[] args)
Invokes a constructor

Parameters:
node - the SimpleAllocation node
args - the arguments

invokeConstructor

public java.lang.Object invokeConstructor(ClassAllocation node,
                                          java.lang.Object[] args)
Invokes a constructor

Parameters:
node - the ClassAllocation node
args - the arguments

lookupMethod

public java.lang.reflect.Method lookupMethod(Node prefix,
                                             java.lang.String mname,
                                             java.lang.Class[] params)
                                      throws java.lang.NoSuchMethodException
Looks for a method

Parameters:
prefix - the method prefix
mname - the method name
params - the parameter types
Throws:
java.lang.NoSuchMethodException - if the method cannot be found

lookupFunction

public MethodDeclaration lookupFunction(java.lang.String mname,
                                        java.lang.Class[] params)
                                 throws NoSuchFunctionException
Looks for a function

Parameters:
mname - the function name
params - the parameter types
Throws:
NoSuchFunctionException - if the function cannot be found

lookupSuperMethod

public java.lang.reflect.Method lookupSuperMethod(Node node,
                                                  java.lang.String mname,
                                                  java.lang.Class[] params)
                                           throws java.lang.NoSuchMethodException
Looks for a super method

Parameters:
node - the current node
mname - the method name
params - the parameter types
Throws:
java.lang.NoSuchMethodException - if the method cannot be found

getField

public java.lang.reflect.Field getField(java.lang.Class fc,
                                        java.lang.String fn)
                                 throws java.lang.NoSuchFieldException,
                                        AmbiguousFieldException
Looks for a field

Parameters:
fc - the field class
fn - the field name
Throws:
java.lang.NoSuchFieldException - if the field cannot be found
AmbiguousFieldException - if the field is ambiguous

getSuperField

public java.lang.reflect.Field getSuperField(Node node,
                                             java.lang.String fn)
                                      throws java.lang.NoSuchFieldException,
                                             AmbiguousFieldException
Looks for a field in the super class

Parameters:
node - the current node
fn - the field name
Throws:
java.lang.NoSuchFieldException - if the field cannot be found
AmbiguousFieldException - if the field is ambiguous


Copyright © 2001 Stephane Hillion. All Rights Reserved.