org.mozilla.javascript

## Interface Evaluator

- All Known Implementing Classes:
    Codegen, Interpreter

      public interface Evaluator

  Abstraction of evaluation, which can be implemented either by an interpreter or compiler.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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 information
    `java.util.List<java.lang.String>` | `getScriptStack(RhinoException ex)` Get the script stack for the given exception
    `java.lang.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.

- - ### Method Detail

    - #### compile

          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.
      Parameters:
        `compilerEnv` - Compiler environment
        `tree` - parse tree
        `encodedSource` - encoding of the source code for decompilation
        `returnFunction` - if true, compiling a function
      Returns:
        an opaque object that can be passed to either createFunctionObject or createScriptObject, depending on the value of returnFunction

    - #### createFunctionObject

          Function createFunctionObject(Context cx,
                                      Scriptable scope,
                                      java.lang.Object bytecode,
                                      java.lang.Object staticSecurityDomain)

      Create a function object.
      Parameters:
        `cx` - Current context
        `scope` - scope of the function
        `bytecode` - opaque object returned by compile
        `staticSecurityDomain` - security domain
      Returns:
        Function object that can be called

    - #### createScriptObject

          Script createScriptObject(java.lang.Object bytecode,
                                  java.lang.Object staticSecurityDomain)

      Create a script object.
      Parameters:
        `bytecode` - opaque object returned by compile
        `staticSecurityDomain` - security domain
      Returns:
        Script object that can be evaluated

    - #### captureStackInfo

          void captureStackInfo(RhinoException ex)

      Capture stack information from the given exception.
      Parameters:
        `ex` - an exception thrown during execution

    - #### getSourcePositionFromStack

          java.lang.String getSourcePositionFromStack(Context cx,
                                                    int[] linep)

      Get the source position information by examining the stack.
      Parameters:
        `cx` - Context
        `linep` - 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

          java.lang.String getPatchedStack(RhinoException ex,
                                         java.lang.String nativeStackTrace)

      Given a native stack trace, patch it with script-specific source and line information
      Parameters:
        `ex` - exception
        `nativeStackTrace` - the native stack trace
      Returns:
        patched stack trace

    - #### getScriptStack

          java.util.List<java.lang.String> getScriptStack(RhinoException ex)

      Get the script stack for the given exception
      Parameters:
        `ex` - exception from execution
      Returns:
        list of strings for the stack trace

    - #### setEvalScriptFlag

          void setEvalScriptFlag(Script script)

      Mark the given script to indicate it was created by a call to eval() or to a Function constructor.
      Parameters:
        `script` - script to mark as from eval