This is interface that all functions in JavaScript must implement. The interface provides for calling functions and constructors. @see org.mozilla.javascript.Scriptable @author Norris Boyd
| 16 | * @author Norris Boyd |
| 17 | */ |
| 18 | public interface Function extends Scriptable, Callable, Constructable { |
| 19 | /** |
| 20 | * Call the function. |
| 21 | * |
| 22 | * <p>Note that the array of arguments is not guaranteed to have length greater than 0. |
| 23 | * |
| 24 | * @param cx the current Context for this thread |
| 25 | * @param scope the scope to execute the function relative to. This is set to the value returned |
| 26 | * by getParentScope() except when the function is called from a closure. |
| 27 | * @param thisObj the JavaScript {@code this} object |
| 28 | * @param args the array of arguments |
| 29 | * @return the result of the call |
| 30 | */ |
| 31 | @Override |
| 32 | Object call(Context cx, VarScope scope, Scriptable thisObj, Object[] args); |
| 33 | |
| 34 | /** |
| 35 | * Call the function as a constructor. |
| 36 | * |
| 37 | * <p>This method is invoked by the runtime in order to satisfy a use of the JavaScript {@code |
| 38 | * new} operator. This method is expected to create a new object and return it. |
| 39 | * |
| 40 | * @param cx the current Context for this thread |
| 41 | * @param scope an enclosing scope of the caller except when the function is called from a |
| 42 | * closure. |
| 43 | * @param args the array of arguments |
| 44 | * @return the allocated object |
| 45 | */ |
| 46 | @Override |
| 47 | Scriptable construct(Context cx, VarScope scope, Object[] args); |
| 48 | |
| 49 | /** |
| 50 | * Return the scope in which this function was declared or closed over. This is the |
| 51 | * "[[Environment]]" defined in https://tc39.es/ecma262/#sec-ecmascript-function-objects. |
| 52 | * Although this is currently precisely equal to the parent scope (or "__parent__") of an object |
| 53 | * it is useful to distinguish the two concepts as parent scopes are no longer supported by the |
| 54 | * spec in general and present a significant barrier to future optimisations. |
| 55 | */ |
| 56 | default VarScope getDeclarationScope() { |
| 57 | return this.getParentScope(); |
| 58 | } |
| 59 | |
| 60 | /** Return whether this function can be called as a constructor. */ |
| 61 | default boolean isConstructor() { |
| 62 | return true; |
| 63 | } |
| 64 | } |
no outgoing calls
no test coverage detected