aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-10-05 09:29:51 +0000
committerGerd Moellmann2001-10-05 09:29:51 +0000
commit3614fc84dea86c39a2d526498d925701efb3be5f (patch)
tree923dd5e0c119d41ea920324696ae03ef4f5863df
parenta273d3e0c5792707b0737ce55ead6ba41294f762 (diff)
downloademacs-3614fc84dea86c39a2d526498d925701efb3be5f.tar.gz
emacs-3614fc84dea86c39a2d526498d925701efb3be5f.zip
(byte-recompile-directory): Make sure the file is readable.
(byte-compile-file): Don't compile if `no-byte-compile' is set. (byte-compile-defvar): Update to reflect the change in Fdefvar. (batch-byte-recompile-directory): Pass arg=0.
-rw-r--r--lisp/emacs-lisp/bytecomp.el131
1 files changed, 71 insertions, 60 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 7e6fbeea10c..f68ec7941e7 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -10,7 +10,7 @@
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.84 $") 13(defconst byte-compile-version "$Revision: 2.85.2.1 $")
14 14
15;; This file is part of GNU Emacs. 15;; This file is part of GNU Emacs.
16 16
@@ -161,16 +161,16 @@
161 ;; This really ought to be loaded already! 161 ;; This really ought to be loaded already!
162 (load-library "byte-run")) 162 (load-library "byte-run"))
163 163
164;;; The feature of compiling in a specific target Emacs version 164;; The feature of compiling in a specific target Emacs version
165;;; has been turned off because compile time options are a bad idea. 165;; has been turned off because compile time options are a bad idea.
166(defmacro byte-compile-single-version () nil) 166(defmacro byte-compile-single-version () nil)
167(defmacro byte-compile-version-cond (cond) cond) 167(defmacro byte-compile-version-cond (cond) cond)
168 168
169;;; The crud you see scattered through this file of the form 169;; The crud you see scattered through this file of the form
170;;; (or (and (boundp 'epoch::version) epoch::version) 170;; (or (and (boundp 'epoch::version) epoch::version)
171;;; (string-lessp emacs-version "19")) 171;; (string-lessp emacs-version "19"))
172;;; is because the Epoch folks couldn't be bothered to follow the 172;; is because the Epoch folks couldn't be bothered to follow the
173;;; normal emacs version numbering convention. 173;; normal emacs version numbering convention.
174 174
175;; (if (byte-compile-version-cond 175;; (if (byte-compile-version-cond
176;; (or (and (boundp 'epoch::version) epoch::version) 176;; (or (and (boundp 'epoch::version) epoch::version)
@@ -663,35 +663,35 @@ otherwise pop it")
663(byte-extrude-byte-code-vectors) 663(byte-extrude-byte-code-vectors)
664 664
665;;; lapcode generator 665;;; lapcode generator
666;;; 666;;
667;;; the byte-compiler now does source -> lapcode -> bytecode instead of 667;; the byte-compiler now does source -> lapcode -> bytecode instead of
668;;; source -> bytecode, because it's a lot easier to make optimizations 668;; source -> bytecode, because it's a lot easier to make optimizations
669;;; on lapcode than on bytecode. 669;; on lapcode than on bytecode.
670;;; 670;;
671;;; Elements of the lapcode list are of the form (<instruction> . <parameter>) 671;; Elements of the lapcode list are of the form (<instruction> . <parameter>)
672;;; where instruction is a symbol naming a byte-code instruction, 672;; where instruction is a symbol naming a byte-code instruction,
673;;; and parameter is an argument to that instruction, if any. 673;; and parameter is an argument to that instruction, if any.
674;;; 674;;
675;;; The instruction can be the pseudo-op TAG, which means that this position 675;; The instruction can be the pseudo-op TAG, which means that this position
676;;; in the instruction stream is a target of a goto. (car PARAMETER) will be 676;; in the instruction stream is a target of a goto. (car PARAMETER) will be
677;;; the PC for this location, and the whole instruction "(TAG pc)" will be the 677;; the PC for this location, and the whole instruction "(TAG pc)" will be the
678;;; parameter for some goto op. 678;; parameter for some goto op.
679;;; 679;;
680;;; If the operation is varbind, varref, varset or push-constant, then the 680;; If the operation is varbind, varref, varset or push-constant, then the
681;;; parameter is (variable/constant . index_in_constant_vector). 681;; parameter is (variable/constant . index_in_constant_vector).
682;;; 682;;
683;;; First, the source code is macroexpanded and optimized in various ways. 683;; First, the source code is macroexpanded and optimized in various ways.
684;;; Then the resultant code is compiled into lapcode. Another set of 684;; Then the resultant code is compiled into lapcode. Another set of
685;;; optimizations are then run over the lapcode. Then the variables and 685;; optimizations are then run over the lapcode. Then the variables and
686;;; constants referenced by the lapcode are collected and placed in the 686;; constants referenced by the lapcode are collected and placed in the
687;;; constants-vector. (This happens now so that variables referenced by dead 687;; constants-vector. (This happens now so that variables referenced by dead
688;;; code don't consume space.) And finally, the lapcode is transformed into 688;; code don't consume space.) And finally, the lapcode is transformed into
689;;; compacted byte-code. 689;; compacted byte-code.
690;;; 690;;
691;;; A distinction is made between variables and constants because the variable- 691;; A distinction is made between variables and constants because the variable-
692;;; referencing instructions are more sensitive to the variables being near the 692;; referencing instructions are more sensitive to the variables being near the
693;;; front of the constants-vector than the constant-referencing instructions. 693;; front of the constants-vector than the constant-referencing instructions.
694;;; Also, this lets us notice references to free variables. 694;; Also, this lets us notice references to free variables.
695 695
696(defun byte-compile-lapcode (lap) 696(defun byte-compile-lapcode (lap)
697 "Turns lapcode into bytecode. The lapcode is destroyed." 697 "Turns lapcode into bytecode. The lapcode is destroyed."
@@ -842,23 +842,23 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
842 (and byte-compile-last-warned-form 842 (and byte-compile-last-warned-form
843 (not (eq byte-compile-current-form 843 (not (eq byte-compile-current-form
844 byte-compile-last-warned-form)))) 844 byte-compile-last-warned-form))))
845;;; This is redundant, since it is given at the start of the file, 845 ;; This is redundant, since it is given at the start of the
846;;; and the extra clutter gets in the way -- rms. 846 ;; file, and the extra clutter gets in the way -- rms.
847;;; (if (and byte-compile-current-file 847 ;; (if (and byte-compile-current-file
848;;; (not (equal byte-compile-current-file 848 ;; (not (equal byte-compile-current-file
849;;; byte-compile-last-logged-file))) 849 ;; byte-compile-last-logged-file)))
850;;; (insert "\n\^L\n" (current-time-string) "\n")) 850 ;; (insert "\n\^L\n" (current-time-string) "\n"))
851 (insert "\nWhile compiling " 851 (insert "\nWhile compiling "
852 (if byte-compile-current-form 852 (if byte-compile-current-form
853 (format "%s" byte-compile-current-form) 853 (format "%s" byte-compile-current-form)
854 "toplevel forms")) 854 "toplevel forms"))
855;;; This is redundant, since it is given at the start of the file, 855 ;; This is redundant, since it is given at the start of the file,
856;;; and the extra clutter gets in the way -- rms. 856 ;; and the extra clutter gets in the way -- rms.
857;;; (if byte-compile-current-file 857 ;; (if byte-compile-current-file
858;;; (if (stringp byte-compile-current-file) 858 ;; (if (stringp byte-compile-current-file)
859;;; (insert " in file " byte-compile-current-file) 859 ;; (insert " in file " byte-compile-current-file)
860;;; (insert " in buffer " 860 ;; (insert " in buffer "
861;;; (buffer-name byte-compile-current-file)))) 861 ;; (buffer-name byte-compile-current-file))))
862 (insert ":\n"))) 862 (insert ":\n")))
863 (insert " " string "\n") 863 (insert " " string "\n")
864 (if (and fill (not (string-match "\n" string))) 864 (if (and fill (not (string-match "\n" string)))
@@ -890,10 +890,10 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
890 (if byte-compile-error-on-warn 890 (if byte-compile-error-on-warn
891 (error "%s" format) ; byte-compile-file catches and logs it 891 (error "%s" format) ; byte-compile-file catches and logs it
892 (byte-compile-log-1 (concat "** " format) t) 892 (byte-compile-log-1 (concat "** " format) t)
893;;; It is useless to flash warnings too fast to be read. 893 ;; It is useless to flash warnings too fast to be read.
894;;; Besides, they will all be shown at the end. 894 ;; Besides, they will all be shown at the end.
895;;; (or noninteractive ; already written on stdout. 895 ;; (or noninteractive ; already written on stdout.
896;;; (message "Warning: %s" format)) 896 ;; (message "Warning: %s" format))
897 )) 897 ))
898 898
899;;; This function should be used to report errors that have halted 899;;; This function should be used to report errors that have halted
@@ -1295,6 +1295,7 @@ recompile every `.el' file that already has a `.elc' file."
1295 (nconc directories (list source)))) 1295 (nconc directories (list source))))
1296 ;; It is an ordinary file. Decide whether to compile it. 1296 ;; It is an ordinary file. Decide whether to compile it.
1297 (if (and (string-match emacs-lisp-file-regexp source) 1297 (if (and (string-match emacs-lisp-file-regexp source)
1298 (file-readable-p source)
1298 (not (auto-save-file-name-p source)) 1299 (not (auto-save-file-name-p source))
1299 (setq dest (byte-compile-dest-file source)) 1300 (setq dest (byte-compile-dest-file source))
1300 (if (file-exists-p dest) 1301 (if (file-exists-p dest)
@@ -1324,7 +1325,7 @@ recompile every `.el' file that already has a `.elc' file."
1324(defun byte-compile-file (filename &optional load) 1325(defun byte-compile-file (filename &optional load)
1325 "Compile a file of Lisp code named FILENAME into a file of byte code. 1326 "Compile a file of Lisp code named FILENAME into a file of byte code.
1326The output file's name is made by appending `c' to the end of FILENAME. 1327The output file's name is made by appending `c' to the end of FILENAME.
1327With prefix arg (noninteractively: 2nd arg), load the file after compiling. 1328With prefix arg (noninteractively: 2nd arg), LOAD the file after compiling.
1328The value is t if there were no errors, nil if errors." 1329The value is t if there were no errors, nil if errors."
1329;; (interactive "fByte compile file: \nP") 1330;; (interactive "fByte compile file: \nP")
1330 (interactive 1331 (interactive
@@ -1352,8 +1353,6 @@ The value is t if there were no errors, nil if errors."
1352 (y-or-n-p (format "Save buffer %s first? " (buffer-name b)))) 1353 (y-or-n-p (format "Save buffer %s first? " (buffer-name b))))
1353 (save-excursion (set-buffer b) (save-buffer))))) 1354 (save-excursion (set-buffer b) (save-buffer)))))
1354 1355
1355 (if byte-compile-verbose
1356 (message "Compiling %s..." filename))
1357 (let ((byte-compile-current-file filename) 1356 (let ((byte-compile-current-file filename)
1358 (byte-compile-last-logged-file nil) 1357 (byte-compile-last-logged-file nil)
1359 (set-auto-coding-for-load t) 1358 (set-auto-coding-for-load t)
@@ -1386,6 +1385,18 @@ The value is t if there were no errors, nil if errors."
1386 (setq filename buffer-file-name)) 1385 (setq filename buffer-file-name))
1387 ;; Set the default directory, in case an eval-when-compile uses it. 1386 ;; Set the default directory, in case an eval-when-compile uses it.
1388 (setq default-directory (file-name-directory filename))) 1387 (setq default-directory (file-name-directory filename)))
1388 ;; Check if the file's local variables explicitly specify not to
1389 ;; compile this file.
1390 (if (with-current-buffer input-buffer
1391 (and (boundp 'no-byte-compile) no-byte-compile))
1392 (progn
1393 (message "%s not compiled because of `no-byte-compile: %s'"
1394 (file-relative-name filename)
1395 (with-current-buffer input-buffer no-byte-compile))
1396 (if (file-exists-p target-file)
1397 (condition-case nil (delete-file target-file) (error nil))))
1398 (if byte-compile-verbose
1399 (message "Compiling %s..." filename))
1389 (setq byte-compiler-error-flag nil) 1400 (setq byte-compiler-error-flag nil)
1390 ;; It is important that input-buffer not be current at this call, 1401 ;; It is important that input-buffer not be current at this call,
1391 ;; so that the value of point set in input-buffer 1402 ;; so that the value of point set in input-buffer
@@ -1430,7 +1441,7 @@ The value is t if there were no errors, nil if errors."
1430 (display-call-tree filename))) 1441 (display-call-tree filename)))
1431 (if load 1442 (if load
1432 (load target-file)) 1443 (load target-file))
1433 t))) 1444 t))))
1434 1445
1435;;(defun byte-compile-and-load-file (&optional filename) 1446;;(defun byte-compile-and-load-file (&optional filename)
1436;; "Compile a file of Lisp code named FILENAME into a file of byte code, 1447;; "Compile a file of Lisp code named FILENAME into a file of byte code,
@@ -3249,7 +3260,7 @@ If FORM is a lambda or a macro, byte-compile it as a function."
3249 (list 3260 (list
3250 ;; Put the defined variable in this library's load-history entry 3261 ;; Put the defined variable in this library's load-history entry
3251 ;; just as a real defvar would, but only in top-level forms. 3262 ;; just as a real defvar would, but only in top-level forms.
3252 (when (null byte-compile-current-form) 3263 (when (and (cddr form) (null byte-compile-current-form))
3253 `(push ',var current-load-list)) 3264 `(push ',var current-load-list))
3254 (when (> (length form) 3) 3265 (when (> (length form) 3)
3255 (when (and string (not (stringp string))) 3266 (when (and string (not (stringp string)))
@@ -3566,7 +3577,7 @@ For example, invoke `emacs -batch -f batch-byte-recompile-directory .'."
3566 (or command-line-args-left 3577 (or command-line-args-left
3567 (setq command-line-args-left '("."))) 3578 (setq command-line-args-left '(".")))
3568 (while command-line-args-left 3579 (while command-line-args-left
3569 (byte-recompile-directory (car command-line-args-left)) 3580 (byte-recompile-directory (car command-line-args-left) 0)
3570 (setq command-line-args-left (cdr command-line-args-left))) 3581 (setq command-line-args-left (cdr command-line-args-left)))
3571 (kill-emacs 0)) 3582 (kill-emacs 0))
3572 3583