|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoscript.OscriptInterpreter
The toplevel and main interface for the interpreter. There can only be one instance of this object. The scope object can be used to create logically isolated interpreter "instances".
This does need some cleanup, and perhaps should be a front-end for other stuff someone embedding this in an application might want, such as creating a new scope...
Description of properties that are interesting:
property | description | regular default | webstart default |
---|---|---|---|
oscript.cache.path | where the cache directory is created | $CWD/.cache | $HOME/.cache |
oscript.cwd | the current working directory | $CWD | $HOME/Desktop || $HOME |
Nested Class Summary | |
static class |
OscriptInterpreter.CacheEntry
An entry in the node-evaluator cache. |
Field Summary | |
static java.lang.String |
CACHE_VERSION
the CACHE_VERSION should change any time a change is made in the interpreter that could cause incompatibility with previously serialized cache entries. |
static Value |
DEFAULT_ARRAY_SORT_COMPARISION_FXN
|
static NodeEvaluator |
EMPTY_EXPR_LIST_EVALUATOR
|
static long |
et
|
Constructor Summary | |
OscriptInterpreter()
|
Method Summary | |
static void |
__declareInScope(java.lang.String name,
Value val,
Scope scope)
|
static Value |
__eval(java.lang.String str)
|
static Value |
__eval(java.lang.String str,
Scope scope)
|
static void |
addParser(Parser parser)
Add the parser to list of recognized parsers. |
static void |
addScriptPath(java.lang.String path)
Add the specified path to the paths that are searched to import a file. |
static NodeEvaluator |
createNodeEvaluator(java.lang.String name,
Node node)
Create a NodeEvaluator to evaluate a node. |
static Value |
eval(AbstractFile file)
Evaluate from the specified abstract file. |
static Value |
eval(AbstractFile file,
Scope scope)
Evaluate from the specified abstract file. |
static Value |
eval(java.lang.String str)
Evaluate the specified sting. |
static Value |
eval(java.lang.String str,
Scope scope)
Evaluate the specified sting. |
static Scope |
getGlobalScope()
Get the global scope object. |
static java.util.Iterator |
getScriptPath()
Return an iterator of entries in the script-path. |
static java.lang.String |
getVersionString()
Get a descriptive version string. |
static java.lang.Class |
loadClassFromCache(java.lang.String className)
|
static void |
mountJarFile(AbstractFile file)
Mount a .jar file under /jar/file.jar and add to script path |
static Node |
parse(AbstractFile file)
Parse the input stream to a syntaxtree. |
static Node |
parse(java.lang.String str)
Parse the string to a syntaxtree. |
static void |
removeParser(Parser parser)
Remove the parser from list of recognized parsers. |
static void |
removeScriptPath(java.lang.String path)
Remove the specified path to the paths that are searched to import a file. |
static AbstractFile |
resolve(java.lang.String path,
boolean create)
Try to load the specified file from one of the registered filesystems. |
static void |
setErr(java.io.PrintStream err)
Set the error stream. |
static void |
setIn(java.io.InputStream in)
Set the input stream. |
static void |
setOut(java.io.PrintStream out)
Set the output stream. |
static void |
useCompiler(boolean useCompiler)
Set whether the compiler should be used or not. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final NodeEvaluator EMPTY_EXPR_LIST_EVALUATOR
public static final java.lang.String CACHE_VERSION
public static Value DEFAULT_ARRAY_SORT_COMPARISION_FXN
public static long et
Constructor Detail |
public OscriptInterpreter()
Method Detail |
public static java.lang.Class loadClassFromCache(java.lang.String className) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.String getVersionString()
public static void useCompiler(boolean useCompiler)
useCompiler
- iff true
, enabled compiler, otherwise
use only the interpreterpublic static void setIn(java.io.InputStream in)
in
- the stream to use for inputpublic static void setOut(java.io.PrintStream out)
out
- the stream to use for outputpublic static void setErr(java.io.PrintStream err)
err
- the stream to use for error outputpublic static Scope getGlobalScope()
globalScope
is static,
meaning that all script code in an application shares a single global
scope. But, since the interpreter is multi-threaded, you can achieve
the same effect of having multiple interpreter instances by creating
a new level of scope (ie with globalScope
as it's parent,
an evaluate within that scope.
globalScope
objectpublic static Value eval(AbstractFile file) throws ParseException, java.io.IOException
file
- the file to evaluate
ParseException
- if error parsing input
java.io.IOException
- if something goes poorly when reading filepublic static Value eval(AbstractFile file, Scope scope) throws ParseException, java.io.IOException
file
- the file to evaluatescope
- the scope to evaluate in
ParseException
- if error parsing input
java.io.IOException
- if something goes poorly when reading filepublic static Value eval(java.lang.String str) throws ParseException
str
- the string to evaluate
ParseException
- if error parsing stringpublic static final Value __eval(java.lang.String str) throws ParseException
ParseException
public static Value eval(java.lang.String str, Scope scope) throws ParseException
str
- the string to evaluatescope
- the scope to evaluate in
ParseException
- if error parsing stringpublic static final Value __eval(java.lang.String str, Scope scope) throws ParseException
ParseException
public static final void __declareInScope(java.lang.String name, Value val, Scope scope)
public static void addParser(Parser parser)
parser
to list of recognized parsers. The
registered parsers will determine what sorts of input the interpreter
can handle.
parser
- the parser to registerremoveParser(oscript.Parser)
public static void removeParser(Parser parser)
parser
from list of recognized parsers. The
registered parsers will determine what sorts of input the interpreter
can handle.
parser
- the parser to registeraddParser(oscript.Parser)
public static Node parse(AbstractFile file) throws ParseException, java.io.IOException
file
- the file to parse
ParseException
java.io.IOException
public static Node parse(java.lang.String str) throws ParseException
str
- the string to parse
ParseException
public static NodeEvaluator createNodeEvaluator(java.lang.String name, Node node)
node
- the node
public static void addScriptPath(java.lang.String path)
path
- a path to search for importspublic static void removeScriptPath(java.lang.String path)
path
- a path to search for importspublic static java.util.Iterator getScriptPath()
resolve(java.lang.String, boolean)
in the
process of trying to resolve a file.
public static AbstractFile resolve(java.lang.String path, boolean create) throws java.io.IOException
path
- the path to the file to resolvecreate
- create the file if it does not exist
java.io.IOException
- if something goes wrong when reading fileaddScriptPath(java.lang.String)
public static final void mountJarFile(AbstractFile file) throws java.lang.Exception
/jar/file.jar
and add to script path
file
- the jar file to mount
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |