java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.BaseFunction
- All Implemented Interfaces:
Serializable,Callable,ConstProperties<Scriptable>,Constructable,DebuggableObject,Function,PropHolder<Scriptable>,Scriptable,SymbolScriptable
- Direct Known Subclasses:
BoundFunction,FunctionObject,IdFunctionObject,JSFunction,LambdaFunction,NativeFunction,NativeJavaConstructor,NativeJavaMethod,Require
The base class for Function objects. That is one of two purposes. It is also the prototype for
every "function" defined except those that are used as GeneratorFunctions via the ES6 "function
*" syntax.
See ECMA 15.3.
- Author:
- Norris Boyd
- 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
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intFields 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
ConstructorsConstructorDescriptionBaseFunction(VarScope scope) BaseFunction(VarScope scope, Scriptable prototype) -
Method Summary
Modifier and TypeMethodDescriptionfinal ObjectShould be overridden.Call the function as a constructor.createObject(Context cx, VarScope scope) Creates new script object.createObject(Context cx, VarScope scope, Object nt) protected voidprotected voidprotected voidcreatePrototypeProperty(CompoundOperationMap<Scriptable> compoundOp) protected final ObjectdefaultGet(String name) protected final booleandefaultHas(String name) protected final voiddefaultPut(String name, Object value) intgetArity()Return the name of the class.Return the scope in which this function was declared or closed over.intGets the value returned by calling the typeof operator on this object.protected booleanbooleanhasInstance(Scriptable instance) Implements the instanceof operator for JavaScript Function objects.protected booleanbooleanReturn whether this function can be called as a constructor.protected booleanprotected static booleanprototypeDescSetter(BaseFunction builtIn, BuiltInSlot<BaseFunction> current, Object id, ScriptableObject.DescriptorInfo info, boolean checkValid, Object key, int index) voidsetHomeObject(Scriptable homeObject) voidsetImmunePrototypeProperty(Object value) Make value as DontEnum, DontDelete, ReadOnly prototype property of this Function objectprotected voidsetPrototypeProperty(Object prototype) voidsetPrototypePropertyAttributes(int attributes) voidsetStandardPropertyAttributes(int attributes) Sets the attributes of the "name", "length", and "arity" properties, which differ for many native objects.protected ObjectsetupDefaultPrototype(VarScope scope) Methods 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
-
Id_length
protected static final int Id_length- See Also:
-
Id_arity
protected static final int Id_arity- See Also:
-
Id_name
protected static final int Id_name- See Also:
-
Id_prototype
protected static final int Id_prototype- See Also:
-
Id_arguments
protected static final int Id_arguments- See Also:
-
MAX_INSTANCE_ID
protected static final int MAX_INSTANCE_ID- See Also:
-
-
Constructor Details
-
BaseFunction
-
BaseFunction
-
-
Method Details
-
createProperties
protected void createProperties() -
createPrototypeProperty
protected void createPrototypeProperty() -
createPrototypeProperty
-
prototypeDescSetter
protected static boolean prototypeDescSetter(BaseFunction builtIn, BuiltInSlot<BaseFunction> current, Object id, ScriptableObject.DescriptorInfo info, boolean checkValid, Object key, int index) -
defaultHas
-
defaultGet
-
defaultPut
-
getClassName
Description copied from class:ScriptableObjectReturn the name of the class.This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.
- Specified by:
getClassNamein interfaceScriptable- Specified by:
getClassNamein classScriptableObject
-
isGeneratorFunction
protected boolean isGeneratorFunction() -
hasDefaultParameters
protected boolean hasDefaultParameters() -
getTypeOf
Gets the value returned by calling the typeof operator on this object.- Overrides:
getTypeOfin classScriptableObject- Returns:
- "function" or "undefined" if
ScriptableObject.avoidObjectDetection()returnstrue - See Also:
-
hasInstance
Implements the instanceof operator for JavaScript Function objects.foo = new Foo();
foo instanceof Foo; // true
- Specified by:
hasInstancein interfaceScriptable- Overrides:
hasInstancein classScriptableObject- Parameters:
instance- The value that appeared on the LHS of the instanceof operator- Returns:
- true if the "prototype" property of "this" appears in value's prototype chain
-
setImmunePrototypeProperty
Make value as DontEnum, DontDelete, ReadOnly prototype property of this Function object -
getClassPrototype
-
call
Should be overridden.- Specified by:
callin interfaceCallable- Specified by:
callin interfaceFunction- Parameters:
cx- the current Context for this threadscope- the scope to execute the function relative to. This is set to the value returned by getParentScope() except when the function is called from a closure.thisObj- the JavaScriptthisobjectargs- the array of arguments- Returns:
- the result of the call
-
call
-
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- 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
-
createObject
Creates new script object. The default implementation ofconstruct(org.htmlunit.corejs.javascript.Context, java.lang.Object, org.htmlunit.corejs.javascript.VarScope, java.lang.Object[])uses this method to to get the value forthisObjargument when invokingcall(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.VarScope, java.lang.Object, java.lang.Object[]). The method is allowed to returnnullto indicate thatcall(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.VarScope, java.lang.Object, java.lang.Object[])will create a new object itself. In this caseconstruct(org.htmlunit.corejs.javascript.Context, java.lang.Object, org.htmlunit.corejs.javascript.VarScope, java.lang.Object[])will set scope and prototype on the resultcall(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.VarScope, java.lang.Object, java.lang.Object[])unless they are already set. -
createObject
-
getArity
public int getArity() -
getLength
public int getLength() -
getFunctionName
-
setStandardPropertyAttributes
public void setStandardPropertyAttributes(int attributes) Sets the attributes of the "name", "length", and "arity" properties, which differ for many native objects. -
setPrototypePropertyAttributes
public void setPrototypePropertyAttributes(int attributes) -
hasPrototypeProperty
protected boolean hasPrototypeProperty() -
getPrototypeProperty
-
setPrototypeProperty
-
setupDefaultPrototype
-
setHomeObject
-
getHomeObject
-
isConstructor
public boolean isConstructor()Description copied from interface:FunctionReturn whether this function can be called as a constructor.- Specified by:
isConstructorin interfaceFunction
-
getDeclarationScope
Description copied from interface:FunctionReturn the scope in which this function was declared or closed over. This is the "[[Environment]]" defined in https://tc39.es/ecma262/#sec-ecmascript-function-objects. Although this is currently precisely equal to the parent scope (or "__parent__") of an object it is useful to distinguish the two concepts as parent scopes are no longer supported by the spec in general and present a significant barrier to future optimisations.- Specified by:
getDeclarationScopein interfaceFunction
-