From 18efe8b595bc230f6482fafad586d873c12b50d0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 1 Mar 2014 00:05:07 -0800 Subject: * eval.c (lookup_sym_lisp1): Bugfix: wasn't following the dynamic environment at all, and still had vestiges of support for the the old cptr based global variables. --- ChangeLog | 6 ++++++ eval.c | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01ed91f3..073e9a24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-02-28 Kaz Kylheku + + * eval.c (lookup_sym_lisp1): Bugfix: wasn't following the dynamic + environment at all, and still had vestiges of support for the the old + cptr based global variables. + 2014-02-28 Kaz Kylheku * Makefile: Use target-specific assignment diff --git a/eval.c b/eval.c index 87398d64..c1b28671 100644 --- a/eval.c +++ b/eval.c @@ -154,6 +154,31 @@ val lookup_var(val env, val sym) return(gethash(top_vb, sym)); } +static val lookup_sym_lisp1(val env, val sym) +{ + uses_or2; + + if (env) { + type_check(env, ENV); + + for (; env; env = env->e.up_env) { + val binding = or2(assoc(sym, env->e.vbindings), + assoc(sym, env->e.fbindings)); + if (binding) + return binding; + } + } + + for (env = dyn_env; env; env = env->e.up_env) { + val binding = or2(assoc(sym, env->e.vbindings), + assoc(sym, env->e.fbindings)); + if (binding) + return binding; + } + + return or2(gethash(top_vb, sym), gethash(top_fb, sym)); +} + val *lookup_var_l(val env, val sym) { if (env) { @@ -226,31 +251,6 @@ static val lookup_symac(val menv, val sym) } } -static val lookup_sym_lisp1(val env, val sym) -{ - uses_or2; - - if (nilp(env)) { - val bind = gethash(top_vb, sym); - if (cobjp(bind)) { - struct c_var *cv = (struct c_var *) cptr_get(bind); - set(cv->bind->c.cdr, *cv->loc); - return cv->bind; - } - return or2(bind, gethash(top_fb, sym)); - } else { - type_check(env, ENV); - - { - val binding = or2(assoc(sym, env->e.vbindings), - assoc(sym, env->e.fbindings)); - if (binding) - return binding; - return lookup_sym_lisp1(env->e.up_env, sym); - } - } -} - static void mark_special(val sym) { sethash(special, sym, t); -- cgit v1.2.3