klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit bbcde7082c26480918d04fd5915fbe48df5434f3
parent f92b211ba3c24d8385a9f053a1d81c2042485515
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Sat, 16 Apr 2011 10:40:39 -0300

Added a new dummy pair, needed by map.

Diffstat:
Msrc/kgc.c | 3++-
Msrc/kpair.h | 14++++++++++++++
Msrc/kstate.c | 1+
Msrc/kstate.h | 3++-
4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/kgc.c b/src/kgc.c @@ -569,7 +569,7 @@ static void markroot (klisp_State *K) { /* Mark all objects in the auxiliary stack, (all valid indexes are below top), all the objects in - the two protected areas, and the two two dummy pairs */ + the two protected areas, and the three dummy pairs */ markvaluearray(K, K->sbuf, K->stop); markvaluearray(K, K->rooted_tvs_buf, K->rooted_tvs_top); /* the area protecting variables is an array of type TValue *[] */ @@ -580,6 +580,7 @@ static void markroot (klisp_State *K) { markvalue(K, K->dummy_pair1); markvalue(K, K->dummy_pair2); + markvalue(K, K->dummy_pair3); /* markmt(g); */ K->gcstate = GCSpropagate; } diff --git a/src/kpair.h b/src/kpair.h @@ -92,4 +92,18 @@ inline TValue kcutoff_dummy2(klisp_State *K) return res; } +inline TValue kget_dummy3(klisp_State *K) +{ + klisp_assert(ttispair(K->dummy_pair3) && ttisnil(kcdr(K->dummy_pair3))); + return K->dummy_pair3; +} + +inline TValue kcutoff_dummy3(klisp_State *K) +{ + klisp_assert(ttispair(K->dummy_pair3)); + TValue res = kcdr(K->dummy_pair3); + kset_cdr(K->dummy_pair3, KNIL); + return res; +} + #endif diff --git a/src/kstate.c b/src/kstate.c @@ -121,6 +121,7 @@ klisp_State *klisp_newstate (klisp_Alloc f, void *ud) { K->dummy_pair1 = kcons(K, KINERT, KNIL); K->dummy_pair2 = kcons(K, KINERT, KNIL); + K->dummy_pair3 = kcons(K, KINERT, KNIL); /* initialize strings */ /* Empty string */ diff --git a/src/kstate.h b/src/kstate.h @@ -138,12 +138,13 @@ struct klisp_State { int32_t rooted_vars_top; TValue *rooted_vars_buf[GC_PROTECT_SIZE]; - /* These two are useful for constructing lists by means of set-car & + /* These three are useful for constructing lists by means of set-car & set-cdr. The idea is that these dummy pairs start as the head of the list (protecting the entire chain from GC) and at the end of the construction, the list is cut off from the cdr of the dummy */ TValue dummy_pair1; TValue dummy_pair2; + TValue dummy_pair3; }; /* some size related macros */