java.lang.Object
org.mozilla.javascript.SlotMapOwner
org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.BaseFunction
org.mozilla.javascript.JSFunction
- All Implemented Interfaces:
Serializable,Callable,ConstProperties,Constructable,DebuggableObject,Function,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.mozilla.javascript.ScriptableObject
ScriptableObject.DescriptorInfo, ScriptableObject.KeyComparator, ScriptableObject.LambdaGetterFunction, ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.mozilla.javascript.BaseFunction
Id_arguments, Id_arity, Id_length, Id_name, Id_prototype, MAX_INSTANCE_IDFields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionJSFunction(Context cx, Scriptable scope, JSDescriptor<JSFunction> descriptor, Scriptable lexicalThis, Scriptable homeObject) -
Method Summary
Modifier and TypeMethodDescriptioncall(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) Should be overridden.construct(Context cx, Scriptable scope, Object[] args) Call the function as a constructor.static JSFunctioncreateFunction(Context cx, Scriptable 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) protected booleanbooleanhasFunctionNamed(String name) protected booleanprotected booleanbooleanisScript()booleanbooleanisStrict()resumeGenerator(Context cx, Scriptable scope, int operation, Object state, Object value) voidsetHomeObject(Scriptable homeObject) Methods inherited from class org.mozilla.javascript.BaseFunction
createObject, createProperties, createPrototypeProperty, defaultGet, defaultHas, defaultPut, getClassName, getClassPrototype, getPrototypeProperty, getTypeOf, hasInstance, includeNonStandardProps, prototypeDescSetter, setImmunePrototypeProperty, setPrototypeProperty, setPrototypePropertyAttributes, setStandardPropertyAttributes, setupDefaultPrototypeMethods inherited from class org.mozilla.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, equivalentValues, get, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, has, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, put, putConst, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.mozilla.javascript.SlotMapOwner
createSlotMapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.mozilla.javascript.Scriptable
delete, delete, get, get, getDefaultValue, getIds, getParentScope, getPrototype, has, has, put, put, setParentScope, setPrototype
-
Constructor Details
-
JSFunction
public JSFunction(Context cx, Scriptable scope, JSDescriptor<JSFunction> descriptor, Scriptable lexicalThis, Scriptable homeObject)
-
-
Method Details
-
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>
-
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
Description copied from class:BaseFunctionShould be overridden.- Specified by:
callin interfaceCallable- Specified by:
callin interfaceFunction- Overrides:
callin classBaseFunction- 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
-
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.- Specified by:
constructin interfaceConstructable- Specified by:
constructin interfaceFunction- Overrides:
constructin classBaseFunction- Parameters:
cx- the current Context for this threadscope- 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
-
hasFunctionNamed
-
getFunctionName
- Overrides:
getFunctionNamein classBaseFunction
-
resumeGenerator
public Object resumeGenerator(Context cx, Scriptable scope, int operation, Object state, Object value) -
getHomeObject
- Specified by:
getHomeObjectin interfaceScriptOrFn<JSFunction>- Overrides:
getHomeObjectin classBaseFunction
-
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, Scriptable scope, JSDescriptor<JSFunction> desc, Scriptable homeObject, Object staticSecurityDomain) Create function compiled from Function(...) constructor.
-