java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.BaseFunction
org.htmlunit.corejs.javascript.LambdaFunction
- All Implemented Interfaces:
Serializable,Callable,ConstProperties<Scriptable>,Constructable,DebuggableObject,Function,PropHolder<Scriptable>,Scriptable,SymbolScriptable
- Direct Known Subclasses:
KnownBuiltInFunction,LambdaConstructor
This class implements a single JavaScript function that has the prototype of the built-in
Function class, and which is implemented using a single function that can easily be implemented
using a lambda expression.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
ScriptableObject.DescriptorInfo, ScriptableObject.KeyComparator, ScriptableObject.LambdaGetterFunction, ScriptableObject.LambdaSetterFunction -
Field Summary
FieldsFields inherited from class org.htmlunit.corejs.javascript.BaseFunction
Id_arguments, Id_arity, Id_length, Id_name, Id_prototype, MAX_INSTANCE_IDFields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, LEGACY_CONST, PERMANENT, READONLY, STRICTLY_READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionLambdaFunction(VarScope scope, int length, SerializableCallable target) Create a new built-in function, with no name, and no default prototype.LambdaFunction(VarScope scope, String name, int length, Object prototype, SerializableCallable target) Create a new function.LambdaFunction(VarScope scope, String name, int length, SerializableCallable target) Create a new function.LambdaFunction(VarScope scope, String name, int length, SerializableCallable target, boolean defaultPrototype) Create a new function. -
Method Summary
Modifier and TypeMethodDescriptionCall the function as a constructor.intgetArity()intbooleanReturn whether this function can be called as a constructor.Methods inherited from class org.htmlunit.corejs.javascript.BaseFunction
call, createObject, createObject, createProperties, createPrototypeProperty, createPrototypeProperty, defaultGet, defaultHas, defaultPut, getClassName, getClassPrototype, getDeclarationScope, getHomeObject, getPrototypeProperty, getTypeOf, hasDefaultParameters, hasInstance, hasPrototypeProperty, isGeneratorFunction, prototypeDescSetter, setHomeObject, setImmunePrototypeProperty, setPrototypeProperty, setPrototypePropertyAttributes, setStandardPropertyAttributes, setupDefaultPrototypeMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, equivalentValues, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, has, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, createSlotMap, defineProperty, defineProperty, get, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Constructable
constructMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
delete, delete, delete, get, get, get, getAncestor, getDefaultValue, getIds, getParentScope, getPrototype, has, has, has, put, put, put, setParentScope, setPrototypeMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Field Details
-
target
-
-
Constructor Details
-
LambdaFunction
public LambdaFunction(VarScope scope, String name, int length, SerializableCallable target, boolean defaultPrototype) Create a new function. The new object will have the Function prototype and no parent. The caller is responsible for binding this object to the appropriate scope.- Parameters:
scope- scope of the calling contextname- name of the functionlength- the arity of the functiontarget- an object that implements the function in Java. Since Callable is a single-function interface this will typically be implemented as a lambda.defaultPrototype- set up a prototype on the new function
-
LambdaFunction
Create a new function. The new object will have the Function prototype and no parent. The caller is responsible for binding this object to the appropriate scope.- Parameters:
scope- scope of the calling contextname- name of the functionlength- the arity of the functiontarget- an object that implements the function in Java. Since Callable is a single-function interface this will typically be implemented as a lambda.
-
LambdaFunction
public LambdaFunction(VarScope scope, String name, int length, Object prototype, SerializableCallable target) Create a new function. The new object will have the Function prototype and no parent. The caller is responsible for binding this object to the appropriate scope.- Parameters:
scope- scope of the calling contextname- name of the functionlength- the arity of the functionprototype- prototype to set for this functiontarget- an object that implements the function in Java. Since Callable is a single-function interface this will typically be implemented as a lambda.
-
LambdaFunction
Create a new built-in function, with no name, and no default prototype.
-
-
Method Details
-
call
- Overrides:
callin classBaseFunction
-
construct
Description copied from interface:FunctionCall the function as a constructor.This method is invoked by the runtime in order to satisfy a use of the JavaScript
newoperator. This method is expected to create a new object and return it.If nt is equal to this then this call is equivalent `new f(...arguments), but reflection and super constructor calls may pass in different values.
- Specified by:
constructin interfaceConstructable- Specified by:
constructin interfaceFunction- Overrides:
constructin classBaseFunction- Parameters:
cx- the current Context for this threadnt- the new.target for this call,scope- an enclosing scope of the caller except when the function is called from a closure.args- the array of arguments- Returns:
- the allocated object
-
getLength
public int getLength()- Overrides:
getLengthin classBaseFunction
-
getArity
public int getArity()- Overrides:
getArityin classBaseFunction
-
getFunctionName
- Overrides:
getFunctionNamein classBaseFunction
-
isConstructor
public boolean isConstructor()Description copied from interface:FunctionReturn whether this function can be called as a constructor.- Specified by:
isConstructorin interfaceFunction- Overrides:
isConstructorin classBaseFunction
-