DynamicJava Javadoc: Class GlobalContext

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## koala.dynamicjava.interpreter.context
Class GlobalContext

    java.lang.Object
      |
      +--koala.dynamicjava.interpreter.context.VariableContext
            |
            +--koala.dynamicjava.interpreter.context.GlobalContext

All Implemented Interfaces:
  Context, SimpleContext

Direct Known Subclasses:
  StaticContext

public class GlobalContext
extends VariableContext
implements Context

A global context.

Inner Class Summary
`protected class` | `GlobalContext.PseudoClassLoader` To test the existance of a class without loading it
`protected class` | `GlobalContext.PseudoError` To test the existance of a class without loading it

Inner classes inherited from class koala.dynamicjava.interpreter.context.VariableContext
`VariableContext.AbstractVariable, VariableContext.Constant, VariableContext.Link, VariableContext.LinkFactory, VariableContext.Scope, VariableContext.Variable`

Field Summary
`protected boolean` | `accessible`
`protected static ReferenceType` | `CLASS_TYPE`
`protected static int` | `classCount` To generate an unique name for the generated classes
`protected java.lang.ClassLoader` | `classLoader` The class loader
`protected ClassLoaderContainer` | `clc` The class loader container
`protected java.util.List` | `functions` The functions
`protected ImportationManager` | `importationManager` The importation manager
`protected Interpreter` | `interpreter` The interpreter
`protected static FieldDeclaration` | `LOCALS`
`protected static java.lang.String` | `LOCALS_NAME`
`protected static ReferenceType` | `MAP_TYPE`
`protected static ArrayType` | `OBJECT_ARRAY_ARRAY`
`protected static TypeExpression` | `OBJECT_CLASS`
`protected static ReferenceType` | `OBJECT_TYPE`

Fields inherited from class koala.dynamicjava.interpreter.context.VariableContext
`cscope, scope, scopes`

Constructor Summary
`GlobalContext(Interpreter i)` Creates a new context
`GlobalContext(Interpreter i, java.lang.ClassLoader cl)` Creates a new context
`GlobalContext(Interpreter i, java.util.Set entries)` Creates a new context initialized with the given entries defined in the initial scope.

Method Summary
`boolean` | `classExists(java.lang.String name)` Whether a simple identifier is a class
`protected ArrayInitializer` | `createClassArrayInitializer()` Creates an initializer for the variable class array used to implement inner classes
`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 or type in this context.
`boolean` | `getAccessible()` Returns the accessibility state of this context.
`protected java.lang.ClassLoader` | `getAdditionalClassLoader()` Gets the additional class loader
`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
`protected java.lang.String` | `getPackageName(java.lang.Class c)` Gets the package name for the given class
`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 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
`protected void` | `setAccessFlag(java.lang.reflect.Member m)` Sets the access flag of a member
`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[] cargs)` Sets the properties of a SimpleAllocation node

Methods inherited from class koala.dynamicjava.interpreter.context.VariableContext
`define, defineConstant, defineVariables, enterScope, enterScope, get, getConstants, getCurrentScopeVariableNames, getCurrentScopeVariables, isDefinedVariable, isFinal, leaveScope, set, setConstant, setVariable`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface koala.dynamicjava.interpreter.context.SimpleContext
`define, defineConstant, defineVariables, enterScope, enterScope, get, getConstants, getCurrentScopeVariableNames, getCurrentScopeVariables, isDefinedVariable, isFinal, leaveScope, set, setConstant, setVariable`

Field Detail

### CLASS_TYPE

    protected static final ReferenceType CLASS_TYPE

### MAP_TYPE

    protected static final ReferenceType MAP_TYPE

### OBJECT_TYPE

    protected static final ReferenceType OBJECT_TYPE

### OBJECT_ARRAY_ARRAY

    protected static final ArrayType OBJECT_ARRAY_ARRAY

### OBJECT_CLASS

    protected static final TypeExpression OBJECT_CLASS

### LOCALS_NAME

    protected static final java.lang.String LOCALS_NAME

### LOCALS

    protected static final FieldDeclaration LOCALS

### classCount

    protected static int classCount

  To generate an unique name for the generated classes

### importationManager

    protected ImportationManager importationManager

  The importation manager

### interpreter

    protected Interpreter interpreter

  The interpreter

### classLoader

    protected java.lang.ClassLoader classLoader

  The class loader

### clc

    protected ClassLoaderContainer clc

  The class loader container

### functions

    protected java.util.List functions

  The functions

### accessible

    protected boolean accessible

Constructor Detail

### GlobalContext

    public GlobalContext(Interpreter i)

  Creates a new context
  Parameters:
    `i` - the interpreter

### GlobalContext

    public GlobalContext(Interpreter i,
                         java.lang.ClassLoader cl)

  Creates a new context
  Parameters:
    `i` - the interpreter
    `cl` - the classloader to use
    `cl2` - the additional classloader

### GlobalContext

    public GlobalContext(Interpreter i,
                         java.util.Set entries)

  Creates a new context initialized with the given entries defined in the initial scope.
  Parameters:
    `i` - the interpreter
    `entries` - a set of string

Method Detail

### setAdditionalClassLoaderContainer

    public void setAdditionalClassLoaderContainer(ClassLoaderContainer clc)

  Sets the additional class loader container
  Specified by:
    `setAdditionalClassLoaderContainer` in interface `Context`

### setAccessible

    public void setAccessible(boolean accessible)

  Allows the scripts to access private fields.
  Specified by:
    `setAccessible` in interface `Context`

### getAccessible

    public boolean getAccessible()

  Returns the accessibility state of this context.
  Specified by:
    `getAccessible` in interface `Context`

### getAdditionalClassLoader

    protected java.lang.ClassLoader getAdditionalClassLoader()

  Gets the additional class loader

### setFunctions

    public void setFunctions(java.util.List l)

  Sets the defined functions
  Specified by:
    `setFunctions` in interface `Context`

### getFunctions

    public java.util.List getFunctions()

  Returns the defined functions
  Specified by:
    `getFunctions` in interface `Context`

### getInterpreter

    public Interpreter getInterpreter()

  Returns the current interpreter
  Specified by:
    `getInterpreter` in interface `Context`

### getImportationManager

    public ImportationManager getImportationManager()

  Returns the importation manager
  Specified by:
    `getImportationManager` in interface `Context`

### setImportationManager

    public void setImportationManager(ImportationManager im)

  Sets the importation manager
  Specified by:
    `setImportationManager` in interface `Context`

### exists

    public boolean exists(java.lang.String name)

  Whether a simple identifier represents an existing variable or field or type in this context.
  Specified by:
    `exists` in interface `Context`
  Parameters:
    `name` - the identifier

### classExists

    public boolean classExists(java.lang.String name)

  Whether a simple identifier is a class
  Specified by:
    `classExists` in interface `Context`
  Parameters:
    `name` - the identifier

### defineFunction

    public void defineFunction(MethodDeclaration node)

  Defines a MethodDeclaration as a function
  Specified by:
    `defineFunction` in interface `Context`
  Parameters:
    `node` - the function declaration

### defineClass

    public void defineClass(TypeDeclaration node)

  Defines a class from its syntax tree
  Specified by:
    `defineClass` in interface `Context`
  Parameters:
    `node` - the class declaration

### isDefined

    public boolean isDefined(java.lang.String name)

  Tests whether a variable is defined in this context
  Specified by:
    `isDefined` in interface `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
  Specified by:
    `setCurrentPackage` in interface `Context`
  Parameters:
    `pkg` - the package name

### getCurrentPackage

    public java.lang.String getCurrentPackage()

  Returns the current package
  Specified by:
    `getCurrentPackage` in interface `Context`

### declarePackageImport

    public void declarePackageImport(java.lang.String pkg)

  Declares a new import-on-demand clause
  Specified by:
    `declarePackageImport` in interface `Context`
  Parameters:
    `pkg` - the package name

### declareClassImport

    public void declareClassImport(java.lang.String cname)
                            throws java.lang.ClassNotFoundException

  Declares a new single-type-import clause
  Specified by:
    `declareClassImport` in interface `Context`
  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
  Specified by:
    `getDefaultQualifier` in interface `Context`
  Parameters:
    `node` - the current node

### getDefaultQualifier

    public Node getDefaultQualifier(Node node,
                                    java.lang.String tname)

  Returns the default qualifier for this context
  Specified by:
    `getDefaultQualifier` in interface `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
  Specified by:
    `getModifier` in interface `Context`
  Parameters:
    `node` - a tree node

### getModifier

    public LeftHandSideModifier getModifier(ObjectFieldAccess node)

  Returns the modifier that match the given node
  Specified by:
    `getModifier` in interface `Context`
  Parameters:
    `node` - a tree node

### getModifier

    public LeftHandSideModifier getModifier(StaticFieldAccess node)

  Returns the modifier that match the given node
  Specified by:
    `getModifier` in interface `Context`
  Parameters:
    `node` - a tree node

### getModifier

    public LeftHandSideModifier getModifier(SuperFieldAccess node)

  Returns the modifier that match the given node
  Specified by:
    `getModifier` in interface `Context`
  Parameters:
    `node` - a tree node

### getHiddenArgument

    public java.lang.Object getHiddenArgument()

  Returns the default argument to pass to methods in this context
  Specified by:
    `getHiddenArgument` in interface `Context`

### createName

    public Expression createName(Node node,
                                 IdentifierToken name)

  Creates the tree that is associated with the given name
  Specified by:
    `createName` in interface `Context`
  Parameters:
    `node` - the current node
    `name` - the variable name
  Throws:
    `java.lang.IllegalStateException` - if the variable is not defined

### lookupClass

    public java.lang.Class lookupClass(java.lang.String cname)
                                throws java.lang.ClassNotFoundException

  Looks for a class
  Specified by:
    `lookupClass` in interface `Context`
  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)
  Specified by:
    `lookupClass` in interface `Context`
  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[] cargs)

  Sets the properties of a SimpleAllocation node
  Specified by:
    `setProperties` in interface `Context`
  Parameters:
    `node` - the allocation node
    `c` - the class of the constructor
    `cargs` - 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
  Specified by:
    `setProperties` in interface `Context`
  Parameters:
    `node` - the allocation node
    `c` - the class of the constructor
    `args` - the classes of the arguments of the constructor
    `memb` - the class members

### createClassArrayInitializer

    protected ArrayInitializer createClassArrayInitializer()

  Creates an initializer for the variable class array used to implement inner classes

### lookupConstructor

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

  Looks for a constructor
  Specified by:
    `lookupConstructor` in interface `Context`
  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
  Specified by:
    `invokeConstructor` in interface `Context`
  Parameters:
    `node` - the SimpleAllocation node
    `args` - the arguments

### invokeConstructor

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

  Invokes a constructor
  Specified by:
    `invokeConstructor` in interface `Context`
  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
  Specified by:
    `lookupMethod` in interface `Context`
  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
  Specified by:
    `lookupFunction` in interface `Context`
  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
  Specified by:
    `lookupSuperMethod` in interface `Context`
  Parameters:
    `node` - the current node
    `mname` - the method name
    `params` - the parameter types
  Throws:
    `java.lang.NoSuchMethodException` - if the method cannot be find

### getField

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

  Looks for a field
  Specified by:
    `getField` in interface `Context`
  Parameters:
    `fc` - the field class
    `fn` - the field name
  Throws:
    `java.lang.NoSuchFieldException` - if the field cannot be find
    `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
  Specified by:
    `getSuperField` in interface `Context`
  Parameters:
    `node` - the current node
    `fn` - the field name
  Throws:
    `java.lang.NoSuchFieldException` - if the field cannot be find
    `AmbiguousFieldException` - if the field is ambiguous

### setAccessFlag

    protected void setAccessFlag(java.lang.reflect.Member m)

  Sets the access flag of a member

### getPackageName

    protected java.lang.String getPackageName(java.lang.Class c)

  Gets the package name for the given class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001 Stephane Hillion. All Rights Reserved.