commit a3a8cb1b47042ff83890b8c2b50cbfef5c6952e6
parent efc978422a041f203fe00c9252cfee1de1215416
Author: Andres Navarro <canavarro82@gmail.com>
Date: Fri, 29 Apr 2011 20:14:44 -0300
Added better source code info tracking to do_seq, do_cond and do_Sandp_Sorp. ($sequence, $vau, $lambda, $cond, $load, $import, $and?, $or?, $let, ...).
Diffstat:
6 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/src/kgbooleans.c b/src/kgbooleans.c
@@ -115,12 +115,12 @@ void do_Sandp_Sorp(klisp_State *K, TValue *xparams, TValue obj)
kapply_cc(K, obj);
} else {
TValue first = kcar(ls);
- ls = kcdr(ls);
+ TValue tail = kcdr(ls);
/* This is the important part of tail context + bool check */
- if (!ttisnil(ls) || !kis_bool_check_cont(kget_cc(K))) {
+ if (!ttisnil(tail) || !kis_bool_check_cont(kget_cc(K))) {
TValue new_cont =
kmake_continuation(K, kget_cc(K), do_Sandp_Sorp,
- 4, sname, term_bool, ls, denv);
+ 4, sname, term_bool, tail, denv);
/*
** Mark as a bool checking cont this is needed in the last operand
** to allow both tail recursive behaviour and boolean checking.
@@ -131,6 +131,11 @@ void do_Sandp_Sorp(klisp_State *K, TValue *xparams, TValue obj)
*/
kset_bool_check_cont(new_cont);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, ls));
+#endif
}
ktail_eval(K, first, denv);
}
@@ -152,7 +157,8 @@ void Sandp_Sorp(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
sname, term_bool, ls, denv);
krooted_tvs_pop(K);
/* there's no need to mark it as bool checking, no evaluation
- is done in the dynamic extent of this cont */
+ is done in the dynamic extent of this cont, no need for
+ source info either */
kset_cc(K, new_cont);
kapply_cc(K, knegp(term_bool)); /* pass dummy value to start */
}
diff --git a/src/kgcombiners.c b/src/kgcombiners.c
@@ -108,6 +108,11 @@ void do_vau(klisp_State *K, TValue *xparams, TValue obj, TValue denv)
TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, env);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, body));
+#endif
}
krooted_tvs_pop(K);
ktail_eval(K, kcar(body), env);
diff --git a/src/kgcontrol.c b/src/kgcontrol.c
@@ -86,6 +86,11 @@ void Ssequence(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue new_cont = kmake_continuation(K, kget_cc(K), do_seq, 2,
tail, denv);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, ls));
+#endif
krooted_tvs_pop(K);
}
ktail_eval(K, kcar(ls), denv);
@@ -109,6 +114,11 @@ void do_seq(klisp_State *K, TValue *xparams, TValue obj)
TValue new_cont = kmake_continuation(K, kget_cc(K), do_seq, 2, tail,
denv);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, ls));
+#endif
}
ktail_eval(K, first, denv);
}
@@ -213,6 +223,11 @@ void do_cond(klisp_State *K, TValue *xparams, TValue obj)
TValue new_cont = kmake_continuation(K, kget_cc(K), do_seq, 2,
tail, denv);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, this_body));
+#endif
}
ktail_eval(K, kcar(this_body), denv);
}
@@ -232,6 +247,11 @@ void do_cond(klisp_State *K, TValue *xparams, TValue obj)
*/
kset_bool_check_cont(new_cont);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, tests));
+#endif
ktail_eval(K, kcar(tests), denv);
}
}
@@ -258,7 +278,7 @@ void Scond(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
KNIL, tests, bodies, denv);
/* there is no need to mark this continuation with bool check
because it is just a dummy, no evaluation happens in its
- dynamic extent */
+ dynamic extent, no need for source info either */
kset_cc(K, new_cont);
obj = KFALSE;
}
diff --git a/src/kgenv_mut.c b/src/kgenv_mut.c
@@ -237,6 +237,11 @@ void SprovideB(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, new_env);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, body));
+#endif
}
krooted_tvs_pop(K);
krooted_tvs_pop(K);
diff --git a/src/kgenvironments.c b/src/kgenvironments.c
@@ -189,6 +189,11 @@ void do_let(klisp_State *K, TValue *xparams, TValue obj)
TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, env);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, body));
+#endif
}
ktail_eval(K, kcar(body), env);
}
diff --git a/src/kgports.c b/src/kgports.c
@@ -447,6 +447,11 @@ void load(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, denv);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, ls));
+#endif
krooted_tvs_pop(K); /* ls */
}
krooted_tvs_pop(K); /* port */
@@ -499,6 +504,11 @@ void get_module(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, env);
kset_cc(K, new_cont);
+#if KTRACK_SI
+ /* put the source info of the list including the element
+ that we are about to evaluate */
+ kset_source_info(K, new_cont, ktry_get_si(K, ls));
+#endif
krooted_tvs_pop(K);
}
krooted_tvs_pop(K); /* port */