Class InterpretedFunction

All Implemented Interfaces:
Serializable, Callable, ConstProperties, Constructable, DebuggableObject, Function, IdFunctionCall, Script, Scriptable, SymbolScriptable

final class InterpretedFunction extends NativeFunction implements Script
  • Field Details

  • Constructor Details

  • Method Details

    • createScript

      static InterpretedFunction createScript(InterpreterData idata, Object staticSecurityDomain)
      Create script from compiled bytecode.
    • createFunction

      static InterpretedFunction createFunction(Context cx, Scriptable scope, InterpreterData idata, 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 String getFunctionName()
      Overrides:
      getFunctionName in class BaseFunction
    • call

      public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
      Calls the function.
      Specified by:
      call in interface Callable
      Specified by:
      call in interface Function
      Overrides:
      call in class BaseFunction
      Parameters:
      cx - the current context
      scope - the scope used for the call
      thisObj - the value of "this"
      args - function arguments. Must not be null. You can use ScriptRuntime.emptyArgs to pass empty arguments.
      Returns:
      the result of the function call.
    • exec

      public 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 interface Script
      Parameters:
      cx - the Context associated with the current thread
      scope - the scope to execute relative to
      Returns:
      the result of executing the script
      See Also:
    • isScript

      public boolean isScript()
    • getEncodedSource

      public String getEncodedSource()
      Description copied from class: NativeFunction
      Get encoded source string.
      Overrides:
      getEncodedSource in class NativeFunction
    • getDebuggableView

      public DebuggableScript getDebuggableView()
      Overrides:
      getDebuggableView in class NativeFunction
    • resumeGenerator

      public Object resumeGenerator(Context cx, Scriptable scope, int operation, Object state, Object value)
      Description copied from class: NativeFunction
      Resume execution of a suspended generator.
      Overrides:
      resumeGenerator in class NativeFunction
      Parameters:
      cx - The current context
      scope - Scope for the parent generator function
      operation - 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 class NativeFunction
    • getParamCount

      protected int getParamCount()
      Description copied from class: NativeFunction
      Get number of declared parameters. It should be 0 for scripts.
      Specified by:
      getParamCount in class NativeFunction
    • getParamAndVarCount

      protected int getParamAndVarCount()
      Description copied from class: NativeFunction
      Get number of declared parameters and variables defined through var statements.
      Specified by:
      getParamAndVarCount in class NativeFunction
    • getParamOrVarName

      protected String getParamOrVarName(int index)
      Description copied from class: NativeFunction
      Get parameter or variable name. If index < NativeFunction.getParamCount(), then return the name of the corresponding parameter. Otherwise return the name of variable.
      Specified by:
      getParamOrVarName in class NativeFunction
    • getParamOrVarConst

      protected boolean getParamOrVarConst(int index)
      Description copied from class: NativeFunction
      Get parameter or variable const-ness. If index < NativeFunction.getParamCount(), then return the const-ness of the corresponding parameter. Otherwise return whether the variable is const.
      Overrides:
      getParamOrVarConst in class NativeFunction
    • toString

      public String toString()
      Provides the decompiled source of the function what is helpful while debugging.
      Overrides:
      toString in class Object
    • setArguments

      void setArguments(Arguments arguments)
    • get

      public Object get(String name, Scriptable start)
      Description copied from class: ScriptableObject
      Returns the value of the named property or NOT_FOUND.

      If the property was created using defineProperty, the appropriate getter method is called.

      Specified by:
      get in interface Scriptable
      Overrides:
      get in class IdScriptableObject
      Parameters:
      name - the name of the property
      start - the object in which the lookup began
      Returns:
      the value of the property (may be null), or NOT_FOUND
      See Also:
    • hasFunctionNamed

      boolean hasFunctionNamed(String name)