Class OptJSFunctionCode

All Implemented Interfaces:
JSCodeExec<JSFunction>, JSCodeResume<JSFunction>

public abstract class OptJSFunctionCode extends OptJSCode<JSFunction>
Subclass of OptJSCode which narrows the type paramter to JSFunction. This allows compiled code to be type safe and avoid casting when accessing the executable object.
  • Constructor Details

    • OptJSFunctionCode

      protected OptJSFunctionCode()
  • Method Details

    • execute

      public abstract Object execute(Context cx, JSFunction executableObject, Object newTarget, Scriptable scope, Object thisObj, Object[] args)
      Description copied from interface: JSCodeExec
      Executes the code represented by this object.
      Parameters:
      cx - should be context in which the call is being made
      executableObject - should be function or script which owns this code.
      newTarget - should be null in the case of script or function calls, and the `new.target` of constructors.
      scope - should be the scope in which the script, function, or constructor should execute. This should normally be derived from the scope which the function or constructor was declared, or for scripts should be the scope in which they are being executed.
      thisObj - should be the value of `this` that the code will see while executing.
      args - is the array of arguments passed to the code.
      Returns:
      the result of executing the code.
    • resume

      public abstract Object resume(Context cx, JSFunction executableObject, Object state, Scriptable scope, int operation, Object value)
      Description copied from interface: JSCodeResume
      Resuem execution of the code represented by this object.
      Parameters:
      cx - should be context in which the call is being made
      executableObject - should be function or script which owns this code.
      state - should be the state object created at some previous point when execution was yielded.
      scope - should be the scope in which the code will be executed.
      operation - should be one of the constants defined on NativeGenerator and represents the operation being performed.
      value - represents the value being passed into the generator (see https://tc39.es/ecma262/#sec-generatorresume for details).
      Returns:
      the result of executing the code.