Package org.mozilla.javascript
Class Interpreter
- java.lang.Object
-
- org.mozilla.javascript.Interpreter
-
-
Constructor Summary
Constructors Constructor Description Interpreter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NativeContinuation
captureContinuation(Context cx)
void
captureStackInfo(RhinoException ex)
Capture stack information from the given exception.java.lang.Object
compile(CompilerEnvirons compilerEnv, ScriptNode tree, java.lang.String encodedSource, boolean returnFunction)
Compile the script or function from intermediate representation tree into an executable form.Function
createFunctionObject(Context cx, Scriptable scope, java.lang.Object bytecode, java.lang.Object staticSecurityDomain)
Create a function object.Script
createScriptObject(java.lang.Object bytecode, java.lang.Object staticSecurityDomain)
Create a script object.java.lang.String
getPatchedStack(RhinoException ex, java.lang.String nativeStackTrace)
Given a native stack trace, patch it with script-specific source and line informationjava.util.List<java.lang.String>
getScriptStack(RhinoException ex)
Get the script stack for the given exceptionScriptStackElement[][]
getScriptStackElements(RhinoException ex)
java.lang.String
getSourcePositionFromStack(Context cx, int[] linep)
Get the source position information by examining the stack.static java.lang.Object
restartContinuation(NativeContinuation c, Context cx, Scriptable scope, java.lang.Object[] args)
static java.lang.Object
resumeGenerator(Context cx, Scriptable scope, int operation, java.lang.Object savedState, java.lang.Object value)
void
setEvalScriptFlag(Script script)
Mark the given script to indicate it was created by a call to eval() or to a Function constructor.
-
-
-
Method Detail
-
compile
public java.lang.Object compile(CompilerEnvirons compilerEnv, ScriptNode tree, java.lang.String encodedSource, boolean returnFunction)
Description copied from interface:Evaluator
Compile the script or function from intermediate representation tree into an executable form.- Specified by:
compile
in interfaceEvaluator
- Parameters:
compilerEnv
- Compiler environmenttree
- parse treeencodedSource
- encoding of the source code for decompilationreturnFunction
- if true, compiling a function- Returns:
- an opaque object that can be passed to either createFunctionObject or createScriptObject, depending on the value of returnFunction
-
createScriptObject
public Script createScriptObject(java.lang.Object bytecode, java.lang.Object staticSecurityDomain)
Description copied from interface:Evaluator
Create a script object.- Specified by:
createScriptObject
in interfaceEvaluator
- Parameters:
bytecode
- opaque object returned by compilestaticSecurityDomain
- security domain- Returns:
- Script object that can be evaluated
-
setEvalScriptFlag
public void setEvalScriptFlag(Script script)
Description copied from interface:Evaluator
Mark the given script to indicate it was created by a call to eval() or to a Function constructor.- Specified by:
setEvalScriptFlag
in interfaceEvaluator
- Parameters:
script
- script to mark as from eval
-
createFunctionObject
public Function createFunctionObject(Context cx, Scriptable scope, java.lang.Object bytecode, java.lang.Object staticSecurityDomain)
Description copied from interface:Evaluator
Create a function object.- Specified by:
createFunctionObject
in interfaceEvaluator
- Parameters:
cx
- Current contextscope
- scope of the functionbytecode
- opaque object returned by compilestaticSecurityDomain
- security domain- Returns:
- Function object that can be called
-
captureStackInfo
public void captureStackInfo(RhinoException ex)
Description copied from interface:Evaluator
Capture stack information from the given exception.- Specified by:
captureStackInfo
in interfaceEvaluator
- Parameters:
ex
- an exception thrown during execution
-
getSourcePositionFromStack
public java.lang.String getSourcePositionFromStack(Context cx, int[] linep)
Description copied from interface:Evaluator
Get the source position information by examining the stack.- Specified by:
getSourcePositionFromStack
in interfaceEvaluator
- Parameters:
cx
- Contextlinep
- Array object of length >= 1; getSourcePositionFromStack will assign the line number to linep[0].- Returns:
- the name of the file or other source container
-
getPatchedStack
public java.lang.String getPatchedStack(RhinoException ex, java.lang.String nativeStackTrace)
Description copied from interface:Evaluator
Given a native stack trace, patch it with script-specific source and line information- Specified by:
getPatchedStack
in interfaceEvaluator
- Parameters:
ex
- exceptionnativeStackTrace
- the native stack trace- Returns:
- patched stack trace
-
getScriptStack
public java.util.List<java.lang.String> getScriptStack(RhinoException ex)
Description copied from interface:Evaluator
Get the script stack for the given exception- Specified by:
getScriptStack
in interfaceEvaluator
- Parameters:
ex
- exception from execution- Returns:
- list of strings for the stack trace
-
getScriptStackElements
public ScriptStackElement[][] getScriptStackElements(RhinoException ex)
-
resumeGenerator
public static java.lang.Object resumeGenerator(Context cx, Scriptable scope, int operation, java.lang.Object savedState, java.lang.Object value)
-
restartContinuation
public static java.lang.Object restartContinuation(NativeContinuation c, Context cx, Scriptable scope, java.lang.Object[] args)
-
captureContinuation
public static NativeContinuation captureContinuation(Context cx)
-
-