klisp

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

commit 87b0db6c9711724d0ca2941e483ff591fa7a5deb
parent bcd9a93ad84db454df531452eebbcf4fd800dcb0
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed, 20 Apr 2011 01:51:42 -0300

Bugfix: in do_vau, add_binding was called to set the environment parameter even when it was #ignore.

Diffstat:
Msrc/kenvironment.c | 8+++++++-
Msrc/kgcombiners.c | 3++-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/kenvironment.c b/src/kenvironment.c @@ -90,7 +90,8 @@ TValue kmake_environment(klisp_State *K, TValue parents) */ TValue kfind_local_binding(klisp_State *K, TValue bindings, TValue sym) { - (void) K; + UNUSED(K); + while(!ttisnil(bindings)) { TValue first = kcar(bindings); TValue first_sym = kcar(first); @@ -111,6 +112,9 @@ TValue kfind_local_binding(klisp_State *K, TValue bindings, TValue sym) right now, but that could change */ void kadd_binding(klisp_State *K, TValue env, TValue sym, TValue val) { + klisp_assert(ttisenvironment(env)); + klisp_assert(ttissymbol(sym)); + TValue bindings = kenv_bindings(K, env); if (ttistable(bindings)) { TValue *cell = klispH_setsym(K, tv2table(bindings), tv2sym(sym)); @@ -179,6 +183,8 @@ inline bool try_get_binding(klisp_State *K, TValue env, TValue sym, TValue kget_binding(klisp_State *K, TValue env, TValue sym) { + klisp_assert(ttisenvironment(env)); + klisp_assert(ttissymbol(sym)); TValue value; if (try_get_binding(K, env, sym, &value)) { return value; diff --git a/src/kgcombiners.c b/src/kgcombiners.c @@ -81,7 +81,8 @@ void do_vau(klisp_State *K, TValue *xparams, TValue obj, TValue denv) /* TODO use name from operative */ match(K, "[user-operative]", env, ptree, obj); - kadd_binding(K, env, penv, denv); + if (!ttisignore(penv)) + kadd_binding(K, env, penv, denv); /* keep env in stack in case a cont has to be constructed */