From 42dbd5fe9813de03a15225169f583076c8c2454e Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 14 Oct 2013 18:28:52 +0900 Subject: [PATCH] save some special symbols in pic_state structure --- include/picrin.h | 1 + src/state.c | 3 +++ src/vm.c | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/picrin.h b/include/picrin.h index 626a52a4..3435ee77 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -18,6 +18,7 @@ typedef struct { pic_value *sp; pic_value *stbase, *stend; + pic_value sDEFINE, sCONS, sADD; struct pic_env *global_env; struct heap_page *heap; diff --git a/src/state.c b/src/state.c index 5d96b76a..80588d95 100644 --- a/src/state.c +++ b/src/state.c @@ -35,6 +35,9 @@ pic_open() pic->arena_idx = 0; pic->global_env = pic_new_empty_env(); + pic->sDEFINE = pic_intern_cstr(pic, "define"); + pic->sCONS = pic_intern_cstr(pic, "cons"); + pic->sADD = pic_intern_cstr(pic, "add"); return pic; } diff --git a/src/vm.c b/src/vm.c index 851f02f1..255f3efc 100644 --- a/src/vm.c +++ b/src/vm.c @@ -57,9 +57,9 @@ pic_gen(pic_state *pic, struct pic_irep *irep, pic_value obj, struct pic_env *en { pic_value sDEFINE, sCONS, sADD; - sDEFINE = pic_intern_cstr(pic, "define"); - sCONS = pic_intern_cstr(pic, "cons"); - sADD = pic_intern_cstr(pic, "add"); + sDEFINE = pic->sDEFINE; + sCONS = pic->sCONS; + sADD = pic->sADD; switch (pic_type(obj)) { case PIC_TT_SYMBOL: {