diff --git a/include/picrin.h b/include/picrin.h index 03209454..7f9015e4 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -13,6 +13,8 @@ struct pic_env { typedef struct { pic_value *sp; + pic_value *stbase, *stend; + struct pic_env *global_env; } pic_state; diff --git a/src/state.c b/src/state.c index c1e08699..8666b8f8 100644 --- a/src/state.c +++ b/src/state.c @@ -20,7 +20,11 @@ pic_open() pic_state *pic; pic = (pic_state *)malloc(sizeof(pic_state)); - pic->sp = (pic_value *)malloc(sizeof(pic_value) * 1024); + + /* prepare VM stack */ + pic->stbase = pic->sp = (pic_value *)malloc(sizeof(pic_value) * 1024); + pic->stend = pic->stbase + 1024; + pic->global_env = pic_new_empty_env(); return pic;