From 54005c4d668c9b5e18e1f6d48c5b8487cf075115 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Tue, 20 Jul 2010 08:21:43 +0900 Subject: [PATCH] adding source info to all pairs in a list and checking cdr's when analyzing this preserves source info for named lets without any need for source info copying in the macro itself. --- eval.c | 4 ++++ sexp.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/eval.c b/eval.c index 6e567770..3c108113 100644 --- a/eval.c +++ b/eval.c @@ -550,6 +550,10 @@ static sexp analyze_lambda (sexp ctx, sexp x) { /* build lambda and analyze body */ res = sexp_make_lambda(ctx, tmp=sexp_copy_list(ctx, sexp_cadr(x))); sexp_lambda_source(res) = sexp_pair_source(x); + if (! (sexp_lambda_source(res) && sexp_pairp(sexp_lambda_source(res)))) + sexp_lambda_source(res) = sexp_pair_source(sexp_cdr(x)); + if (! (sexp_lambda_source(res) && sexp_pairp(sexp_lambda_source(res)))) + sexp_lambda_source(res) = sexp_pair_source(sexp_cddr(x)); ctx2 = sexp_make_child_context(ctx, res); tmp = sexp_flatten_dot(ctx2, sexp_lambda_params(res)); sexp_context_env(ctx2) = sexp_extend_env(ctx2, sexp_context_env(ctx2), tmp, res); diff --git a/sexp.c b/sexp.c index 910e8523..d976a147 100644 --- a/sexp.c +++ b/sexp.c @@ -1549,6 +1549,9 @@ sexp sexp_read_raw (sexp ctx, sexp in) { break; } res = sexp_cons(ctx, tmp, res); + if (sexp_port_sourcep(in) && (line >= 0)) + sexp_pair_source(res) + = sexp_cons(ctx, sexp_port_name(in), sexp_make_fixnum(line)); tmp = sexp_read_raw(ctx, in); } if (! sexp_exceptionp(res)) {