###IDEA keep PMC pointers in explicit shadow-stack, a linked list of frames
###IMPLEMENTATION
struct frame
{
struct frame *prev;
size_t size;
PMC **pmcs;
};
-
function prolog (add frame to stack):
PMC *pmcs[42] = { 0 }; struct frame frame = { interp->last_frame, sizeof pmcs / sizeof *pmcs, pmcs }; interp->last_frame = &frame;
-
function epilogue (remove frame from stack):
interp->last_frame = frame.prev;
###PRO
- can be done in standard C
- resembles current approach, but portable
###CONTRA
- awkward: PMC variables could never be named
- not general enough for all use cases
###ALTERNATIVES
- add ref count to PMCs which tracks external references; such a more general approach would make things like easy C++ integration via smart pointers possible