diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-05-15 06:26:55 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-05-15 06:26:55 -0700 |
commit | 35c8f215451961d7551187261cdf6cbf2c6ee7d3 (patch) | |
tree | 8db0ae888ba577eaa4eb9eeb38e837de1e39e8d5 /eval.c | |
parent | 843300f468d8950ebffdfa19a91353c640105080 (diff) | |
download | txr-35c8f215451961d7551187261cdf6cbf2c6ee7d3.tar.gz txr-35c8f215451961d7551187261cdf6cbf2c6ee7d3.tar.bz2 txr-35c8f215451961d7551187261cdf6cbf2c6ee7d3.zip |
vm: bugfix: global lexicals looked up dynamically.
The getlx and setlx VM instructions are using dynamic lookup
for uncached bindings, due to using the same lookup_fun
search function. They should use lookup_global_fun.
That doesn't have an environment parameter though, so the
type is not right. However, the VM never uses the environment
parameter; it's always passing nil. We will get rid of the
environment parameter in the lookup_fn callback and introduce
a few wrappers.
* eval.c, eval.h (lookup_global_fun, lookup_dynamic_var,
lookup_dynamic_sym_lisp1): New functions.
* vm.c (vm_stab_slowpath, vm_get_binding): lookup_fn argument
loses environment parameter, and so we don't have to pass nil.
(vm_gcall, vm_gapply): Use pass lookup_global_fun to
to vm_stab.
(vm_getsym, vm_getbind, vm_setsym, vm_gettab, vm_settab):
lookup_fn argument loses environment parameter.
(vm_execute): lookup functions replaced with the appropriate
one-argument ones. GETLX and SETLX see a behavior change,
due to using lookup_global_var which doesn't search the
dynamic environment.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -530,6 +530,11 @@ val lookup_global_var(val sym) if2(autoload_try_var(sym), gethash(top_vb, sym))); } +val lookup_global_fun(val sym) +{ + return lookup_fun(nil, sym); +} + val lookup_var(val env, val sym) { if (env) { @@ -593,6 +598,16 @@ loc lookup_var_l(val env, val sym) uw_throwf(error_s, lit("variable ~s unexpectedly unbound"), sym, nao); } +val lookup_dynamic_var(val sym) +{ + return lookup_var(nil, sym); +} + +val lookup_dynamic_sym_lisp1(val sym) +{ + return lookup_sym_lisp1(nil, sym); +} + static val lookup_mac(val menv, val sym); val lookup_fun(val env, val sym) |