java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.BaseFunction
org.htmlunit.corejs.javascript.JSFunction
- All Implemented Interfaces:
Serializable,Callable,ConstProperties<Scriptable>,Constructable,DebuggableObject,Function,PropHolder<Scriptable>,Scriptable,ScriptOrFn<JSFunction>,SymbolScriptable
Represents a JavaScript function built upon a a
JSDescriptor. All the immutable metadata
associated with the function is stored on the descriptor, with only the lexically bound this, the
home object required for super calls, and mutable properties held on the function object itself.- 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
Fields 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
ConstructorsConstructorDescriptionJSFunction(Context cx, VarScope scope, JSDescriptor<JSFunction> descriptor, Object lexicalThis, Object lexicalNewTarget, Scriptable homeObject) -
Method Summary
Modifier and TypeMethodDescriptionCall the function as a constructor.static JSFunctioncreateFunction(Context cx, VarScope scope, JSDescriptor<JSFunction> desc, Scriptable homeObject, Object staticSecurityDomain) Create function compiled from Function(...) constructor.protected voidstatic JSScriptcreateScript(JSDescriptor<JSScript> desc, Scriptable homeObject, Object staticSecurityDomain) Create script from compiled bytecode.intgetArity()Return the scope in which this function was declared or closed over.getFunctionThis(Scriptable functionThis) protected intintprotected intprotected intprotected booleangetParamOrVarConst(int index) protected StringgetParamOrVarName(int index) final ObjectgetThisObj(Object thisObj) protected booleanbooleanprotected booleanbooleanReturn whether this function can be called as a constructor.protected booleanbooleanisScript()booleanbooleanisStrict()resumeGenerator(Context cx, VarScope scope, int operation, Object state, Object value) voidsetHomeObject(Scriptable homeObject) protected voidsetPrototypeProperty(Object prototype) Methods inherited from class org.htmlunit.corejs.javascript.BaseFunction
call, createObject, createObject, createProperties, createPrototypeProperty, defaultGet, defaultHas, defaultPut, getClassName, getClassPrototype, getPrototypeProperty, getTypeOf, hasInstance, prototypeDescSetter, setImmunePrototypeProperty, 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
-
Constructor Details
-
JSFunction
public JSFunction(Context cx, VarScope scope, JSDescriptor<JSFunction> descriptor, Object lexicalThis, Object lexicalNewTarget, Scriptable homeObject)
-
-
Method Details
-
setPrototypeProperty
- Overrides:
setPrototypePropertyin classBaseFunction
-
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- Specified by:
getDeclarationScopein interfaceScriptOrFn<JSFunction>- Overrides:
getDeclarationScopein classBaseFunction
-
getDescriptor
- Specified by:
getDescriptorin interfaceScriptOrFn<JSFunction>
-
isShorthand
public boolean isShorthand() -
isStrict
public boolean isStrict() -
getArity
public int getArity()- Overrides:
getArityin classBaseFunction
-
getDebuggableView
-
getLanguageVersion
protected int getLanguageVersion() -
hasPrototypeProperty
protected boolean hasPrototypeProperty()- Overrides:
hasPrototypePropertyin classBaseFunction
-
isGeneratorFunction
protected boolean isGeneratorFunction()- Overrides:
isGeneratorFunctionin classBaseFunction
-
getLength
public int getLength()- Overrides:
getLengthin classBaseFunction
-
getParamAndVarCount
protected int getParamAndVarCount() -
getParamCount
protected int getParamCount() -
getParamOrVarConst
protected boolean getParamOrVarConst(int index) -
getParamOrVarName
-
getRawSource
-
createPrototypeProperty
protected void createPrototypeProperty()- Overrides:
createPrototypePropertyin classBaseFunction
-
call
- Overrides:
callin classBaseFunction
-
getThisObj
-
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,s- an enclosing scope of the caller except when the function is called from a closure.args- the array of arguments- Returns:
- the allocated object
-
isScript
public boolean isScript() -
hasDefaultParameters
protected boolean hasDefaultParameters()- Overrides:
hasDefaultParametersin classBaseFunction
-
hasNoFunctionStatementNamed
-
getFunctionName
- Overrides:
getFunctionNamein classBaseFunction
-
resumeGenerator
-
getHomeObject
- Specified by:
getHomeObjectin interfaceScriptOrFn<JSFunction>- Overrides:
getHomeObjectin classBaseFunction
-
getLexicalNewTarget
-
setHomeObject
- Overrides:
setHomeObjectin classBaseFunction
-
getFunctionThis
-
createScript
public static JSScript createScript(JSDescriptor<JSScript> desc, Scriptable homeObject, Object staticSecurityDomain) Create script from compiled bytecode. -
createFunction
public static JSFunction createFunction(Context cx, VarScope scope, JSDescriptor<JSFunction> desc, Scriptable homeObject, Object staticSecurityDomain) Create function compiled from Function(...) constructor. -
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
-