| 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 | // API class |
| 8 | |
| 9 | package org.mozilla.javascript; |
| 10 | |
| 11 | /** |
| 12 | * All compiled scripts implement this interface. |
| 13 | * <p> |
| 14 | * This class encapsulates script execution relative to an |
| 15 | * object scope. |
| 16 | * @since 1.3 |
| 17 | * @author Norris Boyd |
| 18 | */ |
| 19 | |
| 20 | public interface Script { |
| 21 | |
| 22 | /** |
| 23 | * Execute the script. |
| 24 | * <p> |
| 25 | * The script is executed in a particular runtime Context, which |
| 26 | * must be associated with the current thread. |
| 27 | * The script is executed relative to a scope--definitions and |
| 28 | * uses of global top-level variables and functions will access |
| 29 | * properties of the scope object. For compliant ECMA |
| 30 | * programs, the scope must be an object that has been initialized |
| 31 | * as a global object using <code>Context.initStandardObjects</code>. |
| 32 | * <p> |
| 33 | * |
| 34 | * @param cx the Context associated with the current thread |
| 35 | * @param scope the scope to execute relative to |
| 36 | * @return the result of executing the script |
| 37 | * @see org.mozilla.javascript.Context#initStandardObjects() |
| 38 | */ |
| 39 | public Object exec(Context cx, Scriptable scope); |
| 40 | |
| 41 | } |