diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-12-17 06:16:02 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-12-17 15:53:05 -0800 |
commit | 169c03e5ba18ed980683f38ca9d8451987cc0610 (patch) | |
tree | 7023715728b56ab7a62fa3aec41d634ba588c646 /eval.c | |
parent | f8c5f7d4950a6fb660c533625ef5004f998432b1 (diff) | |
download | txr-169c03e5ba18ed980683f38ca9d8451987cc0610.tar.gz txr-169c03e5ba18ed980683f38ca9d8451987cc0610.tar.bz2 txr-169c03e5ba18ed980683f38ca9d8451987cc0610.zip |
Set macro ancestry info in place expansions.
* eval.c (set_origin): New static function.
(eval_init): Register set_origin as sys:set-macro-ancestor.
* share/txr/stdlib/place.tl (sys:pl-expand): Set macro
ancestry when expanding a place macro.
(sys:cp-origin): New function.
(call-update-expander, call-clobber-expander,
call-delete-expander): Use sys:cp-origin to walk through
expanded code and attach the place form as the macro
ancestor of all the getter, setter or deleter calls,
effectively to say that those calls are expansions of
the place, which is approximately the case.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -220,6 +220,12 @@ val lookup_origin(val form) return gethash(origin_hash, form); } +static val set_origin(val form, val origin) +{ + (void) sethash(origin_hash, form, origin); + return form; +} + void error_trace(val exsym, val exvals, val out_stream, val prefix) { val last = last_form_evaled; @@ -5071,6 +5077,7 @@ void eval_init(void) reg_fun(intern(lit("source-loc"), user_package), func_n1(source_loc)); reg_fun(intern(lit("source-loc-str"), user_package), func_n2o(source_loc_str, 1)); reg_fun(intern(lit("macro-ancestor"), user_package), func_n1(lookup_origin)); + reg_fun(intern(lit("set-macro-ancestor"), system_package), func_n2(set_origin)); reg_fun(intern(lit("rlcp"), user_package), func_n2(rlcp)); eval_error_s = intern(lit("eval-error"), user_package); |