commit 7fefb8001f8a6dc8b459b7eeea37246876cad4cf
parent d968518a33393a2b0bf8230757b2fa7f7a821bff
Author: Andres Navarro <canavarro82@gmail.com>
Date: Thu, 21 Apr 2011 20:09:38 -0300
Added source code tracking to applicatives (created with either wrap or $lambda) & applicatives (created with $vau).
Diffstat:
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/src/kgcombiners.c b/src/kgcombiners.c
@@ -55,6 +55,14 @@ void Svau(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue new_op = kmake_operative(K, do_vau, 4, vptree, vpenv, vbody, denv);
+ #if KTRACK_SI
+ /* save as source code info the info from the expression whose evaluation
+ got us here */
+ krooted_tvs_push(K, new_op);
+ kset_source_info(K, new_op, kget_csi(K));
+ krooted_tvs_pop(K);
+ #endif
+
krooted_tvs_pop(K);
krooted_tvs_pop(K);
kapply_cc(K, new_op);
@@ -106,10 +114,18 @@ void do_vau(klisp_State *K, TValue *xparams, TValue obj, TValue denv)
/* 4.10.4 wrap */
void wrap(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
{
- (void) denv;
- (void) xparams;
+ UNUSED(denv);
+ UNUSED(xparams);
+
bind_1tp(K, "wrap", ptree, "combiner", ttiscombiner, comb);
TValue new_app = kwrap(K, comb);
+ #if KTRACK_SI
+ /* save as source code info the info from the expression whose evaluation
+ got us here */
+ krooted_tvs_push(K, new_app);
+ kset_source_info(K, new_app, kget_csi(K));
+ krooted_tvs_pop(K);
+ #endif
kapply_cc(K, new_app);
}
@@ -143,6 +159,14 @@ void Slambda(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue new_app = kmake_applicative(K, do_vau, 4, vptree, KIGNORE, vbody,
denv);
+ #if KTRACK_SI
+ /* save as source code info the info from the expression whose evaluation
+ got us here */
+ krooted_tvs_push(K, new_app);
+ kset_source_info(K, new_app, kget_csi(K));
+ krooted_tvs_pop(K);
+ #endif
+
krooted_tvs_pop(K);
krooted_tvs_pop(K);
kapply_cc(K, new_app);
@@ -152,8 +176,9 @@ void Slambda(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
void apply(klisp_State *K, TValue *xparams, TValue ptree,
TValue denv)
{
- (void) denv;
- (void) xparams;
+ UNUSED(denv);
+ UNUSED(xparams);
+
bind_al2tp(K, "apply", ptree,
"applicative", ttisapplicative, app,
"any", anytype, obj,
@@ -165,7 +190,7 @@ void apply(klisp_State *K, TValue *xparams, TValue ptree,
krooted_tvs_push(K, env);
TValue expr = kcons(K, kunwrap(app), obj);
krooted_tvs_pop(K);
-
+ /* TODO track source code info */
ktail_eval(K, expr, env);
}
diff --git a/src/kgenvironments.c b/src/kgenvironments.c
@@ -35,10 +35,12 @@
void eval(klisp_State *K, TValue *xparams, TValue ptree,
TValue denv)
{
- (void) denv;
+ UNUSED(denv);
+ UNUSED(xparams);
+
bind_2tp(K, "eval", ptree, "any", anytype, expr,
"environment", ttisenvironment, env);
-
+ /* TODO: track source code info */
ktail_eval(K, expr, env);
}
@@ -46,8 +48,9 @@ void eval(klisp_State *K, TValue *xparams, TValue ptree,
void make_environment(klisp_State *K, TValue *xparams, TValue ptree,
TValue denv)
{
- (void) denv;
- (void) xparams;
+ UNUSED(denv);
+ UNUSED(xparams);
+
TValue new_env;
if (ttisnil(ptree)) {
new_env = kmake_empty_environment(K);