< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunctionData.java

Print this page

        

*** 68,77 **** --- 68,80 ---- // Parameter arity of the function, corresponding to "f.length". E.g. "function f(a, b, c) { ... }" arity is 3, and // some built-in ECMAScript functions have their arity declared by the specification. Note that regardless of this // value, the function might still be capable of receiving variable number of arguments, see isVariableArity. private int arity; + // this may be null, if not available + private String documentation; + /** * A pair of method handles used for generic invoker and constructor. Field is volatile as it can be initialized by * multiple threads concurrently, but we still tolerate a race condition in it as all values stored into it are * idempotent. */
*** 116,125 **** --- 119,132 ---- final int getArity() { return arity; } + final String getDocumentation() { + return documentation != null? documentation : toSource(); + } + final boolean isVariableArity() { return (flags & IS_VARIABLE_ARITY) != 0; } final boolean isPropertyAccessor() {
*** 135,144 **** --- 142,160 ---- throw new IllegalArgumentException(String.valueOf(arity)); } this.arity = arity; } + /** + * Used from nasgen generated code. + * + * @param doc documentation for this function + */ + void setDocumentation(final String doc) { + this.documentation = doc; + } + CompiledFunction bind(final CompiledFunction originalInv, final ScriptFunction fn, final Object self, final Object[] args) { final MethodHandle boundInvoker = bindInvokeHandle(originalInv.createComposableInvoker(), fn, self, args); if (isConstructor()) { return new CompiledFunction(boundInvoker, bindConstructHandle(originalInv.createComposableConstructor(), fn, args), null);
< prev index next >