aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emacs-lisp/bytecomp.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r--lisp/emacs-lisp/bytecomp.el58
1 files changed, 31 insertions, 27 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 2116cc33b34..ee29039e05e 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1,7 +1,7 @@
1;;; bytecomp.el --- compilation of Lisp code into byte code 1;;; bytecomp.el --- compilation of Lisp code into byte code
2 2
3;; Copyright (C) 1985,86,87,92,94,1998,2000,01,02,03,2004 3;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1998, 2000, 2001, 2002,
4;; Free Software Foundation, Inc. 4;; 2003, 2004 Free Software Foundation, Inc.
5 5
6;; Author: Jamie Zawinski <jwz@lucid.com> 6;; Author: Jamie Zawinski <jwz@lucid.com>
7;; Hallvard Furuseth <hbf@ulrik.uio.no> 7;; Hallvard Furuseth <hbf@ulrik.uio.no>
@@ -447,7 +447,9 @@ Each element looks like (MACRONAME . DEFINITION). It is
447 "Alist of functions defined in the file being compiled. 447 "Alist of functions defined in the file being compiled.
448This is so we can inline them when necessary. 448This is so we can inline them when necessary.
449Each element looks like (FUNCTIONNAME . DEFINITION). It is 449Each element looks like (FUNCTIONNAME . DEFINITION). It is
450\(FUNCTIONNAME . nil) when a function is redefined as a macro.") 450\(FUNCTIONNAME . nil) when a function is redefined as a macro.
451It is \(FUNCTIONNAME . t) when all we know is that it was defined,
452and we don't know the definition.")
451 453
452(defvar byte-compile-unresolved-functions nil 454(defvar byte-compile-unresolved-functions nil
453 "Alist of undefined functions to which calls have been compiled. 455 "Alist of undefined functions to which calls have been compiled.
@@ -1103,6 +1105,10 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
1103 1105
1104;;; sanity-checking arglists 1106;;; sanity-checking arglists
1105 1107
1108;; If a function has an entry saying (FUNCTION . t).
1109;; that means we know it is defined but we don't know how.
1110;; If a function has an entry saying (FUNCTION . nil),
1111;; that means treat it as not defined.
1106(defun byte-compile-fdefinition (name macro-p) 1112(defun byte-compile-fdefinition (name macro-p)
1107 (let* ((list (if macro-p 1113 (let* ((list (if macro-p
1108 byte-compile-macro-environment 1114 byte-compile-macro-environment
@@ -1168,7 +1174,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
1168(defun byte-compile-callargs-warn (form) 1174(defun byte-compile-callargs-warn (form)
1169 (let* ((def (or (byte-compile-fdefinition (car form) nil) 1175 (let* ((def (or (byte-compile-fdefinition (car form) nil)
1170 (byte-compile-fdefinition (car form) t))) 1176 (byte-compile-fdefinition (car form) t)))
1171 (sig (if def 1177 (sig (if (and def (not (eq def t)))
1172 (byte-compile-arglist-signature 1178 (byte-compile-arglist-signature
1173 (if (eq 'lambda (car-safe def)) 1179 (if (eq 'lambda (car-safe def))
1174 (nth 1 def) 1180 (nth 1 def)
@@ -1198,7 +1204,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
1198 (byte-compile-format-warn form) 1204 (byte-compile-format-warn form)
1199 ;; Check to see if the function will be available at runtime 1205 ;; Check to see if the function will be available at runtime
1200 ;; and/or remember its arity if it's unknown. 1206 ;; and/or remember its arity if it's unknown.
1201 (or (and (or sig (fboundp (car form))) ; might be a subr or autoload. 1207 (or (and (or def (fboundp (car form))) ; might be a subr or autoload.
1202 (not (memq (car form) byte-compile-noruntime-functions))) 1208 (not (memq (car form) byte-compile-noruntime-functions)))
1203 (eq (car form) byte-compile-current-form) ; ## this doesn't work 1209 (eq (car form) byte-compile-current-form) ; ## this doesn't work
1204 ; with recursion. 1210 ; with recursion.
@@ -1209,9 +1215,8 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
1209 (if cons 1215 (if cons
1210 (or (memq n (cdr cons)) 1216 (or (memq n (cdr cons))
1211 (setcdr cons (cons n (cdr cons)))) 1217 (setcdr cons (cons n (cdr cons))))
1212 (setq byte-compile-unresolved-functions 1218 (push (list (car form) n)
1213 (cons (list (car form) n) 1219 byte-compile-unresolved-functions))))))
1214 byte-compile-unresolved-functions)))))))
1215 1220
1216(defun byte-compile-format-warn (form) 1221(defun byte-compile-format-warn (form)
1217 "Warn if FORM is `format'-like with inconsistent args. 1222 "Warn if FORM is `format'-like with inconsistent args.
@@ -1243,7 +1248,7 @@ extra args."
1243;; number of arguments. 1248;; number of arguments.
1244(defun byte-compile-arglist-warn (form macrop) 1249(defun byte-compile-arglist-warn (form macrop)
1245 (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) 1250 (let ((old (byte-compile-fdefinition (nth 1 form) macrop)))
1246 (if old 1251 (if (and old (not (eq old t)))
1247 (let ((sig1 (byte-compile-arglist-signature 1252 (let ((sig1 (byte-compile-arglist-signature
1248 (if (eq 'lambda (car-safe old)) 1253 (if (eq 'lambda (car-safe old))
1249 (nth 1 old) 1254 (nth 1 old)
@@ -2123,9 +2128,9 @@ list that represents a doc string reference.
2123 (eq (car (nth 1 form)) 'quote) 2128 (eq (car (nth 1 form)) 'quote)
2124 (consp (cdr (nth 1 form))) 2129 (consp (cdr (nth 1 form)))
2125 (symbolp (nth 1 (nth 1 form)))) 2130 (symbolp (nth 1 (nth 1 form))))
2126 (add-to-list 'byte-compile-function-environment 2131 (push (cons (nth 1 (nth 1 form))
2127 (cons (nth 1 (nth 1 form)) 2132 (cons 'autoload (cdr (cdr form))))
2128 (cons 'autoload (cdr (cdr form)))))) 2133 byte-compile-function-environment))
2129 (if (stringp (nth 3 form)) 2134 (if (stringp (nth 3 form))
2130 form 2135 form
2131 ;; No doc string, so we can compile this as a normal form. 2136 ;; No doc string, so we can compile this as a normal form.
@@ -3608,7 +3613,6 @@ being undefined will be suppressed."
3608(byte-defop-compiler-1 defconst byte-compile-defvar) 3613(byte-defop-compiler-1 defconst byte-compile-defvar)
3609(byte-defop-compiler-1 autoload) 3614(byte-defop-compiler-1 autoload)
3610(byte-defop-compiler-1 lambda byte-compile-lambda-form) 3615(byte-defop-compiler-1 lambda byte-compile-lambda-form)
3611(byte-defop-compiler-1 defalias)
3612 3616
3613(defun byte-compile-defun (form) 3617(defun byte-compile-defun (form)
3614 ;; This is not used for file-level defuns with doc strings. 3618 ;; This is not used for file-level defuns with doc strings.
@@ -3710,22 +3714,22 @@ being undefined will be suppressed."
3710 (error "`lambda' used as function name is invalid")) 3714 (error "`lambda' used as function name is invalid"))
3711 3715
3712;; Compile normally, but deal with warnings for the function being defined. 3716;; Compile normally, but deal with warnings for the function being defined.
3713(defun byte-compile-defalias (form) 3717(put 'defalias 'byte-hunk-handler 'byte-compile-file-form-defalias)
3718(defun byte-compile-file-form-defalias (form)
3714 (if (and (consp (cdr form)) (consp (nth 1 form)) 3719 (if (and (consp (cdr form)) (consp (nth 1 form))
3715 (eq (car (nth 1 form)) 'quote) 3720 (eq (car (nth 1 form)) 'quote)
3716 (consp (cdr (nth 1 form))) 3721 (consp (cdr (nth 1 form)))
3717 (symbolp (nth 1 (nth 1 form))) 3722 (symbolp (nth 1 (nth 1 form))))
3718 (consp (nthcdr 2 form)) 3723 (let ((constant
3719 (consp (nth 2 form)) 3724 (and (consp (nthcdr 2 form))
3720 (eq (car (nth 2 form)) 'quote) 3725 (consp (nth 2 form))
3721 (consp (cdr (nth 2 form))) 3726 (eq (car (nth 2 form)) 'quote)
3722 (symbolp (nth 1 (nth 2 form)))) 3727 (consp (cdr (nth 2 form)))
3723 (progn 3728 (symbolp (nth 1 (nth 2 form))))))
3724 (byte-compile-defalias-warn (nth 1 (nth 1 form))) 3729 (byte-compile-defalias-warn (nth 1 (nth 1 form)))
3725 (setq byte-compile-function-environment 3730 (push (cons (nth 1 (nth 1 form))
3726 (cons (cons (nth 1 (nth 1 form)) 3731 (if constant (nth 1 (nth 2 form)) t))
3727 (nth 1 (nth 2 form))) 3732 byte-compile-function-environment)))
3728 byte-compile-function-environment))))
3729 (byte-compile-normal-call form)) 3733 (byte-compile-normal-call form))
3730 3734
3731;; Turn off warnings about prior calls to the function being defalias'd. 3735;; Turn off warnings about prior calls to the function being defalias'd.
@@ -3928,7 +3932,7 @@ invoked interactively."
3928 (while rest 3932 (while rest
3929 (or (nth 1 (car rest)) 3933 (or (nth 1 (car rest))
3930 (null (setq f (car (car rest)))) 3934 (null (setq f (car (car rest))))
3931 (byte-compile-fdefinition f t) 3935 (functionp (byte-compile-fdefinition f t))
3932 (commandp (byte-compile-fdefinition f nil)) 3936 (commandp (byte-compile-fdefinition f nil))
3933 (setq uncalled (cons f uncalled))) 3937 (setq uncalled (cons f uncalled)))
3934 (setq rest (cdr rest))) 3938 (setq rest (cdr rest)))
@@ -4110,5 +4114,5 @@ For example, invoke `emacs -batch -f batch-byte-recompile-directory .'."
4110 4114
4111(run-hooks 'bytecomp-load-hook) 4115(run-hooks 'bytecomp-load-hook)
4112 4116
4113;;; arch-tag: 9c97b0f0-8745-4571-bfc3-8dceb677292a 4117;; arch-tag: 9c97b0f0-8745-4571-bfc3-8dceb677292a
4114;;; bytecomp.el ends here 4118;;; bytecomp.el ends here