|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 *interp, const char *name)
stack->nameis used for debugging/error reporting.
void mark_stack(Interp *interp, Stack_Chunk_t *chunk)
void stack_destroy(Stack_Chunk_t *top)
size_t stack_height(Interp *interp, const Stack_Chunk_t *top)
Stack_Entry_t *stack_entry(Interp *interp, 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 *interp, 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 *interp, 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 *interp, Stack_Chunk_t **stack_p, void *where, Stack_entry_type type)
void *pop_dest(Interp *interp)
void *stack_peek(Interp *interp, Stack_Chunk_t *stack_base, Stack_entry_type *type)
Stack_entry_type get_entry_type(Interp *interp, Stack_Entry_t *entry)
void Parrot_dump_dynamic_environment(Interp *interp, struct Stack_Chunk *dynamic_env)
PIO_eprintf). This is used only temporarily for debugging.
include/parrot/stacks.h, include/parrot/enums.h, and src/stack_common.c