summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-04-13 19:52:40 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-04-13 19:52:40 -0700
commitd32108aad0575f904286c37146906fba4409c4de (patch)
treecfd5cb8b08d337cfa19c0cee055ccdcdd5e4de09 /eval.c
parent8ee1fbd550bebd87ee9c3998e33a2140f34c2f4e (diff)
downloadtxr-d32108aad0575f904286c37146906fba4409c4de.tar.gz
txr-d32108aad0575f904286c37146906fba4409c4de.tar.bz2
txr-d32108aad0575f904286c37146906fba4409c4de.zip
More thorough job of tracking expansion origins.
This promotes better diagnostics. Simple test case: [(ret @5) 1]. * eval.c (do_expand): Manual tail recursion via backwards goto is removed; the function recurses now, and it recurses through the expand wrapper rather than by calling itself. That is needed in order to properly install the origin tracking for each expansion. (expand): Record origin for each expansion that already doesn't have one.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/eval.c b/eval.c
index d4ec01a9..a40f41b7 100644
--- a/eval.c
+++ b/eval.c
@@ -3317,7 +3317,6 @@ static val do_expand(val form, val menv)
menv = default_bool_arg(menv);
-tail:
if (nilp(form)) {
return nil;
} else if (bindable(form)) {
@@ -3327,8 +3326,7 @@ tail:
val symac = cdr(symac_bind);
if (symac == form)
return form;
- form = rlcp_tree(symac, form);
- goto tail;
+ return expand(rlcp_tree(symac, form), menv);
}
return form;
} else if (atom(form)) {
@@ -3552,8 +3550,7 @@ tail:
val mac_expand = expand_macro(form, macro, menv);
if (mac_expand == form)
return form;
- form = rlcp_tree(rlcp_tree(mac_expand, form), macro);
- goto tail;
+ return expand(rlcp_tree(rlcp_tree(mac_expand, form), macro), menv);
} else if (sym == progn_s) {
val args = rest(form);
@@ -3568,8 +3565,7 @@ tail:
return car(args_ex);
}
- form = first(args);
- goto tail;
+ return expand(first(args), menv);
} else if (sym == sys_lisp1_value_s) {
return expand_lisp1_value(form, menv);
} else {
@@ -3603,6 +3599,9 @@ val expand(val form, val menv)
ret = do_expand(form, menv);
last_form_expanded = lfe_save;
+ if (!lookup_origin(ret))
+ set_origin(ret, form);
+
return ret;
}