koala.dynamicjava.interpreter.context
Class MethodContext

java.lang.Object
  extended bykoala.dynamicjava.interpreter.context.VariableContext
      extended bykoala.dynamicjava.interpreter.context.GlobalContext
          extended bykoala.dynamicjava.interpreter.context.StaticContext
              extended bykoala.dynamicjava.interpreter.context.MethodContext
All Implemented Interfaces:
Context, SimpleContext

public class MethodContext
extends StaticContext

A method method context.


Nested Class Summary
 
Nested classes inherited from class koala.dynamicjava.interpreter.context.GlobalContext
GlobalContext.PseudoClassLoader, GlobalContext.PseudoError
 
Nested classes inherited from class koala.dynamicjava.interpreter.context.VariableContext
VariableContext.AbstractVariable, VariableContext.Constant, VariableContext.Link, VariableContext.LinkFactory, VariableContext.Scope, VariableContext.Variable
 
Field Summary
protected static Identifier thisIdentifier
          The "this" identifier
 
Fields inherited from class koala.dynamicjava.interpreter.context.StaticContext
declaringClass, defaultQualifier
 
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
MethodContext(Interpreter i, java.lang.Class c, java.lang.Object obj, ImportationManager im)
          Creates a new context
MethodContext(Interpreter i, java.lang.Class c, java.lang.Object obj, java.util.Set fp)
          Creates a new context
 
Method Summary
 Expression createName(Node node, IdentifierToken name)
          Creates the tree that is associated with the given name
 Node getDefaultQualifier(Node node, java.lang.String tname)
          Returns the default qualifier for this context
 java.lang.Object getHiddenArgument()
          Returns the default argument to pass to methods in this context
protected  java.lang.String getOuterThisName(java.lang.Class c)
          Finds the name of the reference to an outerclass in the given 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
protected  boolean isInnerclass(java.lang.Class ic, java.lang.Class oc)
          Tests whether an class is an inner class of another
 java.lang.reflect.Method lookupMethod(Node prefix, java.lang.String mname, java.lang.Class[] params)
          Looks for a method
 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.StaticContext
classExists, defineClass, defineFunction, fieldExists, getDefaultQualifier, getField, getModifier, getSuperField, isDefined, isInnerClass, lookupClass, lookupSuperMethod, setAccessFlag
 
Methods inherited from class koala.dynamicjava.interpreter.context.GlobalContext
createClassArrayInitializer, declareClassImport, declarePackageImport, exists, getAccessible, getAdditionalClassLoader, getCurrentPackage, getFunctions, getImportationManager, getInterpreter, getModifier, getModifier, getModifier, getPackageName, lookupClass, lookupConstructor, lookupFunction, setAccessible, setAdditionalClassLoaderContainer, setCurrentPackage, setFunctions, setImportationManager
 
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

thisIdentifier

protected static final Identifier thisIdentifier
The "this" identifier

Constructor Detail

MethodContext

public MethodContext(Interpreter i,
                     java.lang.Class c,
                     java.lang.Object obj,
                     ImportationManager im)
Creates a new context

Parameters:
i - the interpreter
c - the declaring class of the method
obj - the current object
im - the importation manager

MethodContext

public MethodContext(Interpreter i,
                     java.lang.Class c,
                     java.lang.Object obj,
                     java.util.Set fp)
Creates a new context

Parameters:
i - the interpreter
c - the declaring class of the method
obj - the current object
fp - the formal parameters
Method Detail

getDefaultQualifier

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

Specified by:
getDefaultQualifier in interface Context
Overrides:
getDefaultQualifier in class GlobalContext
Parameters:
node - the current node
tname - the qualifier of 'this'

createName

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

Specified by:
createName in interface Context
Overrides:
createName in class StaticContext
Parameters:
node - the current node
name - the variable name
Throws:
java.lang.IllegalStateException - if the variable is not defined

getHiddenArgument

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

Specified by:
getHiddenArgument in interface Context
Overrides:
getHiddenArgument in class GlobalContext

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

invokeConstructor

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

Specified by:
invokeConstructor in interface Context
Overrides:
invokeConstructor in class GlobalContext
Parameters:
node - the SimpleAllocation node
args - the arguments

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

invokeConstructor

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

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

isInnerclass

protected boolean isInnerclass(java.lang.Class ic,
                               java.lang.Class oc)
Tests whether an class is an inner class of another

Parameters:
ic - the possibly inner class
oc - the possibly outer class

getOuterThisName

protected java.lang.String getOuterThisName(java.lang.Class c)
Finds the name of the reference to an outerclass in the given class



Copyright © 2001 Stephane Hillion. All Rights Reserved.