summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-04-20 16:46:51 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-04-20 16:46:51 -0700
commitab1059ae34e48d37d0c5702c3bd5e3bf2afb1a20 (patch)
treec61c189345b70a7bfe6bda78c271b772762c4a43
parent7140d05317586521cc4ba124714a7231e43f332a (diff)
downloadtxr-ab1059ae34e48d37d0c5702c3bd5e3bf2afb1a20.tar.gz
txr-ab1059ae34e48d37d0c5702c3bd5e3bf2afb1a20.tar.bz2
txr-ab1059ae34e48d37d0c5702c3bd5e3bf2afb1a20.zip
defun: record source loc info.
The interpreted defun should tag the function form that is obtainable with func-get-form with source location info. * eval.c (op_defun): In all cases, propagate source loc info from the form to the function form that is bound to the function name. (op_defmacro): Propagate the source location info in the same manner: not from the body (which could be empty) but from the form.
-rw-r--r--eval.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/eval.c b/eval.c
index 518730fd..bf575c9c 100644
--- a/eval.c
+++ b/eval.c
@@ -1990,14 +1990,14 @@ static val op_defun(val form, val env)
if (!consp(name)) {
val block = cons(block_s, cons(name, body));
- val fun = cons(name, cons(params, cons(block, nil)));
+ val fun = rlcp(cons(name, cons(params, cons(block, nil))), form);
return rt_defun(name, func_interp(env, fun));
} else if (car(name) == meth_s) {
val binding = lookup_fun(nil, intern(lit("define-method"), system_package));
val type_sym = second(name);
val meth_name = third(name);
val block = cons(block_s, cons(meth_name, body));
- val fun = cons(meth_name, cons(params, cons(block, nil)));
+ val fun = rlcp(cons(meth_name, cons(params, cons(block, nil))), form);
bug_unless (binding);
@@ -2005,7 +2005,7 @@ static val op_defun(val form, val env)
} else if (car(name) == macro_s) {
val sym = cadr(name);
val block = cons(block_s, cons(sym, body));
- val fun = cons(name, cons(params, cons(block, nil)));
+ val fun = rlcp(cons(name, cons(params, cons(block, nil))), form);
if (!bindable(sym))
eval_error(form, lit("defun: ~s isn't a bindable symbol in ~s"),
@@ -2043,7 +2043,7 @@ static val op_defmacro(val form, val env)
val name = first(args);
val params = second(args);
val body = rest(rest(args));
- val block = rlcp(cons(block_s, cons(name, body)), body);
+ val block = rlcp(cons(block_s, cons(name, body)), form);
if (gethash(op_table, name))
eval_error(form, lit("defmacro: ~s is a special operator"), name, nao);