Mercurial > hg > xemacs-beta
changeset 5615:5f4f92a31875
Move the functionality of #'cl-macroexpand into Fmacroexpand, eval.c
src/ChangeLog addition:
2011-12-22 Aidan Kehoe <kehoea@parhasard.net>
* eval.c (Fmacroexpand): Rename Fmacroexpand_internal, add the
functionality that used to be in #'cl-macroexpand--it makes no
sense for us, and needlessly slows things down, to have two
separate functions.
* eval.c:
* eval.c (syms_of_eval):
Move byte-compile-macro-environment here, now it's used by
#'macroexpand.
lisp/ChangeLog addition:
2011-12-22 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp-runtime.el:
* bytecomp-runtime.el (byte-compile-macro-environment): Moved to
eval.c.
* cl.el:
* cl.el ('cl-macroexpand): New alias.
* cl.el ('macroexpand-internal): New alias.
* cl.el (cl-macroexpand): Move the functionality of this to
#'macroexpand (formerly #'macroexpand-internal) in eval.c; since
CL is always loaded in XEmacs, it brings nothing and slows things
down to have the two functions separate.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 22 Dec 2011 12:51:03 +0000 |
parents | 281bf2b87915 |
children | 79e9934779c1 |
files | lisp/ChangeLog lisp/bytecomp-runtime.el lisp/cl.el src/ChangeLog src/eval.c |
diffstat | 5 files changed, 83 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Wed Dec 21 16:54:30 2011 +0000 +++ b/lisp/ChangeLog Thu Dec 22 12:51:03 2011 +0000 @@ -1,3 +1,16 @@ +2011-12-22 Aidan Kehoe <kehoea@parhasard.net> + + * bytecomp-runtime.el: + * bytecomp-runtime.el (byte-compile-macro-environment): Moved to + eval.c. + * cl.el: + * cl.el ('cl-macroexpand): New alias. + * cl.el ('macroexpand-internal): New alias. + * cl.el (cl-macroexpand): Move the functionality of this to + #'macroexpand (formerly #'macroexpand-internal) in eval.c; since + CL is always loaded in XEmacs, it brings nothing and slows things + down to have the two functions separate. + 2011-12-21 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (cl-transform-function-property):
--- a/lisp/bytecomp-runtime.el Wed Dec 21 16:54:30 2011 +0000 +++ b/lisp/bytecomp-runtime.el Thu Dec 22 12:51:03 2011 +0000 @@ -634,9 +634,4 @@ (file-format emacs19))" nil) -(defvar byte-compile-macro-environment nil - "Alist of macros defined in the file being compiled. -Each element looks like (MACRONAME . DEFINITION). It is -\(MACRONAME . nil) when a macro is redefined as a function.") - ;;; bytecomp-runtime.el ends here
--- a/lisp/cl.el Wed Dec 21 16:54:30 2011 +0000 +++ b/lisp/cl.el Thu Dec 22 12:51:03 2011 +0000 @@ -213,35 +213,10 @@ ;;; Macros. -;; XEmacs: we renamed the internal function to macroexpand-internal -;; to avoid doc-file problems. -(defvar cl-old-macroexpand (prog1 (symbol-function 'macroexpand-internal) - (defalias 'macroexpand 'cl-macroexpand))) - -(defun cl-macroexpand (cl-macro &optional cl-env) - "Return result of expanding macros at top level of FORM. -If FORM is not a macro call, it is returned unchanged. -Otherwise, the macro is expanded and the expansion is considered -in place of FORM. When a non-macro-call results, it is returned. - -The second optional arg ENVIRONMENT specifies an environment of macro -definitions to shadow the loaded ones for use in file byte-compilation." - (let ((byte-compile-macro-environment - (if byte-compile-macro-environment - (append cl-env byte-compile-macro-environment) cl-env)) - eq-hash) - (while (progn (setq cl-macro - (macroexpand-internal cl-macro - byte-compile-macro-environment)) - (and (symbolp cl-macro) - (setq eq-hash (eq-hash cl-macro)) - (cdr (if (fixnump eq-hash) - (assq eq-hash byte-compile-macro-environment) - (assoc eq-hash byte-compile-macro-environment))))) - (setq cl-macro (cadr (assoc* eq-hash byte-compile-macro-environment)))) - cl-macro)) - -;;; Declarations. +;; XEmacs: incorporate the functionality of #'cl-macroexpand into +;; #'macroexpand, in eval.c. +(defalias 'cl-macroexpand 'macroexpand) +(defalias 'macroexpand-internal 'macroexpand) (defvar cl-compiling-file nil) (defun cl-compiling-file ()
--- a/src/ChangeLog Wed Dec 21 16:54:30 2011 +0000 +++ b/src/ChangeLog Thu Dec 22 12:51:03 2011 +0000 @@ -1,3 +1,14 @@ +2011-12-22 Aidan Kehoe <kehoea@parhasard.net> + + * eval.c (Fmacroexpand): Rename Fmacroexpand_internal, add the + functionality that used to be in #'cl-macroexpand--it makes no + sense for us, and needlessly slows things down, to have two + separate functions. + * eval.c: + * eval.c (syms_of_eval): + Move byte-compile-macro-environment here, now it's used by + #'macroexpand. + 2011-12-10 Aidan Kehoe <kehoea@parhasard.net> * lread.c (read1): Add the zero, *then* flush, when reading an
--- a/src/eval.c Wed Dec 21 16:54:30 2011 +0000 +++ b/src/eval.c Thu Dec 22 12:51:03 2011 +0000 @@ -230,7 +230,7 @@ Lisp_Object Qand_rest, Qand_optional; Lisp_Object Qdebug_on_error, Qstack_trace_on_error; Lisp_Object Qdebug_on_signal, Qstack_trace_on_signal; -Lisp_Object Qdebugger; +Lisp_Object Qdebugger, Qbyte_compile_macro_environment; Lisp_Object Qinhibit_quit; Lisp_Object Qfinalize_list; Lisp_Object Qrun_hooks; @@ -273,7 +273,7 @@ (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */ Lisp_Object Vautoload_queue; -Lisp_Object Vmacro_declaration_function; +Lisp_Object Vmacro_declaration_function, Vbyte_compile_macro_environment; /* Current number of specbindings allocated in specpdl. */ int specpdl_size; @@ -1549,7 +1549,7 @@ /* XEmacs: user-variable-p is in symbols.c, since it needs to mess around with the symbol variable aliases. */ -DEFUN ("macroexpand-internal", Fmacroexpand_internal, 1, 2, 0, /* +DEFUN ("macroexpand", Fmacroexpand, 1, 2, 0, /* Return result of expanding macros at top level of FORM. If FORM is not a macro call, it is returned unchanged. Otherwise, the macro is expanded and the expansion is considered @@ -1563,11 +1563,51 @@ /* This function can GC */ /* With cleanups from Hallvard Furuseth. */ REGISTER Lisp_Object expander, sym, def, tem; + int speccount = specpdl_depth (); + + if (!NILP (environment)) + { + if (NILP (Vbyte_compile_macro_environment)) + { + specbind (Qbyte_compile_macro_environment, environment); + } + else + { + specbind (Qbyte_compile_macro_environment, + nconc2 (Fcopy_list (environment), + Vbyte_compile_macro_environment)); + environment = Vbyte_compile_macro_environment; + } + } while (1) { /* Come back here each time we expand a macro call, in case it expands into another macro call. */ + if (SYMBOLP (form)) + { + Lisp_Object hashed = make_integer ((EMACS_INT) (LISP_HASH (form))); + Lisp_Object assocked; + + if (BIGNUMP (hashed)) + { + struct gcpro gcpro1; + GCPRO1 (hashed); + assocked = Fassoc (hashed, environment); + UNGCPRO; + } + else + { + assocked = Fassq (hashed, environment); + } + + if (CONSP (assocked) && !NILP (XCDR (assocked))) + { + form = Fcar (XCDR (assocked)); + continue; + } + } + if (!CONSP (form)) break; /* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */ @@ -1624,6 +1664,9 @@ } form = apply1 (expander, XCDR (form)); } + + unbind_to (speccount); + return form; } @@ -7334,6 +7377,7 @@ DEFSYMBOL (Qinhibit_quit); DEFSYMBOL (Qautoload); + DEFSYMBOL (Qbyte_compile_macro_environment); DEFSYMBOL (Qdebug_on_error); DEFSYMBOL (Qstack_trace_on_error); DEFSYMBOL (Qdebug_on_signal); @@ -7379,7 +7423,7 @@ DEFSUBR (Flet); DEFSUBR (FletX); DEFSUBR (Fwhile); - DEFSUBR (Fmacroexpand_internal); + DEFSUBR (Fmacroexpand); DEFSUBR (Fcatch); DEFSUBR (Fthrow); DEFSUBR (Funwind_protect); @@ -7611,6 +7655,13 @@ */); Vmacro_declaration_function = Qnil; + DEFVAR_LISP ("byte-compile-macro-environment", &Vbyte_compile_macro_environment /* +Alist of macros defined in the file being compiled. +Each element looks like (MACRONAME . DEFINITION). It is +\(MACRONAME . nil) when a macro is redefined as a function. +*/); + Vbyte_compile_macro_environment = Qnil; + staticpro (&Vcatch_everything_tag); Vcatch_everything_tag = make_opaque (OPAQUE_CLEAR, 0);