Package org.rapidcontext.core.proc
Class CallStack
java.lang.Object
org.rapidcontext.core.proc.CallStack
A procedure call stack. The stack contains an ordered list of the
procedures currently being called.
- Version:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncaller()
Returns the procedure calling the currently executing procedure.boolean
Checks if the specified procedure exists in the call stack.int
height()
Returns the current height of the call stack.top
(int offset) Returns the most recent caller from the stack.toStackTrace
(int maxSize) Returns a printable stack trace for debugging purposes.
-
Constructor Details
-
CallStack
public CallStack()Creates a new empty procedure call stack.
-
-
Method Details
-
contains
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
Returns the procedure calling the currently executing procedure.- Returns:
- the caller procedure, or null if top-level
-
top
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
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
-