Module org.htmlunit.corejs
Package org.htmlunit.corejs.javascript
Class JSDescriptor<T extends ScriptOrFn<T>>
java.lang.Object
org.htmlunit.corejs.javascript.JSDescriptor<T>
- All Implemented Interfaces:
Serializable,DebuggableScript
public final class JSDescriptor<T extends ScriptOrFn<T>>
extends Object
implements Serializable, DebuggableScript
This class holds all the meta-data associated with a function in as an immutable form as
possible, along with the executable things associated with the function. The idea here is to push
all the expensive parts of creating this to an object that can be cached and reused, while
function objects represented by
JSFunctions become more lightweight in their creation.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classJSDescriptor.Builder<T extends ScriptOrFn<T>>A mutable object for creating the final immutableJSDescriptor. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJSDescriptor(JSCode<T> code, JSCode<T> constructor, JSDescriptor<?> parent, String[] paramAndVarNames, boolean[] paramIsConst, boolean isStrict, boolean isScript, boolean isTopLevel, boolean isES6Generator, boolean isShorthand, boolean hasPrototype, boolean hasLexicalThis, boolean isEvalFunction, boolean hasRestArg, String sourceFile, SourceCodeProvider sourceCodeProvider, int sourceStart, int sourceEnd, String name, int languageVersion, int paramAndVarCount, int paramCount, int arity, boolean hasDefaultParameters, boolean requiresActivationFrame, boolean requiresArgumentObject, boolean declaredAsFunctionExpression, boolean derivedConstructor, SecurityController securityController, Object securityDomain, int functionType) -
Method Summary
Modifier and TypeMethodDescriptionbooleanintgetArity()getCode()getFunction(int index) intGet name of the function described by this script.intintint[]Get array containing the line numbers that that can be passed toDebugFrame.onLineChange().getName()intGet number of declared parameters and local variables.intGet number of declared parameters in the function.booleangetParamOrVarConst(int index) getParamOrVarName(int index) Get name of a declared parameter or local variable.Get the name of the source (usually filename or URL) of the script.booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanReturns true if this is a function, false if it is a script.booleanReturns true if this script or function were runtime-generated from JavaScript usingevalfunction orFunctionorScriptconstructors.booleanisScript()booleanbooleanisStrict()booleanbooleanboolean
-
Field Details
-
nestedFunctions
-
-
Constructor Details
-
JSDescriptor
public JSDescriptor(JSCode<T> code, JSCode<T> constructor, JSDescriptor<?> parent, String[] paramAndVarNames, boolean[] paramIsConst, boolean isStrict, boolean isScript, boolean isTopLevel, boolean isES6Generator, boolean isShorthand, boolean hasPrototype, boolean hasLexicalThis, boolean isEvalFunction, boolean hasRestArg, String sourceFile, SourceCodeProvider sourceCodeProvider, int sourceStart, int sourceEnd, String name, int languageVersion, int paramAndVarCount, int paramCount, int arity, boolean hasDefaultParameters, boolean requiresActivationFrame, boolean requiresArgumentObject, boolean declaredAsFunctionExpression, boolean derivedConstructor, SecurityController securityController, Object securityDomain, int functionType)
-
-
Method Details
-
getCode
-
getConstructor
-
getNestedFunctions
-
isStrict
public boolean isStrict() -
isScript
public boolean isScript() -
isTopLevel
public boolean isTopLevel()- Specified by:
isTopLevelin interfaceDebuggableScript
-
isFunction
public boolean isFunction()Description copied from interface:DebuggableScriptReturns true if this is a function, false if it is a script.- Specified by:
isFunctionin interfaceDebuggableScript
-
isES6Generator
public boolean isES6Generator() -
isShorthand
public boolean isShorthand() -
hasPrototype
public boolean hasPrototype() -
hasLexicalThis
public boolean hasLexicalThis() -
isEvalFunction
public boolean isEvalFunction() -
hasRestArg
public boolean hasRestArg() -
getSourceName
Description copied from interface:DebuggableScriptGet the name of the source (usually filename or URL) of the script.- Specified by:
getSourceNamein interfaceDebuggableScript
-
getSource
-
getName
-
getLanguageVersion
public int getLanguageVersion() -
getParamAndVarCount
public int getParamAndVarCount()Description copied from interface:DebuggableScriptGet number of declared parameters and local variables. Return number of declared global variables if this script is not a function.- Specified by:
getParamAndVarCountin interfaceDebuggableScript- See Also:
-
getParamCount
public int getParamCount()Description copied from interface:DebuggableScriptGet number of declared parameters in the function. Return 0 if this script is not a function.- Specified by:
getParamCountin interfaceDebuggableScript- See Also:
-
getArity
public int getArity() -
getParamOrVarConst
public boolean getParamOrVarConst(int index) -
getParamOrVarName
Description copied from interface:DebuggableScriptGet name of a declared parameter or local variable.indexshould be less thenDebuggableScript.getParamAndVarCount(). Ifindex <, return the name of the corresponding parameter, otherwise return the name of variable. If this script is not function, return the name of the declared global variable.DebuggableScript.getParamCount()- Specified by:
getParamOrVarNamein interfaceDebuggableScript
-
hasDefaultParameters
public boolean hasDefaultParameters() -
hasNoFunctionStatementNamed
-
getFunctionCount
public int getFunctionCount()- Specified by:
getFunctionCountin interfaceDebuggableScript
-
getFunction
- Specified by:
getFunctionin interfaceDebuggableScript
-
getFunctionName
Description copied from interface:DebuggableScriptGet name of the function described by this script. Return null or an empty string if this script is not a function.- Specified by:
getFunctionNamein interfaceDebuggableScript
-
isGeneratedScript
public boolean isGeneratedScript()Description copied from interface:DebuggableScriptReturns true if this script or function were runtime-generated from JavaScript usingevalfunction orFunctionorScriptconstructors.- Specified by:
isGeneratedScriptin interfaceDebuggableScript
-
getLineNumbers
public int[] getLineNumbers()Description copied from interface:DebuggableScriptGet array containing the line numbers that that can be passed toDebugFrame.onLineChange(). Note that line order in the resulting array is arbitrary- Specified by:
getLineNumbersin interfaceDebuggableScript
-
requiresActivationFrame
public boolean requiresActivationFrame() -
requiresArgumentObject
public boolean requiresArgumentObject() -
declaredAsFunctionExpression
public boolean declaredAsFunctionExpression() -
getSecurityController
-
getSecurityDomain
-
getFunctionType
public int getFunctionType() -
getParent
- Specified by:
getParentin interfaceDebuggableScript
-