koala.dynamicjava.interpreter.context
Class StaticContext

java.lang.Object
  |
  +--koala.dynamicjava.interpreter.context.VariableContext
        |
        +--koala.dynamicjava.interpreter.context.GlobalContext
              |
              +--koala.dynamicjava.interpreter.context.StaticContext
All Implemented Interfaces:
Context, SimpleContext
Direct Known Subclasses:
MethodContext

public class StaticContext
extends GlobalContext

A static method context.


Inner classes inherited from class koala.dynamicjava.interpreter.context.GlobalContext
GlobalContext.PseudoClassLoader, GlobalContext.PseudoError
 
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  java.lang.Class declaringClass
          The declaring class of the method
protected  Node defaultQualifier
          The default qualifier
 
Fields inherited from class koala.dynamicjava.interpreter.context.GlobalContext
accessible, CLASS_TYPE, classCount, classLoader, clc, functions, importationManager, interpreter, LOCALS, LOCALS_NAME, MAP_TYPE, OBJECT_ARRAY_ARRAY, OBJECT_CLASS, OBJECT_TYPE
 
Fields inherited from class koala.dynamicjava.interpreter.context.VariableContext
cscope, scope, scopes
 
Constructor Summary
StaticContext(Interpreter i, java.lang.Class c, ImportationManager im)
          Creates a new context
StaticContext(Interpreter i, java.lang.Class c, java.util.Set fp)
          Creates a new context
 
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 defineClass(TypeDeclaration node)
          Defines a class from its syntax tree
 void defineFunction(MethodDeclaration node)
          Defines a MethodDeclaration as a function
protected  boolean fieldExists(java.lang.String name)
          Whether the given name represents a field in this context
 Node getDefaultQualifier(Node node)
          Returns the default qualifier for this context
 java.lang.reflect.Field getField(java.lang.Class fc, java.lang.String fn)
          Looks for a field
 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
 boolean isDefined(java.lang.String name)
          Tests whether a variable is defined in this context
protected  boolean isInnerClass(java.lang.Class c1, java.lang.Class c2)
          Is c1 an inner class of c2?
 java.lang.Class lookupClass(java.lang.String cname)
          Looks for a class
 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
 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
 
Methods inherited from class koala.dynamicjava.interpreter.context.GlobalContext
createClassArrayInitializer, declareClassImport, declarePackageImport, exists, getAccessible, getAdditionalClassLoader, getCurrentPackage, getDefaultQualifier, getFunctions, getHiddenArgument, getImportationManager, getInterpreter, getModifier, getModifier, getModifier, getPackageName, invokeConstructor, invokeConstructor, lookupClass, lookupConstructor, lookupFunction, setAccessible, setAdditionalClassLoaderContainer, setCurrentPackage, setFunctions, setImportationManager, setProperties
 
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

declaringClass

protected java.lang.Class declaringClass
The declaring class of the method

defaultQualifier

protected Node defaultQualifier
The default qualifier
Constructor Detail

StaticContext

public StaticContext(Interpreter i,
                     java.lang.Class c,
                     ImportationManager im)
Creates a new context
Parameters:
i - the interpreter
c - the declaring class of the method
im - the importation manager

StaticContext

public StaticContext(Interpreter i,
                     java.lang.Class c,
                     java.util.Set fp)
Creates a new context
Parameters:
i - the interpreter
c - the declaring class of the method
fp - the formal parameters
Method Detail

isDefined

public boolean isDefined(java.lang.String name)
Tests whether a variable is defined in this context
Overrides:
isDefined in class GlobalContext
Parameters:
name - the name of the entry
Returns:
false if the variable is undefined

getField

public java.lang.reflect.Field getField(java.lang.Class fc,
                                        java.lang.String fn)
                                 throws java.lang.NoSuchFieldException,
                                        AmbiguousFieldException
Looks for a field
Overrides:
getField in class GlobalContext
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

createName

public Expression createName(Node node,
                             IdentifierToken name)
Creates the tree that is associated with the given name
Overrides:
createName in class GlobalContext
Parameters:
node - the current node
name - the variable name
Throws:
java.lang.IllegalStateException - if the variable is not defined

getDefaultQualifier

public Node getDefaultQualifier(Node node)
Returns the default qualifier for this context
Overrides:
getDefaultQualifier in class GlobalContext
Parameters:
node - the current node

getModifier

public LeftHandSideModifier getModifier(SuperFieldAccess node)
Returns the modifier that match the given node
Overrides:
getModifier in class GlobalContext
Parameters:
node - a tree node

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
Overrides:
lookupMethod in class GlobalContext
Parameters:
prefix - the method prefix
mname - the method name
params - the parameter types
Throws:
java.lang.NoSuchMethodException - if the method cannot be found

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
Overrides:
getSuperField in class GlobalContext
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

lookupClass

public java.lang.Class lookupClass(java.lang.String cname)
                            throws java.lang.ClassNotFoundException
Looks for a class
Overrides:
lookupClass in class GlobalContext
Parameters:
cname - the class name
Throws:
java.lang.ClassNotFoundException - if the class cannot be found

defineFunction

public void defineFunction(MethodDeclaration node)
Defines a MethodDeclaration as a function
Overrides:
defineFunction in class GlobalContext
Parameters:
node - the function declaration

defineClass

public void defineClass(TypeDeclaration node)
Defines a class from its syntax tree
Overrides:
defineClass in class GlobalContext
Parameters:
node - the class declaration

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
Overrides:
setProperties in class GlobalContext
Parameters:
node - the allocation node
c - the class of the constructor
args - the classes of the arguments of the constructor
memb - the class members

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
Overrides:
lookupSuperMethod in class GlobalContext
Parameters:
node - the current node
mname - the method name
params - the parameter types
Throws:
java.lang.NoSuchMethodException - if the method cannot be found

classExists

public boolean classExists(java.lang.String name)
Whether a simple identifier is a class
Overrides:
classExists in class GlobalContext
Parameters:
name - the identifier

setAccessFlag

protected void setAccessFlag(java.lang.reflect.Member m)
Sets the access flag of a member
Overrides:
setAccessFlag in class GlobalContext

isInnerClass

protected boolean isInnerClass(java.lang.Class c1,
                               java.lang.Class c2)
Is c1 an inner class of c2?

fieldExists

protected boolean fieldExists(java.lang.String name)
Whether the given name represents a field in this context
Parameters:
name - the field name


Copyright © 2001 Stephane Hillion. All Rights Reserved.