|parrotcode: Stack handling routines for Parrot|
|Contents | C|
src/stacks.c - Stack handling routines for Parrot
The stack is stored as a linked list of chunks (
where each chunk has room for one entry.
Stack_Chunk_t *new_stack(Interp *interpreter, const char *name)
stack->nameis used for debugging/error reporting.
void mark_stack(Interp *interpreter, Stack_Chunk_t *chunk)
void stack_destroy(Stack_Chunk_t *top)
size_t stack_height(Interp *interpreter, Stack_Chunk_t *top)
Stack_Entry_t *stack_entry(Interp *interpreter, Stack_Chunk_t *stack, INTVAL depth)
depth >= 0, return the entry at that depth from the top of the stack, with 0 being the top entry. If
depth < 0, then return the entry
|depth|entries from the bottom of the stack. Returns
|depth|number> of entries in stack.
void rotate_entries(Interp *interpreter, Stack_Chunk_t **stack_p, INTVAL num_entries)
N0>, the rotation is bubble up, so the top most element becomes the Nth element. If
N < 0, the rotation is bubble down, so that the Nth element becomes the top most element.
void stack_push(Interp *interpreter, Stack_Chunk_t **stack_p, void *thing, Stack_entry_type type, Stack_cleanup_method cleanup)
NULL, points to a routine that'll be called when the entry is removed from the stack. This is handy for those cases where you need some sort of activity to take place when an entry is removed, such as when you push a lexical lock onto the call stack, or localize (or tempify, or whatever we're calling it) variable or something.
void *stack_pop(Interp *interpreter, Stack_Chunk_t **stack_p, void *where, Stack_entry_type type)
void *pop_dest(Interp *interpreter)
void *stack_peek(Interp *interpreter, Stack_Chunk_t *stack_base, Stack_entry_type *type)
Stack_entry_type get_entry_type(Interp *interpreter, Stack_Entry_t *entry)
include/parrot/stacks.h, include/parrot/enums.h, and src/stack_common.c