commit 3236c00af124e4d040f87f8264bb46adb30faa20
parent 67be5f15acf3f21da992fbbb3d35cab597594003
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Fri, 29 Apr 2011 17:17:26 -0300
Added source info to error & root continuations.
Diffstat:
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/src/kcontinuation.c b/src/kcontinuation.c
@@ -45,6 +45,8 @@ TValue kmake_continuation(klisp_State *K, TValue parent, klisp_Cfunc fn,
 
     TValue res = gc2cont(new_cont);
     /* Add the current source info as source info (may be changed later) */
+    /* TODO: find all the places where this should be changed (like $and?, 
+       $sequence, and change it */
     kset_source_info(K, res, kget_csi(K));
     return res;
 }
diff --git a/src/krepl.c b/src/krepl.c
@@ -22,6 +22,8 @@
 /* for names */
 #include "ktable.h"
 
+/* TODO add names & source info to the repl continuations */
+
 /* the exit continuation, it exits the loop */
 void exit_fn(klisp_State *K, TValue *xparams, TValue obj)
 {
@@ -208,10 +210,35 @@ void kinit_repl(klisp_State *K)
     symbol = ksymbol_new(K, "root-continuation");
     /* GC: symbol should already be in root */
     kadd_binding(K, K->ground_env, symbol, root_cont);
+
+    /* TODO: find a cleaner way of doing this..., maybe disable gc */
+    /* Add source info to the cont */
+    TValue str = kstring_new_b_imm(K, __FILE__);
+    krooted_tvs_push(K, str);
+    TValue tail = kcons(K, i2tv(__LINE__), i2tv(0));
+    krooted_tvs_push(K, tail);
+    TValue si = kcons(K, str, tail);
+    krooted_tvs_push(K, si);
+    kset_source_info(K, root_cont, si);
+    krooted_tvs_pop(K);
+    krooted_tvs_pop(K);
+    krooted_tvs_pop(K);
+
     symbol = ksymbol_new(K, "error-continuation"); 
     /* GC: symbol should already be in root */
     kadd_binding(K, K->ground_env, symbol, error_cont);
 
+    str = kstring_new_b_imm(K, __FILE__);
+    krooted_tvs_push(K, str);
+    tail = kcons(K, i2tv(__LINE__), i2tv(0));
+    krooted_tvs_push(K, tail);
+    si = kcons(K, str, tail);
+    krooted_tvs_push(K, si);
+    kset_source_info(K, error_cont, si);
+    krooted_tvs_pop(K);
+    krooted_tvs_pop(K);
+    krooted_tvs_pop(K);
+
     /* and save them in the structure */
     K->root_cont = root_cont;
     K->error_cont = error_cont;