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.
| 6 | * operation. |
| 7 | */ |
| 8 | public 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected