- All Known Implementing Classes:
AInterpreter,Interpreter,InterpreterV2
public interface Evaluator
Abstraction of evaluation, which can be implemented either by an interpreter or compiler.
-
Method Summary
Modifier and TypeMethodDescriptionvoidCapture stack information from the given exception.compileFunction(CompilerEnvirons compilerEnv, ScriptNode tree, String rawSource) Compile a function from intermediate representation tree into an executable form.compileScript(CompilerEnvirons compilerEnv, ScriptNode tree, String rawSource) Compile a script from intermediate representation tree into an executable form.createFunctionObject(Context cx, VarScope scope, CompilationResult<JSFunction> compiled, Object staticSecurityDomain) Create a function object.createScriptObject(CompilationResult<JSScript> compiled, Object staticSecurityDomain) Create a script object.getPatchedStack(RhinoException ex, String nativeStackTrace) Given a native stack trace, patch it with script-specific source and line informationGet the script stack for the given exceptiongetSourcePositionFromStack(Context cx, int[] linep) Get the source position information by examining the stack.
-
Method Details
-
compileScript
CompilationResult<JSScript> compileScript(CompilerEnvirons compilerEnv, ScriptNode tree, String rawSource) Compile a script from intermediate representation tree into an executable form.- Parameters:
compilerEnv- Compiler environmenttree- parse treerawSource- the source code- Returns:
- a result that can be passed to
createScriptObject(org.htmlunit.corejs.javascript.CompilationResult<org.htmlunit.corejs.javascript.JSScript>, java.lang.Object)
-
compileFunction
CompilationResult<JSFunction> compileFunction(CompilerEnvirons compilerEnv, ScriptNode tree, String rawSource) Compile a function from intermediate representation tree into an executable form.- Parameters:
compilerEnv- Compiler environmenttree- parse treerawSource- the source code- Returns:
- a result that can be passed to
createFunctionObject(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.VarScope, org.htmlunit.corejs.javascript.CompilationResult<org.htmlunit.corejs.javascript.JSFunction>, java.lang.Object)
-
createFunctionObject
Function createFunctionObject(Context cx, VarScope scope, CompilationResult<JSFunction> compiled, Object staticSecurityDomain) Create a function object.- Parameters:
cx- Current contextscope- scope of the functioncompiled- the result returned bycompileFunction(org.htmlunit.corejs.javascript.CompilerEnvirons, org.htmlunit.corejs.javascript.ast.ScriptNode, java.lang.String)staticSecurityDomain- security domain- Returns:
- Function object that can be called
-
createScriptObject
Create a script object.- Parameters:
compiled- the result returned bycompileScript(org.htmlunit.corejs.javascript.CompilerEnvirons, org.htmlunit.corejs.javascript.ast.ScriptNode, java.lang.String)staticSecurityDomain- security domain- Returns:
- Script object that can be evaluated
-
captureStackInfo
Capture stack information from the given exception.- Parameters:
ex- an exception thrown during execution
-
getSourcePositionFromStack
Get the source position information by examining the stack.- 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
Given a native stack trace, patch it with script-specific source and line information- Parameters:
ex- exceptionnativeStackTrace- the native stack trace- Returns:
- patched stack trace
-
getScriptStack
Get the script stack for the given exception- Parameters:
ex- exception from execution- Returns:
- list of strings for the stack trace
-