NAME ^

src/stacks.c - Stack handling routines for Parrot

DESCRIPTION ^

The stack is stored as a linked list of chunks (Stack_Chunk), where each chunk has room for one entry.

Functions ^

*/

#include "parrot/parrot.h" #include "parrot/stacks.h"

/* HEADERIZER HFILE: include/parrot/stacks.h */

/*

FUNCDOC: new_stack

Create a new stack and name it. stack->name is used for debugging/error reporting.

*/

PARROT_API PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT Stack_Chunk_t * new_stack(PARROT_INTERP, NOTNULL(const char *name)) { return register_new_stack(interp, name, sizeof (Stack_Entry_t)); }

/*

FUNCDOC: mark_stack

Mark entries in a stack structure during DOD.

*/

PARROT_API void mark_stack(PARROT_INTERP, NOTNULL(Stack_Chunk_t *chunk)) { 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

stack_destroy() doesn't need to do anything, since GC does it all.

SEE ALSO ^

include/parrot/stacks.h, include/parrot/enums.h, and src/stack_common.c


parrot