Class Frame

java.lang.Object
org.apache.commons.jexl3.internal.Frame
Direct Known Subclasses:
ReferenceFrame

public class Frame extends Object
A call frame, created from a scope, stores the arguments and local variables in a "stack frame" (sic).
Since:
3.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    Number of curried parameters.
    private final Scope
    The scope.
    protected final Object[]
    The actual stack frame.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Frame(Scope s, Object[] r, int c)
    Creates a new frame.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) Frame
    assign(Object... values)
    Assign values to this frame.
    (package private) Object
    capture(int s, boolean lexical)
    Captures a value.
    (package private) Object
    get(int s)
    Gets a value.
    Gets the scope.
    Gets this script unbound parameters, i.e.
    (package private) boolean
    has(int s)
    Tests whether this frame defines a symbol, ie declared it and assigned it a value.
    (package private) Frame
    newFrame(Scope s, Object[] r, int c)
    Creates a new from of this frame"s class.
    (package private) Object[]
    Replace any instance of a closure in this stack by its (fuzzy encoded) offset in it.
    (package private) void
    set(int r, Object value)
    Sets a value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • scope

      private final Scope scope
      The scope.
    • stack

      protected final Object[] stack
      The actual stack frame.
    • curried

      private final int curried
      Number of curried parameters.
  • Constructor Details

    • Frame

      protected Frame(Scope s, Object[] r, int c)
      Creates a new frame.
      Parameters:
      s - The scope
      r - The stack frame
      c - The number of curried parameters
  • Method Details

    • assign

      Frame assign(Object... values)
      Assign values to this frame.
      Parameters:
      values - The values
      Returns:
      this frame
    • newFrame

      Frame newFrame(Scope s, Object[] r, int c)
      Creates a new from of this frame"s class.
      Parameters:
      s - The scope
      r - The arguments
      c - The number of curried parameters
      Returns:
      A new instance of frame
    • capture

      Object capture(int s, boolean lexical)
      Captures a value.
      Parameters:
      s - The offset in this frame
      lexical - true if this captured symbol is redefined locally
      Returns:
      The stacked value
    • get

      Object get(int s)
      Gets a value.
      Parameters:
      s - The offset in this frame
      Returns:
      The stacked value
    • set

      void set(int r, Object value)
      Sets a value.
      Parameters:
      r - The offset in this frame
      value - The value to set in this frame
    • getScope

      public Scope getScope()
      Gets the scope.
      Returns:
      this frame scope
    • getUnboundParameters

      public String[] getUnboundParameters()
      Gets this script unbound parameters, i.e. parameters not bound through curry().
      Returns:
      The parameter names
    • has

      boolean has(int s)
      Tests whether this frame defines a symbol, ie declared it and assigned it a value.
      Parameters:
      s - The offset in this frame
      Returns:
      true if this symbol has been assigned a value, false otherwise
    • nocycleStack

      Object[] nocycleStack(Closure closure)
      Replace any instance of a closure in this stack by its (fuzzy encoded) offset in it.

      This is to avoid the cyclic dependency between the closure and its frame stack that may point back to it that occur with recursive function definitions.

      Parameters:
      closure - The owning closure
      Returns:
      The cleaned-up stack or the stack itself (most of the time)