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:
  • Field Details

  • 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

      public JSCode<T> getCode()
    • getConstructor

      public JSCode<T> getConstructor()
    • getNestedFunctions

      public List<JSDescriptor<JSFunction>> getNestedFunctions()
    • isStrict

      public boolean isStrict()
    • isScript

      public boolean isScript()
    • isTopLevel

      public boolean isTopLevel()
      Specified by:
      isTopLevel in interface DebuggableScript
    • isFunction

      public boolean isFunction()
      Description copied from interface: DebuggableScript
      Returns true if this is a function, false if it is a script.
      Specified by:
      isFunction in interface DebuggableScript
    • 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

      public String getSourceName()
      Description copied from interface: DebuggableScript
      Get the name of the source (usually filename or URL) of the script.
      Specified by:
      getSourceName in interface DebuggableScript
    • getSource

      public String getSource()
    • getName

      public String getName()
    • getLanguageVersion

      public int getLanguageVersion()
    • getParamAndVarCount

      public int getParamAndVarCount()
      Description copied from interface: DebuggableScript
      Get number of declared parameters and local variables. Return number of declared global variables if this script is not a function.
      Specified by:
      getParamAndVarCount in interface DebuggableScript
      See Also:
    • getParamCount

      public int getParamCount()
      Description copied from interface: DebuggableScript
      Get number of declared parameters in the function. Return 0 if this script is not a function.
      Specified by:
      getParamCount in interface DebuggableScript
      See Also:
    • getArity

      public int getArity()
    • getParamOrVarConst

      public boolean getParamOrVarConst(int index)
    • getParamOrVarName

      public String getParamOrVarName(int index)
      Description copied from interface: DebuggableScript
      Get name of a declared parameter or local variable. index should be less then DebuggableScript.getParamAndVarCount(). If index < DebuggableScript.getParamCount() , 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.
      Specified by:
      getParamOrVarName in interface DebuggableScript
    • hasDefaultParameters

      public boolean hasDefaultParameters()
    • hasNoFunctionStatementNamed

      public boolean hasNoFunctionStatementNamed(String name)
    • getFunctionCount

      public int getFunctionCount()
      Specified by:
      getFunctionCount in interface DebuggableScript
    • getFunction

      public JSDescriptor<JSFunction> getFunction(int index)
      Specified by:
      getFunction in interface DebuggableScript
    • getFunctionName

      public String getFunctionName()
      Description copied from interface: DebuggableScript
      Get name of the function described by this script. Return null or an empty string if this script is not a function.
      Specified by:
      getFunctionName in interface DebuggableScript
    • isGeneratedScript

      public boolean isGeneratedScript()
      Description copied from interface: DebuggableScript
      Returns true if this script or function were runtime-generated from JavaScript using eval function or Function or Script constructors.
      Specified by:
      isGeneratedScript in interface DebuggableScript
    • getLineNumbers

      public int[] getLineNumbers()
      Description copied from interface: DebuggableScript
      Get array containing the line numbers that that can be passed to DebugFrame.onLineChange(). Note that line order in the resulting array is arbitrary
      Specified by:
      getLineNumbers in interface DebuggableScript
    • requiresActivationFrame

      public boolean requiresActivationFrame()
    • requiresArgumentObject

      public boolean requiresArgumentObject()
    • declaredAsFunctionExpression

      public boolean declaredAsFunctionExpression()
    • getSecurityController

      public SecurityController getSecurityController()
    • getSecurityDomain

      public Object getSecurityDomain()
    • getFunctionType

      public int getFunctionType()
    • getParent

      public DebuggableScript getParent()
      Specified by:
      getParent in interface DebuggableScript