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

Interface Function

rhino/src/main/java/org/mozilla/javascript/Function.java:18–64  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

16 * @author Norris Boyd
17 */
18public 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}

Callers 15

regress-418641.jsFile · 0.85
testFunction · 0.85
buildFunction · 0.85
regress-192288.jsFile · 0.85
timeitFunction · 0.85
errstack-001.jsFile · 0.85
regress-325269.jsFile · 0.85
testFunction · 0.85
regress-365692.jsFile · 0.85
regress-313630.jsFile · 0.85

Implementers 10

NativeProxyFunctionrhino/src/main/java/org/mozilla/javasc
JSFunctionrhino/src/main/java/org/mozilla/javasc
XMLListrhino-xml/src/main/java/org/mozilla/ja
BaseFunctionrhino/src/main/java/org/mozilla/javasc
Delegatorrhino/src/main/java/org/mozilla/javasc
NativeJavaClassrhino/src/main/java/org/mozilla/javasc
NativeContinuationrhino/src/main/java/org/mozilla/javasc
NativeJavaTopPackagerhino/src/main/java/org/mozilla/javasc
NativeRegExpCallablerhino/src/main/java/org/mozilla/javasc
Printtests/src/test/java/org/mozilla/javasc

Calls

no outgoing calls

Tested by

no test coverage detected