diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-05-25 07:05:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-05-25 07:05:23 -0700 |
commit | 535999c69576b3e57e35f1936bac852c6aedc983 (patch) | |
tree | 61f0ecce088b10802583cd62e73f052b12b02ecd | |
parent | d036239788b1825bfa05588d7f9ee379cd95fc54 (diff) | |
download | txr-535999c69576b3e57e35f1936bac852c6aedc983.tar.gz txr-535999c69576b3e57e35f1936bac852c6aedc983.tar.bz2 txr-535999c69576b3e57e35f1936bac852c6aedc983.zip |
Fix mismanaged dyn_env variable.
* eval.c (bindings_helper): In the parallel binding case, only allocate
a new dynamic env when it is needed (because a special variable is
being bound), rather than unconditionally.
Consequently, only modify dyn_env when the dynamic environment actually
needs to be extended. Constructs that use bindings_helper are only
wrapped in the dynamic environment save/restore form
sys:with-saved-vars if they bind special variables.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | eval.c | 7 |
2 files changed, 16 insertions, 3 deletions
@@ -1,3 +1,15 @@ +2015-05-25 Kaz Kylheku <kaz@kylheku.com> + + Fix mismanaged dyn_env variable. + + * eval.c (bindings_helper): In the parallel binding case, only allocate + a new dynamic env when it is needed (because a special variable is + being bound), rather than unconditionally. + Consequently, only modify dyn_env when the dynamic environment actually + needs to be extended. Constructs that use bindings_helper are only + wrapped in the dynamic environment save/restore form + sys:with-saved-vars if they bind special variables. + 2015-05-22 Kaz Kylheku <kaz@kylheku.com> Ligher weight debug instrumentation. @@ -1135,7 +1135,7 @@ static val bindings_helper(val vars, val env, val sequential, val ctx_form) { val iter; - val de = if3(sequential, dyn_env, make_env(nil, nil, dyn_env)); + val de = if3(sequential, dyn_env, nil); val ne = if3(sequential, env, make_env(nil, nil, env)); list_collect_decl (new_bindings, ptail); @@ -1152,7 +1152,8 @@ static val bindings_helper(val vars, val env, val sequential, if (var == special_s) { val special = car(item); - val binding = env_vbind(de, special, value); + val binding = env_vbind(de = (de ? de : make_env(nil, nil, dyn_env)), + special, value); if (ret_new_bindings) ptail = list_collect (ptail, binding); } else if (bindable(var)) { @@ -1167,7 +1168,7 @@ static val bindings_helper(val vars, val env, val sequential, } } - if (de != dyn_env) + if (de && de != dyn_env) dyn_env = de; if (env_out) *env_out = ne; |