MCPcopy Create free account
hub / github.com/mozilla/rhino / JSScript

Class JSScript

rhino/src/main/java/org/mozilla/javascript/JSScript.java:8–46  ·  view source on GitHub ↗

Represents a script object built upon a JSDescriptor. This class does not support the Callable interface scripts do not support arguments or some other parts of a call operation.

Source from the content-addressed store, hash-verified

6 * operation.
7 */
8public class JSScript implements Script, ScriptOrFn<JSScript> {
9 private final JSDescriptor<JSScript> descriptor;
10 private final Scriptable homeObject;
11
12 public JSScript(JSDescriptor<JSScript> descriptor, Scriptable homeObject) {
13 this.descriptor = descriptor;
14 this.homeObject = homeObject;
15 }
16
17 @Override
18 public JSDescriptor<JSScript> getDescriptor() {
19 return descriptor;
20 }
21
22 @Override
23 public Scriptable getHomeObject() {
24 return homeObject;
25 }
26
27 JSCode<JSScript> getCode() {
28 return descriptor.getCode();
29 }
30
31 @Override
32 public Object exec(Context cx, VarScope scope, Scriptable thisObj) {
33 Object ret;
34 if (!ScriptRuntime.hasTopCall(cx)) {
35 // It will go through "call" path. but they are equivalent
36 ret = ScriptRuntime.doTopCall(this, cx, scope, thisObj, descriptor.isStrict());
37 cx.processMicrotasks();
38 } else {
39 ret =
40 descriptor
41 .getCode()
42 .execute(cx, this, null, scope, thisObj, ScriptRuntime.emptyArgs);
43 }
44 return ret;
45 }
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected