1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 14:30:50 -08:00

* lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment):

Byte-compile *before* eval in eval-and-compile.
(byte-compile-log-warning): Remove redundant inhibit-read-only.
(byte-compile-file-form-autoload): Don't hide actual definition.
(byte-compile-maybe-guarded): Accept `functionp' as well.
This commit is contained in:
Stefan Monnier 2012-11-08 09:58:15 -05:00
parent a9a5c7f690
commit e703069f9c

View file

@ -419,8 +419,8 @@ This list lives partly on the stack.")
(defconst byte-compile-initial-macro-environment (defconst byte-compile-initial-macro-environment
'( '(
;; (byte-compiler-options . (lambda (&rest forms) ;; (byte-compiler-options . (lambda (&rest forms)
;; (apply 'byte-compiler-options-handler forms))) ;; (apply 'byte-compiler-options-handler forms)))
(declare-function . byte-compile-macroexpand-declare-function) (declare-function . byte-compile-macroexpand-declare-function)
(eval-when-compile . (lambda (&rest body) (eval-when-compile . (lambda (&rest body)
(list (list
@ -429,8 +429,19 @@ This list lives partly on the stack.")
(byte-compile-top-level (byte-compile-top-level
(byte-compile-preprocess (cons 'progn body))))))) (byte-compile-preprocess (cons 'progn body)))))))
(eval-and-compile . (lambda (&rest body) (eval-and-compile . (lambda (&rest body)
(byte-compile-eval-before-compile (cons 'progn body)) ;; Byte compile before running it. Do it piece by
(cons 'progn body)))) ;; piece, in case further expressions need earlier
;; ones to be evaluated already, as is the case in
;; eieio.el.
`(progn
,@(mapcar (lambda (exp)
(let ((cexp
(byte-compile-top-level
(byte-compile-preprocess
exp))))
(eval cexp)
cexp))
body)))))
"The default macro-environment passed to macroexpand by the compiler. "The default macro-environment passed to macroexpand by the compiler.
Placing a macro here will cause a macro to have different semantics when Placing a macro here will cause a macro to have different semantics when
expanded by the compiler as when expanded by the interpreter.") expanded by the compiler as when expanded by the interpreter.")
@ -731,9 +742,11 @@ otherwise pop it")
;; Also, this lets us notice references to free variables. ;; Also, this lets us notice references to free variables.
(defmacro byte-compile-push-bytecodes (&rest args) (defmacro byte-compile-push-bytecodes (&rest args)
"Push BYTE... onto BYTES, and increment PC by the number of bytes pushed. "Push bytes onto BVAR, and increment CVAR by the number of bytes pushed.
ARGS is of the form (BYTE... BYTES PC), where BYTES and PC are variable names. BVAR and CVAR are variables which are updated after evaluating
BYTES and PC are updated after evaluating all the arguments." all the arguments.
\(fn BYTE1 BYTE2 ... BYTEn BVAR CVAR)"
(let ((byte-exprs (butlast args 2)) (let ((byte-exprs (butlast args 2))
(bytes-var (car (last args 2))) (bytes-var (car (last args 2)))
(pc-var (car (last args)))) (pc-var (car (last args))))
@ -1097,8 +1110,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
(defun byte-compile-log-warning (string &optional fill level) (defun byte-compile-log-warning (string &optional fill level)
(let ((warning-prefix-function 'byte-compile-warning-prefix) (let ((warning-prefix-function 'byte-compile-warning-prefix)
(warning-type-format "") (warning-type-format "")
(warning-fill-prefix (if fill " ")) (warning-fill-prefix (if fill " ")))
(inhibit-read-only t))
(display-warning 'bytecomp string level byte-compile-log-buffer))) (display-warning 'bytecomp string level byte-compile-log-buffer)))
(defun byte-compile-warn (format &rest args) (defun byte-compile-warn (format &rest args)
@ -2189,7 +2201,10 @@ list that represents a doc string reference.
(when (and (consp (nth 1 form)) (when (and (consp (nth 1 form))
(eq (car (nth 1 form)) 'quote) (eq (car (nth 1 form)) 'quote)
(consp (cdr (nth 1 form))) (consp (cdr (nth 1 form)))
(symbolp (nth 1 (nth 1 form)))) (symbolp (nth 1 (nth 1 form)))
;; Don't add it if it's already defined. Otherwise, it might
;; hide the actual definition.
(not (fboundp (nth 1 (nth 1 form)))))
(push (cons (nth 1 (nth 1 form)) (push (cons (nth 1 (nth 1 form))
(cons 'autoload (cdr (cdr form)))) (cons 'autoload (cdr (cdr form))))
byte-compile-function-environment) byte-compile-function-environment)
@ -3689,10 +3704,10 @@ If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs),
that suppresses all warnings during execution of BODY." that suppresses all warnings during execution of BODY."
(declare (indent 1) (debug t)) (declare (indent 1) (debug t))
`(let* ((fbound-list (byte-compile-find-bound-condition `(let* ((fbound-list (byte-compile-find-bound-condition
,condition (list 'fboundp) ,condition '(fboundp functionp)
byte-compile-unresolved-functions)) byte-compile-unresolved-functions))
(bound-list (byte-compile-find-bound-condition (bound-list (byte-compile-find-bound-condition
,condition (list 'boundp 'default-boundp))) ,condition '(boundp default-boundp)))
;; Maybe add to the bound list. ;; Maybe add to the bound list.
(byte-compile-bound-variables (byte-compile-bound-variables
(append bound-list byte-compile-bound-variables))) (append bound-list byte-compile-bound-variables)))