Class CallStack

java.lang.Object
org.rapidcontext.core.proc.CallStack

public class CallStack extends Object
A procedure call stack. The stack contains an ordered list of the procedures currently being called.
Version:
1.0
  • Constructor Details

    • CallStack

      public CallStack()
      Creates a new empty procedure call stack.
  • Method Details

    • contains

      public boolean contains(Procedure proc)
      Checks if the specified procedure exists in the call stack.
      Parameters:
      proc - the procedure definition
      Returns:
      true if the procedure exists in the call stack, or false otherwise
    • height

      public int height()
      Returns the current height of the call stack.
      Returns:
      the current height of the call stack
    • caller

      public Procedure caller()
      Returns the procedure calling the currently executing procedure.
      Returns:
      the caller procedure, or null if top-level
    • top

      public Path top(int offset)
      Returns the most recent caller from the stack.
      Parameters:
      offset - the offset from the top (0 for top)
      Returns:
      the top caller in the stack, or null if the stack is empty
    • toStackTrace

      public List<String> toStackTrace(int maxSize)
      Returns a printable stack trace for debugging purposes.
      Parameters:
      maxSize - the maximum stack trace length
      Returns:
      an array with all the procedures on the stack