Class ScriptStackFrame

java.lang.Object
org.praxislive.script.ScriptStackFrame
All Implemented Interfaces:
StackFrame

public final class ScriptStackFrame extends Object implements StackFrame
A stackframe implementation that supports parsing and running of Pcl scripts.
  • Method Details

    • getState

      public StackFrame.State getState()
      Description copied from interface: StackFrame
      Get the current state of this StackFrame.
      Specified by:
      getState in interface StackFrame
      Returns:
      current state
    • process

      public StackFrame process(Env context)
      Description copied from interface: StackFrame
      Process the StackFrame. After processing, the StackFrame should have made one or more Calls, returned a child StackFrame, or moved out of the Incomplete state.

      Process may be called multiple times if the state is still incomplete after this method returns and a response has been posted.

      Specified by:
      process in interface StackFrame
      Parameters:
      context - processing environment
      Returns:
      child StackFrame or null
    • postResponse

      public void postResponse(Call call)
      Description copied from interface: StackFrame
      Used by the script executor to post the result of a Call. The StackFrame should validate the match ID of the response call against any pending calls before processing the call state or arguments.

      If the state is still incomplete after a response is posted, StackFrame.process(org.praxislive.script.Env) will be called again.

      Specified by:
      postResponse in interface StackFrame
      Parameters:
      call - response call
    • postResponse

      public void postResponse(StackFrame.State state, List<Value> args)
      Description copied from interface: StackFrame
      Used by the script executor to post the result of a child StackFrame returned by StackFrame.process(org.praxislive.script.Env).

      If the state is still incomplete after a response is posted, StackFrame.process(org.praxislive.script.Env) will be called again.

      Specified by:
      postResponse in interface StackFrame
      Parameters:
      state - the completion state of the child stack frame
      args - the result of the child stack frame
    • result

      public List<Value> result()
      Description copied from interface: StackFrame
      Access the result of this StackFrame.
      Specified by:
      result in interface StackFrame
      Returns:
      result
    • forScript

      public static ScriptStackFrame.Builder forScript(Namespace namespace, String script)
      Create a ScriptStackFrame.Builder for the provided namespace and script. By default the script will be evaluated in a dedicated child namespace. Neither the builder or the stack frame are reusable.
      Parameters:
      namespace - namespace to run script in
      script - script to parse and run
      Returns:
      builder
      Throws:
      InvalidSyntaxException - if the script cannot be parsed