Package org.mozilla.javascript
Class InterpretedFunction
- java.lang.Object
-
- org.mozilla.javascript.ScriptableObject
-
- org.mozilla.javascript.IdScriptableObject
-
- org.mozilla.javascript.BaseFunction
-
- org.mozilla.javascript.NativeFunction
-
- org.mozilla.javascript.InterpretedFunction
-
- All Implemented Interfaces:
java.io.Serializable
,Callable
,ConstProperties
,DebuggableObject
,Function
,IdFunctionCall
,Script
,Scriptable
,SymbolScriptable
final class InterpretedFunction extends NativeFunction implements Script
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
ScriptableObject.GetterSlot, ScriptableObject.KeyComparator, ScriptableObject.Slot, ScriptableObject.SlotAccess
-
-
Field Summary
Fields Modifier and Type Field Description (package private) InterpreterData
idata
(package private) SecurityController
securityController
(package private) java.lang.Object
securityDomain
private static long
serialVersionUID
-
Fields inherited from class org.mozilla.javascript.BaseFunction
GENERATOR_FUNCTION_CLASS
-
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
-
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
-
Constructor Summary
Constructors Modifier Constructor Description private
InterpretedFunction(InterpretedFunction parent, int index)
private
InterpretedFunction(InterpreterData idata, java.lang.Object staticSecurityDomain)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
call(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
Calls the function.(package private) static InterpretedFunction
createFunction(Context cx, Scriptable scope, InterpretedFunction parent, int index)
Create function embedded in script or another function.(package private) static InterpretedFunction
createFunction(Context cx, Scriptable scope, InterpreterData idata, java.lang.Object staticSecurityDomain)
Create function compiled from Function(...) constructor.(package private) static InterpretedFunction
createScript(InterpreterData idata, java.lang.Object staticSecurityDomain)
Create script from compiled bytecode.java.lang.Object
exec(Context cx, Scriptable scope)
Execute the script.DebuggableScript
getDebuggableView()
java.lang.String
getEncodedSource()
Get encoded source string.java.lang.String
getFunctionName()
protected int
getLanguageVersion()
protected int
getParamAndVarCount()
Get number of declared parameters and variables defined through var statements.protected int
getParamCount()
Get number of declared parameters.protected boolean
getParamOrVarConst(int index)
Get parameter or variable const-ness.protected java.lang.String
getParamOrVarName(int index)
Get parameter or variable name.(package private) boolean
hasFunctionNamed(java.lang.String name)
boolean
isScript()
java.lang.Object
resumeGenerator(Context cx, Scriptable scope, int operation, java.lang.Object state, java.lang.Object value)
Resume execution of a suspended generator.-
Methods inherited from class org.mozilla.javascript.NativeFunction
decompile, getArity, getLength, initScriptFunction, initScriptFunction, jsGet_name
-
Methods inherited from class org.mozilla.javascript.BaseFunction
construct, createObject, execIdCall, fillConstructorProperties, findInstanceIdInfo, findPrototypeId, getClassName, getClassPrototype, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, getPrototypeProperty, getTypeOf, hasInstance, hasPrototypeProperty, init, initAsGeneratorFunction, initPrototypeId, isApply, isApplyOrCall, isGeneratorFunction, setImmunePrototypeProperty, setInstanceIdAttributes, setInstanceIdValue
-
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, exportAsJSClass, findInstanceIdInfo, findPrototypeId, get, get, getAttributes, getAttributes, getIds, getOwnPropertyDescriptor, has, has, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, put, put, setAttributes
-
Methods inherited from class org.mozilla.javascript.ScriptableObject
addLazilyInitializedValue, applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildClassCtor, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, checkValidAttributes, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.mozilla.javascript.Scriptable
delete, delete, get, get, getDefaultValue, getIds, getParentScope, getPrototype, has, has, put, put, setParentScope, setPrototype
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
idata
InterpreterData idata
-
securityController
SecurityController securityController
-
securityDomain
java.lang.Object securityDomain
-
-
Constructor Detail
-
InterpretedFunction
private InterpretedFunction(InterpreterData idata, java.lang.Object staticSecurityDomain)
-
InterpretedFunction
private InterpretedFunction(InterpretedFunction parent, int index)
-
-
Method Detail
-
createScript
static InterpretedFunction createScript(InterpreterData idata, java.lang.Object staticSecurityDomain)
Create script from compiled bytecode.
-
createFunction
static InterpretedFunction createFunction(Context cx, Scriptable scope, InterpreterData idata, java.lang.Object staticSecurityDomain)
Create function compiled from Function(...) constructor.
-
createFunction
static InterpretedFunction createFunction(Context cx, Scriptable scope, InterpretedFunction parent, int index)
Create function embedded in script or another function.
-
getFunctionName
public java.lang.String getFunctionName()
- Overrides:
getFunctionName
in classBaseFunction
-
call
public java.lang.Object call(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
Calls the function.- Specified by:
call
in interfaceCallable
- Specified by:
call
in interfaceFunction
- Overrides:
call
in classBaseFunction
- Parameters:
cx
- the current contextscope
- the scope used for the callthisObj
- the value of "this"args
- function arguments. Must not be null. You can useScriptRuntime.emptyArgs
to pass empty arguments.- Returns:
- the result of the function call.
-
exec
public java.lang.Object exec(Context cx, Scriptable scope)
Description copied from interface:Script
Execute the script.The script is executed in a particular runtime Context, which must be associated with the current thread. The script is executed relative to a scope--definitions and uses of global top-level variables and functions will access properties of the scope object. For compliant ECMA programs, the scope must be an object that has been initialized as a global object using
Context.initStandardObjects
.- Specified by:
exec
in interfaceScript
- Parameters:
cx
- the Context associated with the current threadscope
- the scope to execute relative to- Returns:
- the result of executing the script
- See Also:
Context.initStandardObjects()
-
isScript
public boolean isScript()
-
getEncodedSource
public java.lang.String getEncodedSource()
Description copied from class:NativeFunction
Get encoded source string.- Overrides:
getEncodedSource
in classNativeFunction
-
getDebuggableView
public DebuggableScript getDebuggableView()
- Overrides:
getDebuggableView
in classNativeFunction
-
resumeGenerator
public java.lang.Object resumeGenerator(Context cx, Scriptable scope, int operation, java.lang.Object state, java.lang.Object value)
Description copied from class:NativeFunction
Resume execution of a suspended generator.- Overrides:
resumeGenerator
in classNativeFunction
- Parameters:
cx
- The current contextscope
- Scope for the parent generator functionoperation
- The resumption operation (next, send, etc.. )state
- The generator state (has locals, stack, etc.)value
- The return value of yield (if required).- Returns:
- The next yielded value (if any)
-
getLanguageVersion
protected int getLanguageVersion()
- Specified by:
getLanguageVersion
in classNativeFunction
-
getParamCount
protected int getParamCount()
Description copied from class:NativeFunction
Get number of declared parameters. It should be 0 for scripts.- Specified by:
getParamCount
in classNativeFunction
-
getParamAndVarCount
protected int getParamAndVarCount()
Description copied from class:NativeFunction
Get number of declared parameters and variables defined through var statements.- Specified by:
getParamAndVarCount
in classNativeFunction
-
getParamOrVarName
protected java.lang.String getParamOrVarName(int index)
Description copied from class:NativeFunction
Get parameter or variable name. Ifindex <
, then return the name of the corresponding parameter. Otherwise return the name of variable.NativeFunction.getParamCount()
- Specified by:
getParamOrVarName
in classNativeFunction
-
getParamOrVarConst
protected boolean getParamOrVarConst(int index)
Description copied from class:NativeFunction
Get parameter or variable const-ness. Ifindex <
, then return the const-ness of the corresponding parameter. Otherwise return whether the variable is const.NativeFunction.getParamCount()
- Overrides:
getParamOrVarConst
in classNativeFunction
-
hasFunctionNamed
boolean hasFunctionNamed(java.lang.String name)
-
-