|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkoala.dynamicjava.interpreter.context.VariableContext
koala.dynamicjava.interpreter.context.GlobalContext
A global context.
Nested 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 |
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 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 |
protected static final ReferenceType CLASS_TYPE
protected static final ReferenceType MAP_TYPE
protected static final ReferenceType OBJECT_TYPE
protected static final ArrayType OBJECT_ARRAY_ARRAY
protected static final TypeExpression OBJECT_CLASS
protected static final java.lang.String LOCALS_NAME
protected static final FieldDeclaration LOCALS
protected static int classCount
protected ImportationManager importationManager
protected Interpreter interpreter
protected java.lang.ClassLoader classLoader
protected ClassLoaderContainer clc
protected java.util.List functions
protected boolean accessible
Constructor Detail |
public GlobalContext(Interpreter i)
i
- the interpreterpublic GlobalContext(Interpreter i, java.lang.ClassLoader cl)
i
- the interpretercl
- the classloader to usepublic GlobalContext(Interpreter i, java.util.Set entries)
i
- the interpreterentries
- a set of stringMethod Detail |
public void setAdditionalClassLoaderContainer(ClassLoaderContainer clc)
setAdditionalClassLoaderContainer
in interface Context
public void setAccessible(boolean accessible)
setAccessible
in interface Context
public boolean getAccessible()
getAccessible
in interface Context
protected java.lang.ClassLoader getAdditionalClassLoader()
public void setFunctions(java.util.List l)
setFunctions
in interface Context
public java.util.List getFunctions()
getFunctions
in interface Context
public Interpreter getInterpreter()
getInterpreter
in interface Context
public ImportationManager getImportationManager()
getImportationManager
in interface Context
public void setImportationManager(ImportationManager im)
setImportationManager
in interface Context
public boolean exists(java.lang.String name)
exists
in interface Context
name
- the identifierpublic boolean classExists(java.lang.String name)
classExists
in interface Context
name
- the identifierpublic void defineFunction(MethodDeclaration node)
defineFunction
in interface Context
node
- the function declarationpublic void defineClass(TypeDeclaration node)
defineClass
in interface Context
node
- the class declarationpublic boolean isDefined(java.lang.String name)
isDefined
in interface Context
name
- the name of the entry
public void setCurrentPackage(java.lang.String pkg)
setCurrentPackage
in interface Context
pkg
- the package namepublic java.lang.String getCurrentPackage()
getCurrentPackage
in interface Context
public void declarePackageImport(java.lang.String pkg)
declarePackageImport
in interface Context
pkg
- the package namepublic void declareClassImport(java.lang.String cname) throws java.lang.ClassNotFoundException
declareClassImport
in interface Context
cname
- the fully qualified class name
java.lang.ClassNotFoundException
- if the class cannot be foundpublic Node getDefaultQualifier(Node node)
getDefaultQualifier
in interface Context
node
- the current nodepublic Node getDefaultQualifier(Node node, java.lang.String tname)
getDefaultQualifier
in interface Context
node
- the current nodetname
- the qualifier of 'this'public LeftHandSideModifier getModifier(QualifiedName node)
getModifier
in interface Context
node
- a tree nodepublic LeftHandSideModifier getModifier(ObjectFieldAccess node)
getModifier
in interface Context
node
- a tree nodepublic LeftHandSideModifier getModifier(StaticFieldAccess node)
getModifier
in interface Context
node
- a tree nodepublic LeftHandSideModifier getModifier(SuperFieldAccess node)
getModifier
in interface Context
node
- a tree nodepublic java.lang.Object getHiddenArgument()
getHiddenArgument
in interface Context
public Expression createName(Node node, IdentifierToken name)
createName
in interface Context
node
- the current nodename
- the variable name
java.lang.IllegalStateException
- if the variable is not definedpublic java.lang.Class lookupClass(java.lang.String cname) throws java.lang.ClassNotFoundException
lookupClass
in interface Context
cname
- the class name
java.lang.ClassNotFoundException
- if the class cannot be foundpublic java.lang.Class lookupClass(java.lang.String cname, java.lang.String ccname) throws java.lang.ClassNotFoundException
lookupClass
in interface Context
cname
- the class nameccname
- the fully qualified name of the context class
java.lang.ClassNotFoundException
- if the class cannot be foundpublic java.lang.Class setProperties(SimpleAllocation node, java.lang.Class c, java.lang.Class[] cargs)
setProperties
in interface Context
node
- the allocation nodec
- the class of the constructorcargs
- the classes of the arguments of the constructorpublic java.lang.Class setProperties(ClassAllocation node, java.lang.Class c, java.lang.Class[] args, java.util.List memb)
setProperties
in interface Context
node
- the allocation nodec
- the class of the constructorargs
- the classes of the arguments of the constructormemb
- the class membersprotected ArrayInitializer createClassArrayInitializer()
public java.lang.reflect.Constructor lookupConstructor(java.lang.Class c, java.lang.Class[] params) throws java.lang.NoSuchMethodException
lookupConstructor
in interface Context
c
- the class of the constructorparams
- the parameter types
java.lang.NoSuchMethodException
- if the constructor cannot be foundpublic java.lang.Object invokeConstructor(SimpleAllocation node, java.lang.Object[] args)
invokeConstructor
in interface Context
node
- the SimpleAllocation nodeargs
- the argumentspublic java.lang.Object invokeConstructor(ClassAllocation node, java.lang.Object[] args)
invokeConstructor
in interface Context
node
- the ClassAllocation nodeargs
- the argumentspublic java.lang.reflect.Method lookupMethod(Node prefix, java.lang.String mname, java.lang.Class[] params) throws java.lang.NoSuchMethodException
lookupMethod
in interface Context
prefix
- the method prefixmname
- the method nameparams
- the parameter types
java.lang.NoSuchMethodException
- if the method cannot be foundpublic MethodDeclaration lookupFunction(java.lang.String mname, java.lang.Class[] params) throws NoSuchFunctionException
lookupFunction
in interface Context
mname
- the function nameparams
- the parameter types
NoSuchFunctionException
- if the function cannot be foundpublic java.lang.reflect.Method lookupSuperMethod(Node node, java.lang.String mname, java.lang.Class[] params) throws java.lang.NoSuchMethodException
lookupSuperMethod
in interface Context
node
- the current nodemname
- the method nameparams
- the parameter types
java.lang.NoSuchMethodException
- if the method cannot be findpublic java.lang.reflect.Field getField(java.lang.Class fc, java.lang.String fn) throws java.lang.NoSuchFieldException, AmbiguousFieldException
getField
in interface Context
fc
- the field classfn
- the field name
java.lang.NoSuchFieldException
- if the field cannot be find
AmbiguousFieldException
- if the field is ambiguouspublic java.lang.reflect.Field getSuperField(Node node, java.lang.String fn) throws java.lang.NoSuchFieldException, AmbiguousFieldException
getSuperField
in interface Context
node
- the current nodefn
- the field name
java.lang.NoSuchFieldException
- if the field cannot be find
AmbiguousFieldException
- if the field is ambiguousprotected void setAccessFlag(java.lang.reflect.Member m)
protected java.lang.String getPackageName(java.lang.Class c)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |