Debian Codegraph @

rhino/src/org/mozilla/javascript/Evaluator.java

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 package org.mozilla.javascript;
8
9 import org.mozilla.javascript.ast.ScriptNode;
10
11 import java.util.List;
12
13 /**
14 * Abstraction of evaluation, which can be implemented either by an
15 * interpreter or compiler.
16 */
17 public interface Evaluator {
18
19 /**
20 * Compile the script or function from intermediate representation
21 * tree into an executable form.
22 *
23 * @param compilerEnv Compiler environment
24 * @param tree parse tree
25 * @param encodedSource encoding of the source code for decompilation
26 * @param returnFunction if true, compiling a function
27 * @return an opaque object that can be passed to either
28 * createFunctionObject or createScriptObject, depending on the
29 * value of returnFunction
30 */
31 public Object compile(CompilerEnvirons compilerEnv,
32 ScriptNode tree,
33 String encodedSource,
34 boolean returnFunction);
35
36 /**
37 * Create a function object.
38 *
39 * @param cx Current context
40 * @param scope scope of the function
41 * @param bytecode opaque object returned by compile
42 * @param staticSecurityDomain security domain
43 * @return Function object that can be called
44 */
45 public Function createFunctionObject(Context cx, Scriptable scope,
46 Object bytecode, Object staticSecurityDomain);
47
48 /**
49 * Create a script object.
50 *
51 * @param bytecode opaque object returned by compile
52 * @param staticSecurityDomain security domain
53 * @return Script object that can be evaluated
54 */
55 public Script createScriptObject(Object bytecode,
56 Object staticSecurityDomain);
57
58 /**
59 * Capture stack information from the given exception.
60 * @param ex an exception thrown during execution
61 */
62 public void captureStackInfo(RhinoException ex);
63
64 /**
65 * Get the source position information by examining the stack.
66 * @param cx Context
67 * @param linep Array object of length >= 1; getSourcePositionFromStack
68 * will assign the line number to linep[0].
69 * @return the name of the file or other source container
70 */
71 public String getSourcePositionFromStack(Context cx, int[] linep);
72
73 /**
74 * Given a native stack trace, patch it with script-specific source
75 * and line information
76 * @param ex exception
77 * @param nativeStackTrace the native stack trace
78 * @return patched stack trace
79 */
80 public String getPatchedStack(RhinoException ex,
81 String nativeStackTrace);
82
83 /**
84 * Get the script stack for the given exception
85 * @param ex exception from execution
86 * @return list of strings for the stack trace
87 */
88 public List<String> getScriptStack(RhinoException ex);
89
90 /**
91 * Mark the given script to indicate it was created by a call to
92 * eval() or to a Function constructor.
93 * @param script script to mark as from eval
94 */
95 public void setEvalScriptFlag(Script script);
96 }