emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113744: * lisp/emacs-lisp/bytecomp.el: Check existe


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r113744: * lisp/emacs-lisp/bytecomp.el: Check existence of f in #'f.
Date: Wed, 07 Aug 2013 17:33:48 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113744
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2013-08-07 13:33:30 -0400
message:
  * lisp/emacs-lisp/bytecomp.el: Check existence of f in #'f.
  (byte-compile-callargs-warn): Use `push'.
  (byte-compile-arglist-warn): Ignore higher-order "calls".
  (byte-compile-file-form-autoload): Use `pcase'.
  (byte-compile-function-form): If quoting a symbol, check that it exists.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emacs-lisp/byte-run.el    byterun.el-20091113204419-o5vbwnq5f7feedwu-2586
  lisp/emacs-lisp/bytecomp.el    bytecomp.el-20091113204419-o5vbwnq5f7feedwu-492
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-08-07 16:37:04 +0000
+++ b/lisp/ChangeLog    2013-08-07 17:33:30 +0000
@@ -1,3 +1,11 @@
+2013-08-07  Stefan Monnier  <address@hidden>
+
+       * emacs-lisp/bytecomp.el: Check existence of f in #'f.
+       (byte-compile-callargs-warn): Use `push'.
+       (byte-compile-arglist-warn): Ignore higher-order "calls".
+       (byte-compile-file-form-autoload): Use `pcase'.
+       (byte-compile-function-form): If quoting a symbol, check that it exists.
+
 2013-08-07  Eli Zaretskii  <address@hidden>
 
        * progmodes/dos.el (dos-font-lock-keywords): Rename LINUX to UNIX

=== modified file 'lisp/emacs-lisp/byte-run.el'
--- a/lisp/emacs-lisp/byte-run.el       2013-03-13 02:19:31 +0000
+++ b/lisp/emacs-lisp/byte-run.el       2013-08-07 17:33:30 +0000
@@ -83,7 +83,6 @@
                    (list 'quote f) (list 'quote new-name) (list 'quote when))))
    (list 'compiler-macro
          #'(lambda (f args compiler-function)
-             ;; FIXME: Make it possible to just reuse `args'.
              `(eval-and-compile
                 (put ',f 'compiler-macro
                      ,(if (eq (car-safe compiler-function) 'lambda)

=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- a/lisp/emacs-lisp/bytecomp.el       2013-06-19 07:35:00 +0000
+++ b/lisp/emacs-lisp/bytecomp.el       2013-08-07 17:33:30 +0000
@@ -1273,7 +1273,7 @@
              (n (length (cdr form))))
          (if cons
              (or (memq n (cdr cons))
-                 (setcdr cons (cons n (cdr cons))))
+                 (push n (cdr cons)))
            (push (list (car form) n)
                  byte-compile-unresolved-functions))))))
 
@@ -1364,7 +1364,10 @@
       ;; This is the first definition.  See if previous calls are compatible.
       (let ((calls (assq name byte-compile-unresolved-functions))
            nums sig min max)
-       (when calls
+        (setq byte-compile-unresolved-functions
+              (delq calls byte-compile-unresolved-functions))
+        (setq calls (delq t calls))  ;Ignore higher-order uses of the function.
+       (when (cdr calls)
           (when (and (symbolp name)
                      (eq (function-get name 'byte-optimizer)
                          'byte-compile-inline-expand))
@@ -1382,10 +1385,7 @@
              name
              (byte-compile-arglist-signature-string sig)
              (if (equal sig '(1 . 1)) " arg" " args")
-             (byte-compile-arglist-signature-string (cons min max))))
-
-          (setq byte-compile-unresolved-functions
-                (delq calls byte-compile-unresolved-functions)))))))
+             (byte-compile-arglist-signature-string (cons min max)))))))))
 
 (defvar byte-compile-cl-functions nil
   "List of functions defined in CL.")
@@ -2214,37 +2214,33 @@
 (defun byte-compile-file-form-autoload (form)
   (and (let ((form form))
         (while (if (setq form (cdr form)) (macroexp-const-p (car form))))
-        (null form))                   ;Constants only
+        (null form))                        ;Constants only
        (memq (eval (nth 5 form)) '(t macro)) ;Macro
-       (eval form))                    ;Define the autoload.
+       (eval form))                          ;Define the autoload.
   ;; Avoid undefined function warnings for the autoload.
-  (when (and (consp (nth 1 form))
-          (eq (car (nth 1 form)) 'quote)
-          (consp (cdr (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.  However, do remove any entry from
-    ;; byte-compile-noruntime-functions, in case we have an autoload
-    ;; of foo-func following an (eval-when-compile (require 'foo)).
-    (unless (fboundp (nth 1 (nth 1 form)))
-      (push (cons (nth 1 (nth 1 form))
-                 (cons 'autoload (cdr (cdr form))))
-           byte-compile-function-environment))
-    ;; If an autoload occurs _before_ the first call to a function,
-    ;; byte-compile-callargs-warn does not add an entry to
-    ;; byte-compile-unresolved-functions.  Here we mimic the logic
-    ;; of byte-compile-callargs-warn so as not to warn if the
-    ;; autoload comes _after_ the function call.
-    ;; Alternatively, similar logic could go in
-    ;; byte-compile-warn-about-unresolved-functions.
-    (if (memq (nth 1 (nth 1 form)) byte-compile-noruntime-functions)
-       (setq byte-compile-noruntime-functions
-             (delq (nth 1 (nth 1 form)) byte-compile-noruntime-functions)
-             byte-compile-noruntime-functions)
-      (setq byte-compile-unresolved-functions
-           (delq (assq (nth 1 (nth 1 form))
-                       byte-compile-unresolved-functions)
-                 byte-compile-unresolved-functions))))
+  (pcase (nth 1 form)
+    (`',(and (pred symbolp) funsym)
+     ;; Don't add it if it's already defined.  Otherwise, it might
+     ;; hide the actual definition.  However, do remove any entry from
+     ;; byte-compile-noruntime-functions, in case we have an autoload
+     ;; of foo-func following an (eval-when-compile (require 'foo)).
+     (unless (fboundp funsym)
+       (push (cons funsym (cons 'autoload (cdr (cdr form))))
+             byte-compile-function-environment))
+     ;; If an autoload occurs _before_ the first call to a function,
+     ;; byte-compile-callargs-warn does not add an entry to
+     ;; byte-compile-unresolved-functions.  Here we mimic the logic
+     ;; of byte-compile-callargs-warn so as not to warn if the
+     ;; autoload comes _after_ the function call.
+     ;; Alternatively, similar logic could go in
+     ;; byte-compile-warn-about-unresolved-functions.
+     (if (memq funsym byte-compile-noruntime-functions)
+         (setq byte-compile-noruntime-functions
+               (delq funsym byte-compile-noruntime-functions)
+               byte-compile-noruntime-functions)
+       (setq byte-compile-unresolved-functions
+             (delq (assq funsym byte-compile-unresolved-functions)
+                   byte-compile-unresolved-functions)))))
   (if (stringp (nth 3 form))
       form
     ;; No doc string, so we can compile this as a normal form.
@@ -3574,10 +3570,32 @@
 ;; and (funcall (function foo)) will lose with autoloads.
 
 (defun byte-compile-function-form (form)
-  (byte-compile-constant (if (eq 'lambda (car-safe (nth 1 form)))
-                             (byte-compile-lambda (nth 1 form))
-                           (nth 1 form))))
-
+  (let ((f (nth 1 form)))
+    (when (and (symbolp f)
+               (byte-compile-warning-enabled-p 'callargs))
+      (when (get f 'byte-obsolete-info)
+        (byte-compile-warn-obsolete (car form)))
+
+      ;; Check to see if the function will be available at runtime
+      ;; and/or remember its arity if it's unknown.
+      (or (and (or (fboundp f)          ; Might be a subr or autoload.
+                   (byte-compile-fdefinition (car form) nil))
+               (not (memq f byte-compile-noruntime-functions)))
+          (eq f byte-compile-current-form) ; ## This doesn't work
+                                           ; with recursion.
+          ;; It's a currently-undefined function.
+          ;; Remember number of args in call.
+          (let ((cons (assq f byte-compile-unresolved-functions)))
+            (if cons
+                (or (memq t (cdr cons))
+                    (push t (cdr cons)))
+              (push (list f t)
+                    byte-compile-unresolved-functions)))))
+
+    (byte-compile-constant (if (eq 'lambda (car-safe f))
+                               (byte-compile-lambda f)
+                             f))))
+  
 (defun byte-compile-indent-to (form)
   (let ((len (length form)))
     (cond ((= len 2)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]