]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/bytecomp.el
* lisp/emacs-lisp/cl-generic.el: Add support for cl-next-method-p.
[gnu-emacs] / lisp / emacs-lisp / bytecomp.el
index 7fd72dd770593c9a72224edca6ac7623534fa480..1acd4fe76b28d98b1292195b17a60d7ae333992c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; bytecomp.el --- compilation of Lisp code into byte code -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1987, 1992, 1994, 1998, 2000-2014 Free Software
+;; Copyright (C) 1985-1987, 1992, 1994, 1998, 2000-2015 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Jamie Zawinski <jwz@lucid.com>
@@ -417,7 +417,7 @@ specify different fields to sort on."
 This list lives partly on the stack.")
 (defvar byte-compile-lexical-variables nil
   "List of variables that have been treated as lexical.
-Filled in `cconv-analyse-form' but initialized and consulted here.")
+Filled in `cconv-analyze-form' but initialized and consulted here.")
 (defvar byte-compile-const-variables nil
   "List of variables declared as constants during compilation of this file.")
 (defvar byte-compile-free-references)
@@ -448,26 +448,28 @@ Return the compile-time value of FORM."
     ;;                        (apply 'byte-compiler-options-handler forms)))
     (declare-function . byte-compile-macroexpand-declare-function)
     (eval-when-compile . ,(lambda (&rest body)
-                                  (let ((result nil))
-                                    (byte-compile-recurse-toplevel
-                                     (cons 'progn body)
-                                     (lambda (form)
-                                       (setf result
-                                             (byte-compile-eval
-                                              (byte-compile-top-level
-                                               (byte-compile-preprocess form))))))
-                                    (list 'quote result))))
+                            (let ((result nil))
+                              (byte-compile-recurse-toplevel
+                               (cons 'progn body)
+                               (lambda (form)
+                                 (setf result
+                                       (byte-compile-eval
+                                        (byte-compile-top-level
+                                         (byte-compile-preprocess form))))))
+                              (list 'quote result))))
     (eval-and-compile . ,(lambda (&rest body)
-                                 (byte-compile-recurse-toplevel
-                                  (cons 'progn body)
-                                  (lambda (form)
-                                    ;; Don't compile here, since we don't know
-                                    ;; whether to compile as byte-compile-form
-                                    ;; or byte-compile-file-form.
-                                    (let ((expanded
-                                           (byte-compile-preprocess form)))
-                                      (eval expanded lexical-binding)
-                                      expanded))))))
+                           (byte-compile-recurse-toplevel
+                            (cons 'progn body)
+                            (lambda (form)
+                              ;; Don't compile here, since we don't know
+                              ;; whether to compile as byte-compile-form
+                              ;; or byte-compile-file-form.
+                              (let ((expanded
+                                     (macroexpand-all
+                                      form
+                                      macroexpand-all-environment)))
+                                (eval expanded lexical-binding)
+                                expanded))))))
   "The default macro-environment passed to macroexpand by the compiler.
 Placing a macro here will cause a macro to have different semantics when
 expanded by the compiler as when expanded by the interpreter.")
@@ -1165,10 +1167,13 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
        (byte-compile-warn "%s" msg)))))
 
 (defun byte-compile-report-error (error-info)
-  "Report Lisp error in compilation.  ERROR-INFO is the error data."
+  "Report Lisp error in compilation.
+ERROR-INFO is the error data, in the form of either (ERROR-SYMBOL . DATA)
+or STRING."
   (setq byte-compiler-error-flag t)
   (byte-compile-log-warning
-   (error-message-string error-info)
+   (if (stringp error-info) error-info
+     (error-message-string error-info))
    nil :error))
 \f
 ;;; sanity-checking arglists
@@ -1853,7 +1858,7 @@ The value is non-nil if there were no errors, nil if errors."
                ;; recompiled).  Previously this was accomplished by
                ;; deleting target-file before writing it.
                (rename-file tempfile target-file t)
-               (message "Wrote %s" target-file))
+               (or noninteractive (message "Wrote %s" target-file)))
            ;; This is just to give a better error message than write-region
            (signal 'file-error
                    (list "Opening output file"
@@ -2119,11 +2124,6 @@ list that represents a doc string reference.
                         (eq (aref (nth (nth 1 info) form) 0) ?*))
                    (setq position (- position)))))
 
-        (if preface
-            (progn
-              (insert preface)
-              (prin1 name byte-compile--outbuffer)))
-        (insert (car info))
         (let ((print-continuous-numbering t)
               print-number-table
               (index 0)
@@ -2136,6 +2136,15 @@ list that represents a doc string reference.
               (print-gensym t)
               (print-circle             ; Handle circular data structures.
                (not byte-compile-disable-print-circle)))
+          (if preface
+              (progn
+                ;; FIXME: We don't handle uninterned names correctly.
+                ;; E.g. if cl-define-compiler-macro uses uninterned name we get:
+                ;;    (defalias '#1=#:foo--cmacro #[514 ...])
+                ;;    (put 'foo 'compiler-macro '#:foo--cmacro)
+                (insert preface)
+                (prin1 name byte-compile--outbuffer)))
+          (insert (car info))
           (prin1 (car form) byte-compile--outbuffer)
           (while (setq form (cdr form))
             (setq index (1+ index))
@@ -3811,6 +3820,10 @@ that suppresses all warnings during execution of BODY."
         ;; If things not being bound at all is ok, so must them being
         ;; obsolete.  Note that we add to the existing lists since Tramp
         ;; (ab)uses this feature.
+         ;; FIXME: If `foo' is obsoleted by `bar', the code below
+         ;; correctly arranges to silence the warnings after testing
+         ;; existence of `foo', but the warning should also be
+         ;; silenced after testing the existence of `bar'.
         (let ((byte-compile-not-obsolete-vars
                (append byte-compile-not-obsolete-vars bound-list))
               (byte-compile-not-obsolete-funcs