|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--koala.dynamicjava.interpreter.TreeInterpreter
This class contains method to interpret the constructs of the language.
| Inner Class Summary | |
protected class |
TreeInterpreter.ConstructorParametersDescriptor
Used to store the informations about explicit constructors invocation |
protected class |
TreeInterpreter.MethodDescriptor
Used to store the informations about dynamically created methods |
| Field Summary | |
protected boolean |
accessible
Track the state of calls to 'setAccessible' |
protected Context |
checkVisitorContext
|
protected TreeClassLoader |
classLoader
The class loader |
protected static java.util.Map |
constructorParameters
The explicit constructor call parameters |
protected Context |
evalVisitorContext
|
protected LibraryFinder |
libraryFinder
The library finder |
protected static java.util.Map |
methods
The methods |
protected Context |
nameVisitorContext
|
protected static int |
nClass
Used to generate classes |
protected ParserFactory |
parserFactory
The parser |
| Constructor Summary | |
TreeInterpreter(ParserFactory pf)
Creates a new interpreter |
|
| Method Summary | |
void |
addClassPath(java.lang.String path)
Adds a class search path |
void |
addClassURL(java.net.URL url)
Adds a class search URL |
void |
addLibraryPath(java.lang.String path)
Adds a library search path |
void |
addLibrarySuffix(java.lang.String s)
Adds a library file suffix |
java.util.List |
buildStatementList(java.io.Reader r,
java.lang.String fname)
Parses a script and creates the associated syntax trees. |
java.lang.Class |
defineClass(java.lang.String name,
byte[] code)
Converts an array of bytes into an instance of the class Class |
void |
defineVariable(java.lang.String name,
boolean value)
Defines a boolean variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
byte value)
Defines a byte variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
char value)
Defines a char variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
double value)
Defines an double variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
float value)
Defines an float variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
int value)
Defines an int variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
long value)
Defines an long variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
java.lang.Object value)
Defines a variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
java.lang.Object value,
java.lang.Class c)
Defines a variable in the interpreter environment |
void |
defineVariable(java.lang.String name,
short value)
Defines a short variable in the interpreter environment |
protected void |
finalize()
Called before the destruction of the interpreter |
boolean |
getAccessible()
Observe the state of calls to setAccessible() |
java.lang.ClassLoader |
getClassLoader()
Gets the class loader |
java.util.Set |
getClassNames()
Returns the defined class names |
java.lang.Class |
getExceptionClass()
Returns the class of the execution exception |
LibraryFinder |
getLibraryFinder()
Gets the library finder |
ParserFactory |
getParserFactory()
Gets the parser factory |
java.lang.Object |
getVariable(java.lang.String name)
Gets the value of a variable |
java.lang.Class |
getVariableClass(java.lang.String name)
Gets the class of a variable |
java.util.Set |
getVariableNames()
Returns the defined variable names |
java.lang.Object |
interpret(java.io.InputStream is,
java.lang.String fname)
Runs the interpreter |
java.lang.Object |
interpret(java.util.List statements)
Runs the interpreter on a statement list. |
java.lang.Object |
interpret(java.io.Reader r,
java.lang.String fname)
Runs the interpreter |
java.lang.Object |
interpret(java.lang.String fname)
Runs the interpreter |
protected java.lang.Object[] |
interpretArguments(java.lang.Class c,
TreeInterpreter.ConstructorParametersDescriptor cpd,
java.lang.Object[] args)
This method is used to implement constructor invocation. |
static java.lang.Object[] |
interpretArguments(java.lang.String key,
java.lang.Object[] args)
This method is used to implement constructor invocation. |
protected java.lang.Object |
interpretMethod(java.lang.Class c,
TreeInterpreter.MethodDescriptor md,
java.lang.Object obj,
java.lang.Object[] params)
Interprets the body of a method |
static java.lang.Object |
invokeMethod(java.lang.String key,
java.lang.Object obj,
java.lang.Object[] params)
Interprets the body of a method |
java.lang.Class |
loadClass(java.lang.String name)
Loads an interpreted class |
void |
registerConstructorArguments(java.lang.String sig,
java.util.List params,
java.util.List exprs,
ImportationManager im)
Registers a constructor arguments |
void |
registerMethod(java.lang.String sig,
MethodDeclaration md,
ImportationManager im)
Registers a method. |
void |
setAccessible(boolean accessible)
Set the interpreter contexts to override public/protected/private access restrictions on the methods and fields it handles. |
void |
setVariable(java.lang.String name,
java.lang.Object value)
Sets the value of a variable |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected ParserFactory parserFactory
protected LibraryFinder libraryFinder
protected TreeClassLoader classLoader
protected static java.util.Map methods
protected static java.util.Map constructorParameters
protected static int nClass
protected Context nameVisitorContext
protected Context checkVisitorContext
protected Context evalVisitorContext
protected boolean accessible
setAccessible(boolean)| Constructor Detail |
public TreeInterpreter(ParserFactory pf)
pf - the parser factory| Method Detail |
public java.lang.Object interpret(java.io.Reader r,
java.lang.String fname)
throws InterpreterException
interpret in interface Interpreteris - the reader from which the statements are readfname - the name of the parsed stream
public java.lang.Object interpret(java.io.InputStream is,
java.lang.String fname)
throws InterpreterException
interpret in interface Interpreteris - the input stream from which the statements are readfname - the name of the parsed stream
public java.lang.Object interpret(java.lang.String fname)
throws InterpreterException,
java.io.IOException
interpret in interface Interpreterfname - the name of a file to interpret
public java.util.List buildStatementList(java.io.Reader r,
java.lang.String fname)
throws InterpreterException
is - the reader from which the statements are readfname - the name of the parsed stream
public java.lang.Object interpret(java.util.List statements)
throws InterpreterException
statements - the statement list to evaluatefname - the name of the parsed stream
public void defineVariable(java.lang.String name,
java.lang.Object value,
java.lang.Class c)
name - the variable's namevalue - the initial value of the variablec - the variable's type.java.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
java.lang.Object value)
defineVariable in interface Interpretername - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
boolean value)
name - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
byte value)
name - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
short value)
name - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
char value)
name - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
int value)
name - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
long value)
name - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
float value)
name - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void defineVariable(java.lang.String name,
double value)
name - the variable's namevalue - the initial value of the variablejava.lang.IllegalStateException - if name is already defined
public void setVariable(java.lang.String name,
java.lang.Object value)
setVariable in interface Interpretername - the variable's namevalue - the value of the variablejava.lang.IllegalStateException - if the assignment is invalidpublic java.lang.Object getVariable(java.lang.String name)
getVariable in interface Interpretername - the variable's namejava.lang.IllegalStateException - if the variable do not existpublic java.lang.Class getVariableClass(java.lang.String name)
getVariableClass in interface Interpretername - the variable's namejava.lang.IllegalStateException - if the variable do not existpublic java.util.Set getVariableNames()
getVariableNames in interface Interpreterpublic void setAccessible(boolean accessible)
InterpretersetAccessible in interface Interpreterpublic boolean getAccessible()
InterpretergetAccessible in interface Interpreterpublic java.util.Set getClassNames()
getClassNames in interface Interpreterpublic void addClassPath(java.lang.String path)
addClassPath in interface Interpreterpath - the path to addpublic void addClassURL(java.net.URL url)
addClassURL in interface Interpreterurl - the url to addpublic void addLibraryPath(java.lang.String path)
addLibraryPath in interface Interpreterpath - the path to addpublic void addLibrarySuffix(java.lang.String s)
addLibrarySuffix in interface Interpreters - the suffix to add
public java.lang.Class loadClass(java.lang.String name)
throws java.lang.ClassNotFoundException
loadClass in interface Interpreters - the fully qualified name of the class to loadjava.lang.ClassNotFoundException - if the class cannot be find
public java.lang.Class defineClass(java.lang.String name,
byte[] code)
defineClass in interface Interpreterjava.lang.ClassFormatError - if the class cannot be definedpublic java.lang.ClassLoader getClassLoader()
getClassLoader in interface Interpreterpublic LibraryFinder getLibraryFinder()
getLibraryFinder in interface Interpreterpublic ParserFactory getParserFactory()
getParserFactory in interface Interpreterpublic java.lang.Class getExceptionClass()
public void registerMethod(java.lang.String sig,
MethodDeclaration md,
ImportationManager im)
sig - the method's signaturemd - the method declarationim - the importation manager
public static java.lang.Object invokeMethod(java.lang.String key,
java.lang.Object obj,
java.lang.Object[] params)
key - the key used to find the body of a methodobj - the object (this)params - the arguments
protected java.lang.Object interpretMethod(java.lang.Class c,
TreeInterpreter.MethodDescriptor md,
java.lang.Object obj,
java.lang.Object[] params)
c - the declaring class of the methodmd - the method descriptorobj - the object (this)params - the arguments
public void registerConstructorArguments(java.lang.String sig,
java.util.List params,
java.util.List exprs,
ImportationManager im)
public static java.lang.Object[] interpretArguments(java.lang.String key,
java.lang.Object[] args)
key - the key used to find the informations about the constructorargs - the arguments passed to this constructor
protected java.lang.Object[] interpretArguments(java.lang.Class c,
TreeInterpreter.ConstructorParametersDescriptor cpd,
java.lang.Object[] args)
c - the declaring class of the constructorcpd - the parameter descriptorargs - the arguments passed to this constructor
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||