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.
This commit is contained in:
Alex Shinn 2010-07-20 08:21:43 +09:00
parent 66ae7b1c03
commit 54005c4d66
2 changed files with 7 additions and 0 deletions

4
eval.c
View file

@ -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);

3
sexp.c
View file

@ -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)) {