Mercurial > emacs
comparison lisp/emacs-lisp/bytecomp.el @ 46003:503e1f14ba3d
(byte-compile-callargs-warn):
Check for `noruntime' even if the function has a known sig.
(byte-compile-file, byte-compile-output-docform):
Don't hard code point-min = 1.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 25 Jun 2002 01:09:52 +0000 |
parents | 288c321d3282 |
children | 9c0b15b35ce2 |
comparison
equal
deleted
inserted
replaced
46002:6f298513c731 | 46003:503e1f14ba3d |
---|---|
8 ;; Maintainer: FSF | 8 ;; Maintainer: FSF |
9 ;; Keywords: lisp | 9 ;; Keywords: lisp |
10 | 10 |
11 ;;; This version incorporates changes up to version 2.10 of the | 11 ;;; This version incorporates changes up to version 2.10 of the |
12 ;;; Zawinski-Furuseth compiler. | 12 ;;; Zawinski-Furuseth compiler. |
13 (defconst byte-compile-version "$Revision: 2.98 $") | 13 (defconst byte-compile-version "$Revision: 2.99 $") |
14 | 14 |
15 ;; This file is part of GNU Emacs. | 15 ;; This file is part of GNU Emacs. |
16 | 16 |
17 ;; GNU Emacs is free software; you can redistribute it and/or modify | 17 ;; GNU Emacs is free software; you can redistribute it and/or modify |
18 ;; it under the terms of the GNU General Public License as published by | 18 ;; it under the terms of the GNU General Public License as published by |
1111 (car form) ncall | 1111 (car form) ncall |
1112 (if (= 1 ncall) "" "s") | 1112 (if (= 1 ncall) "" "s") |
1113 (if (< ncall (car sig)) | 1113 (if (< ncall (car sig)) |
1114 "requires" | 1114 "requires" |
1115 "accepts only") | 1115 "accepts only") |
1116 (byte-compile-arglist-signature-string sig))) | 1116 (byte-compile-arglist-signature-string sig)))) |
1117 (or (and (fboundp (car form)) ; might be a subr or autoload. | 1117 ;; Check to see if the function will be available at runtime |
1118 (not (get (car form) 'byte-compile-noruntime))) | 1118 ;; and/or remember its arity if it's unknown. |
1119 (eq (car form) byte-compile-current-form) ; ## this doesn't work | 1119 (or (and (or sig (fboundp (car form))) ; might be a subr or autoload. |
1120 ; with recursion. | 1120 (not (get (car form) 'byte-compile-noruntime))) |
1121 ;; It's a currently-undefined function. | 1121 (eq (car form) byte-compile-current-form) ; ## this doesn't work |
1122 ;; Remember number of args in call. | 1122 ; with recursion. |
1123 (let ((cons (assq (car form) byte-compile-unresolved-functions)) | 1123 ;; It's a currently-undefined function. |
1124 (n (length (cdr form)))) | 1124 ;; Remember number of args in call. |
1125 (if cons | 1125 (let ((cons (assq (car form) byte-compile-unresolved-functions)) |
1126 (or (memq n (cdr cons)) | 1126 (n (length (cdr form)))) |
1127 (setcdr cons (cons n (cdr cons)))) | 1127 (if cons |
1128 (setq byte-compile-unresolved-functions | 1128 (or (memq n (cdr cons)) |
1129 (cons (list (car form) n) | 1129 (setcdr cons (cons n (cdr cons)))) |
1130 byte-compile-unresolved-functions)))))))) | 1130 (setq byte-compile-unresolved-functions |
1131 (cons (list (car form) n) | |
1132 byte-compile-unresolved-functions))))))) | |
1131 | 1133 |
1132 ;; Warn if the function or macro is being redefined with a different | 1134 ;; Warn if the function or macro is being redefined with a different |
1133 ;; number of arguments. | 1135 ;; number of arguments. |
1134 (defun byte-compile-arglist-warn (form macrop) | 1136 (defun byte-compile-arglist-warn (form macrop) |
1135 (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) | 1137 (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) |
1490 ;; hard-links continue to point to the old file (this makes | 1492 ;; hard-links continue to point to the old file (this makes |
1491 ;; it possible for installed files to share disk space with | 1493 ;; it possible for installed files to share disk space with |
1492 ;; the build tree, without causing problems when emacs-lisp | 1494 ;; the build tree, without causing problems when emacs-lisp |
1493 ;; files in the build tree are recompiled). | 1495 ;; files in the build tree are recompiled). |
1494 (delete-file target-file)) | 1496 (delete-file target-file)) |
1495 (write-region 1 (point-max) target-file)) | 1497 (write-region (point-min) (point-max) target-file)) |
1496 ;; This is just to give a better error message than write-region | 1498 ;; This is just to give a better error message than write-region |
1497 (signal 'file-error | 1499 (signal 'file-error |
1498 (list "Opening output file" | 1500 (list "Opening output file" |
1499 (if (file-exists-p target-file) | 1501 (if (file-exists-p target-file) |
1500 "cannot overwrite file" | 1502 "cannot overwrite file" |
1807 ;; for make-docfile's sake. | 1809 ;; for make-docfile's sake. |
1808 (insert "\n") | 1810 (insert "\n") |
1809 (setq position | 1811 (setq position |
1810 (byte-compile-output-as-comment | 1812 (byte-compile-output-as-comment |
1811 (nth (nth 1 info) form) nil)) | 1813 (nth (nth 1 info) form) nil)) |
1812 (setq position (position-bytes position)) | 1814 (setq position (- (position-bytes position) (point-min) -1)) |
1813 ;; If the doc string starts with * (a user variable), | 1815 ;; If the doc string starts with * (a user variable), |
1814 ;; negate POSITION. | 1816 ;; negate POSITION. |
1815 (if (and (stringp (nth (nth 1 info) form)) | 1817 (if (and (stringp (nth (nth 1 info) form)) |
1816 (> (length (nth (nth 1 info) form)) 0) | 1818 (> (length (nth (nth 1 info) form)) 0) |
1817 (eq (aref (nth (nth 1 info) form) 0) ?*)) | 1819 (eq (aref (nth (nth 1 info) form) 0) ?*)) |
1841 (cond ((and (numberp specindex) (= index specindex)) | 1843 (cond ((and (numberp specindex) (= index specindex)) |
1842 (let ((position | 1844 (let ((position |
1843 (byte-compile-output-as-comment | 1845 (byte-compile-output-as-comment |
1844 (cons (car form) (nth 1 form)) | 1846 (cons (car form) (nth 1 form)) |
1845 t))) | 1847 t))) |
1846 (setq position (position-bytes position)) | 1848 (setq position (- (position-bytes position) (point-min) -1)) |
1847 (princ (format "(#$ . %d) nil" position) outbuffer) | 1849 (princ (format "(#$ . %d) nil" position) outbuffer) |
1848 (setq form (cdr form)) | 1850 (setq form (cdr form)) |
1849 (setq index (1+ index)))) | 1851 (setq index (1+ index)))) |
1850 ((= index (nth 1 info)) | 1852 ((= index (nth 1 info)) |
1851 (if position | 1853 (if position |
2402 ;; a number or symbol - ie not some big sequence. The return value | 2404 ;; a number or symbol - ie not some big sequence. The return value |
2403 ;; isn't returned, but it would be a shame if some textually large | 2405 ;; isn't returned, but it would be a shame if some textually large |
2404 ;; constant was not optimized away because we chose to return it. | 2406 ;; constant was not optimized away because we chose to return it. |
2405 (and (not (assq nil byte-compile-constants)) ; Nil is often there. | 2407 (and (not (assq nil byte-compile-constants)) ; Nil is often there. |
2406 (let ((tmp (reverse byte-compile-constants))) | 2408 (let ((tmp (reverse byte-compile-constants))) |
2407 (while (and tmp (not (or (symbolp (car (car tmp))) | 2409 (while (and tmp (not (or (symbolp (caar tmp)) |
2408 (numberp (car (car tmp)))))) | 2410 (numberp (caar tmp))))) |
2409 (setq tmp (cdr tmp))) | 2411 (setq tmp (cdr tmp))) |
2410 (car (car tmp))))))) | 2412 (caar tmp)))))) |
2411 (byte-compile-out 'byte-return 0) | 2413 (byte-compile-out 'byte-return 0) |
2412 (setq byte-compile-output (nreverse byte-compile-output)) | 2414 (setq byte-compile-output (nreverse byte-compile-output)) |
2413 (if (memq byte-optimize '(t byte)) | 2415 (if (memq byte-optimize '(t byte)) |
2414 (setq byte-compile-output | 2416 (setq byte-compile-output |
2415 (byte-optimize-lapcode byte-compile-output for-effect))) | 2417 (byte-optimize-lapcode byte-compile-output for-effect))) |