From 1a45eab148f3143b8e87e81f28bf299a80968a64 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 12 Oct 2013 00:20:53 +0900 Subject: [PATCH] store stack base and end --- include/picrin.h | 2 ++ src/state.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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;