We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Stack Frames

Think back to the warnings I gave you about working with void* data types. It's easy to push the wrong kinds of data onto our stack_t because, like Starbucks Wi-Fi, it will let anything in.

So, to prevent us from shooting ourselves in the foot, we will create some functions that are more type safe and make it much more difficult to do the wrong thing when interacting with our vm_t. Wrong things like:

// The C compiler won't stop us :'(
stack_push(vm->frames, (void *)7);
stack_push(vm->frames, (void *)"uh oh");

But we want to make it easier on ourselves to only push frame_t * types onto vm->frames, so we'll write some wrapper functions to help us out.

Assignment

Take a look at the frame_t type in vm.h. It's a simple struct that holds a stack_t of snek_object_t * pointers that represent the object references in the frame.