diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-03-01 00:05:07 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-03-01 00:05:07 -0800 |
commit | 18efe8b595bc230f6482fafad586d873c12b50d0 (patch) | |
tree | eee3cfdaed3f5fb108d7b9da79a1c71b9582f7cf /eval.c | |
parent | 7807ce0cf494506e4fb596ba7d5c026f813a5349 (diff) | |
download | txr-18efe8b595bc230f6482fafad586d873c12b50d0.tar.gz txr-18efe8b595bc230f6482fafad586d873c12b50d0.tar.bz2 txr-18efe8b595bc230f6482fafad586d873c12b50d0.zip |
* 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.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 50 |
1 files changed, 25 insertions, 25 deletions
@@ -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); |