From 8220c2ea55a59bee7bfdef3b5c9b180005ef95ee Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 10 Dec 2015 20:34:32 -0800 Subject: 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. --- eval.c | 14 ++++++++------ 1 file 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); } -- cgit v1.2.3