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 (Stack_Chunk
),
where each chunk has room for one entry.
*/
#include "parrot/parrot.h" #include "parrot/stacks.h" #include <assert.h>
/* HEADER: include/parrot/stacks.h */
/*
FUNCDOC: Create a new stack and name it.
stack->name
is used for debugging/error reporting.
*/
PARROT_API Stack_Chunk_t * new_stack(Interp *interp, const char *name /*NN*/) /* WARN_UNUSED */ { return register_new_stack(interp, name, sizeof (Stack_Entry_t)); }
/*
FUNCDOC: Mark entries in a stack structure during DOD.
*/
PARROT_API void mark_stack(Interp *interp /*NN*/, Stack_Chunk_t *chunk /*NN*/) { for (; ; chunk = chunk->prev) { Stack_Entry_t *entry;
pobject_lives(interp, (PObj*)chunk);
if (chunk == chunk->prev)
break;
entry = (Stack_Entry_t *)STACK_DATAP(chunk);
switch (entry->entry_type) {
case STACK_ENTRY_PMC:
if (UVal_pmc(entry->entry))
pobject_lives(interp, (PObj *)UVal_pmc(entry->entry));
break;
case STACK_ENTRY_STRING:
if (UVal_str(entry->entry))
pobject_lives(interp, (PObj *)UVal_str(entry->entry));
break;
default:
break;
}
}
}
/*
FUNCDOC: stack_destroy() doesn't need to do anything, since GC does it all.
include/parrot/stacks.h, include/parrot/enums.h, and src/stack_common.c
|