summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-10 20:34:32 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-10 20:34:32 -0800
commit8220c2ea55a59bee7bfdef3b5c9b180005ef95ee (patch)
tree266f15f86387d19459942d7a001f9b6c689c98f9 /eval.c
parent74b1c122d257d06199c583851672909eea181289 (diff)
downloadtxr-8220c2ea55a59bee7bfdef3b5c9b180005ef95ee.tar.gz
txr-8220c2ea55a59bee7bfdef3b5c9b180005ef95ee.tar.bz2
txr-8220c2ea55a59bee7bfdef3b5c9b180005ef95ee.zip
Change representation of top-level macro bindings.
* eval.c (expand_macro): The expander argument is now a macro binding, which is a cons cell for built-in macros written in C also, not only for Lisp-defined macros. (symbol_function): Dereference macro binding. (reg_mac): Construct cons cell binding for built-in macro instead of sticking it into the table directly.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index 31ce0733..7ee210a5 100644
--- a/eval.c
+++ b/eval.c
@@ -1564,8 +1564,10 @@ static val op_defmacro(val form, val env)
return name;
}
-static val expand_macro(val form, val expander, val menv)
+static val expand_macro(val form, val mac_binding, val menv)
{
+ val expander = cdr(mac_binding);
+
if (cobjp(expander)) {
mefun_t fp = coerce(mefun_t, cptr_get(expander));
val expanded = fp(form, menv);
@@ -1574,9 +1576,9 @@ static val expand_macro(val form, val expander, val menv)
debug_enter;
val name = car(form);
val arglist = rest(form);
- val env = car(cdr(expander));
- val params = car(cdr(cdr(expander)));
- val body = cdr(cdr(cdr(expander)));
+ val env = car(expander);
+ val params = cadr(expander);
+ val body = cddr(expander);
val saved_de = set_dyn_env(make_env(nil, nil, dyn_env));
val exp_env = bind_macro_params(env, menv, params, arglist, nil, form);
val result;
@@ -3692,7 +3694,7 @@ static val symbol_function(val sym)
{
uses_or2;
return or2(or2(cdr(lookup_fun(nil, sym)),
- lookup_mac(nil, sym)),
+ cdr(lookup_mac(nil, sym))),
gethash(op_table, sym));
}
@@ -4109,7 +4111,7 @@ void reg_fun(val sym, val fun)
static void reg_mac(val sym, mefun_t fun)
{
assert (sym != 0);
- sethash(top_mb, sym, cptr(coerce(mem_t *, fun)));
+ sethash(top_mb, sym, cons(sym, cptr(coerce(mem_t *, fun))));
sethash(builtin, sym, defmacro_s);
}