org.mozilla.javascript.optimizer
Class Codegen
java.lang.Objectorg.mozilla.javascript.optimizer.Codegen
- Evaluator
public class Codegen
extends java.lang.Object
This class generates code for a given IR tree.
- Norris Boyd
- Roger Lawrence
void | captureStackInfo(RhinoException ex)- Capture stack information from the given exception.
|
Object | compile(CompilerEnvirons compilerEnv, ScriptOrFnNode tree, String encodedSource, boolean returnFunction)- Compile the script or function from intermediate representation
tree into an executable form.
|
Function | createFunctionObject(Context cx, Scriptable scope, Object bytecode, Object staticSecurityDomain)- Create a function object.
|
Script | createScriptObject(Object bytecode, Object staticSecurityDomain)- Create a script object.
|
String | getPatchedStack(RhinoException ex, String nativeStackTrace)- Given a native stack trace, patch it with script-specific source
and line information
|
List | getScriptStack(RhinoException ex)- Get the script stack for the given exception
|
String | getSourcePositionFromStack(Context cx, int[] linep)- Get the source position information by examining the stack.
|
void | setEvalScriptFlag(Script script)- Mark the given script to indicate it was created by a call to
eval() or to a Function constructor.
|
captureStackInfo
public void captureStackInfo(RhinoException ex)
Capture stack information from the given exception.
- captureStackInfo in interface Evaluator
ex - an exception thrown during execution
compile
public Object compile(CompilerEnvirons compilerEnv,
ScriptOrFnNode tree,
String encodedSource,
boolean returnFunction) Compile the script or function from intermediate representation
tree into an executable form.
- compile in interface Evaluator
compilerEnv - Compiler environmenttree - intermediate representationencodedSource - encoding of the source code for decompilationreturnFunction - if true, compiling a function
- an opaque object that can be passed to either
createFunctionObject or createScriptObject, depending on the
value of returnFunction
createFunctionObject
public Function createFunctionObject(Context cx,
Scriptable scope,
Object bytecode,
Object staticSecurityDomain) Create a function object.
- createFunctionObject in interface Evaluator
cx - Current contextscope - scope of the functionbytecode - opaque object returned by compilestaticSecurityDomain - security domain
- Function object that can be called
createScriptObject
public Script createScriptObject(Object bytecode,
Object staticSecurityDomain) Create a script object.
- createScriptObject in interface Evaluator
bytecode - opaque object returned by compilestaticSecurityDomain - security domain
- Script object that can be evaluated
getPatchedStack
public String getPatchedStack(RhinoException ex,
String nativeStackTrace) Given a native stack trace, patch it with script-specific source
and line information
- getPatchedStack in interface Evaluator
ex - exceptionnativeStackTrace - the native stack trace
getScriptStack
public List getScriptStack(RhinoException ex)
Get the script stack for the given exception
- getScriptStack in interface Evaluator
ex - exception from execution
- list of strings for the stack trace
getSourcePositionFromStack
public String getSourcePositionFromStack(Context cx,
int[] linep) Get the source position information by examining the stack.
- getSourcePositionFromStack in interface Evaluator
cx - Contextlinep - Array object of length >= 1; getSourcePositionFromStack
will assign the line number to linep[0].
- the name of the file or other source container
setEvalScriptFlag
public void setEvalScriptFlag(Script script)
Mark the given script to indicate it was created by a call to
eval() or to a Function constructor.
- setEvalScriptFlag in interface Evaluator
script - script to mark as from eval