Mercurial > hg > xemacs-beta
annotate lisp/bytecomp.el @ 5503:7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
lisp/ChangeLog addition:
2011-05-07 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el:
* bytecomp.el (byte-compile-two-args-19->20): Removed.
* bytecomp.el (byte-compile-emacs19-compatibility): Removed.
* bytecomp.el (byte-defop-compiler20): Removed.
* bytecomp.el (byte-defop-compiler-rmsfun): Removed.
* bytecomp.el (emacs-lisp-file-regexp):
* bytecomp.el (byte-compile-print-gensym):
* bytecomp.el (byte-compiler-legal-options):
* bytecomp.el (byte-compiler-obsolete-options):
* bytecomp.el (byte-compile-close-variables):
* bytecomp.el (byte-compile-insert-header):
* bytecomp.el (byte-compile-output-file-form):
* bytecomp.el (byte-compile-output-docform):
* bytecomp.el (byte-compile-out-toplevel):
* bytecomp.el (byte-compile-form):
* bytecomp.el (byte-defop-compiler-1):
* bytecomp.el (eq):
* bytecomp.el (equal):
* bytecomp.el (member):
* bytecomp.el (byte-compile-noop):
* bytecomp.el (byte-compile-save-current-buffer):
Remove support for generating code appropriate to Emacs 19.
* bytecomp.el (byte-compile-eval):
Avoid erroring here if the car of some entry in the macro
environment is not a symbol, as is the case for symbol macros.
* bytecomp.el (or):
Use slightly better style when compiling the most important
functions if bytecomp.el has just been loaded interpreted.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 07 May 2011 12:26:39 +0100 |
parents | 248176c74e6b |
children | b0d87f92e60b |
rev | line source |
---|---|
428 | 1 ;;; bytecomp.el --- compilation of Lisp code into byte code. |
2 | |
3 ;;; Copyright (C) 1985-1987, 1991-1994 Free Software Foundation, Inc. | |
4 ;;; Copyright (C) 1996 Ben Wing. | |
5 | |
442 | 6 ;; Authors: Jamie Zawinski <jwz@jwz.org> |
428 | 7 ;; Hallvard Furuseth <hbf@ulrik.uio.no> |
442 | 8 ;; Ben Wing <ben@xemacs.org> |
9 ;; Martin Buchholz <martin@xemacs.org> | |
10 ;; Richard Stallman <rms@gnu.org> | |
11 ;; Keywords: internal lisp | |
12 | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
13 (defconst byte-compile-version "2.28 XEmacs; 2009-08-09.") |
428 | 14 |
15 ;; This file is part of XEmacs. | |
16 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
17 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
18 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
19 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
20 ;; option) any later version. |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
21 |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
22 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
23 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
24 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
25 ;; for more details. |
428 | 26 |
27 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5269
diff
changeset
|
28 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
428 | 29 |
30 ;;; Synched up with: FSF 19.30. | |
31 | |
32 ;;; Commentary: | |
33 | |
34 ;; The Emacs Lisp byte compiler. This crunches lisp source into a | |
442 | 35 ;; sort of p-code (`bytecode') which takes up less space and can be |
36 ;; interpreted faster. First, the source code forms are converted to | |
37 ;; an intermediate form, `lapcode' [`LAP' == `Lisp Assembly Program'] | |
38 ;; which is much easier to manipulate than bytecode. Then the lapcode | |
39 ;; is converted to bytecode, which can be considered to be actual | |
40 ;; machine language. Optimizations can occur at either the source | |
41 ;; level or the lapcode level. | |
42 | |
43 ;; The user entry points are byte-compile-file, | |
428 | 44 ;; byte-recompile-directory and byte-compile-buffer. |
45 | |
46 ;;; Code: | |
47 | |
48 ;;; ======================================================================== | |
49 ;;; Entry points: | |
50 ;;; byte-recompile-directory, byte-compile-file, | |
51 ;;; batch-byte-compile, batch-byte-recompile-directory, | |
52 ;;; byte-compile, compile-defun, | |
53 ;;; display-call-tree | |
54 ;;; RMS says: | |
55 ;;; (byte-compile-buffer and byte-compile-and-load-file were turned off | |
56 ;;; because they are not terribly useful and get in the way of completion.) | |
57 ;;; But I'm leaving them. --ben | |
58 | |
59 ;;; This version of the byte compiler has the following improvements: | |
60 ;;; + optimization of compiled code: | |
61 ;;; - removal of unreachable code; | |
62 ;;; - removal of calls to side-effectless functions whose return-value | |
63 ;;; is unused; | |
64 ;;; - compile-time evaluation of safe constant forms, such as (consp nil) | |
65 ;;; and (ash 1 6); | |
66 ;;; - open-coding of literal lambdas; | |
67 ;;; - peephole optimization of emitted code; | |
68 ;;; - trivial functions are left uncompiled for speed. | |
69 ;;; + support for inline functions; | |
70 ;;; + compile-time evaluation of arbitrary expressions; | |
71 ;;; + compile-time warning messages for: | |
72 ;;; - functions being redefined with incompatible arglists; | |
73 ;;; - functions being redefined as macros, or vice-versa; | |
74 ;;; - functions or macros defined multiple times in the same file; | |
75 ;;; - functions being called with the incorrect number of arguments; | |
76 ;;; - functions being called which are not defined globally, in the | |
77 ;;; file, or as autoloads; | |
78 ;;; - assignment and reference of undeclared free variables; | |
79 ;;; - various syntax errors; | |
80 ;;; + correct compilation of nested defuns, defmacros, defvars and defsubsts; | |
81 ;;; + correct compilation of top-level uses of macros; | |
82 ;;; + the ability to generate a histogram of functions called. | |
83 | |
84 ;;; User customization variables: | |
85 ;;; | |
86 ;;; byte-compile-verbose Whether to report the function currently being | |
87 ;;; compiled in the minibuffer; | |
88 ;;; byte-optimize Whether to do optimizations; this may be | |
89 ;;; t, nil, 'source, or 'byte; | |
90 ;;; byte-optimize-log Whether to report (in excruciating detail) | |
91 ;;; exactly which optimizations have been made. | |
92 ;;; This may be t, nil, 'source, or 'byte; | |
93 ;;; byte-compile-error-on-warn Whether to stop compilation when a warning is | |
94 ;;; produced; | |
95 ;;; byte-compile-delete-errors Whether the optimizer may delete calls or | |
96 ;;; variable references that are side-effect-free | |
97 ;;; except that they may return an error. | |
98 ;;; byte-compile-generate-call-tree Whether to generate a histogram of | |
99 ;;; function calls. This can be useful for | |
100 ;;; finding unused functions, as well as simple | |
101 ;;; performance metering. | |
102 ;;; byte-compile-warnings List of warnings to issue, or t. May contain | |
103 ;;; 'free-vars (references to variables not in the | |
104 ;;; current lexical scope) | |
105 ;;; 'unused-vars (non-global variables bound but | |
106 ;;; not referenced) | |
107 ;;; 'unresolved (calls to unknown functions) | |
108 ;;; 'callargs (lambda calls with args that don't | |
109 ;;; match the lambda's definition) | |
110 ;;; 'subr-callargs (calls to subrs with args that | |
111 ;;; don't match the subr's definition) | |
112 ;;; 'redefine (function cell redefined from | |
113 ;;; a macro to a lambda or vice versa, | |
114 ;;; or redefined to take other args) | |
115 ;;; 'obsolete (obsolete variables and functions) | |
116 ;;; 'pedantic (references to Emacs-compatible | |
117 ;;; symbols) | |
4719
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
118 ;;; 'discarded-consing (use of mapcar instead of |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
119 ;;; mapc, and similar) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
120 ;;; 'quoted-lambda (quoting a lambda expression |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
121 ;;; as data, not as a function, |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
122 ;;; and using it in a function |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
123 ;;; context ) |
428 | 124 ;;; emacs-lisp-file-regexp Regexp for the extension of source-files; |
444 | 125 ;;; see also the function `byte-compile-dest-file'. |
428 | 126 ;;; byte-compile-overwrite-file If nil, delete old .elc files before saving. |
127 ;;; | |
128 ;;; Most of the above parameters can also be set on a file-by-file basis; see | |
129 ;;; the documentation of the `byte-compiler-options' macro. | |
130 | |
131 ;;; New Features: | |
132 ;;; | |
133 ;;; o The form `defsubst' is just like `defun', except that the function | |
134 ;;; generated will be open-coded in compiled code which uses it. This | |
135 ;;; means that no function call will be generated, it will simply be | |
136 ;;; spliced in. Lisp functions calls are very slow, so this can be a | |
137 ;;; big win. | |
138 ;;; | |
139 ;;; You can generally accomplish the same thing with `defmacro', but in | |
140 ;;; that case, the defined procedure can't be used as an argument to | |
141 ;;; mapcar, etc. | |
142 ;;; | |
143 ;;; o You can make a given function be inline even if it has already been | |
144 ;;; defined with `defun' by using the `proclaim-inline' form like so: | |
145 ;;; (proclaim-inline my-function) | |
146 ;;; This is, in fact, exactly what `defsubst' does. To make a function no | |
147 ;;; longer be inline, you must use `proclaim-notinline'. Beware that if | |
148 ;;; you define a function with `defsubst' and later redefine it with | |
444 | 149 ;;; `defun', it will still be open-coded until you use `proclaim-notinline'. |
428 | 150 ;;; |
151 ;;; o You can also open-code one particular call to a function without | |
152 ;;; open-coding all calls. Use the 'inline' form to do this, like so: | |
153 ;;; | |
154 ;;; (inline (foo 1 2 3)) ;; `foo' will be open-coded | |
155 ;;; or... | |
156 ;;; (inline ;; `foo' and `baz' will be | |
157 ;;; (foo 1 2 3 (bar 5)) ;; open-coded, but `bar' will not. | |
158 ;;; (baz 0)) | |
159 ;;; | |
160 ;;; o It is possible to open-code a function in the same file it is defined | |
161 ;;; in without having to load that file before compiling it. the | |
162 ;;; byte-compiler has been modified to remember function definitions in | |
163 ;;; the compilation environment in the same way that it remembers macro | |
164 ;;; definitions. | |
165 ;;; | |
166 ;;; o Forms like ((lambda ...) ...) are open-coded. | |
167 ;;; | |
444 | 168 ;;; o The form `eval-when-compile' is like `progn', except that the body |
428 | 169 ;;; is evaluated at compile-time. When it appears at top-level, this |
170 ;;; is analogous to the Common Lisp idiom (eval-when (compile) ...). | |
171 ;;; When it does not appear at top-level, it is similar to the | |
172 ;;; Common Lisp #. reader macro (but not in interpreted code). | |
173 ;;; | |
444 | 174 ;;; o The form `eval-and-compile' is similar to `eval-when-compile', |
175 ;;; but the whole form is evalled both at compile-time and at run-time. | |
428 | 176 ;;; |
177 ;;; o The command M-x byte-compile-and-load-file does what you'd think. | |
178 ;;; | |
444 | 179 ;;; o The command `compile-defun' is analogous to `eval-defun'. |
428 | 180 ;;; |
444 | 181 ;;; o If you run `byte-compile-file' on a filename which is visited in a |
428 | 182 ;;; buffer, and that buffer is modified, you are asked whether you want |
183 ;;; to save the buffer before compiling. | |
184 ;;; | |
185 ;;; o You can add this to /etc/magic to make file(1) recognize the files | |
186 ;;; generated by this compiler: | |
187 ;;; | |
613 | 188 ;;; 0 string ;ELC XEmacs Lisp compiled file, |
428 | 189 ;;; >4 byte x version %d |
190 ;;; | |
191 ;;; TO DO: | |
192 ;;; | |
193 ;;; o Should implement declarations and proclamations, notably special, | |
194 ;;; unspecial, and ignore. Do this in such a way as to not break cl.el. | |
195 ;;; o The bound-but-not-used warnings are not issued for variables whose | |
196 ;;; bindings were established in the arglist, due to the lack of an | |
197 ;;; ignore declaration. Once ignore exists, this should be turned on. | |
198 ;;; o Warn about functions and variables defined but not used? | |
199 ;;; Maybe add some kind of `export' declaration for this? | |
200 ;;; (With interactive functions being automatically exported?) | |
201 ;;; o Any reference to a variable, even one which is a no-op, will cause | |
202 ;;; the warning not to be given. Possibly we could use the for-effect | |
203 ;;; flag to determine when this reference is useless; possibly more | |
204 ;;; complex flow analysis would be necessary. | |
205 ;;; o If the optimizer deletes a variable reference, we might be left with | |
206 ;;; a bound-but-not-referenced warning. Generally this is ok, but not if | |
207 ;;; it's a synergistic result of macroexpansion. Need some way to note | |
208 ;;; that a varref is being optimized away? Of course it would be nice to | |
209 ;;; optimize away the binding too, someday, but it's unsafe today. | |
210 ;;; o (See byte-optimize.el for the optimization TODO list.) | |
211 | |
212 (require 'backquote) | |
213 | |
214 (or (fboundp 'defsubst) | |
215 ;; This really ought to be loaded already! | |
216 (load-library "bytecomp-runtime")) | |
217 | |
444 | 218 (defvar emacs-lisp-file-regexp "\\.el$" |
428 | 219 "*Regexp which matches Emacs Lisp source files. |
220 You may want to redefine `byte-compile-dest-file' if you change this.") | |
221 | |
222 ;; This enables file name handlers such as jka-compr | |
223 ;; to remove parts of the file name that should not be copied | |
224 ;; through to the output file name. | |
225 (defun byte-compiler-base-file-name (filename) | |
226 (let ((handler (find-file-name-handler filename | |
227 'byte-compiler-base-file-name))) | |
228 (if handler | |
229 (funcall handler 'byte-compiler-base-file-name filename) | |
230 filename))) | |
231 | |
232 (unless (fboundp 'byte-compile-dest-file) | |
233 ;; The user may want to redefine this along with emacs-lisp-file-regexp, | |
234 ;; so only define it if it is undefined. | |
235 (defun byte-compile-dest-file (filename) | |
236 "Convert an Emacs Lisp source file name to a compiled file name." | |
237 (setq filename (byte-compiler-base-file-name filename)) | |
238 (setq filename (file-name-sans-versions filename)) | |
239 (if (string-match emacs-lisp-file-regexp filename) | |
240 (concat (substring filename 0 (match-beginning 0)) ".elc") | |
241 (concat filename ".elc")))) | |
242 | |
243 ;; This can be the 'byte-compile property of any symbol. | |
244 (autoload 'byte-compile-inline-expand "byte-optimize") | |
245 | |
246 ;; This is the entrypoint to the lapcode optimizer pass1. | |
247 (autoload 'byte-optimize-form "byte-optimize") | |
248 ;; This is the entrypoint to the lapcode optimizer pass2. | |
249 (autoload 'byte-optimize-lapcode "byte-optimize") | |
250 (autoload 'byte-compile-unfold-lambda "byte-optimize") | |
251 | |
252 ;; This is the entry point to the decompiler, which is used by the | |
253 ;; disassembler. The disassembler just requires 'byte-compile, but | |
254 ;; that doesn't define this function, so this seems to be a reasonable | |
255 ;; thing to do. | |
256 (autoload 'byte-decompile-bytecode "byte-optimize") | |
257 | |
258 (defvar byte-compile-verbose | |
259 (and (not noninteractive) (> (device-baud-rate) search-slow-speed)) | |
260 "*Non-nil means print messages describing progress of byte-compiler.") | |
261 | |
262 (defvar byte-compile-print-gensym t | |
263 "*Non-nil means generate code that creates unique symbols at run-time. | |
264 This is achieved by printing uninterned symbols using the `#:SYMBOL' | |
265 notation, so that they will be read uninterned when run. | |
266 | |
267 With this feature, code that uses uninterned symbols in macros will | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
268 not be runnable under pre-21.0 XEmacsen.") |
428 | 269 |
270 (defvar byte-optimize t | |
271 "*Enables optimization in the byte compiler. | |
272 nil means don't do any optimization. | |
273 t means do all optimizations. | |
274 `source' means do source-level optimizations only. | |
275 `byte' means do code-level optimizations only.") | |
276 | |
277 (defvar byte-compile-delete-errors t | |
278 "*If non-nil, the optimizer may delete forms that may signal an error. | |
279 This includes variable references and calls to functions such as `car'.") | |
280 | |
281 ;; XEmacs addition | |
282 (defvar byte-compile-new-bytecodes nil | |
283 "This is completely ignored. It is only around for backwards | |
284 compatibility.") | |
285 | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
286 (defvar byte-compile-checks-on-load '((featurep 'xemacs)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
287 "A list of expressions to check when first loading a file. |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
288 Emacs will throw an error if any of them fail; checks will be made in |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
289 reverse order.") |
428 | 290 |
291 ;; FSF enables byte-compile-dynamic-docstrings but not byte-compile-dynamic | |
292 ;; by default. This would be a reasonable conservative approach except | |
293 ;; for the fact that if you enable either of these, you get incompatible | |
294 ;; byte code that can't be read by XEmacs 19.13 or before or FSF 19.28 or | |
295 ;; before. | |
296 ;; | |
297 ;; Therefore, neither is enabled for 19.14. Both are enabled for 20.0 | |
298 ;; because we have no reason to be conservative about changing the | |
299 ;; way things work. (Ben) | |
300 | |
301 ;; However, I don't think that defaulting byte-compile-dynamic to nil | |
302 ;; is a compatibility issue - rather it is a performance issue. | |
303 ;; Therefore I am setting byte-compile-dynamic back to nil. (mrb) | |
304 | |
305 (defvar byte-compile-dynamic nil | |
306 "*If non-nil, compile function bodies so they load lazily. | |
307 They are hidden comments in the compiled file, and brought into core when the | |
308 function is called. | |
309 | |
310 To enable this option, make it a file-local variable | |
311 in the source file you want it to apply to. | |
312 For example, add -*-byte-compile-dynamic: t;-*- on the first line. | |
313 | |
314 When this option is true, if you load the compiled file and then move it, | |
315 the functions you loaded will not be able to run.") | |
316 | |
317 (defvar byte-compile-dynamic-docstrings (emacs-version>= 20) | |
318 "*If non-nil, compile doc strings for lazy access. | |
319 We bury the doc strings of functions and variables | |
320 inside comments in the file, and bring them into core only when they | |
321 are actually needed. | |
322 | |
323 When this option is true, if you load the compiled file and then move it, | |
324 you won't be able to find the documentation of anything in that file. | |
325 | |
326 To disable this option for a certain file, make it a file-local variable | |
327 in the source file. For example, add this to the first line: | |
328 -*-byte-compile-dynamic-docstrings:nil;-*- | |
329 You can also set the variable globally. | |
330 | |
331 This option is enabled by default because it reduces Emacs memory usage.") | |
332 | |
333 (defvar byte-optimize-log nil | |
334 "*If true, the byte-compiler will log its optimizations into *Compile-Log*. | |
335 If this is 'source, then only source-level optimizations will be logged. | |
336 If it is 'byte, then only byte-level optimizations will be logged.") | |
337 | |
338 (defvar byte-compile-error-on-warn nil | |
339 "*If true, the byte-compiler reports warnings with `error'.") | |
340 | |
341 ;; byte-compile-warning-types in FSF. | |
342 (defvar byte-compile-default-warnings | |
4719
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
343 '(redefine callargs subr-callargs free-vars unresolved unused-vars obsolete |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
344 discarded-consing quoted-lambda) |
428 | 345 "*The warnings used when byte-compile-warnings is t.") |
346 | |
347 (defvar byte-compile-warnings t | |
348 "*List of warnings that the compiler should issue (t for the default set). | |
349 Elements of the list may be: | |
350 | |
351 free-vars references to variables not in the current lexical scope. | |
352 unused-vars references to non-global variables bound but not referenced. | |
353 unresolved calls to unknown functions. | |
354 callargs lambda calls with args that don't match the definition. | |
355 subr-callargs calls to subrs with args that don't match the definition. | |
356 redefine function cell redefined from a macro to a lambda or vice | |
357 versa, or redefined to take a different number of arguments. | |
358 obsolete use of an obsolete function or variable. | |
359 pedantic warn of use of compatible symbols. | |
4719
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
360 discarded-consing |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
361 calls to (some) functions that allocate memory, where that |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
362 memory is immediately discarded; canonically, the use of |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
363 mapcar instead of mapc |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
364 quoted-lambda passing a lambda expression not quoted as a function, as a |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
365 function argument |
428 | 366 |
367 The default set is specified by `byte-compile-default-warnings' and | |
368 normally encompasses all possible warnings. | |
369 | |
370 See also the macro `byte-compiler-options'.") | |
371 | |
372 (defvar byte-compile-generate-call-tree nil | |
373 "*Non-nil means collect call-graph information when compiling. | |
374 This records functions that were called and from where. | |
375 If the value is t, compilation displays the call graph when it finishes. | |
376 If the value is neither t nor nil, compilation asks you whether to display | |
377 the graph. | |
378 | |
379 The call tree only lists functions called, not macros used. Those functions | |
380 which the byte-code interpreter knows about directly (eq, cons, etc.) are | |
381 not reported. | |
382 | |
383 The call tree also lists those functions which are not known to be called | |
384 \(that is, to which no calls have been compiled). Functions which can be | |
385 invoked interactively are excluded from this list.") | |
386 | |
387 (defconst byte-compile-call-tree nil "Alist of functions and their call tree. | |
388 Each element looks like | |
389 | |
390 \(FUNCTION CALLERS CALLS\) | |
391 | |
392 where CALLERS is a list of functions that call FUNCTION, and CALLS | |
393 is a list of functions for which calls were generated while compiling | |
394 FUNCTION.") | |
395 | |
396 (defvar byte-compile-call-tree-sort 'name | |
397 "*If non-nil, sort the call tree. | |
398 The values `name', `callers', `calls', `calls+callers' | |
399 specify different fields to sort on.") | |
400 | |
401 (defvar byte-compile-overwrite-file t | |
402 "If nil, old .elc files are deleted before the new is saved, and .elc | |
403 files will have the same modes as the corresponding .el file. Otherwise, | |
404 existing .elc files will simply be overwritten, and the existing modes | |
405 will not be changed. If this variable is nil, then an .elc file which | |
406 is a symbolic link will be turned into a normal file, instead of the file | |
407 which the link points to being overwritten.") | |
408 | |
409 (defvar byte-recompile-directory-ignore-errors-p nil | |
410 "If true, then `byte-recompile-directory' will continue compiling even | |
411 when an error occurs in a file. This is bound to t by | |
412 `batch-byte-recompile-directory'.") | |
413 | |
502 | 414 (defvar byte-recompile-ignore-uncompilable-mule-files t |
415 "If non-nil, `byte-recompile-*' ignores non-ASCII .el files in a non-Mule | |
416 XEmacs. This assumes that such files have a -*- coding: ??? -*- magic | |
417 cookie in their first line or a ;;;###coding system: magic cookie | |
418 early in the file.") | |
419 | |
428 | 420 (defvar byte-recompile-directory-recursively t |
421 "*If true, then `byte-recompile-directory' will recurse on subdirectories.") | |
422 | |
423 (defvar byte-compile-constants nil | |
424 "list of all constants encountered during compilation of this form") | |
425 (defvar byte-compile-variables nil | |
426 "list of all variables encountered during compilation of this form") | |
427 (defvar byte-compile-bound-variables nil | |
428 "Alist of variables bound in the context of the current form, | |
429 that is, the current lexical environment. This list lives partly | |
430 on the specbind stack. The cdr of each cell is an integer bitmask.") | |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
431 (defvar byte-compile-output-preface nil |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
432 "Form to output before current by `byte-compile-output-file-form' |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
433 This is used for implementing `load-time-value'.") |
428 | 434 |
4623
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
435 (defvar byte-compile-force-escape-quoted nil |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
436 "If t, `byte-compile-maybe-reset-coding' always chooses `escape-quoted' |
4623
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
437 |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
438 This is for situations where the byte compiler output file needs to be |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
439 able to encode character values above ?\\xFF, but this cannot be |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
440 easily determined from the input file.") |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
441 |
428 | 442 (defconst byte-compile-referenced-bit 1) |
443 (defconst byte-compile-assigned-bit 2) | |
444 (defconst byte-compile-arglist-bit 4) | |
445 (defconst byte-compile-global-bit 8) | |
446 | |
447 (defvar byte-compile-free-references) | |
448 (defvar byte-compile-free-assignments) | |
449 | |
450 (defvar byte-compiler-error-flag) | |
451 | |
446 | 452 ;;; A form of eval that includes the currently defined macro definitions. |
453 ;;; This helps implement the promise made in the Lispref: | |
454 ;;; | |
455 ;;; "If a file being compiled contains a `defmacro' form, the macro is | |
456 ;;; defined temporarily for the rest of the compilation of that file." | |
457 (defun byte-compile-eval (form) | |
458 (let ((save-macro-environment nil)) | |
459 (unwind-protect | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
460 (loop |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
461 for (sym . def) in byte-compile-macro-environment |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
462 do (when (symbolp sym) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
463 (push |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
464 (if (fboundp sym) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
465 (cons sym (symbol-function sym)) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
466 sym) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
467 save-macro-environment) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
468 (fset sym (cons 'macro def))) |
446 | 469 finally return (eval form)) |
470 (dolist (elt save-macro-environment) | |
471 (if (symbolp elt) | |
472 (fmakunbound elt) | |
473 (fset (car elt) (cdr elt))))))) | |
474 | |
428 | 475 (defconst byte-compile-initial-macro-environment |
5263
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
476 `((byte-compiler-options |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
477 . ,#'(lambda (&rest forms) |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
478 (apply 'byte-compiler-options-handler forms))) |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
479 (eval-when-compile |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
480 . ,#'(lambda (&rest body) |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
481 (list 'quote (byte-compile-eval (cons 'progn body))))) |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
482 (eval-and-compile |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
483 . ,#'(lambda (&rest body) |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
484 (byte-compile-eval (cons 'progn body)) |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
485 (cons 'progn body))) |
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
486 (the . |
5269
90a0084b3541
Rephrase the #'the docstring, make it nicer while byte-compiling.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5265
diff
changeset
|
487 ,#'(lambda (type form) |
5282
dcc34e28cd84
Warn at byte-compile in #'the if FORM constant & not TYPE; fix byte-compile-constp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5269
diff
changeset
|
488 (if (cl-const-expr-p form) |
dcc34e28cd84
Warn at byte-compile in #'the if FORM constant & not TYPE; fix byte-compile-constp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5269
diff
changeset
|
489 (or (eval (cl-make-type-test form type)) |
dcc34e28cd84
Warn at byte-compile in #'the if FORM constant & not TYPE; fix byte-compile-constp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5269
diff
changeset
|
490 (byte-compile-warn |
dcc34e28cd84
Warn at byte-compile in #'the if FORM constant & not TYPE; fix byte-compile-constp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5269
diff
changeset
|
491 "%s is not of type %s" form type))) |
5263
0d436a78c514
Add an implementation for #'the, cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5182
diff
changeset
|
492 (if byte-compile-delete-errors |
5269
90a0084b3541
Rephrase the #'the docstring, make it nicer while byte-compiling.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5265
diff
changeset
|
493 form |
5356
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
494 (funcall (cdr (symbol-function 'the)) type form))))) |
428 | 495 "The default macro-environment passed to macroexpand by the compiler. |
496 Placing a macro here will cause a macro to have different semantics when | |
497 expanded by the compiler as when expanded by the interpreter.") | |
498 | |
499 (defvar byte-compile-macro-environment byte-compile-initial-macro-environment | |
500 "Alist of macros defined in the file being compiled. | |
501 Each element looks like (MACRONAME . DEFINITION). It is | |
502 \(MACRONAME . nil) when a macro is redefined as a function.") | |
503 | |
504 (defvar byte-compile-function-environment nil | |
505 "Alist of functions defined in the file being compiled. | |
506 This is so we can inline them when necessary. | |
507 Each element looks like (FUNCTIONNAME . DEFINITION). It is | |
508 \(FUNCTIONNAME . nil) when a function is redefined as a macro.") | |
509 | |
510 (defvar byte-compile-autoload-environment nil | |
511 "Alist of functions and macros defined by autoload in the file being compiled. | |
512 This is so we can suppress warnings about calls to these functions, even though | |
513 they do not have `real' definitions. | |
514 Each element looks like (FUNCTIONNAME . CALL-TO-AUTOLOAD).") | |
515 | |
516 (defvar byte-compile-unresolved-functions nil | |
517 "Alist of undefined functions to which calls have been compiled (used for | |
518 warnings when the function is later defined with incorrect args).") | |
519 | |
520 (defvar byte-compile-file-domain) ; domain of file being compiled | |
521 | |
522 (defvar byte-compile-tag-number 0) | |
523 (defvar byte-compile-output nil | |
524 "Alist describing contents to put in byte code string. | |
525 Each element is (INDEX . VALUE)") | |
526 (defvar byte-compile-depth 0 "Current depth of execution stack.") | |
527 (defvar byte-compile-maxdepth 0 "Maximum depth of execution stack.") | |
528 | |
529 | |
530 ;;; The byte codes; this information is duplicated in bytecode.c | |
531 | |
532 (defconst byte-code-vector nil | |
533 "An array containing byte-code names indexed by byte-code values.") | |
534 | |
535 (defconst byte-stack+-info nil | |
536 "An array with the stack adjustment for each byte-code.") | |
537 | |
538 (defmacro byte-defop (opcode stack-adjust opname &optional docstring) | |
539 ;; This is a speed-hack for building the byte-code-vector at compile-time. | |
540 ;; We fill in the vector at macroexpand-time, and then after the last call | |
541 ;; to byte-defop, we write the vector out as a constant instead of writing | |
542 ;; out a bunch of calls to aset. | |
543 ;; Actually, we don't fill in the vector itself, because that could make | |
544 ;; it problematic to compile big changes to this compiler; we store the | |
545 ;; values on its plist, and remove them later in -extrude. | |
546 (let ((v1 (or (get 'byte-code-vector 'tmp-compile-time-value) | |
547 (put 'byte-code-vector 'tmp-compile-time-value | |
548 (make-vector 256 nil)))) | |
549 (v2 (or (get 'byte-stack+-info 'tmp-compile-time-value) | |
550 (put 'byte-stack+-info 'tmp-compile-time-value | |
551 (make-vector 256 nil))))) | |
552 (aset v1 opcode opname) | |
553 (aset v2 opcode stack-adjust)) | |
554 (if docstring | |
555 (list 'defconst opname opcode (concat "Byte code opcode " docstring ".")) | |
556 (list 'defconst opname opcode))) | |
557 | |
558 (defmacro byte-extrude-byte-code-vectors () | |
559 (prog1 (list 'setq 'byte-code-vector | |
560 (get 'byte-code-vector 'tmp-compile-time-value) | |
561 'byte-stack+-info | |
562 (get 'byte-stack+-info 'tmp-compile-time-value)) | |
563 (remprop 'byte-code-vector 'tmp-compile-time-value) | |
564 (remprop 'byte-stack+-info 'tmp-compile-time-value))) | |
565 | |
566 | |
567 ;; unused: 0-7 | |
568 | |
569 ;; These opcodes are special in that they pack their argument into the | |
570 ;; opcode word. | |
571 ;; | |
572 (byte-defop 8 1 byte-varref "for variable reference") | |
573 (byte-defop 16 -1 byte-varset "for setting a variable") | |
574 (byte-defop 24 -1 byte-varbind "for binding a variable") | |
575 (byte-defop 32 0 byte-call "for calling a function") | |
576 (byte-defop 40 0 byte-unbind "for unbinding special bindings") | |
577 ;; codes 8-47 are consumed by the preceding opcodes | |
578 | |
579 ;; unused: 48-55 | |
580 | |
581 (byte-defop 56 -1 byte-nth) | |
582 (byte-defop 57 0 byte-symbolp) | |
583 (byte-defop 58 0 byte-consp) | |
584 (byte-defop 59 0 byte-stringp) | |
585 (byte-defop 60 0 byte-listp) | |
586 (byte-defop 61 -1 byte-old-eq) | |
587 (byte-defop 62 -1 byte-old-memq) | |
588 (byte-defop 63 0 byte-not) | |
589 (byte-defop 64 0 byte-car) | |
590 (byte-defop 65 0 byte-cdr) | |
591 (byte-defop 66 -1 byte-cons) | |
592 (byte-defop 67 0 byte-list1) | |
593 (byte-defop 68 -1 byte-list2) | |
594 (byte-defop 69 -2 byte-list3) | |
595 (byte-defop 70 -3 byte-list4) | |
596 (byte-defop 71 0 byte-length) | |
597 (byte-defop 72 -1 byte-aref) | |
598 (byte-defop 73 -2 byte-aset) | |
599 (byte-defop 74 0 byte-symbol-value) | |
600 (byte-defop 75 0 byte-symbol-function) ; this was commented out | |
601 (byte-defop 76 -1 byte-set) | |
602 (byte-defop 77 -1 byte-fset) ; this was commented out | |
603 (byte-defop 78 -1 byte-get) | |
5089
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
604 (byte-defop 79 -2 byte-subseq) |
428 | 605 (byte-defop 80 -1 byte-concat2) |
606 (byte-defop 81 -2 byte-concat3) | |
607 (byte-defop 82 -3 byte-concat4) | |
608 (byte-defop 83 0 byte-sub1) | |
609 (byte-defop 84 0 byte-add1) | |
610 (byte-defop 85 -1 byte-eqlsign) | |
611 (byte-defop 86 -1 byte-gtr) | |
612 (byte-defop 87 -1 byte-lss) | |
613 (byte-defop 88 -1 byte-leq) | |
614 (byte-defop 89 -1 byte-geq) | |
615 (byte-defop 90 -1 byte-diff) | |
616 (byte-defop 91 0 byte-negate) | |
617 (byte-defop 92 -1 byte-plus) | |
618 (byte-defop 93 -1 byte-max) | |
619 (byte-defop 94 -1 byte-min) | |
620 (byte-defop 95 -1 byte-mult) | |
621 (byte-defop 96 1 byte-point) | |
622 (byte-defop 97 -1 byte-eq) ; new as of v20 | |
623 (byte-defop 98 0 byte-goto-char) | |
624 (byte-defop 99 0 byte-insert) | |
625 (byte-defop 100 1 byte-point-max) | |
626 (byte-defop 101 1 byte-point-min) | |
627 (byte-defop 102 0 byte-char-after) | |
628 (byte-defop 103 1 byte-following-char) | |
629 (byte-defop 104 1 byte-preceding-char) | |
630 (byte-defop 105 1 byte-current-column) | |
631 (byte-defop 106 0 byte-indent-to) | |
632 (byte-defop 107 -1 byte-equal) ; new as of v20 | |
633 (byte-defop 108 1 byte-eolp) | |
634 (byte-defop 109 1 byte-eobp) | |
635 (byte-defop 110 1 byte-bolp) | |
636 (byte-defop 111 1 byte-bobp) | |
637 (byte-defop 112 1 byte-current-buffer) | |
638 (byte-defop 113 0 byte-set-buffer) | |
639 (byte-defop 114 0 byte-save-current-buffer | |
640 "To make a binding to record the current buffer.") | |
641 ;;(byte-defop 114 1 byte-read-char-OBSOLETE) ;obsolete as of v19 | |
642 (byte-defop 115 -1 byte-memq) ; new as of v20 | |
643 (byte-defop 116 1 byte-interactive-p) | |
644 | |
645 (byte-defop 117 0 byte-forward-char) | |
646 (byte-defop 118 0 byte-forward-word) | |
647 (byte-defop 119 -1 byte-skip-chars-forward) | |
648 (byte-defop 120 -1 byte-skip-chars-backward) | |
649 (byte-defop 121 0 byte-forward-line) | |
650 (byte-defop 122 0 byte-char-syntax) | |
651 (byte-defop 123 -1 byte-buffer-substring) | |
652 (byte-defop 124 -1 byte-delete-region) | |
653 (byte-defop 125 -1 byte-narrow-to-region) | |
654 (byte-defop 126 1 byte-widen) | |
655 (byte-defop 127 0 byte-end-of-line) | |
656 | |
657 ;; unused: 128 | |
658 | |
659 ;; These store their argument in the next two bytes | |
660 (byte-defop 129 1 byte-constant2 | |
661 "for reference to a constant with vector index >= byte-constant-limit") | |
662 (byte-defop 130 0 byte-goto "for unconditional jump") | |
663 (byte-defop 131 -1 byte-goto-if-nil "to pop value and jump if it's nil") | |
664 (byte-defop 132 -1 byte-goto-if-not-nil | |
665 "to pop value and jump if it's not nil") | |
666 (byte-defop 133 -1 byte-goto-if-nil-else-pop | |
667 "to examine top-of-stack, jump and don't pop it if it's nil, | |
668 otherwise pop it") | |
669 (byte-defop 134 -1 byte-goto-if-not-nil-else-pop | |
670 "to examine top-of-stack, jump and don't pop it if it's non-nil, | |
671 otherwise pop it") | |
672 | |
673 (byte-defop 135 -1 byte-return "to pop a value and return it from `byte-code'") | |
674 (byte-defop 136 -1 byte-discard "to discard one value from stack") | |
675 (byte-defop 137 1 byte-dup "to duplicate the top of the stack") | |
676 | |
677 (byte-defop 138 0 byte-save-excursion | |
678 "to make a binding to record the buffer, point and mark") | |
4775
1d61580e0cf7
Remove Fsave_window_excursion from window.c, it's overridden by Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4743
diff
changeset
|
679 (byte-defop 139 0 byte-save-window-excursion ; almost obsolete |
428 | 680 "to make a binding to record entire window configuration") |
681 (byte-defop 140 0 byte-save-restriction | |
682 "to make a binding to record the current buffer clipping restrictions") | |
683 (byte-defop 141 -1 byte-catch | |
684 "for catch. Takes, on stack, the tag and an expression for the body") | |
685 (byte-defop 142 -1 byte-unwind-protect | |
686 "for unwind-protect. Takes, on stack, an expression for the unwind-action") | |
687 | |
688 ;; For condition-case. Takes, on stack, the variable to bind, | |
689 ;; an expression for the body, and a list of clauses. | |
690 (byte-defop 143 -2 byte-condition-case) | |
691 | |
692 ;; For entry to with-output-to-temp-buffer. | |
693 ;; Takes, on stack, the buffer name. | |
694 ;; Binds standard-output and does some other things. | |
695 ;; Returns with temp buffer on the stack in place of buffer name. | |
696 (byte-defop 144 0 byte-temp-output-buffer-setup) | |
697 | |
698 ;; For exit from with-output-to-temp-buffer. | |
699 ;; Expects the temp buffer on the stack underneath value to return. | |
700 ;; Pops them both, then pushes the value back on. | |
701 ;; Unbinds standard-output and makes the temp buffer visible. | |
702 (byte-defop 145 -1 byte-temp-output-buffer-show) | |
703 | |
704 ;; To unbind back to the beginning of this frame. | |
705 ;; Not used yet, but will be needed for tail-recursion elimination. | |
706 (byte-defop 146 0 byte-unbind-all) | |
707 | |
708 (byte-defop 147 -2 byte-set-marker) | |
709 (byte-defop 148 0 byte-match-beginning) | |
710 (byte-defop 149 0 byte-match-end) | |
711 (byte-defop 150 0 byte-upcase) | |
712 (byte-defop 151 0 byte-downcase) | |
713 (byte-defop 152 -1 byte-string=) | |
714 (byte-defop 153 -1 byte-string<) | |
715 (byte-defop 154 -1 byte-old-equal) | |
716 (byte-defop 155 -1 byte-nthcdr) | |
717 (byte-defop 156 -1 byte-elt) | |
718 (byte-defop 157 -1 byte-old-member) | |
719 (byte-defop 158 -1 byte-old-assq) | |
720 (byte-defop 159 0 byte-nreverse) | |
721 (byte-defop 160 -1 byte-setcar) | |
722 (byte-defop 161 -1 byte-setcdr) | |
723 (byte-defop 162 0 byte-car-safe) | |
724 (byte-defop 163 0 byte-cdr-safe) | |
725 (byte-defop 164 -1 byte-nconc) | |
726 (byte-defop 165 -1 byte-quo) | |
727 (byte-defop 166 -1 byte-rem) | |
728 (byte-defop 167 0 byte-numberp) | |
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
729 (byte-defop 168 0 byte-fixnump) |
428 | 730 |
731 ;; unused: 169 | |
732 | |
733 ;; These are not present in FSF. | |
734 ;; | |
735 (byte-defop 170 0 byte-rel-goto) | |
736 (byte-defop 171 -1 byte-rel-goto-if-nil) | |
737 (byte-defop 172 -1 byte-rel-goto-if-not-nil) | |
738 (byte-defop 173 -1 byte-rel-goto-if-nil-else-pop) | |
739 (byte-defop 174 -1 byte-rel-goto-if-not-nil-else-pop) | |
740 | |
741 (byte-defop 175 nil byte-listN) | |
742 (byte-defop 176 nil byte-concatN) | |
743 (byte-defop 177 nil byte-insertN) | |
744 | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
745 (byte-defop 178 1 byte-bind-multiple-value-limits) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
746 (byte-defop 179 -3 byte-multiple-value-list-internal) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
747 (byte-defop 180 0 byte-multiple-value-call) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
748 (byte-defop 181 -1 byte-throw) |
428 | 749 |
750 ;; these ops are new to v20 | |
751 (byte-defop 182 -1 byte-member) | |
752 (byte-defop 183 -1 byte-assq) | |
753 | |
754 ;; unused: 184-191 | |
755 | |
756 (byte-defop 192 1 byte-constant "for reference to a constant") | |
757 ;; codes 193-255 are consumed by byte-constant. | |
758 (defconst byte-constant-limit 64 | |
759 "Exclusive maximum index usable in the `byte-constant' opcode.") | |
760 | |
444 | 761 (defconst byte-goto-ops |
762 '(byte-goto byte-goto-if-nil byte-goto-if-not-nil | |
763 byte-goto-if-nil-else-pop | |
764 byte-goto-if-not-nil-else-pop) | |
428 | 765 "List of byte-codes whose offset is a pc.") |
766 | |
767 (defconst byte-goto-always-pop-ops | |
444 | 768 '(byte-goto-if-nil byte-goto-if-not-nil)) |
428 | 769 |
770 (defconst byte-rel-goto-ops | |
444 | 771 '(byte-rel-goto byte-rel-goto-if-nil byte-rel-goto-if-not-nil |
772 byte-rel-goto-if-nil-else-pop byte-rel-goto-if-not-nil-else-pop) | |
428 | 773 "byte-codes for relative jumps.") |
774 | |
775 (byte-extrude-byte-code-vectors) | |
776 | |
777 ;;; lapcode generator | |
778 ;;; | |
779 ;;; the byte-compiler now does source -> lapcode -> bytecode instead of | |
780 ;;; source -> bytecode, because it's a lot easier to make optimizations | |
781 ;;; on lapcode than on bytecode. | |
782 ;;; | |
783 ;;; Elements of the lapcode list are of the form (<instruction> . <parameter>) | |
784 ;;; where instruction is a symbol naming a byte-code instruction, | |
785 ;;; and parameter is an argument to that instruction, if any. | |
786 ;;; | |
787 ;;; The instruction can be the pseudo-op TAG, which means that this position | |
788 ;;; in the instruction stream is a target of a goto. (car PARAMETER) will be | |
789 ;;; the PC for this location, and the whole instruction "(TAG pc)" will be the | |
790 ;;; parameter for some goto op. | |
791 ;;; | |
792 ;;; If the operation is varbind, varref, varset or push-constant, then the | |
793 ;;; parameter is (variable/constant . index_in_constant_vector). | |
794 ;;; | |
795 ;;; First, the source code is macroexpanded and optimized in various ways. | |
796 ;;; Then the resultant code is compiled into lapcode. Another set of | |
797 ;;; optimizations are then run over the lapcode. Then the variables and | |
798 ;;; constants referenced by the lapcode are collected and placed in the | |
799 ;;; constants-vector. (This happens now so that variables referenced by dead | |
800 ;;; code don't consume space.) And finally, the lapcode is transformed into | |
801 ;;; compacted byte-code. | |
802 ;;; | |
803 ;;; A distinction is made between variables and constants because the variable- | |
804 ;;; referencing instructions are more sensitive to the variables being near the | |
805 ;;; front of the constants-vector than the constant-referencing instructions. | |
806 ;;; Also, this lets us notice references to free variables. | |
807 | |
808 (defun byte-compile-lapcode (lap) | |
809 "Turns lapcode into bytecode. The lapcode is destroyed." | |
810 ;; Lapcode modifications: changes the ID of a tag to be the tag's PC. | |
811 (let ((pc 0) ; Program counter | |
812 op off ; Operation & offset | |
813 (bytes '()) ; Put the output bytes here | |
814 (patchlist nil) ; List of tags and goto's to patch | |
815 rest rel tmp) | |
816 (while lap | |
817 (setq op (car (car lap)) | |
818 off (cdr (car lap))) | |
819 (cond ((not (symbolp op)) | |
820 (error "Non-symbolic opcode `%s'" op)) | |
821 ((eq op 'TAG) | |
822 (setcar off pc) | |
823 (push off patchlist)) | |
824 ((memq op byte-goto-ops) | |
825 (setq pc (+ pc 3)) | |
826 (setq bytes (cons (cons pc (cdr off)) | |
827 (cons nil | |
828 (cons (symbol-value op) bytes)))) | |
829 (push bytes patchlist)) | |
830 (t | |
831 (setq bytes | |
832 (cond ((cond ((consp off) | |
833 ;; Variable or constant reference | |
834 (setq off (cdr off)) | |
835 (eq op 'byte-constant))) | |
836 (cond ((< off byte-constant-limit) | |
837 (setq pc (1+ pc)) | |
838 (cons (+ byte-constant off) bytes)) | |
839 (t | |
840 (setq pc (+ 3 pc)) | |
841 (cons (lsh off -8) | |
842 (cons (logand off 255) | |
843 (cons byte-constant2 bytes)))))) | |
844 ((and (<= byte-listN (symbol-value op)) | |
845 (<= (symbol-value op) byte-insertN)) | |
846 (setq pc (+ 2 pc)) | |
847 (cons off (cons (symbol-value op) bytes))) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
848 ((= byte-multiple-value-call (symbol-value op)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
849 (setq pc (1+ pc)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
850 ;; Ignore off. |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
851 (cons (symbol-value op) bytes)) |
428 | 852 ((< off 6) |
853 (setq pc (1+ pc)) | |
854 (cons (+ (symbol-value op) off) bytes)) | |
855 ((< off 256) | |
856 (setq pc (+ 2 pc)) | |
857 (cons off (cons (+ (symbol-value op) 6) bytes))) | |
858 (t | |
859 (setq pc (+ 3 pc)) | |
860 (cons (lsh off -8) | |
861 (cons (logand off 255) | |
862 (cons (+ (symbol-value op) 7) | |
863 bytes)))))))) | |
864 (setq lap (cdr lap))) | |
865 ;;(if (not (= pc (length bytes))) | |
866 ;; (error "Compiler error: pc mismatch - %s %s" pc (length bytes))) | |
867 (cond (t ;; starting with Emacs 19. | |
868 ;; Make relative jumps | |
869 (setq patchlist (nreverse patchlist)) | |
870 (while (progn | |
871 (setq off 0) ; PC change because of deleted bytes | |
872 (setq rest patchlist) | |
873 (while rest | |
874 (setq tmp (car rest)) | |
875 (and (consp (car tmp)) ; Jump | |
876 (prog1 (null (nth 1 tmp)) ; Absolute jump | |
877 (setq tmp (car tmp))) | |
878 (progn | |
879 (setq rel (- (car (cdr tmp)) (car tmp))) | |
880 (and (<= -129 rel) (< rel 128))) | |
881 (progn | |
882 ;; Convert to relative jump. | |
883 (setcdr (car rest) (cdr (cdr (car rest)))) | |
884 (setcar (cdr (car rest)) | |
885 (+ (car (cdr (car rest))) | |
886 (- byte-rel-goto byte-goto))) | |
887 (setq off (1- off)))) | |
888 (setcar tmp (+ (car tmp) off)) ; Adjust PC | |
889 (setq rest (cdr rest))) | |
890 ;; If optimizing, repeat until no change. | |
891 (and byte-optimize | |
892 (not (zerop off))))))) | |
893 ;; Patch PC into jumps | |
894 (let (bytes) | |
895 (while patchlist | |
896 (setq bytes (car patchlist)) | |
897 (cond ((atom (car bytes))) ; Tag | |
898 ((nth 1 bytes) ; Relative jump | |
899 (setcar bytes (+ (- (car (cdr (car bytes))) (car (car bytes))) | |
900 128))) | |
901 (t ; Absolute jump | |
902 (setq pc (car (cdr (car bytes)))) ; Pick PC from tag | |
903 (setcar (cdr bytes) (logand pc 255)) | |
904 (setcar bytes (lsh pc -8)))) | |
905 (setq patchlist (cdr patchlist)))) | |
906 (concat (nreverse bytes)))) | |
907 | |
908 | |
909 ;;; byte compiler messages | |
910 | |
911 (defvar byte-compile-current-form nil) | |
912 (defvar byte-compile-current-file nil) | |
913 (defvar byte-compile-dest-file nil) | |
914 | |
915 (defmacro byte-compile-log (format-string &rest args) | |
916 `(when (and byte-optimize (memq byte-optimize-log '(t source))) | |
917 (let ((print-escape-newlines t) | |
918 (print-level 4) | |
919 (print-length 4)) | |
920 (byte-compile-log-1 (format ,format-string ,@args))))) | |
921 | |
922 (defconst byte-compile-last-warned-form 'nothing) | |
923 | |
924 ;; Log a message STRING in *Compile-Log*. | |
925 ;; Also log the current function and file if not already done. | |
926 (defun byte-compile-log-1 (string &optional fill) | |
927 (let* ((this-form (or byte-compile-current-form "toplevel forms")) | |
928 (while-compiling-msg | |
929 (when (or byte-compile-current-file | |
930 (not (eq this-form byte-compile-last-warned-form))) | |
931 (format | |
932 "While compiling %s%s:" | |
933 this-form | |
934 (cond | |
935 ((stringp byte-compile-current-file) | |
936 (concat " in file " byte-compile-current-file)) | |
937 ((bufferp byte-compile-current-file) | |
938 (concat " in buffer " | |
939 (buffer-name byte-compile-current-file))) | |
940 ("")))))) | |
941 (if noninteractive | |
942 (progn | |
943 (when while-compiling-msg (message "%s" while-compiling-msg)) | |
944 (message " %s" string)) | |
945 (with-current-buffer (get-buffer-create "*Compile-Log*") | |
946 (goto-char (point-max)) | |
947 (when byte-compile-current-file | |
948 (when (> (point-max) (point-min)) | |
949 (insert "\n\^L\n")) | |
950 (insert (current-time-string) "\n")) | |
951 (when while-compiling-msg (insert while-compiling-msg "\n")) | |
952 (insert " " string "\n") | |
953 (when (and fill (not (string-match "\n" string))) | |
954 (let ((fill-prefix " ") | |
955 (fill-column 78)) | |
956 (fill-paragraph nil))))) | |
957 (setq byte-compile-current-file nil) | |
958 (setq byte-compile-last-warned-form this-form))) | |
959 | |
960 ;; Log the start of a file in *Compile-Log*, and mark it as done. | |
961 ;; But do nothing in batch mode. | |
962 (defun byte-compile-log-file () | |
963 (when (and byte-compile-current-file (not noninteractive)) | |
964 (with-current-buffer (get-buffer-create "*Compile-Log*") | |
965 (when (> (point-max) (point-min)) | |
966 (goto-char (point-max)) | |
967 (insert "\n\^L\n")) | |
968 (insert "Compiling " | |
969 (if (stringp byte-compile-current-file) | |
970 (concat "file " byte-compile-current-file) | |
971 (concat "buffer " (buffer-name byte-compile-current-file))) | |
972 " at " (current-time-string) "\n") | |
973 (setq byte-compile-current-file nil)))) | |
974 | |
502 | 975 (defvar byte-compile-inbuffer) |
976 (defvar byte-compile-outbuffer) | |
977 | |
428 | 978 (defun byte-compile-warn (format &rest args) |
979 (setq format (apply 'format format args)) | |
980 (if byte-compile-error-on-warn | |
981 (error "%s" format) ; byte-compile-file catches and logs it | |
982 (byte-compile-log-1 (concat "** " format) t) | |
502 | 983 |
984 ;; This was a first attempt to add line numbers to the | |
985 ;; byte-compilation output. Unfortunately, it doesn't work | |
986 ;; perfectly: it reports the line number at the end of the form | |
987 ;; (which may be an entire function), rather than the line number | |
988 ;; of the actual problem. Doing this right is hard because we | |
989 ;; currently use the built-in Lisp parser to parse the entire form | |
990 ;; at once. What we basically need is a whole separate parser | |
991 ;; that annotates its output with line numbers. For example, we | |
992 ;; might modify the parser in lread.c so that, with the right | |
993 ;; option set, it replaces every Lisp object contained in the | |
994 ;; structure it returns with a cons of that object and the line | |
995 ;; number it was found on (determined by counting newlines, | |
996 ;; starting from some arbitrary point). You then have two | |
997 ;; options: (a) Modify the byte compiler so that everything that | |
998 ;; compiles a form deals with the new annotated form rather than | |
999 ;; the old one, or (b) The byte compiler saves this structure | |
1000 ;; while converting it into a normal structure that's given to the | |
1001 ;; various form handlers, which need no (or less) modification. | |
1002 ;; In the former case, finding the line number is trivial because | |
1003 ;; it's in the form. In the latter case, finding the line number | |
1004 ;; depends on having a unique Lisp object that can be looked up in | |
1005 ;; the annotated structure -- i.e. a list, vector, or string. | |
1006 ;; You'd have to look at the various places where errors are spit | |
1007 ;; out (not very many, really), and make sure that such a unique | |
1008 ;; object is available. Then you do a depth-first search through | |
1009 ;; the annotated structure to find the object. | |
1010 ;; | |
1011 ;; An alternative way of doing (b) that's probably much more | |
1012 ;; efficient (and easier to implement) is simply to have the | |
1013 ;; parser in lread.c annotate every unique object using a separate | |
1014 ;; hash table. This also eliminates the need for a search to find | |
1015 ;; the line number. In order to be fine-grained enough to get at | |
1016 ;; every symbol in a form -- e.g. if we want to pinpoint a | |
1017 ;; particular undefined variable in a function call -- we need to | |
1018 ;; annotate every cons, not just each list. We still have | |
1019 ;; (probably unimportant) problems with vectors, since all we have | |
1020 ;; is the start of the vector. If we cared about this, we could | |
1021 ;; store in the hash table a list of the line numbers for each | |
1022 ;; item in the vector, not just its start. | |
1023 ;; | |
1024 ;; --ben | |
1025 | |
1026 ; (byte-compile-log-1 (concat "** line: " | |
1027 ; (save-excursion | |
1028 ; (set-buffer byte-compile-inbuffer) | |
1029 ; (int-to-string (line-number))) | |
1030 ; " " | |
1031 ; format) t) | |
428 | 1032 ;;; RMS says: |
1033 ;;; It is useless to flash warnings too fast to be read. | |
1034 ;;; Besides, they will all be shown at the end. | |
1035 ;;; and comments out the next two lines. | |
1036 (or noninteractive ; already written on stdout. | |
1037 (message "Warning: %s" format)))) | |
1038 | |
1039 ;;; This function should be used to report errors that have halted | |
1040 ;;; compilation of the current file. | |
1041 (defun byte-compile-report-error (error-info) | |
1042 (setq byte-compiler-error-flag t) | |
1043 (byte-compile-log-1 | |
1044 (concat "!! " | |
1045 (format (if (cdr error-info) "%s (%s)" "%s") | |
1046 (get (car error-info) 'error-message) | |
442 | 1047 (prin1-to-string (cdr error-info))))) |
1048 (if stack-trace-on-error | |
1049 (backtrace nil t))) | |
428 | 1050 |
1051 ;;; Used by make-obsolete. | |
1052 (defun byte-compile-obsolete (form) | |
1053 (let ((new (get (car form) 'byte-obsolete-info))) | |
1054 (if (memq 'obsolete byte-compile-warnings) | |
1055 (byte-compile-warn "%s is an obsolete function; %s" (car form) | |
1056 (if (stringp (car new)) | |
1057 (car new) | |
1058 (format "use %s instead." (car new))))) | |
1059 (funcall (or (cdr new) 'byte-compile-normal-call) form))) | |
1060 | |
1061 ;;; Used by make-obsolete. | |
1062 (defun byte-compile-compatible (form) | |
1063 (let ((new (get (car form) 'byte-compatible-info))) | |
1064 (if (memq 'pedantic byte-compile-warnings) | |
1065 (byte-compile-warn "%s is provided for compatibility; %s" (car form) | |
1066 (if (stringp (car new)) | |
1067 (car new) | |
1068 (format "use %s instead." (car new))))) | |
1069 (funcall (or (cdr new) 'byte-compile-normal-call) form))) | |
1070 | |
1071 ;; Compiler options | |
1072 | |
1073 (defconst byte-compiler-legal-options | |
1074 '((optimize byte-optimize (t nil source byte) val) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
1075 (file-format byte-compile-emacs19-compatibility (emacs20) |
428 | 1076 (eq val 'emacs19)) |
1077 (delete-errors byte-compile-delete-errors (t nil) val) | |
1078 (verbose byte-compile-verbose (t nil) val) | |
1079 (new-bytecodes byte-compile-new-bytecodes (t nil) val) | |
1080 (warnings byte-compile-warnings | |
4719
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
1081 ((callargs subr-callargs redefine free-vars unused-vars |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
1082 unresolved discarded-consing quoted-lambda)) |
428 | 1083 val))) |
1084 | |
1085 ;; XEmacs addition | |
1086 (defconst byte-compiler-obsolete-options | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
1087 '((new-bytecodes t) (byte-compile-emacs19-compatibility nil))) |
428 | 1088 |
1089 (defun byte-compiler-options-handler (&rest args) | |
1090 (let (key val desc choices) | |
1091 (while args | |
1092 (if (or (atom (car args)) (nthcdr 2 (car args)) (null (cdr (car args)))) | |
1093 (error "malformed byte-compiler-option %s" (car args))) | |
1094 (setq key (car (car args)) | |
1095 val (car (cdr (car args))) | |
1096 desc (assq key byte-compiler-legal-options)) | |
1097 (or desc | |
1098 (error "unknown byte-compiler option %s" key)) | |
1099 (if (assq key byte-compiler-obsolete-options) | |
1100 (byte-compile-warn "%s is an obsolete byte-compiler option." key)) | |
1101 (setq choices (nth 2 desc)) | |
1102 (if (consp (car choices)) | |
1103 (let* (this | |
1104 (handler 'cons) | |
1105 (var (nth 1 desc)) | |
1106 (ret (and (memq (car val) '(+ -)) | |
1107 (copy-sequence (if (eq t (symbol-value var)) | |
1108 (car choices) | |
1109 (symbol-value var)))))) | |
1110 (setq choices (car choices)) | |
1111 (while val | |
1112 (setq this (car val)) | |
1113 (cond ((memq this choices) | |
1114 (setq ret (funcall handler this ret))) | |
1115 ((eq this '+) (setq handler 'cons)) | |
1116 ((eq this '-) (setq handler 'delq)) | |
1117 ((error "%s only accepts %s." key choices))) | |
1118 (setq val (cdr val))) | |
1119 (set (nth 1 desc) ret)) | |
1120 (or (memq val choices) | |
1121 (error "%s must be one of %s." key choices)) | |
1122 (set (nth 1 desc) (eval (nth 3 desc)))) | |
1123 (setq args (cdr args))) | |
1124 nil)) | |
1125 | |
1126 ;;; sanity-checking arglists | |
1127 | |
1128 (defun byte-compile-fdefinition (name macro-p) | |
1129 (let* ((list (if (memq macro-p '(nil subr)) | |
1130 byte-compile-function-environment | |
1131 byte-compile-macro-environment)) | |
1132 (env (cdr (assq name list)))) | |
1133 (or env | |
1134 (let ((fn name)) | |
1135 (while (and (symbolp fn) | |
1136 (fboundp fn) | |
1137 (or (symbolp (symbol-function fn)) | |
1138 (consp (symbol-function fn)) | |
1139 (and (not macro-p) | |
1140 (compiled-function-p (symbol-function fn))) | |
1141 (and (eq macro-p 'subr) (subrp fn)))) | |
1142 (setq fn (symbol-function fn))) | |
1143 (if (or (and (not macro-p) (compiled-function-p fn)) | |
1144 (and (eq macro-p 'subr) (subrp fn))) | |
1145 fn | |
1146 (and (consp fn) | |
1147 (not (eq macro-p 'subr)) | |
1148 (if (eq 'macro (car fn)) | |
1149 (cdr fn) | |
1150 (if macro-p | |
1151 nil | |
1152 (if (eq 'autoload (car fn)) | |
1153 nil | |
1154 fn))))))))) | |
1155 | |
1156 (defun byte-compile-arglist-signature (arglist) | |
1157 (let ((args 0) | |
1158 opts | |
1159 restp) | |
1160 (while arglist | |
1161 (cond ((eq (car arglist) '&optional) | |
1162 (or opts (setq opts 0))) | |
1163 ((eq (car arglist) '&rest) | |
1164 (if (cdr arglist) | |
1165 (setq restp t | |
1166 arglist nil))) | |
1167 (t | |
1168 (if opts | |
1169 (setq opts (1+ opts)) | |
1170 (setq args (1+ args))))) | |
1171 (setq arglist (cdr arglist))) | |
1172 (cons args (if restp nil (if opts (+ args opts) args))))) | |
1173 | |
1174 | |
1175 (defun byte-compile-arglist-signatures-congruent-p (old new) | |
1176 (not (or | |
1177 (> (car new) (car old)) ; requires more args now | |
1178 (and (null (cdr old)) ; tooks rest-args, doesn't any more | |
1179 (cdr new)) | |
1180 (and (cdr new) (cdr old) ; can't take as many args now | |
1181 (< (cdr new) (cdr old))) | |
1182 ))) | |
1183 | |
1184 (defun byte-compile-arglist-signature-string (signature) | |
1185 (cond ((null (cdr signature)) | |
1186 (format "%d+" (car signature))) | |
1187 ((= (car signature) (cdr signature)) | |
1188 (format "%d" (car signature))) | |
1189 (t (format "%d-%d" (car signature) (cdr signature))))) | |
1190 | |
1191 | |
1192 ;; Warn if the form is calling a function with the wrong number of arguments. | |
1193 (defun byte-compile-callargs-warn (form) | |
1194 (let* ((def (or (byte-compile-fdefinition (car form) nil) | |
1195 (byte-compile-fdefinition (car form) t))) | |
1196 (sig (and def (byte-compile-arglist-signature | |
1197 (if (eq 'lambda (car-safe def)) | |
1198 (nth 1 def) | |
1199 (if (compiled-function-p def) | |
1200 (compiled-function-arglist def) | |
1201 '(&rest def)))))) | |
1202 (ncall (length (cdr form)))) | |
1203 (if (and (null def) | |
1204 (fboundp 'subr-min-args) | |
1205 (setq def (byte-compile-fdefinition (car form) 'subr))) | |
1206 (setq sig (cons (subr-min-args def) (subr-max-args def)))) | |
1207 (if sig | |
1208 (if (or (< ncall (car sig)) | |
1209 (and (cdr sig) (> ncall (cdr sig)))) | |
1210 (byte-compile-warn | |
1211 "%s called with %d argument%s, but %s %s" | |
1212 (car form) ncall | |
1213 (if (= 1 ncall) "" "s") | |
1214 (if (< ncall (car sig)) | |
1215 "requires" | |
1216 "accepts only") | |
1217 (byte-compile-arglist-signature-string sig))) | |
1218 (or (fboundp (car form)) ; might be a subr or autoload. | |
1219 ;; ## this doesn't work with recursion. | |
1220 (eq (car form) byte-compile-current-form) | |
1221 ;; It's a currently-undefined function. | |
1222 ;; Remember number of args in call. | |
1223 (let ((cons (assq (car form) byte-compile-unresolved-functions)) | |
1224 (n (length (cdr form)))) | |
1225 (if cons | |
1226 (or (memq n (cdr cons)) | |
1227 (setcdr cons (cons n (cdr cons)))) | |
1228 (setq byte-compile-unresolved-functions | |
1229 (cons (list (car form) n) | |
1230 byte-compile-unresolved-functions)))))))) | |
1231 | |
1232 ;; Warn if the function or macro is being redefined with a different | |
1233 ;; number of arguments. | |
1234 (defun byte-compile-arglist-warn (form macrop) | |
1235 (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) | |
1236 (if old | |
1237 (let ((sig1 (byte-compile-arglist-signature | |
1238 (if (eq 'lambda (car-safe old)) | |
1239 (nth 1 old) | |
1240 (if (compiled-function-p old) | |
1241 (compiled-function-arglist old) | |
1242 '(&rest def))))) | |
1243 (sig2 (byte-compile-arglist-signature (nth 2 form)))) | |
1244 (or (byte-compile-arglist-signatures-congruent-p sig1 sig2) | |
1245 (byte-compile-warn "%s %s used to take %s %s, now takes %s" | |
1246 (if (eq (car form) 'defun) "function" "macro") | |
1247 (nth 1 form) | |
1248 (byte-compile-arglist-signature-string sig1) | |
1249 (if (equal sig1 '(1 . 1)) "argument" "arguments") | |
1250 (byte-compile-arglist-signature-string sig2)))) | |
1251 ;; This is the first definition. See if previous calls are compatible. | |
1252 (let ((calls (assq (nth 1 form) byte-compile-unresolved-functions)) | |
1253 nums sig min max) | |
1254 (if calls | |
1255 (progn | |
1256 (setq sig (byte-compile-arglist-signature (nth 2 form)) | |
1257 nums (sort (copy-sequence (cdr calls)) (function <)) | |
1258 min (car nums) | |
1259 max (car (nreverse nums))) | |
1260 (if (or (< min (car sig)) | |
1261 (and (cdr sig) (> max (cdr sig)))) | |
1262 (byte-compile-warn | |
1263 "%s being defined to take %s%s, but was previously called with %s" | |
1264 (nth 1 form) | |
1265 (byte-compile-arglist-signature-string sig) | |
1266 (if (equal sig '(1 . 1)) " arg" " args") | |
1267 (byte-compile-arglist-signature-string (cons min max)))) | |
1268 | |
1269 (setq byte-compile-unresolved-functions | |
1270 (delq calls byte-compile-unresolved-functions))))) | |
1271 ))) | |
1272 | |
1273 ;; If we have compiled any calls to functions which are not known to be | |
1274 ;; defined, issue a warning enumerating them. | |
1275 ;; `unresolved' in the list `byte-compile-warnings' disables this. | |
1276 (defun byte-compile-warn-about-unresolved-functions (&optional msg) | |
1277 (if (memq 'unresolved byte-compile-warnings) | |
1278 (let ((byte-compile-current-form (or msg "the end of the data"))) | |
1279 ;; First delete the autoloads from the list. | |
1280 (if byte-compile-autoload-environment | |
1281 (let ((rest byte-compile-unresolved-functions)) | |
1282 (while rest | |
1283 (if (assq (car (car rest)) byte-compile-autoload-environment) | |
1284 (setq byte-compile-unresolved-functions | |
1285 (delq (car rest) byte-compile-unresolved-functions))) | |
1286 (setq rest (cdr rest))))) | |
1287 ;; Now warn. | |
1288 (if (cdr byte-compile-unresolved-functions) | |
1289 (let* ((str "The following functions are not known to be defined: ") | |
1290 (L (+ (length str) 5)) | |
1291 (rest (reverse byte-compile-unresolved-functions)) | |
1292 s) | |
1293 (while rest | |
1294 (setq s (symbol-name (car (car rest))) | |
1295 L (+ L (length s) 2) | |
1296 rest (cdr rest)) | |
1297 (if (<= L (1- fill-column)) | |
1298 (setq str (concat str " " s (and rest ","))) | |
1299 (setq str (concat str "\n " s (and rest ",")) | |
1300 L (+ (length s) 4)))) | |
1301 (byte-compile-warn "%s" str)) | |
1302 (if byte-compile-unresolved-functions | |
1303 (byte-compile-warn "the function %s is not known to be defined." | |
1304 (car (car byte-compile-unresolved-functions))))))) | |
1305 nil) | |
1306 | |
1307 (defun byte-compile-defvar-p (var) | |
1308 ;; Whether the byte compiler thinks that non-lexical references to this | |
1309 ;; variable are ok. | |
1310 (or (globally-boundp var) | |
1311 (let ((rest byte-compile-bound-variables)) | |
1312 (while (and rest var) | |
1313 (if (and (eq var (car-safe (car rest))) | |
1314 (not (= 0 (logand (cdr (car rest)) | |
1315 byte-compile-global-bit)))) | |
1316 (setq var nil)) | |
1317 (setq rest (cdr rest))) | |
1318 ;; if var is nil at this point, it's a defvar in this file. | |
444 | 1319 (not var)) |
1320 ;; Perhaps (eval-when-compile (defvar foo)) | |
1321 (and (boundp 'current-load-list) | |
1322 (memq var current-load-list)))) | |
428 | 1323 |
1324 | |
1325 ;;; If we have compiled bindings of variables which have no referents, warn. | |
1326 (defun byte-compile-warn-about-unused-variables () | |
1327 (let ((rest byte-compile-bound-variables) | |
1328 (unreferenced '()) | |
1329 cell) | |
1330 (while (and rest | |
1331 ;; only warn about variables whose lifetime is now ending, | |
1332 ;; that is, variables from the lexical scope that is now | |
1333 ;; terminating. (Think nested lets.) | |
1334 (not (eq (car rest) 'new-scope))) | |
1335 (setq cell (car rest)) | |
1336 (if (and (= 0 (logand byte-compile-referenced-bit (cdr cell))) | |
1337 ;; Don't warn about declared-but-unused arguments, | |
1338 ;; for two reasons: first, the arglist structure | |
1339 ;; might be imposed by external forces, and we don't | |
1340 ;; have (declare (ignore x)) yet; and second, inline | |
1341 ;; expansion produces forms like | |
1342 ;; ((lambda (arg) (byte-code "..." [arg])) x) | |
1343 ;; which we can't (ok, well, don't) recognize as | |
1344 ;; containing a reference to arg, so every inline | |
1345 ;; expansion would generate a warning. (If we had | |
1346 ;; `ignore' then inline expansion could emit an | |
1347 ;; ignore declaration.) | |
1348 (= 0 (logand byte-compile-arglist-bit (cdr cell))) | |
1349 ;; Don't warn about defvars because this is a | |
1350 ;; legitimate special binding. | |
1351 (not (byte-compile-defvar-p (car cell)))) | |
1352 (setq unreferenced (cons (car cell) unreferenced))) | |
1353 (setq rest (cdr rest))) | |
1354 (setq unreferenced (nreverse unreferenced)) | |
1355 (while unreferenced | |
1356 (byte-compile-warn | |
1357 (format "variable %s bound but not referenced" (car unreferenced))) | |
1358 (setq unreferenced (cdr unreferenced))))) | |
1359 | |
1360 | |
1361 (defmacro byte-compile-constant-symbol-p (symbol) | |
1362 `(or (keywordp ,symbol) (memq ,symbol '(nil t)))) | |
1363 | |
1364 (defmacro byte-compile-constp (form) | |
1365 ;; Returns non-nil if FORM is a constant. | |
5282
dcc34e28cd84
Warn at byte-compile in #'the if FORM constant & not TYPE; fix byte-compile-constp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5269
diff
changeset
|
1366 `(cond ((consp ,form) (memq (car ,form) '(quote function))) |
428 | 1367 ((symbolp ,form) (byte-compile-constant-symbol-p ,form)) |
1368 (t))) | |
1369 | |
1370 (defmacro byte-compile-close-variables (&rest body) | |
1371 `(let | |
1372 (;; | |
1373 ;; Close over these variables to encapsulate the | |
1374 ;; compilation state | |
1375 ;; | |
1376 (byte-compile-macro-environment | |
1377 ;; Copy it because the compiler may patch into the | |
1378 ;; macroenvironment. | |
1379 (copy-alist byte-compile-initial-macro-environment)) | |
1380 (byte-compile-function-environment nil) | |
1381 (byte-compile-autoload-environment nil) | |
1382 (byte-compile-unresolved-functions nil) | |
1383 (byte-compile-bound-variables nil) | |
1384 (byte-compile-free-references nil) | |
1385 (byte-compile-free-assignments nil) | |
1386 ;; | |
1387 ;; Close over these variables so that `byte-compiler-options' | |
1388 ;; can change them on a per-file basis. | |
1389 ;; | |
1390 (byte-compile-verbose byte-compile-verbose) | |
1391 (byte-optimize byte-optimize) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1392 (byte-compile-checks-on-load |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1393 byte-compile-checks-on-load) |
428 | 1394 (byte-compile-dynamic byte-compile-dynamic) |
1395 (byte-compile-dynamic-docstrings | |
1396 byte-compile-dynamic-docstrings) | |
1397 (byte-compile-warnings (if (eq byte-compile-warnings t) | |
1398 byte-compile-default-warnings | |
1399 byte-compile-warnings)) | |
1400 (byte-compile-file-domain nil)) | |
1401 (prog1 | |
1402 (progn ,@body) | |
1403 (if (memq 'unused-vars byte-compile-warnings) | |
1404 ;; done compiling in this scope, warn now. | |
1405 (byte-compile-warn-about-unused-variables))))) | |
1406 | |
1407 | |
1408 (defmacro displaying-byte-compile-warnings (&rest body) | |
1409 `(let* ((byte-compile-log-buffer (get-buffer-create "*Compile-Log*")) | |
1410 (byte-compile-point-max-prev (point-max byte-compile-log-buffer))) | |
1411 ;; Log the file name or buffer name. | |
1412 (byte-compile-log-file) | |
1413 ;; Record how much is logged now. | |
1414 ;; We will display the log buffer if anything more is logged | |
1415 ;; before the end of BODY. | |
1416 (defvar byte-compile-warnings-beginning) | |
1417 (let ((byte-compile-warnings-beginning | |
1418 (if (boundp 'byte-compile-warnings-beginning) | |
1419 byte-compile-warnings-beginning | |
1420 (point-max byte-compile-log-buffer)))) | |
1421 | |
1422 (unwind-protect | |
442 | 1423 (call-with-condition-handler |
1424 #'(lambda (error-info) | |
1425 (byte-compile-report-error error-info)) | |
1426 #'(lambda () | |
1427 (progn ,@body))) | |
428 | 1428 ;; Always set point in log to start of interesting output. |
1429 (with-current-buffer byte-compile-log-buffer | |
1430 (let ((show-begin | |
1431 (progn (goto-char byte-compile-point-max-prev) | |
1432 (skip-chars-forward "\^L\n") | |
1433 (point)))) | |
1434 ;; If there were compilation warnings, display them. | |
1435 (if temp-buffer-show-function | |
1436 (let ((show-buffer (get-buffer-create "*Compile-Log-Show*"))) | |
1437 ;; Always clean show-buffer, even when not displaying it, | |
1438 ;; so that misleading previous messages aren't left around. | |
1439 (with-current-buffer show-buffer | |
1440 (setq buffer-read-only nil) | |
1441 (erase-buffer)) | |
1442 (copy-to-buffer show-buffer show-begin (point-max)) | |
1443 (when (< byte-compile-warnings-beginning (point-max)) | |
1444 (funcall temp-buffer-show-function show-buffer))) | |
1445 (when (< byte-compile-warnings-beginning (point-max)) | |
1446 (select-window | |
1447 (prog1 (selected-window) | |
1448 (select-window (display-buffer (current-buffer))) | |
1449 (goto-char show-begin) | |
1450 (recenter 1))))))))))) | |
1451 | |
1452 | |
1453 ;;;###autoload | |
1454 (defun byte-force-recompile (directory) | |
1455 "Recompile every `.el' file in DIRECTORY that already has a `.elc' file. | |
1456 Files in subdirectories of DIRECTORY are processed also." | |
1457 (interactive "DByte force recompile (directory): ") | |
442 | 1458 (byte-recompile-directory directory nil nil t)) |
428 | 1459 |
1460 ;;;###autoload | |
1461 (defun byte-recompile-directory (directory &optional arg norecursion force) | |
1462 "Recompile every `.el' file in DIRECTORY that needs recompilation. | |
1463 This is if a `.elc' file exists but is older than the `.el' file. | |
444 | 1464 Files in subdirectories of DIRECTORY are also processed unless |
1465 optional argument NORECURSION is non-nil. | |
428 | 1466 |
1467 If the `.elc' file does not exist, normally the `.el' file is *not* compiled. | |
1468 But a prefix argument (optional second arg) means ask user, | |
1469 for each such `.el' file, whether to compile it. Prefix argument 0 means | |
1470 don't ask and compile the file anyway. | |
1471 | |
1472 A nonzero prefix argument also means ask about each subdirectory. | |
1473 | |
444 | 1474 If the fourth optional argument FORCE is non-nil, |
428 | 1475 recompile every `.el' file that already has a `.elc' file." |
1476 (interactive "DByte recompile directory: \nP") | |
1477 (if arg | |
1478 (setq arg (prefix-numeric-value arg))) | |
1479 (if noninteractive | |
1480 nil | |
1481 (save-some-buffers) | |
1482 (redraw-modeline)) | |
1483 (let ((directories (list (expand-file-name directory))) | |
1484 (file-count 0) | |
1485 (dir-count 0) | |
1486 last-dir) | |
1487 (displaying-byte-compile-warnings | |
1488 (while directories | |
1489 (setq directory (file-name-as-directory (car directories))) | |
1490 (or noninteractive (message "Checking %s..." directory)) | |
1491 (let ((files (directory-files directory)) | |
1492 source dest) | |
1493 (while files | |
1494 (setq source (expand-file-name (car files) directory)) | |
1495 (if (and (not (member (car files) '("." ".." "RCS" "CVS" "SCCS"))) | |
1496 ;; Stay away from directory back-links, etc: | |
1497 (not (file-symlink-p source)) | |
1498 (file-directory-p source) | |
1499 byte-recompile-directory-recursively) | |
1500 ;; This file is a subdirectory. Handle them differently. | |
1501 (if (or (null arg) | |
1502 (eq arg 0) | |
1503 (y-or-n-p (concat "Check " source "? "))) | |
1504 (setq directories | |
1505 (nconc directories (list source)))) | |
1506 ;; It is an ordinary file. Decide whether to compile it. | |
1507 (if (and (string-match emacs-lisp-file-regexp source) | |
1508 (not (auto-save-file-name-p source)) | |
502 | 1509 ;; make sure not a mule file we can't handle. |
1510 (or (not byte-recompile-ignore-uncompilable-mule-files) | |
1511 (featurep 'mule) | |
1512 (not (find-coding-system-magic-cookie-in-file | |
1513 source))) | |
428 | 1514 (setq dest (byte-compile-dest-file source)) |
1515 (if (file-exists-p dest) | |
1516 ;; File was already compiled. | |
1517 (or force (file-newer-than-file-p source dest)) | |
1518 ;; No compiled file exists yet. | |
1519 (and arg | |
1520 (or (eq 0 arg) | |
1521 (y-or-n-p (concat "Compile " source "? ")))))) | |
1522 (progn ;(if (and noninteractive (not byte-compile-verbose)) | |
1523 ; (message "Compiling %s..." source)) | |
1524 ; we do this in byte-compile-file. | |
1525 (if byte-recompile-directory-ignore-errors-p | |
1526 (batch-byte-compile-1 source) | |
1527 (byte-compile-file source)) | |
1528 (or noninteractive | |
1529 (message "Checking %s..." directory)) | |
1530 (setq file-count (1+ file-count)) | |
1531 (if (not (eq last-dir directory)) | |
1532 (setq last-dir directory | |
1533 dir-count (1+ dir-count))) | |
1534 ))) | |
1535 (setq files (cdr files)))) | |
1536 (setq directories (cdr directories)))) | |
1537 (message "Done (Total of %d file%s compiled%s)" | |
1538 file-count (if (= file-count 1) "" "s") | |
1539 (if (> dir-count 1) (format " in %d directories" dir-count) "")))) | |
1540 | |
1541 ;;;###autoload | |
1542 (defun byte-recompile-file (filename &optional force) | |
1543 "Recompile a file of Lisp code named FILENAME if it needs recompilation. | |
1544 This is if the `.elc' file exists but is older than the `.el' file. | |
1545 | |
1546 If the `.elc' file does not exist, normally the `.el' file is *not* | |
1547 compiled. But a prefix argument (optional second arg) means ask user | |
1548 whether to compile it. Prefix argument 0 don't ask and recompile anyway." | |
1549 (interactive "fByte recompile file: \nP") | |
1550 (let ((dest)) | |
1551 (if (and (string-match emacs-lisp-file-regexp filename) | |
1552 (not (auto-save-file-name-p filename)) | |
1553 (setq dest (byte-compile-dest-file filename)) | |
1554 (if (file-exists-p dest) | |
1555 (file-newer-than-file-p filename dest) | |
1556 (and force | |
1557 (or (eq 0 force) | |
502 | 1558 (y-or-n-p (concat "Compile " filename "? "))))) |
1559 (or (not byte-recompile-ignore-uncompilable-mule-files) | |
1560 (featurep 'mule) | |
1561 (not (find-coding-system-magic-cookie-in-file filename)))) | |
428 | 1562 (byte-compile-file filename)))) |
1563 | |
1564 ;;;###autoload | |
1565 (defun byte-compile-file (filename &optional load) | |
1566 "Compile a file of Lisp code named FILENAME into a file of byte code. | |
1567 The output file's name is made by appending `c' to the end of FILENAME. | |
1568 With prefix arg (noninteractively: 2nd arg), load the file after compiling." | |
1569 ;; (interactive "fByte compile file: \nP") | |
1570 (interactive | |
1571 (let ((file buffer-file-name) | |
1572 (file-name nil) | |
1573 (file-dir nil)) | |
1574 (and file | |
1575 (eq (cdr (assq 'major-mode (buffer-local-variables))) | |
1576 'emacs-lisp-mode) | |
1577 (setq file-name (file-name-nondirectory file) | |
1578 file-dir (file-name-directory file))) | |
1579 (list (read-file-name (if current-prefix-arg | |
1580 "Byte compile and load file: " | |
1581 "Byte compile file: ") | |
1582 file-dir nil nil file-name) | |
1583 current-prefix-arg))) | |
1584 ;; Expand now so we get the current buffer's defaults | |
1585 (setq filename (expand-file-name filename)) | |
1586 | |
1587 ;; If we're compiling a file that's in a buffer and is modified, offer | |
1588 ;; to save it first. | |
1589 (or noninteractive | |
1590 (let ((b (get-file-buffer (expand-file-name filename)))) | |
1591 (if (and b (buffer-modified-p b) | |
1592 (y-or-n-p (format "save buffer %s first? " (buffer-name b)))) | |
1593 (save-excursion (set-buffer b) (save-buffer))))) | |
1594 | |
1595 (if (or noninteractive byte-compile-verbose) ; XEmacs change | |
1596 (message "Compiling %s..." filename)) | |
1597 (let (;;(byte-compile-current-file (file-name-nondirectory filename)) | |
1598 (byte-compile-current-file filename) | |
1599 target-file input-buffer output-buffer | |
1600 byte-compile-dest-file) | |
1601 (setq target-file (byte-compile-dest-file filename)) | |
1602 (setq byte-compile-dest-file target-file) | |
1603 (save-excursion | |
1604 (setq input-buffer (get-buffer-create " *Compiler Input*")) | |
1605 (set-buffer input-buffer) | |
1606 (erase-buffer) | |
1607 (insert-file-contents filename) | |
1608 ;; Run hooks including the uncompression hook. | |
1609 ;; If they change the file name, then change it for the output also. | |
1610 (let ((buffer-file-name filename) | |
1611 (default-major-mode 'emacs-lisp-mode) | |
1612 (enable-local-eval nil)) | |
1613 (normal-mode) | |
1614 (setq filename buffer-file-name))) | |
1615 (setq byte-compiler-error-flag nil) | |
1616 ;; It is important that input-buffer not be current at this call, | |
1617 ;; so that the value of point set in input-buffer | |
1618 ;; within byte-compile-from-buffer lingers in that buffer. | |
1619 (setq output-buffer (byte-compile-from-buffer input-buffer filename)) | |
1620 (if byte-compiler-error-flag | |
1621 nil | |
1622 (if byte-compile-verbose | |
1623 (message "Compiling %s...done" filename)) | |
1624 (kill-buffer input-buffer) | |
1625 (save-excursion | |
1626 (set-buffer output-buffer) | |
1627 (goto-char (point-max)) | |
1628 (insert "\n") ; aaah, unix. | |
1629 (setq target-file (byte-compile-dest-file filename)) | |
1630 (unless byte-compile-overwrite-file | |
1631 (ignore-file-errors (delete-file target-file))) | |
1632 (if (file-writable-p target-file) | |
4529
6f41fb7f3a65
Protect .elc encoding from latin-unity.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4392
diff
changeset
|
1633 ;; prevent generic hooks from changing our format, eg, |
6f41fb7f3a65
Protect .elc encoding from latin-unity.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4392
diff
changeset
|
1634 ;; latin-unity is known to change the coding system! |
6f41fb7f3a65
Protect .elc encoding from latin-unity.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4392
diff
changeset
|
1635 (let ((write-region-pre-hook nil)) |
6f41fb7f3a65
Protect .elc encoding from latin-unity.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4392
diff
changeset
|
1636 (write-region 1 (point-max) target-file)) |
428 | 1637 ;; This is just to give a better error message than write-region |
1638 (signal 'file-error | |
1639 (list "Opening output file" | |
1640 (if (file-exists-p target-file) | |
1641 "cannot overwrite file" | |
1642 "directory not writable or nonexistent") | |
1643 target-file))) | |
1644 (or byte-compile-overwrite-file | |
1645 (condition-case () | |
1646 (set-file-modes target-file (file-modes filename)) | |
1647 (error nil))) | |
1648 (kill-buffer (current-buffer))) | |
1649 (if (and byte-compile-generate-call-tree | |
1650 (or (eq t byte-compile-generate-call-tree) | |
1651 (y-or-n-p (format "Report call tree for %s? " filename)))) | |
1652 (save-excursion | |
1653 (display-call-tree filename))) | |
1654 (if load | |
1655 (load target-file)) | |
1656 t))) | |
1657 | |
1658 ;; RMS comments the next two out. | |
1659 | |
1660 ;;;###autoload | |
1661 (defun byte-compile-and-load-file (&optional filename) | |
1662 "Compile a file of Lisp code named FILENAME into a file of byte code, | |
1663 and then load it. The output file's name is made by appending \"c\" to | |
1664 the end of FILENAME." | |
1665 (interactive) | |
1666 (if filename ; I don't get it, (interactive-p) doesn't always work | |
1667 (byte-compile-file filename t) | |
1668 (let ((current-prefix-arg '(4))) | |
1669 (call-interactively 'byte-compile-file)))) | |
1670 | |
1671 ;;;###autoload | |
1672 (defun byte-compile-buffer (&optional buffer) | |
1673 "Byte-compile and evaluate contents of BUFFER (default: the current buffer)." | |
1674 (interactive "bByte compile buffer: ") | |
1675 (setq buffer (if buffer (get-buffer buffer) (current-buffer))) | |
1676 (message "Compiling %s..." buffer) | |
1677 (let* ((filename (or (buffer-file-name buffer) | |
1678 (prin1-to-string buffer))) | |
1679 (byte-compile-current-file buffer)) | |
1680 (byte-compile-from-buffer buffer filename t)) | |
1681 (message "Compiling %s...done" buffer) | |
1682 t) | |
1683 | |
1684 ;;; compiling a single function | |
1685 ;;;###autoload | |
1686 (defun compile-defun (&optional arg) | |
1687 "Compile and evaluate the current top-level form. | |
1688 Print the result in the minibuffer. | |
1689 With argument, insert value in current buffer after the form." | |
1690 (interactive "P") | |
1691 (save-excursion | |
1692 (end-of-defun) | |
1693 (beginning-of-defun) | |
1694 (let* ((byte-compile-current-file (buffer-file-name)) | |
1695 (load-file-name (buffer-file-name)) | |
1696 (byte-compile-last-warned-form 'nothing) | |
1697 (value (eval (displaying-byte-compile-warnings | |
1698 (byte-compile-sexp (read (current-buffer)) | |
1699 "toplevel forms"))))) | |
1700 (cond (arg | |
1701 (message "Compiling from buffer... done.") | |
1702 (prin1 value (current-buffer)) | |
1703 (insert "\n")) | |
1704 ((message "%s" (prin1-to-string value))))))) | |
1705 | |
1706 (defun byte-compile-from-buffer (byte-compile-inbuffer filename &optional eval) | |
1707 ;; buffer --> output-buffer, or buffer --> eval form, return nil | |
1708 (let (byte-compile-outbuffer | |
1709 ;; Prevent truncation of flonums and lists as we read and print them | |
1710 (float-output-format nil) | |
1711 (case-fold-search nil) | |
1712 (print-length nil) | |
1713 (print-level nil) | |
1714 ;; Simulate entry to byte-compile-top-level | |
1715 (byte-compile-constants nil) | |
1716 (byte-compile-variables nil) | |
1717 (byte-compile-tag-number 0) | |
1718 (byte-compile-depth 0) | |
1719 (byte-compile-maxdepth 0) | |
1720 (byte-compile-output nil) | |
1721 ;; #### This is bound in b-c-close-variables. | |
1722 ;; (byte-compile-warnings (if (eq byte-compile-warnings t) | |
1723 ;; byte-compile-warning-types | |
1724 ;; byte-compile-warnings)) | |
4623
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1725 (byte-compile-force-escape-quoted byte-compile-force-escape-quoted) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1726 (byte-compile-using-dynamic nil)) |
428 | 1727 (byte-compile-close-variables |
1728 (save-excursion | |
1729 (setq byte-compile-outbuffer | |
1730 (set-buffer (get-buffer-create " *Compiler Output*"))) | |
1731 (erase-buffer) | |
1732 ;; (emacs-lisp-mode) | |
1733 (setq case-fold-search nil) | |
1734 (and filename | |
1735 (not eval) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1736 (byte-compile-maybe-reset-coding byte-compile-inbuffer |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1737 byte-compile-outbuffer)) |
4623
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1738 (setq byte-compile-using-dynamic |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1739 (or (symbol-value-in-buffer 'byte-compile-dynamic |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1740 byte-compile-inbuffer) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1741 (symbol-value-in-buffer 'byte-compile-dynamic-docstrings |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1742 byte-compile-inbuffer))) |
428 | 1743 ;; This is a kludge. Some operating systems (OS/2, DOS) need to |
1744 ;; write files containing binary information specially. | |
1745 ;; Under most circumstances, such files will be in binary | |
1746 ;; overwrite mode, so those OS's use that flag to guess how | |
1747 ;; they should write their data. Advise them that .elc files | |
1748 ;; need to be written carefully. | |
1749 (setq overwrite-mode 'overwrite-mode-binary)) | |
1750 (displaying-byte-compile-warnings | |
1751 (save-excursion | |
4623
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1752 ;; All our save-excursions may have led to a less-than-useful |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1753 ;; value for point in the outbuffer: |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1754 (goto-char (point-max byte-compile-outbuffer) byte-compile-outbuffer) |
428 | 1755 (set-buffer byte-compile-inbuffer) |
1756 (goto-char 1) | |
1757 | |
1758 ;; Compile the forms from the input buffer. | |
1759 (while (progn | |
1760 (while (progn (skip-chars-forward " \t\n\^L") | |
1761 (looking-at ";")) | |
1762 (forward-line 1)) | |
1763 (not (eobp))) | |
1764 (byte-compile-file-form (read byte-compile-inbuffer))) | |
1765 | |
1766 ;; Compile pending forms at end of file. | |
1767 (byte-compile-flush-pending) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1768 (byte-compile-insert-header filename byte-compile-inbuffer |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1769 byte-compile-outbuffer) |
428 | 1770 (byte-compile-warn-about-unresolved-functions) |
1771 ;; Should we always do this? When calling multiple files, it | |
1772 ;; would be useful to delay this warning until all have | |
1773 ;; been compiled. | |
1774 (setq byte-compile-unresolved-functions nil))) | |
1775 (save-excursion | |
1776 (set-buffer byte-compile-outbuffer) | |
4623
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1777 (goto-char (point-min)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1778 (when (and (or byte-compile-using-dynamic |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1779 (eq buffer-file-coding-system 'raw-text-unix)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1780 (re-search-forward "[^\x00-\xff]" nil t)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1781 (when (or noninteractive byte-compile-verbose) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1782 (message |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1783 "%s: includes char above ?\\xFF, recompiling sans dynamic features." |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1784 filename)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1785 (set-symbol-value-in-buffer 'byte-compile-dynamic nil |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1786 byte-compile-inbuffer) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1787 (set-symbol-value-in-buffer 'byte-compile-dynamic-docstrings nil |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1788 byte-compile-inbuffer) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1789 (setq byte-compile-force-escape-quoted t |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1790 byte-compile-outbuffer |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1791 (byte-compile-from-buffer byte-compile-inbuffer |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1792 filename eval))))) |
428 | 1793 (if (not eval) |
1794 byte-compile-outbuffer | |
1795 (let (form) | |
1796 (while (condition-case nil | |
1797 (progn (setq form (read byte-compile-outbuffer)) | |
1798 t) | |
1799 (end-of-file nil)) | |
1800 (eval form))) | |
1801 (kill-buffer byte-compile-outbuffer) | |
1802 nil))) | |
1803 | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1804 (defvar byte-compile-checks-and-comments-space 475 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1805 "Number of octets of space for checks and comments; used by the dynamic |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1806 docstrings code.") |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1807 |
428 | 1808 (defun byte-compile-insert-header (filename byte-compile-inbuffer |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1809 byte-compile-outbuffer) |
428 | 1810 (set-buffer byte-compile-inbuffer) |
4686
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1811 (let (comments) |
428 | 1812 (set-buffer byte-compile-outbuffer) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1813 (delete-region 1 (1+ byte-compile-checks-and-comments-space)) |
428 | 1814 (goto-char 1) |
1815 ;; | |
1816 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After that is | |
1817 ;; the file-format version number (19 or 20) as a byte, followed by some | |
1818 ;; nulls. The primary motivation for doing this is to get some binary | |
1819 ;; characters up in the first line of the file so that `diff' will simply | |
1820 ;; say "Binary files differ" instead of actually doing a diff of two .elc | |
1821 ;; files. An extra benefit is that you can add this to /etc/magic: | |
1822 ;; | |
613 | 1823 ;; 0 string ;ELC XEmacs Lisp compiled file, |
428 | 1824 ;; >4 byte x version %d |
1825 ;; | |
1826 (insert | |
1827 ";ELC" | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
1828 20 |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1829 "\000\000\000\n") |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1830 (when (not (eq (find-coding-system 'raw-text-unix) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1831 (find-coding-system buffer-file-coding-system))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1832 (insert (format ";;;###coding system: %s\n" |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1833 (coding-system-name buffer-file-coding-system)))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1834 (insert (format |
4686
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1835 "\n(or %s\n (error \"Loading this file requires %s\"))\n" |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1836 (let ((print-readably t)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1837 (prin1-to-string (if (> (length |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1838 byte-compile-checks-on-load) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1839 1) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1840 (cons 'and |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1841 (setq byte-compile-checks-on-load |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1842 (reverse |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1843 byte-compile-checks-on-load))) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1844 (car byte-compile-checks-on-load)))) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1845 (loop |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1846 for check in byte-compile-checks-on-load |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1847 with seen-first = nil |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1848 with res = "" |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1849 do |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1850 (if seen-first |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1851 (setq res (concat res ", ")) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1852 (setq seen-first t)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1853 ;; Print featurep calls differently: |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1854 (if (and (eq (car check) 'featurep) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1855 (eq (car (second check)) 'quote) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1856 (symbolp (second (second check)))) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1857 (setq res (concat res |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1858 (symbol-name (second (second check))))) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1859 (setq res (concat res |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1860 (let ((print-readably t)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1861 (prin1-to-string check))))) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
1862 finally return res))) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1863 (setq comments |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1864 (with-string-as-buffer-contents "" |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1865 (insert "\n;;; compiled by " |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1866 (or (and (boundp 'user-mail-address) user-mail-address) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1867 (concat (user-login-name) "@" (system-name))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1868 " on " |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1869 (current-time-string) "\n;;; from file " filename "\n") |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1870 (insert ";;; emacs version " emacs-version ".\n") |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1871 (insert ";;; bytecomp version " byte-compile-version "\n;;; " |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1872 (cond |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1873 ((eq byte-optimize 'source) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1874 "source-level optimization only") |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1875 ((eq byte-optimize 'byte) "byte-level optimization only") |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1876 (byte-optimize "optimization is on") |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1877 (t "optimization is off")) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1878 "\n"))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1879 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1880 ;; We won't trip this unless the byte-compiler changes, in which case |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1881 ;; it's just a matter of upping the space. |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1882 (assert (natnump (- (1+ byte-compile-checks-and-comments-space) (point))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1883 t "Not enough space for the feature checks!") |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1884 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1885 (if (natnump (- (1+ byte-compile-checks-and-comments-space) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1886 (+ (point) (length comments)))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1887 (insert comments)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1888 (insert-char ?\ (- (1+ byte-compile-checks-and-comments-space) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1889 (point))))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1890 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1891 (defun byte-compile-maybe-reset-coding (byte-compile-inbuffer |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1892 byte-compile-outbuffer) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1893 ;; We also reserve some space for the feature checks: |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1894 (goto-char 1) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1895 (insert-char ?\ byte-compile-checks-and-comments-space) |
771 | 1896 (if (or (featurep '(not mule)) ;; Don't scan buffer if we are not muleized |
4623
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1897 (and |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1898 (not byte-compile-force-escape-quoted) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1899 (save-excursion |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1900 (set-buffer byte-compile-inbuffer) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1901 (goto-char (point-min)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1902 ;; Look for any non-Latin-1 literals or Unicode character |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1903 ;; escapes. Any such occurrences in a @#COUNT comment will lead |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1904 ;; to an escape-quoted coding cookie being inserted, but this is |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1905 ;; not true of ordinary comments. |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1906 (let ((non-latin-1-re |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1907 (concat "[^\000-\377]" |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1908 #r"\|\\u[0-9a-fA-F]\{4,4\}\|\\U[0-9a-fA-F]" |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1909 "\\{8,8\\}")) |
4623
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1910 (case-fold-search nil)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1911 (catch 'need-to-escape-quote |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1912 (while (re-search-forward non-latin-1-re nil t) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1913 (skip-chars-backward "^;" (point-at-bol)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1914 (if (bolp) (throw 'need-to-escape-quote nil)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1915 (forward-line 1)) |
a9f83990e6bf
Fix a byte compiler bug with characters above ?\xFF.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4539
diff
changeset
|
1916 t))))) |
771 | 1917 (setq buffer-file-coding-system 'raw-text-unix) |
1918 (setq buffer-file-coding-system 'escape-quoted) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1919 (pushnew '(featurep 'mule) byte-compile-checks-on-load) |
771 | 1920 (save-excursion |
1921 (set-buffer byte-compile-inbuffer) | |
1922 (setq byte-compile-dynamic nil | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
1923 byte-compile-dynamic-docstrings nil)))) |
428 | 1924 |
1925 (defun byte-compile-output-file-form (form) | |
1926 ;; writes the given form to the output buffer, being careful of docstrings | |
1927 ;; in defun, defmacro, defvar, defconst and autoload because make-docfile is | |
1928 ;; so amazingly stupid. | |
1929 ;; defalias calls are output directly by byte-compile-file-form-defmumble; | |
1930 ;; it does not pay to first build the defalias in defmumble and then parse | |
1931 ;; it here. | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4529
diff
changeset
|
1932 (if (and (memq (car-safe form) '(defun defmacro defvar defconst autoload |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4529
diff
changeset
|
1933 custom-declare-variable)) |
428 | 1934 (stringp (nth 3 form))) |
1935 (byte-compile-output-docform nil nil '("\n(" 3 ")") form nil | |
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4529
diff
changeset
|
1936 (memq (car form) |
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4529
diff
changeset
|
1937 '(autoload custom-declare-variable))) |
428 | 1938 (let ((print-escape-newlines t) |
1939 (print-length nil) | |
1940 (print-level nil) | |
1941 (print-readably t) ; print #[] for bytecode, 'x for (quote x) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
1942 (print-gensym (if byte-compile-print-gensym '(t) nil)) |
4392
e8f448f997ac
bytecomp.el: bind print-gensym-alist to nil even with non-defvar, defun, [...] forms.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4304
diff
changeset
|
1943 print-gensym-alist) |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1944 (when byte-compile-output-preface |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1945 (princ "\n(progn " byte-compile-outbuffer) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1946 (prin1 byte-compile-output-preface byte-compile-outbuffer)) |
428 | 1947 (princ "\n" byte-compile-outbuffer) |
1948 (prin1 form byte-compile-outbuffer) | |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1949 (when byte-compile-output-preface (princ ")" byte-compile-outbuffer)) |
428 | 1950 nil))) |
1951 | |
1952 (defun byte-compile-output-docform (preface name info form specindex quoted) | |
1953 "Print a form with a doc string. INFO is (prefix doc-index postfix). | |
1954 If PREFACE and NAME are non-nil, print them too, | |
1955 before INFO and the FORM but after the doc string itself. | |
1956 If SPECINDEX is non-nil, it is the index in FORM | |
1957 of the function bytecode string. In that case, | |
1958 we output that argument and the following argument (the constants vector) | |
1959 together, for lazy loading. | |
1960 QUOTED says that we have to put a quote before the | |
1961 list that represents a doc string reference. | |
1962 `autoload' needs that." | |
1963 ;; We need to examine byte-compile-dynamic-docstrings | |
1964 ;; in the input buffer (now current), not in the output buffer. | |
1965 (let ((dynamic-docstrings byte-compile-dynamic-docstrings)) | |
1966 (set-buffer | |
1967 (prog1 (current-buffer) | |
1968 (set-buffer byte-compile-outbuffer) | |
1969 (let (position) | |
1970 | |
1971 ;; Insert the doc string, and make it a comment with #@LENGTH. | |
1972 (and (>= (nth 1 info) 0) | |
1973 dynamic-docstrings | |
1974 (progn | |
1975 ;; Make the doc string start at beginning of line | |
1976 ;; for make-docfile's sake. | |
1977 (insert "\n") | |
1978 (setq position | |
1979 (byte-compile-output-as-comment | |
1980 (nth (nth 1 info) form) nil)) | |
1981 ;; If the doc string starts with * (a user variable), | |
1982 ;; negate POSITION. | |
1983 (if (and (stringp (nth (nth 1 info) form)) | |
1984 (> (length (nth (nth 1 info) form)) 0) | |
1985 (char= (aref (nth (nth 1 info) form) 0) ?*)) | |
1986 (setq position (- position))))) | |
1987 (let ((print-escape-newlines t) | |
1988 (print-readably t) ; print #[] for bytecode, 'x for (quote x) | |
1989 ;; Use a cons cell to say that we want | |
1990 ;; print-gensym-alist not to be cleared between calls | |
1991 ;; to print functions. | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
1992 (print-gensym (if byte-compile-print-gensym '(t) nil)) |
428 | 1993 print-gensym-alist |
1994 (index 0)) | |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1995 (when byte-compile-output-preface |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1996 (princ "\n(progn " byte-compile-outbuffer) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1997 (prin1 byte-compile-output-preface byte-compile-outbuffer)) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1998 (byte-compile-flush-pending) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
1999 (if preface |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2000 (progn |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2001 (insert preface) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2002 (prin1 name byte-compile-outbuffer))) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2003 (insert (car info)) |
428 | 2004 (prin1 (car form) byte-compile-outbuffer) |
2005 (while (setq form (cdr form)) | |
2006 (setq index (1+ index)) | |
2007 (insert " ") | |
2008 (cond ((and (numberp specindex) (= index specindex)) | |
2009 (let ((position | |
2010 (byte-compile-output-as-comment | |
2011 (cons (car form) (nth 1 form)) | |
2012 t))) | |
2013 (princ (format "(#$ . %d) nil" position) | |
2014 byte-compile-outbuffer) | |
2015 (setq form (cdr form)) | |
2016 (setq index (1+ index)))) | |
2017 ((= index (nth 1 info)) | |
2018 (if position | |
2019 (princ (format (if quoted "'(#$ . %d)" "(#$ . %d)") | |
2020 position) | |
2021 byte-compile-outbuffer) | |
2022 (let ((print-escape-newlines nil)) | |
2023 (goto-char (prog1 (1+ (point)) | |
2024 (prin1 (car form) | |
2025 byte-compile-outbuffer))) | |
2026 (insert "\\\n") | |
2027 (goto-char (point-max))))) | |
2028 (t | |
2029 (prin1 (car form) byte-compile-outbuffer))))) | |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2030 (insert (nth 2 info)) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2031 (when byte-compile-output-preface |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2032 (princ ")" byte-compile-outbuffer)))))) |
428 | 2033 nil) |
2034 | |
2035 (defvar for-effect) ; ## Kludge! This should be an arg, not a special. | |
2036 | |
2037 (defun byte-compile-keep-pending (form &optional handler) | |
2038 (if (memq byte-optimize '(t source)) | |
2039 (setq form (byte-optimize-form form t))) | |
2040 (if handler | |
2041 (let ((for-effect t)) | |
2042 ;; To avoid consing up monstrously large forms at load time, we split | |
2043 ;; the output regularly. | |
2044 (and (memq (car-safe form) '(fset defalias define-function)) | |
2045 (nthcdr 300 byte-compile-output) | |
2046 (byte-compile-flush-pending)) | |
2047 (funcall handler form) | |
2048 (when for-effect | |
2049 (byte-compile-discard))) | |
2050 (byte-compile-form form t)) | |
2051 nil) | |
2052 | |
2053 (defun byte-compile-flush-pending () | |
2054 (if byte-compile-output | |
2055 (let ((form (byte-compile-out-toplevel t 'file))) | |
2056 (cond ((eq (car-safe form) 'progn) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
2057 (mapc 'byte-compile-output-file-form (cdr form))) |
428 | 2058 (form |
2059 (byte-compile-output-file-form form))) | |
2060 (setq byte-compile-constants nil | |
2061 byte-compile-variables nil | |
2062 byte-compile-depth 0 | |
2063 byte-compile-maxdepth 0 | |
2064 byte-compile-output nil)))) | |
2065 | |
2066 (defun byte-compile-file-form (form) | |
2067 (let ((byte-compile-current-form nil) ; close over this for warnings. | |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2068 (byte-compile-output-preface nil) |
428 | 2069 handler) |
2070 (cond | |
2071 ((not (consp form)) | |
2072 (byte-compile-keep-pending form)) | |
2073 ((and (symbolp (car form)) | |
2074 (setq handler (get (car form) 'byte-hunk-handler))) | |
2075 (cond ((setq form (funcall handler form)) | |
2076 (byte-compile-flush-pending) | |
2077 (byte-compile-output-file-form form)))) | |
2078 ((eq form (setq form (macroexpand form byte-compile-macro-environment))) | |
2079 (byte-compile-keep-pending form)) | |
2080 (t | |
2081 (byte-compile-file-form form))))) | |
2082 | |
2083 ;; Functions and variables with doc strings must be output separately, | |
2084 ;; so make-docfile can recognize them. Most other things can be output | |
2085 ;; as byte-code. | |
2086 | |
2087 (put 'defsubst 'byte-hunk-handler 'byte-compile-file-form-defsubst) | |
2088 (defun byte-compile-file-form-defsubst (form) | |
2089 (cond ((assq (nth 1 form) byte-compile-unresolved-functions) | |
2090 (setq byte-compile-current-form (nth 1 form)) | |
2091 (byte-compile-warn "defsubst %s was used before it was defined" | |
2092 (nth 1 form)))) | |
2093 (byte-compile-file-form | |
2094 (macroexpand form byte-compile-macro-environment)) | |
2095 ;; Return nil so the form is not output twice. | |
2096 nil) | |
2097 | |
2098 (put 'autoload 'byte-hunk-handler 'byte-compile-file-form-autoload) | |
2099 (defun byte-compile-file-form-autoload (form) | |
2100 ;; | |
2101 ;; If this is an autoload of a macro, and all arguments are constants (that | |
2102 ;; is, there is no hairy computation going on here) then evaluate the form | |
2103 ;; at compile-time. This is so that we can make use of macros which we | |
2104 ;; have autoloaded from the file being compiled. Normal function autoloads | |
2105 ;; are not automatically evaluated at compile time, because there's not | |
2106 ;; much point to it (so why bother cluttering up the compile-time namespace.) | |
2107 ;; | |
2108 ;; If this is an autoload of a function, then record its definition in the | |
2109 ;; byte-compile-autoload-environment to suppress any `not known to be | |
2110 ;; defined' warnings at the end of this file (this only matters for | |
2111 ;; functions which are autoloaded and compiled in the same file, if the | |
2112 ;; autoload already exists in the compilation environment, we wouldn't have | |
2113 ;; warned anyway.) | |
2114 ;; | |
2115 (let* ((name (if (byte-compile-constp (nth 1 form)) | |
2116 (eval (nth 1 form)))) | |
2117 ;; In v19, the 5th arg to autoload can be t, nil, 'macro, or 'keymap. | |
2118 (macrop (and (byte-compile-constp (nth 5 form)) | |
2119 (memq (eval (nth 5 form)) '(t macro)))) | |
2120 ;; (functionp (and (byte-compile-constp (nth 5 form)) | |
2121 ;; (eq 'nil (eval (nth 5 form))))) | |
2122 ) | |
2123 (if (and macrop | |
2124 (let ((form form)) | |
2125 ;; all forms are constant | |
2126 (while (if (setq form (cdr form)) | |
2127 (byte-compile-constp (car form)))) | |
2128 (null form))) | |
440 | 2129 ;; eval the macro autoload into the compilation environment |
428 | 2130 (eval form)) |
2131 | |
2132 (if name | |
2133 (let ((old (assq name byte-compile-autoload-environment))) | |
2134 (cond (old | |
2135 (if (memq 'redefine byte-compile-warnings) | |
2136 (byte-compile-warn "multiple autoloads for %s" name)) | |
2137 (setcdr old form)) | |
2138 (t | |
2139 ;; We only use the names in the autoload environment, but | |
2140 ;; it might be useful to have the bodies some day. | |
2141 (setq byte-compile-autoload-environment | |
2142 (cons (cons name form) | |
2143 byte-compile-autoload-environment))))))) | |
2144 ;; | |
2145 ;; Now output the form. | |
2146 (if (stringp (nth 3 form)) | |
2147 form | |
2148 ;; No doc string, so we can compile this as a normal form. | |
2149 (byte-compile-keep-pending form 'byte-compile-normal-call))) | |
2150 | |
442 | 2151 (put 'defvar 'byte-hunk-handler 'byte-compile-file-form-defvar-or-defconst) |
2152 (put 'defconst 'byte-hunk-handler 'byte-compile-file-form-defvar-or-defconst) | |
2153 (defun byte-compile-file-form-defvar-or-defconst (form) | |
2154 ;; (defvar|defconst VAR [VALUE [DOCSTRING]]) | |
428 | 2155 (if (> (length form) 4) |
442 | 2156 (byte-compile-warn |
2157 "%s %s called with %d arguments, but accepts only %s" | |
2158 (car form) (nth 1 form) (length (cdr form)) 3)) | |
428 | 2159 (if (and (> (length form) 3) (not (stringp (nth 3 form)))) |
2160 (byte-compile-warn "Third arg to %s %s is not a string: %s" | |
2161 (car form) (nth 1 form) (nth 3 form))) | |
2162 (if (null (nth 3 form)) | |
2163 ;; Since there is no doc string, we can compile this as a normal form, | |
2164 ;; and not do a file-boundary. | |
2165 (byte-compile-keep-pending form) | |
2166 (if (memq 'free-vars byte-compile-warnings) | |
2167 (setq byte-compile-bound-variables | |
2168 (cons (cons (nth 1 form) byte-compile-global-bit) | |
2169 byte-compile-bound-variables))) | |
2170 (cond ((consp (nth 2 form)) | |
2171 (setq form (copy-sequence form)) | |
2172 (setcar (cdr (cdr form)) | |
2173 (byte-compile-top-level (nth 2 form) nil 'file)))) | |
2174 | |
2175 ;; The following turns out not to be necessary, since we emit a call to | |
2176 ;; defvar, which can hack Vfile_domain by itself! | |
2177 ;; | |
2178 ;; If a file domain has been set, emit (put 'VAR 'variable-domain ...) | |
2179 ;; after this defvar. | |
2180 ; (if byte-compile-file-domain | |
2181 ; (progn | |
2182 ; ;; Actually, this will emit the (put ...) before the (defvar ...) | |
2183 ; ;; but I don't think that can matter in this case. | |
2184 ; (byte-compile-keep-pending | |
2185 ; (list 'put (list 'quote (nth 1 form)) ''variable-domain | |
2186 ; (list 'quote byte-compile-file-domain))))) | |
2187 form)) | |
2188 | |
2189 (put 'require 'byte-hunk-handler 'byte-compile-file-form-eval-boundary) | |
2190 (defun byte-compile-file-form-eval-boundary (form) | |
2191 (eval form) | |
2192 (byte-compile-keep-pending form 'byte-compile-normal-call)) | |
2193 | |
4686
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2194 ;; XEmacs change: be careful about multiple values with these three forms. |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2195 (put 'progn 'byte-hunk-handler |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2196 #'(lambda (form) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2197 (mapc 'byte-compile-file-form (cdr form)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2198 ;; Return nil so the forms are not output twice. |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2199 nil)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2200 |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2201 (put 'prog1 'byte-hunk-handler |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2202 #'(lambda (form) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2203 (when (first form) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2204 (byte-compile-file-form `(or ,(first form) nil)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2205 (mapc 'byte-compile-file-form (cdr form)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2206 nil))) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2207 |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2208 (put 'prog2 'byte-hunk-handler |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2209 #'(lambda (form) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2210 (when (first form) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2211 (byte-compile-file-form (first form)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2212 (when (second form) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2213 (setq form (cdr form)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2214 (byte-compile-file-form `(or ,(first form) nil)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2215 (mapc 'byte-compile-file-form (cdr form)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
2216 nil)))) |
428 | 2217 |
2218 ;; This handler is not necessary, but it makes the output from dont-compile | |
2219 ;; and similar macros cleaner. | |
2220 (put 'eval 'byte-hunk-handler 'byte-compile-file-form-eval) | |
2221 (defun byte-compile-file-form-eval (form) | |
2222 (if (eq (car-safe (nth 1 form)) 'quote) | |
2223 (nth 1 (nth 1 form)) | |
2224 (byte-compile-keep-pending form))) | |
2225 | |
2226 (put 'defun 'byte-hunk-handler 'byte-compile-file-form-defun) | |
2227 (defun byte-compile-file-form-defun (form) | |
2228 (byte-compile-file-form-defmumble form nil)) | |
2229 | |
2230 (put 'defmacro 'byte-hunk-handler 'byte-compile-file-form-defmacro) | |
2231 (defun byte-compile-file-form-defmacro (form) | |
2232 (byte-compile-file-form-defmumble form t)) | |
2233 | |
2234 (defun byte-compile-file-form-defmumble (form macrop) | |
2235 (let* ((name (car (cdr form))) | |
2236 (this-kind (if macrop 'byte-compile-macro-environment | |
2237 'byte-compile-function-environment)) | |
2238 (that-kind (if macrop 'byte-compile-function-environment | |
2239 'byte-compile-macro-environment)) | |
2240 (this-one (assq name (symbol-value this-kind))) | |
2241 (that-one (assq name (symbol-value that-kind))) | |
2242 (byte-compile-free-references nil) | |
2243 (byte-compile-free-assignments nil)) | |
2244 | |
2245 ;; When a function or macro is defined, add it to the call tree so that | |
2246 ;; we can tell when functions are not used. | |
2247 (if byte-compile-generate-call-tree | |
2248 (or (assq name byte-compile-call-tree) | |
2249 (setq byte-compile-call-tree | |
2250 (cons (list name nil nil) byte-compile-call-tree)))) | |
2251 | |
2252 (setq byte-compile-current-form name) ; for warnings | |
2253 (when (memq 'redefine byte-compile-warnings) | |
2254 (byte-compile-arglist-warn form macrop)) | |
2255 (defvar filename) ; #### filename used free | |
2256 (when byte-compile-verbose | |
2257 (message "Compiling %s... (%s)" | |
2258 (if filename (file-name-nondirectory filename) "") | |
2259 (nth 1 form))) | |
2260 (cond (that-one | |
2261 (when (and (memq 'redefine byte-compile-warnings) | |
2262 ;; hack hack: don't warn when compiling the stubs in | |
2263 ;; bytecomp-runtime... | |
2264 (not (assq (nth 1 form) | |
2265 byte-compile-initial-macro-environment))) | |
2266 (byte-compile-warn | |
2267 "%s defined multiple times, as both function and macro" | |
2268 (nth 1 form))) | |
2269 (setcdr that-one nil)) | |
2270 (this-one | |
2271 (when (and (memq 'redefine byte-compile-warnings) | |
2272 ;; hack: don't warn when compiling the magic internal | |
2273 ;; byte-compiler macros in bytecomp-runtime.el... | |
2274 (not (assq (nth 1 form) | |
2275 byte-compile-initial-macro-environment))) | |
2276 (byte-compile-warn "%s %s defined multiple times in this file" | |
2277 (if macrop "macro" "function") | |
2278 (nth 1 form)))) | |
2279 ((and (fboundp name) | |
2280 (or (subrp (symbol-function name)) | |
2281 (eq (car-safe (symbol-function name)) | |
2282 (if macrop 'lambda 'macro)))) | |
2283 (if (memq 'redefine byte-compile-warnings) | |
2284 (byte-compile-warn "%s %s being redefined as a %s" | |
2285 (if (subrp (symbol-function name)) | |
2286 "subr" | |
2287 (if macrop "function" "macro")) | |
2288 (nth 1 form) | |
2289 (if macrop "macro" "function"))) | |
2290 ;; shadow existing definition | |
2291 (set this-kind | |
2292 (cons (cons name nil) (symbol-value this-kind))))) | |
2293 (let ((body (nthcdr 3 form))) | |
2294 (if (and (stringp (car body)) | |
2295 (symbolp (car-safe (cdr-safe body))) | |
2296 (car-safe (cdr-safe body)) | |
2297 (stringp (car-safe (cdr-safe (cdr-safe body))))) | |
2298 (byte-compile-warn "Probable `\"' without `\\' in doc string of %s" | |
2299 (nth 1 form)))) | |
2300 (let* ((new-one (byte-compile-lambda (cons 'lambda (nthcdr 2 form)))) | |
5106
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2301 (code (byte-compile-byte-code-maker new-one)) |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2302 (docform-info |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2303 (cond ((atom code) ; compiled-function-p |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2304 (if macrop '(" '(macro . #[" 4 "]))") '(" #[" 4 "])"))) |
5106
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2305 ((eq (car code) 'quote) |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2306 (setq code new-one) |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2307 (if macrop '(" '(macro " 2 "))") '(" '(" 2 "))"))) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2308 ((if macrop '(" (cons 'macro (" 5 ")))") '(" (" 5 "))")))))) |
428 | 2309 (if this-one |
2310 (setcdr this-one new-one) | |
2311 (set this-kind | |
2312 (cons (cons name new-one) (symbol-value this-kind)))) | |
2313 (if (and (stringp (nth 3 form)) | |
2314 (eq 'quote (car-safe code)) | |
2315 (eq 'lambda (car-safe (nth 1 code)))) | |
2316 (cons (car form) | |
5106
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2317 (cons name (cdr (nth 1 code)))) |
428 | 2318 (byte-compile-flush-pending) |
2319 (if (not (stringp (nth 3 form))) | |
5106
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2320 ;; No doc string. Provide -1 as the "doc string index" so that |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2321 ;; no element will be treated as a doc string by |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2322 ;; byte-compile-output-doc-form. |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2323 (setq docform-info (list (first docform-info) -1 |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2324 (third docform-info)))) |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2325 (byte-compile-output-docform |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2326 "\n(defalias '" |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2327 name |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2328 docform-info |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2329 ;; The result of byte-compile-byte-code-maker is either a |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2330 ;; compiled-function object, or a list of some kind. If it's not a |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2331 ;; cons, we must coerce it into a list of the elements to be |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2332 ;; printed to the file. |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2333 (if (consp code) |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2334 code |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2335 (list* (compiled-function-arglist code) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2336 (compiled-function-instructions code) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2337 (compiled-function-constants code) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2338 (compiled-function-stack-depth code) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
2339 (compiled-function-doc-string code) |
5106
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2340 (if (commandp code) |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2341 (list (nth 1 (compiled-function-interactive code)))))) |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2342 (and (atom code) byte-compile-dynamic |
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2343 1) |
428 | 2344 nil)) |
5106
8c3671b62dad
Remove #'byte-compile-compiled-obj-to-list, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5089
diff
changeset
|
2345 nil))) |
428 | 2346 |
2347 ;; Print Lisp object EXP in the output file, inside a comment, | |
2348 ;; and return the file position it will have. | |
2349 ;; If QUOTED is non-nil, print with quoting; otherwise, print without quoting. | |
2350 (defun byte-compile-output-as-comment (exp quoted) | |
2351 (let ((position (point))) | |
2352 (set-buffer | |
2353 (prog1 (current-buffer) | |
2354 (set-buffer byte-compile-outbuffer) | |
2355 | |
2356 ;; Insert EXP, and make it a comment with #@LENGTH. | |
2357 (insert " ") | |
2358 (if quoted | |
2359 (prin1 exp byte-compile-outbuffer) | |
2360 (princ exp byte-compile-outbuffer)) | |
2361 (goto-char position) | |
2362 ;; Quote certain special characters as needed. | |
2363 ;; get_doc_string in doc.c does the unquoting. | |
2364 (while (search-forward "\^A" nil t) | |
2365 (replace-match "\^A\^A" t t)) | |
2366 (goto-char position) | |
2367 (while (search-forward "\000" nil t) | |
2368 (replace-match "\^A0" t t)) | |
2369 (goto-char position) | |
2370 (while (search-forward "\037" nil t) | |
2371 (replace-match "\^A_" t t)) | |
2372 (goto-char (point-max)) | |
2373 (insert "\037") | |
2374 (goto-char position) | |
2375 (insert "#@" (format "%d" (- (point-max) position))) | |
2376 | |
2377 ;; Save the file position of the object. | |
2378 ;; Note we should add 1 to skip the space | |
2379 ;; that we inserted before the actual doc string, | |
2380 ;; and subtract 1 to convert from an 1-origin Emacs position | |
2381 ;; to a file position; they cancel. | |
2382 (setq position (point)) | |
2383 (goto-char (point-max)))) | |
2384 position)) | |
2385 | |
2386 | |
2387 | |
2388 ;; The `domain' declaration. This is legal only at top-level in a file, and | |
2389 ;; should generally be the first form in the file. It is not legal inside | |
2390 ;; function bodies. | |
2391 | |
2392 (put 'domain 'byte-hunk-handler 'byte-compile-file-form-domain) | |
2393 (defun byte-compile-file-form-domain (form) | |
2394 (if (not (null (cdr (cdr form)))) | |
2395 (byte-compile-warn "domain used with too many arguments: %s" form)) | |
2396 (let ((domain (nth 1 form))) | |
2397 (or (null domain) | |
2398 (stringp domain) | |
2399 (progn | |
2400 (byte-compile-warn | |
2401 "argument to `domain' declaration must be a literal string: %s" | |
2402 form) | |
2403 (setq domain nil))) | |
2404 (setq byte-compile-file-domain domain)) | |
2405 (byte-compile-keep-pending form 'byte-compile-normal-call)) | |
2406 | |
2407 (defun byte-compile-domain (form) | |
2408 (byte-compile-warn "The `domain' declaration is legal only at top-level: %s" | |
2409 (let ((print-escape-newlines t) | |
2410 (print-level 4) | |
2411 (print-length 4)) | |
2412 (prin1-to-string form))) | |
2413 (byte-compile-normal-call | |
2414 (list 'signal ''error | |
2415 (list 'quote (list "`domain' used inside a function" form))))) | |
2416 | |
2417 ;; This is part of bytecomp.el in 19.35: | |
2418 (put 'custom-declare-variable 'byte-hunk-handler | |
2419 'byte-compile-file-form-custom-declare-variable) | |
2420 (defun byte-compile-file-form-custom-declare-variable (form) | |
4289 | 2421 ;; XEmacs change; our implementation byte compiles and gives warnings |
2422 ;; about the default value code, which GNU's doesn't. | |
2423 (let* ((quoted-default (car-safe (cdr-safe (cdr-safe form)))) | |
2424 (to-examine (car-safe (cdr-safe quoted-default)))) | |
2425 (if (memq 'free-vars byte-compile-warnings) | |
2426 (setq byte-compile-bound-variables | |
2427 (cons (cons (nth 1 (nth 1 form)) | |
2428 byte-compile-global-bit) | |
2429 byte-compile-bound-variables))) | |
2430 ;; Byte compile anything that smells like a lambda. I initially | |
2431 ;; considered limiting it to the :initialize, :set and :get args, but | |
2432 ;; that's not amazingly forward-compatible, and anyone expecting other | |
2433 ;; things to be stored as data, not code, is unrealistic. | |
2434 (loop | |
2435 for entry in-ref (nthcdr 4 form) | |
2436 do (cond ((and (eq 'function (car-safe entry)) | |
2437 (consp (car-safe (cdr-safe entry)))) | |
2438 (setf entry (copy-sequence entry)) | |
2439 (setcar (cdr entry) (byte-compile-lambda (car (cdr entry))))) | |
2440 ((and (eq 'lambda (car-safe entry))) | |
2441 (setf entry (byte-compile-lambda entry))))) | |
2442 ;; Byte compile the default value, as we do for defvar. | |
2443 (when (consp (cdr-safe to-examine)) | |
2444 (setq form (copy-sequence form)) | |
2445 (setcdr (third form) | |
2446 (list (byte-compile-top-level to-examine nil 'file))) | |
2447 ;; And save a value to be examined in the custom UI, if that differs | |
2448 ;; from the init value. | |
2449 (unless (equal to-examine (car-safe (cdr (third form)))) | |
4304 | 2450 (setcdr (third form) |
2451 (list (byte-compile-top-level | |
2452 ;; This is ugly. custom-declare-variable errors if | |
2453 ;; it's passed a keyword it doesn't know about, and | |
2454 ;; so to make this code run on 21.4, we add code to | |
2455 ;; modify the standard-value property to the | |
2456 ;; byte-compiled value for DEFAULT. | |
2457 `(prog2 (put ,(second form) 'standard-value | |
2458 '(,to-examine)) | |
2459 ,to-examine) | |
2460 nil 'file))))) | |
4289 | 2461 form)) |
428 | 2462 |
2463 ;;;###autoload | |
2464 (defun byte-compile (form) | |
2465 "If FORM is a symbol, byte-compile its function definition. | |
2466 If FORM is a lambda or a macro, byte-compile it as a function." | |
2467 (displaying-byte-compile-warnings | |
2468 (byte-compile-close-variables | |
2469 (let* ((fun (if (symbolp form) | |
2470 (and (fboundp form) (symbol-function form)) | |
2471 form)) | |
2472 (macro (eq (car-safe fun) 'macro))) | |
2473 (if macro | |
2474 (setq fun (cdr fun))) | |
2475 (cond ((eq (car-safe fun) 'lambda) | |
2476 (setq fun (if macro | |
2477 (cons 'macro (byte-compile-lambda fun)) | |
2478 (byte-compile-lambda fun))) | |
2479 (if (symbolp form) | |
2480 (defalias form fun) | |
2481 fun))))))) | |
2482 | |
2483 ;;;###autoload | |
2484 (defun byte-compile-sexp (sexp &optional msg) | |
2485 "Compile and return SEXP." | |
2486 (displaying-byte-compile-warnings | |
2487 (byte-compile-close-variables | |
2488 (prog1 | |
2489 (byte-compile-top-level sexp) | |
2490 (byte-compile-warn-about-unresolved-functions msg))))) | |
2491 | |
2492 ;; Given a function made by byte-compile-lambda, make a form which produces it. | |
2493 (defun byte-compile-byte-code-maker (fun) | |
2494 (cond | |
2495 ;; ## atom is faster than compiled-func-p. | |
2496 ((atom fun) ; compiled-function-p | |
2497 fun) | |
2498 ;; b-c-lambda didn't produce a compiled-function, so it must be a trivial | |
2499 ;; function. | |
2500 ((let (tmp) | |
2501 (if (and (setq tmp (assq 'byte-code (cdr-safe (cdr fun)))) | |
2502 (null (cdr (memq tmp fun)))) | |
2503 ;; Generate a make-byte-code call. | |
2504 (let* ((interactive (assq 'interactive (cdr (cdr fun))))) | |
2505 (nconc (list 'make-byte-code | |
2506 (list 'quote (nth 1 fun)) ;arglist | |
2507 (nth 1 tmp) ;instructions | |
2508 (nth 2 tmp) ;constants | |
2509 (nth 3 tmp)) ;stack-depth | |
2510 (cond ((stringp (nth 2 fun)) | |
2511 (list (nth 2 fun))) ;docstring | |
2512 (interactive | |
2513 (list nil))) | |
2514 (cond (interactive | |
2515 (list (if (or (null (nth 1 interactive)) | |
2516 (stringp (nth 1 interactive))) | |
2517 (nth 1 interactive) | |
2518 ;; Interactive spec is a list or a variable | |
2519 ;; (if it is correct). | |
2520 (list 'quote (nth 1 interactive)))))))) | |
2521 ;; a non-compiled function (probably trivial) | |
2522 (list 'quote fun)))))) | |
2523 | |
2524 ;; Byte-compile a lambda-expression and return a valid function. | |
2525 ;; The value is usually a compiled function but may be the original | |
2526 ;; lambda-expression. | |
2527 (defun byte-compile-lambda (fun) | |
2528 (or (eq 'lambda (car-safe fun)) | |
2529 (error "not a lambda -- %s" (prin1-to-string fun))) | |
2530 (let* ((arglist (nth 1 fun)) | |
2531 (byte-compile-bound-variables | |
2532 (let ((new-bindings | |
2533 (mapcar #'(lambda (x) (cons x byte-compile-arglist-bit)) | |
2534 (and (memq 'free-vars byte-compile-warnings) | |
2535 (delq '&rest (delq '&optional | |
2536 (copy-sequence arglist))))))) | |
2537 (nconc new-bindings | |
2538 (cons 'new-scope byte-compile-bound-variables)))) | |
2539 (body (cdr (cdr fun))) | |
2540 (doc (if (stringp (car body)) | |
2541 (prog1 (car body) | |
1548 | 2542 ;; Discard the doc string |
2543 ;; only if it is not the only element of the body. | |
2544 (if (cdr body) | |
2545 (setq body (cdr body)))))) | |
4639
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2546 (int (assq 'interactive body)) compiled-int) |
428 | 2547 (dolist (arg arglist) |
2548 (cond ((not (symbolp arg)) | |
2549 (byte-compile-warn "non-symbol in arglist: %S" arg)) | |
2550 ((byte-compile-constant-symbol-p arg) | |
2551 (byte-compile-warn "constant symbol in arglist: %s" arg)) | |
2552 ((and (char= ?\& (aref (symbol-name arg) 0)) | |
2553 (not (eq arg '&optional)) | |
2554 (not (eq arg '&rest))) | |
2555 (byte-compile-warn "unrecognized `&' keyword in arglist: %s" | |
2556 arg)))) | |
2557 (cond (int | |
2558 ;; Skip (interactive) if it is in front (the most usual location). | |
2559 (if (eq int (car body)) | |
2560 (setq body (cdr body))) | |
2561 (cond ((consp (cdr int)) | |
2562 (if (cdr (cdr int)) | |
2563 (byte-compile-warn "malformed interactive spec: %s" | |
2564 (prin1-to-string int))) | |
4639
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2565 ;; If the interactive spec is a call to `list', don't |
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2566 ;; store the compiled form, because `call-interactively' |
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2567 ;; looks at the args of `list' and treats certain |
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2568 ;; functions specially. Compiling it is nonetheless |
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2569 ;; useful for warnings. |
428 | 2570 (let ((form (nth 1 int))) |
2571 (while (or (eq (car-safe form) 'let) | |
2572 (eq (car-safe form) 'let*) | |
2573 (eq (car-safe form) 'save-excursion)) | |
2574 (while (consp (cdr form)) | |
2575 (setq form (cdr form))) | |
2576 (setq form (car form))) | |
4639
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2577 (setq compiled-int |
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2578 (byte-compile-top-level (nth 1 int))) |
428 | 2579 (or (eq (car-safe form) 'list) |
4639
7757334005ae
bytecomp.el: always check code in (interactive SEXP) for sanity
Aidan Kehoe <kehoea@parhasard.net>
parents:
4623
diff
changeset
|
2580 (setq int (list 'interactive compiled-int))))) |
428 | 2581 ((cdr int) |
2582 (byte-compile-warn "malformed interactive spec: %s" | |
2583 (prin1-to-string int)))))) | |
2584 (let ((compiled (byte-compile-top-level (cons 'progn body) nil 'lambda))) | |
2585 (if (memq 'unused-vars byte-compile-warnings) | |
2586 ;; done compiling in this scope, warn now. | |
2587 (byte-compile-warn-about-unused-variables)) | |
2588 (if (eq 'byte-code (car-safe compiled)) | |
2589 (apply 'make-byte-code | |
2590 (append (list arglist) | |
2591 ;; byte-string, constants-vector, stack depth | |
2592 (cdr compiled) | |
2593 ;; optionally, the doc string. | |
2594 (if (or doc int) | |
2595 (list doc)) | |
2596 ;; optionally, the interactive spec. | |
2597 (if int | |
2598 (list (nth 1 int))))) | |
2599 (setq compiled | |
2600 (nconc (if int (list int)) | |
2601 (cond ((eq (car-safe compiled) 'progn) (cdr compiled)) | |
2602 (compiled (list compiled))))) | |
2603 (nconc (list 'lambda arglist) | |
2604 (if (or doc (stringp (car compiled))) | |
2605 (cons doc (cond (compiled) | |
2606 (body (list nil)))) | |
2607 compiled)))))) | |
2608 | |
2609 (defun byte-compile-constants-vector () | |
2610 ;; Builds the constants-vector from the current variables and constants. | |
2611 ;; This modifies the constants from (const . nil) to (const . offset). | |
2612 ;; To keep the byte-codes to look up the vector as short as possible: | |
2613 ;; First 6 elements are vars, as there are one-byte varref codes for those. | |
2614 ;; Next up to byte-constant-limit are constants, still with one-byte codes. | |
2615 ;; Next variables again, to get 2-byte codes for variable lookup. | |
2616 ;; The rest of the constants and variables need 3-byte byte-codes. | |
2617 (let* ((i -1) | |
2618 (rest (nreverse byte-compile-variables)) ; nreverse because the first | |
2619 (other (nreverse byte-compile-constants)) ; vars often are used most. | |
2620 ret tmp | |
2621 (limits '(5 ; Use the 1-byte varref codes, | |
2622 63 ; 1-constlim ; 1-byte byte-constant codes, | |
2623 255 ; 2-byte varref codes, | |
2624 65535)) ; 3-byte codes for the rest. | |
2625 limit) | |
2626 (while (or rest other) | |
2627 (setq limit (car limits)) | |
2628 (while (and rest (not (eq i limit))) | |
2629 (if (setq tmp (assq (car (car rest)) ret)) | |
2630 (setcdr (car rest) (cdr tmp)) | |
2631 (setcdr (car rest) (setq i (1+ i))) | |
2632 (setq ret (cons (car rest) ret))) | |
2633 (setq rest (cdr rest))) | |
2634 (setq limits (cdr limits) | |
2635 rest (prog1 other | |
2636 (setq other rest)))) | |
2637 (apply 'vector (nreverse (mapcar 'car ret))))) | |
2638 | |
2639 ;; Given an expression FORM, compile it and return an equivalent byte-code | |
2640 ;; expression (a call to the function byte-code). | |
2641 (defun byte-compile-top-level (form &optional for-effect output-type) | |
2642 ;; OUTPUT-TYPE advises about how form is expected to be used: | |
2643 ;; 'eval or nil -> a single form, | |
2644 ;; 'progn or t -> a list of forms, | |
2645 ;; 'lambda -> body of a lambda, | |
2646 ;; 'file -> used at file-level. | |
2647 (let ((byte-compile-constants nil) | |
2648 (byte-compile-variables nil) | |
2649 (byte-compile-tag-number 0) | |
2650 (byte-compile-depth 0) | |
2651 (byte-compile-maxdepth 0) | |
2652 (byte-compile-output nil)) | |
2653 (if (memq byte-optimize '(t source)) | |
2654 (setq form (byte-optimize-form form for-effect))) | |
2655 (while (and (eq (car-safe form) 'progn) (null (cdr (cdr form)))) | |
2656 (setq form (nth 1 form))) | |
2657 (if (and (eq 'byte-code (car-safe form)) | |
2658 (not (memq byte-optimize '(t byte))) | |
2659 (stringp (nth 1 form)) | |
2660 (vectorp (nth 2 form)) | |
2661 (natnump (nth 3 form))) | |
2662 form | |
2663 (byte-compile-form form for-effect) | |
2664 (byte-compile-out-toplevel for-effect output-type)))) | |
2665 | |
2666 (defun byte-compile-out-toplevel (&optional for-effect output-type) | |
2667 (if for-effect | |
2668 ;; The stack is empty. Push a value to be returned from (byte-code ..). | |
2669 (if (eq (car (car byte-compile-output)) 'byte-discard) | |
2670 (setq byte-compile-output (cdr byte-compile-output)) | |
2671 (byte-compile-push-constant | |
2672 ;; Push any constant - preferably one which already is used, and | |
2673 ;; a number or symbol - ie not some big sequence. The return value | |
2674 ;; isn't returned, but it would be a shame if some textually large | |
2675 ;; constant was not optimized away because we chose to return it. | |
2676 (and (not (assq nil byte-compile-constants)) ; Nil is often there. | |
2677 (let ((tmp (reverse byte-compile-constants))) | |
2678 (while (and tmp (not (or (symbolp (car (car tmp))) | |
2679 (numberp (car (car tmp)))))) | |
2680 (setq tmp (cdr tmp))) | |
2681 (car (car tmp))))))) | |
2682 (byte-compile-out 'byte-return 0) | |
2683 (setq byte-compile-output (nreverse byte-compile-output)) | |
2684 (if (memq byte-optimize '(t byte)) | |
2685 (setq byte-compile-output | |
2686 (byte-optimize-lapcode byte-compile-output for-effect))) | |
2687 | |
2688 ;; Decompile trivial functions: | |
2689 ;; only constants and variables, or a single funcall except in lambdas. | |
2690 ;; Except for Lisp_Compiled objects, forms like (foo "hi") | |
2691 ;; are still quicker than (byte-code "..." [foo "hi"] 2). | |
2692 ;; Note that even (quote foo) must be parsed just as any subr by the | |
2693 ;; interpreter, so quote should be compiled into byte-code in some contexts. | |
2694 ;; What to leave uncompiled: | |
2695 ;; lambda -> never. we used to leave it uncompiled if the body was | |
2696 ;; a single atom, but that causes confusion if the docstring | |
2697 ;; uses the (file . pos) syntax. Besides, now that we have | |
2698 ;; the Lisp_Compiled type, the compiled form is faster. | |
2699 ;; eval -> atom, quote or (function atom atom atom) | |
2700 ;; progn -> as <<same-as-eval>> or (progn <<same-as-eval>> atom) | |
2701 ;; file -> as progn, but takes both quotes and atoms, and longer forms. | |
2702 (let (rest | |
2703 (maycall (not (eq output-type 'lambda))) ; t if we may make a funcall. | |
2704 tmp body) | |
2705 (cond | |
2706 ;; #### This should be split out into byte-compile-nontrivial-function-p. | |
2707 ((or (eq output-type 'lambda) | |
2708 (nthcdr (if (eq output-type 'file) 50 8) byte-compile-output) | |
2709 (assq 'TAG byte-compile-output) ; Not necessary, but speeds up a bit. | |
2710 (not (setq tmp (assq 'byte-return byte-compile-output))) | |
2711 (progn | |
2712 (setq rest (nreverse | |
2713 (cdr (memq tmp (reverse byte-compile-output))))) | |
2714 (while (cond | |
2715 ((memq (car (car rest)) '(byte-varref byte-constant)) | |
2716 (setq tmp (car (cdr (car rest)))) | |
2717 (if (if (eq (car (car rest)) 'byte-constant) | |
2718 (or (consp tmp) | |
2719 (and (symbolp tmp) | |
2720 (not (byte-compile-constant-symbol-p tmp))))) | |
2721 (if maycall | |
2722 (setq body (cons (list 'quote tmp) body))) | |
2723 (setq body (cons tmp body)))) | |
2724 ((and maycall | |
2725 ;; Allow a funcall if at most one atom follows it. | |
2726 (null (nthcdr 3 rest)) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
2727 (setq tmp (get (car (car rest)) 'byte-opcode-invert)) |
428 | 2728 (or (null (cdr rest)) |
2729 (and (memq output-type '(file progn t)) | |
2730 (cdr (cdr rest)) | |
2731 (eq (car (nth 1 rest)) 'byte-discard) | |
2732 (progn (setq rest (cdr rest)) t)))) | |
2733 (setq maycall nil) ; Only allow one real function call. | |
2734 (setq body (nreverse body)) | |
2735 (setq body (list | |
2736 (if (and (eq tmp 'funcall) | |
2737 (eq (car-safe (car body)) 'quote)) | |
2738 (cons (nth 1 (car body)) (cdr body)) | |
2739 (cons tmp body)))) | |
2740 (or (eq output-type 'file) | |
2741 (not (delq nil (mapcar 'consp (cdr (car body)))))))) | |
2742 (setq rest (cdr rest))) | |
2743 rest)) | |
2744 (let ((byte-compile-vector (byte-compile-constants-vector))) | |
2745 (list 'byte-code (byte-compile-lapcode byte-compile-output) | |
2746 byte-compile-vector byte-compile-maxdepth))) | |
2747 ;; it's a trivial function | |
2748 ((cdr body) (cons 'progn (nreverse body))) | |
2749 ((car body))))) | |
2750 | |
2751 ;; Given BODY, compile it and return a new body. | |
2752 (defun byte-compile-top-level-body (body &optional for-effect) | |
2753 (setq body (byte-compile-top-level (cons 'progn body) for-effect t)) | |
2754 (cond ((eq (car-safe body) 'progn) | |
2755 (cdr body)) | |
2756 (body | |
2757 (list body)))) | |
2758 | |
2759 ;; This is the recursive entry point for compiling each subform of an | |
2760 ;; expression. | |
2761 ;; If for-effect is non-nil, byte-compile-form will output a byte-discard | |
2762 ;; before terminating (ie. no value will be left on the stack). | |
2763 ;; A byte-compile handler may, when for-effect is non-nil, choose output code | |
2764 ;; which does not leave a value on the stack, and then set for-effect to nil | |
2765 ;; (to prevent byte-compile-form from outputting the byte-discard). | |
2766 ;; If a handler wants to call another handler, it should do so via | |
2767 ;; byte-compile-form, or take extreme care to handle for-effect correctly. | |
2768 ;; (Use byte-compile-form-do-effect to reset the for-effect flag too.) | |
2769 ;; | |
2770 (defun byte-compile-form (form &optional for-effect) | |
2771 (setq form (macroexpand form byte-compile-macro-environment)) | |
2772 (cond ((not (consp form)) | |
2773 (cond ((or (not (symbolp form)) | |
2774 (byte-compile-constant-symbol-p form)) | |
2775 (byte-compile-constant form)) | |
2776 ((and for-effect byte-compile-delete-errors) | |
2777 (setq for-effect nil)) | |
2778 (t (byte-compile-variable-ref 'byte-varref form)))) | |
2779 ((symbolp (car form)) | |
2780 (let* ((fn (car form)) | |
2781 (handler (get fn 'byte-compile))) | |
2782 (if (memq fn '(t nil)) | |
2783 (byte-compile-warn "%s called as a function" fn)) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
2784 (if handler |
428 | 2785 (funcall handler form) |
2786 (if (memq 'callargs byte-compile-warnings) | |
2787 (byte-compile-callargs-warn form)) | |
2788 (byte-compile-normal-call form)))) | |
2789 ((and (or (compiled-function-p (car form)) | |
2790 (eq (car-safe (car form)) 'lambda)) | |
2791 ;; if the form comes out the same way it went in, that's | |
2792 ;; because it was malformed, and we couldn't unfold it. | |
2793 (not (eq form (setq form (byte-compile-unfold-lambda form))))) | |
2794 (byte-compile-form form for-effect) | |
2795 (setq for-effect nil)) | |
2796 ((byte-compile-normal-call form))) | |
2797 (when for-effect | |
2798 (byte-compile-discard))) | |
2799 | |
5294
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2800 ;; Generate the list of functions with keyword arguments like so: |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2801 ;; |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2802 ;; (delete-duplicates |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2803 ;; (sort* |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2804 ;; (loop |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2805 ;; for symbol being each symbol in obarray |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2806 ;; with arglist = nil |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2807 ;; if (and (fboundp symbol) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2808 ;; (ignore-errors (setq symbol (indirect-function symbol))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2809 ;; (cond |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2810 ;; ((and (subrp symbol) (setq symbol (intern (subr-name symbol))))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2811 ;; ((and (compiled-function-p symbol) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2812 ;; (setq symbol (compiled-function-annotation symbol))))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2813 ;; (setq arglist (function-arglist symbol)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2814 ;; (setq arglist (ignore-errors (read-from-string arglist))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2815 ;; (setq arglist (car arglist)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2816 ;; (setq arglist (position '&key arglist))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2817 ;; collect (cons symbol arglist)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2818 ;; #'string-lessp |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2819 ;; :key #'car) :test #'eq :key #'car) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2820 ;; |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2821 ;; That won't include those that take advantage of cl-seq.el's |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2822 ;; cl-parsing-keywords macro, but the below list does. |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2823 |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2824 (map nil |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2825 (function* |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2826 (lambda ((function . nargs)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2827 ;; Document that the car of OBJECT, a symbol, describes a function |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2828 ;; taking keyword arguments from the argument index described by |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2829 ;; the cdr of OBJECT. |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2830 (put function 'byte-compile-keyword-start nargs))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2831 '((adjoin . 3) (assoc* . 3) (assoc-if . 3) (assoc-if-not . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2832 (count . 3) (count-if . 3) (count-if-not . 3) (define-behavior . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2833 (define-behavior-group . 2) (delete* . 3) (delete-duplicates . 2) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2834 (delete-if . 3) (delete-if-not . 3) (fill . 3) (find . 3) (find-if . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2835 (find-if-not . 3) (internal-make-translation-table . 1) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2836 (make-Print-context . 1) (make-hash-table . 1) (make-saved-window . 1) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2837 (make-window-configuration . 1) (member* . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2838 (member-if . 3) (member-if-not . 3) (merge . 5) (nsublis . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2839 (nsubst . 4) (nsubst-if . 4) (nsubst-if-not . 4) (nsubstitute . 4) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2840 (nsubstitute-if . 4) (nsubstitute-if-not . 4) (override-behavior . 2) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2841 (position . 3) (position-if . 3) (position-if-not . 3) (rassoc* . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2842 (rassoc-if . 3) (rassoc-if-not . 3) (reduce . 3) (remove* . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2843 (remove-duplicates . 2) (remove-if . 3) (remove-if-not . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2844 (replace . 3) (sort* . 3) (stable-sort . 3) (sublis . 3) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2845 (subsetp . 3) (subst . 4) (subst-if . 4) (subst-if-not . 4) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2846 (substitute . 4) (substitute-if . 4) (substitute-if-not . 4) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2847 (tree-equal . 3))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2848 |
428 | 2849 (defun byte-compile-normal-call (form) |
5358
31475de17064
#'byte-compile-normal-call; only examine properties of (car FORM) if a symbol
Aidan Kehoe <kehoea@parhasard.net>
parents:
5356
diff
changeset
|
2850 (and (symbolp (car form)) (get (car form) 'byte-compile-keyword-start) |
5294
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2851 (let ((plist (nthcdr (get (car form) 'byte-compile-keyword-start) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2852 form))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2853 (symbol-macrolet |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2854 ((not-present '#:not-present)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2855 (if (not (valid-plist-p plist)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2856 (byte-compile-warn |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2857 "#'%s: ill-formed keyword argument list: %S" (car form) plist) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2858 (and |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2859 (memq 'callargs byte-compile-warnings) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2860 (map nil |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2861 (function* |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2862 (lambda ((function . nargs)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2863 (and (setq function (plist-get plist function |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2864 not-present)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2865 (not (eq function not-present)) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2866 (byte-compile-constp function) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2867 (byte-compile-callargs-warn |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2868 (cons (eval function) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2869 (member* |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2870 nargs |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2871 ;; Dummy arguments. There's no need for |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2872 ;; it to be longer than even 2, now, but |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2873 ;; very little harm in it. |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2874 '(9 8 7 6 5 4 3 2 1))))))) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2875 '((:key . 1) (:test . 2) (:test-not . 2) |
bbff29a01820
Add compiler macros and compilation sanity-checks for functions with keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5282
diff
changeset
|
2876 (:if . 1) (:if-not . 1)))))))) |
428 | 2877 (if byte-compile-generate-call-tree |
2878 (byte-compile-annotate-call-tree form)) | |
2879 (byte-compile-push-constant (car form)) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
2880 (mapc 'byte-compile-form (cdr form)) ; wasteful, but faster. |
428 | 2881 (byte-compile-out 'byte-call (length (cdr form)))) |
2882 | |
2883 ;; kludge added to XEmacs to work around the bogosities of a nonlexical lisp. | |
2884 (or (fboundp 'globally-boundp) (fset 'globally-boundp 'boundp)) | |
2885 | |
2886 (defun byte-compile-variable-ref (base-op var &optional varbind-flags) | |
2887 (if (or (not (symbolp var)) (byte-compile-constant-symbol-p var)) | |
2888 (byte-compile-warn | |
2889 (case base-op | |
2890 (byte-varref "Variable reference to %s %s") | |
2891 (byte-varset "Attempt to set %s %s") | |
2892 (byte-varbind "Attempt to let-bind %s %s")) | |
2893 (if (symbolp var) "constant symbol" "non-symbol") | |
2894 var) | |
2895 (if (and (get var 'byte-obsolete-variable) | |
2896 (memq 'obsolete byte-compile-warnings)) | |
2897 (let ((ob (get var 'byte-obsolete-variable))) | |
2898 (byte-compile-warn "%s is an obsolete variable; %s" var | |
2899 (if (stringp ob) | |
2900 ob | |
2901 (format "use %s instead." ob))))) | |
2902 (if (and (get var 'byte-compatible-variable) | |
2903 (memq 'pedantic byte-compile-warnings)) | |
2904 (let ((ob (get var 'byte-compatible-variable))) | |
2905 (byte-compile-warn "%s is provided for compatibility; %s" var | |
2906 (if (stringp ob) | |
2907 ob | |
2908 (format "use %s instead." ob))))) | |
2909 (if (memq 'free-vars byte-compile-warnings) | |
2910 (if (eq base-op 'byte-varbind) | |
2911 (setq byte-compile-bound-variables | |
2912 (cons (cons var (or varbind-flags 0)) | |
2913 byte-compile-bound-variables)) | |
2914 (or (globally-boundp var) | |
2915 (let ((cell (assq var byte-compile-bound-variables))) | |
2916 (if cell (setcdr cell | |
2917 (logior (cdr cell) | |
2918 (if (eq base-op 'byte-varset) | |
2919 byte-compile-assigned-bit | |
2920 byte-compile-referenced-bit))))) | |
444 | 2921 (and (boundp 'current-load-list) |
2922 (memq var current-load-list)) | |
428 | 2923 (if (eq base-op 'byte-varset) |
2924 (or (memq var byte-compile-free-assignments) | |
2925 (progn | |
2926 (byte-compile-warn "assignment to free variable %s" | |
2927 var) | |
2928 (setq byte-compile-free-assignments | |
2929 (cons var byte-compile-free-assignments)))) | |
2930 (or (memq var byte-compile-free-references) | |
2931 (progn | |
2932 (byte-compile-warn "reference to free variable %s" var) | |
2933 (setq byte-compile-free-references | |
2934 (cons var byte-compile-free-references))))))))) | |
2935 (let ((tmp (assq var byte-compile-variables))) | |
2936 (or tmp | |
2937 (setq tmp (list var) | |
2938 byte-compile-variables (cons tmp byte-compile-variables))) | |
2939 (byte-compile-out base-op tmp))) | |
2940 | |
2941 (defmacro byte-compile-get-constant (const) | |
2942 `(or (if (stringp ,const) | |
2943 (assoc ,const byte-compile-constants) | |
2944 (assq ,const byte-compile-constants)) | |
2945 (car (setq byte-compile-constants | |
2946 (cons (list ,const) byte-compile-constants))))) | |
2947 | |
2948 ;; Use this when the value of a form is a constant. This obeys for-effect. | |
2949 (defun byte-compile-constant (const) | |
2950 (if for-effect | |
2951 (setq for-effect nil) | |
2952 (byte-compile-out 'byte-constant (byte-compile-get-constant const)))) | |
2953 | |
2954 ;; Use this for a constant that is not the value of its containing form. | |
2955 ;; This ignores for-effect. | |
2956 (defun byte-compile-push-constant (const) | |
2957 (let ((for-effect nil)) | |
2958 (inline (byte-compile-constant const)))) | |
2959 | |
2960 | |
2961 ;; Compile those primitive ordinary functions | |
2962 ;; which have special byte codes just for speed. | |
2963 | |
2964 (defmacro byte-defop-compiler (function &optional compile-handler) | |
2965 ;; add a compiler-form for FUNCTION. | |
446 | 2966 ;; If FUNCTION is a symbol, then the variable "byte-SYMBOL" must name |
2967 ;; the opcode to be used. If is a list, the first element | |
428 | 2968 ;; is the function and the second element is the bytecode-symbol. |
2969 ;; COMPILE-HANDLER is the function to use to compile this byte-op, or | |
2970 ;; may be the abbreviations 0, 1, 2, 3, 0-1, 1-2, 2-3, 0+1, 1+1, 2+1, | |
2971 ;; 0-1+1, 1-2+1, 2-3+1, 0+2, or 1+2. If it is nil, then the handler is | |
2972 ;; "byte-compile-SYMBOL." | |
2973 (let (opcode) | |
2974 (if (symbolp function) | |
2975 (setq opcode (intern (concat "byte-" (symbol-name function)))) | |
2976 (setq opcode (car (cdr function)) | |
2977 function (car function))) | |
2978 (let ((fnform | |
2979 (list 'put (list 'quote function) ''byte-compile | |
2980 (list 'quote | |
2981 (or (cdr (assq compile-handler | |
2982 '((0 . byte-compile-no-args) | |
2983 (1 . byte-compile-one-arg) | |
2984 (2 . byte-compile-two-args) | |
2985 (3 . byte-compile-three-args) | |
2986 (0-1 . byte-compile-zero-or-one-arg) | |
2987 (1-2 . byte-compile-one-or-two-args) | |
2988 (2-3 . byte-compile-two-or-three-args) | |
2989 (0+1 . byte-compile-no-args-with-one-extra) | |
2990 (1+1 . byte-compile-one-arg-with-one-extra) | |
2991 (2+1 . byte-compile-two-args-with-one-extra) | |
2992 (0-1+1 . byte-compile-zero-or-one-arg-with-one-extra) | |
2993 (1-2+1 . byte-compile-one-or-two-args-with-one-extra) | |
2994 (2-3+1 . byte-compile-two-or-three-args-with-one-extra) | |
2995 (0+2 . byte-compile-no-args-with-two-extra) | |
2996 (1+2 . byte-compile-one-arg-with-two-extra) | |
2997 | |
2998 ))) | |
2999 compile-handler | |
3000 (intern (concat "byte-compile-" | |
3001 (symbol-name function)))))))) | |
3002 (if opcode | |
3003 (list 'progn fnform | |
3004 (list 'put (list 'quote function) | |
3005 ''byte-opcode (list 'quote opcode)) | |
3006 (list 'put (list 'quote opcode) | |
3007 ''byte-opcode-invert (list 'quote function))) | |
3008 fnform)))) | |
3009 | |
3010 (defmacro byte-defop-compiler-1 (function &optional compile-handler) | |
3011 (list 'byte-defop-compiler (list function nil) compile-handler)) | |
3012 | |
3013 | |
3014 (put 'byte-call 'byte-opcode-invert 'funcall) | |
3015 (put 'byte-list1 'byte-opcode-invert 'list) | |
3016 (put 'byte-list2 'byte-opcode-invert 'list) | |
3017 (put 'byte-list3 'byte-opcode-invert 'list) | |
3018 (put 'byte-list4 'byte-opcode-invert 'list) | |
3019 (put 'byte-listN 'byte-opcode-invert 'list) | |
3020 (put 'byte-concat2 'byte-opcode-invert 'concat) | |
3021 (put 'byte-concat3 'byte-opcode-invert 'concat) | |
3022 (put 'byte-concat4 'byte-opcode-invert 'concat) | |
3023 (put 'byte-concatN 'byte-opcode-invert 'concat) | |
3024 (put 'byte-insertN 'byte-opcode-invert 'insert) | |
3025 | |
3026 ;; How old is this stuff? -slb | |
3027 ;(byte-defop-compiler (dot byte-point) 0+1) | |
3028 ;(byte-defop-compiler (dot-max byte-point-max) 0+1) | |
3029 ;(byte-defop-compiler (dot-min byte-point-min) 0+1) | |
3030 (byte-defop-compiler point 0+1) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3031 (byte-defop-compiler eq 2) |
428 | 3032 (byte-defop-compiler point-max 0+1) |
3033 (byte-defop-compiler point-min 0+1) | |
3034 (byte-defop-compiler following-char 0+1) | |
3035 (byte-defop-compiler preceding-char 0+1) | |
3036 (byte-defop-compiler current-column 0+1) | |
3037 ;; FSF has special function here; generalized here by the 1+2 stuff. | |
3038 (byte-defop-compiler (indent-to-column byte-indent-to) 1+2) | |
3039 (byte-defop-compiler indent-to 1+2) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3040 (byte-defop-compiler equal 2) |
428 | 3041 (byte-defop-compiler eolp 0+1) |
3042 (byte-defop-compiler eobp 0+1) | |
3043 (byte-defop-compiler bolp 0+1) | |
3044 (byte-defop-compiler bobp 0+1) | |
3045 (byte-defop-compiler current-buffer 0) | |
3046 ;;(byte-defop-compiler read-char 0) ;; obsolete | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3047 (byte-defop-compiler memq 2) |
428 | 3048 (byte-defop-compiler interactive-p 0) |
3049 (byte-defop-compiler widen 0+1) | |
3050 (byte-defop-compiler end-of-line 0-1+1) | |
3051 (byte-defop-compiler forward-char 0-1+1) | |
3052 (byte-defop-compiler forward-line 0-1+1) | |
3053 (byte-defop-compiler symbolp 1) | |
3054 (byte-defop-compiler consp 1) | |
3055 (byte-defop-compiler stringp 1) | |
3056 (byte-defop-compiler listp 1) | |
3057 (byte-defop-compiler not 1) | |
3058 (byte-defop-compiler (null byte-not) 1) | |
3059 (byte-defop-compiler car 1) | |
3060 (byte-defop-compiler cdr 1) | |
3061 (byte-defop-compiler length 1) | |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
3062 (byte-defop-compiler symbol-value) |
428 | 3063 (byte-defop-compiler symbol-function 1) |
3064 (byte-defop-compiler (1+ byte-add1) 1) | |
3065 (byte-defop-compiler (1- byte-sub1) 1) | |
3066 (byte-defop-compiler goto-char 1+1) | |
3067 (byte-defop-compiler char-after 0-1+1) | |
3068 (byte-defop-compiler set-buffer 1) | |
3069 ;;(byte-defop-compiler set-mark 1) ;; obsolete | |
2217 | 3070 (byte-defop-compiler forward-word 0-1+1) |
428 | 3071 (byte-defop-compiler char-syntax 1+1) |
3072 (byte-defop-compiler nreverse 1) | |
3073 (byte-defop-compiler car-safe 1) | |
3074 (byte-defop-compiler cdr-safe 1) | |
3075 (byte-defop-compiler numberp 1) | |
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
3076 (byte-defop-compiler fixnump 1) |
428 | 3077 (byte-defop-compiler skip-chars-forward 1-2+1) |
3078 (byte-defop-compiler skip-chars-backward 1-2+1) | |
5301
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
3079 (byte-defop-compiler eq 2) |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3080 ; (byte-defop-compiler old-eq 2) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3081 ; (byte-defop-compiler old-memq 2) |
428 | 3082 (byte-defop-compiler cons 2) |
3083 (byte-defop-compiler aref 2) | |
3084 (byte-defop-compiler get 2+1) | |
3085 (byte-defop-compiler nth 2) | |
5089
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
3086 (byte-defop-compiler subseq byte-compile-subseq) |
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
3087 (byte-defop-compiler (substring byte-subseq) 2-3) |
428 | 3088 (byte-defop-compiler (move-marker byte-set-marker) 2-3) |
3089 (byte-defop-compiler set-marker 2-3) | |
3090 (byte-defop-compiler match-beginning 1) | |
3091 (byte-defop-compiler match-end 1) | |
3092 (byte-defop-compiler upcase 1+1) | |
3093 (byte-defop-compiler downcase 1+1) | |
3094 (byte-defop-compiler string= 2) | |
3095 (byte-defop-compiler string< 2) | |
3096 (byte-defop-compiler (string-equal byte-string=) 2) | |
3097 (byte-defop-compiler (string-lessp byte-string<) 2) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3098 ; (byte-defop-compiler old-equal 2) |
428 | 3099 (byte-defop-compiler nthcdr 2) |
3100 (byte-defop-compiler elt 2) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3101 (byte-defop-compiler old-member 2) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3102 (byte-defop-compiler old-assq 2) |
428 | 3103 (byte-defop-compiler (rplaca byte-setcar) 2) |
3104 (byte-defop-compiler (rplacd byte-setcdr) 2) | |
3105 (byte-defop-compiler setcar 2) | |
3106 (byte-defop-compiler setcdr 2) | |
3107 (byte-defop-compiler delete-region 2+1) | |
3108 (byte-defop-compiler narrow-to-region 2+1) | |
3109 (byte-defop-compiler (% byte-rem) 2) | |
3110 (byte-defop-compiler aset 3) | |
3111 | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3112 (byte-defop-compiler-1 bind-multiple-value-limits) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3113 (byte-defop-compiler multiple-value-list-internal) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3114 (byte-defop-compiler-1 multiple-value-call) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3115 (byte-defop-compiler throw) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3116 |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3117 (byte-defop-compiler member 2) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
3118 (byte-defop-compiler assq 2) |
428 | 3119 |
3120 ;;####(byte-defop-compiler move-to-column 1) | |
3121 (byte-defop-compiler-1 interactive byte-compile-noop) | |
3122 (byte-defop-compiler-1 domain byte-compile-domain) | |
3123 | |
3124 ;; As of GNU Emacs 19.18 and Lucid Emacs 19.8, mod and % are different: `%' | |
3125 ;; means integral remainder and may have a negative result; `mod' is always | |
3126 ;; positive, and accepts floating point args. All code which uses `mod' and | |
3127 ;; requires the new interpretation must be compiled with bytecomp version 2.18 | |
3128 ;; or newer, or the emitted code will run the byte-code for `%' instead of an | |
3129 ;; actual call to `mod'. So be careful of compiling new code with an old | |
3130 ;; compiler. Note also that `%' is more efficient than `mod' because the | |
3131 ;; former is byte-coded and the latter is not. | |
3132 ;;(byte-defop-compiler (mod byte-rem) 2) | |
3133 | |
3134 | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3135 (defun byte-compile-warn-wrong-args (form n) |
428 | 3136 (when (memq 'subr-callargs byte-compile-warnings) |
3137 (byte-compile-warn "%s called with %d arg%s, but requires %s" | |
3138 (car form) (length (cdr form)) | |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
3139 (if (eql 1 (length (cdr form))) "" "s") n))) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3140 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3141 (defun byte-compile-subr-wrong-args (form n) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3142 (byte-compile-warn-wrong-args form n) |
428 | 3143 ;; get run-time wrong-number-of-args error. |
3144 (byte-compile-normal-call form)) | |
3145 | |
3146 (defun byte-compile-no-args (form) | |
3147 (case (length (cdr form)) | |
3148 (0 (byte-compile-out (get (car form) 'byte-opcode) 0)) | |
3149 (t (byte-compile-subr-wrong-args form "none")))) | |
3150 | |
3151 (defun byte-compile-one-arg (form) | |
3152 (case (length (cdr form)) | |
3153 (1 (byte-compile-form (car (cdr form))) ;; Push the argument | |
3154 (byte-compile-out (get (car form) 'byte-opcode) 0)) | |
3155 (t (byte-compile-subr-wrong-args form 1)))) | |
3156 | |
3157 (defun byte-compile-two-args (form) | |
3158 (case (length (cdr form)) | |
3159 (2 (byte-compile-form (nth 1 form)) ;; Push the arguments | |
3160 (byte-compile-form (nth 2 form)) | |
3161 (byte-compile-out (get (car form) 'byte-opcode) 0)) | |
3162 (t (byte-compile-subr-wrong-args form 2)))) | |
3163 | |
3164 (defun byte-compile-three-args (form) | |
3165 (case (length (cdr form)) | |
3166 (3 (byte-compile-form (nth 1 form)) ;; Push the arguments | |
3167 (byte-compile-form (nth 2 form)) | |
3168 (byte-compile-form (nth 3 form)) | |
3169 (byte-compile-out (get (car form) 'byte-opcode) 0)) | |
3170 (t (byte-compile-subr-wrong-args form 3)))) | |
3171 | |
3172 (defun byte-compile-zero-or-one-arg (form) | |
3173 (case (length (cdr form)) | |
3174 (0 (byte-compile-one-arg (append form '(nil)))) | |
3175 (1 (byte-compile-one-arg form)) | |
3176 (t (byte-compile-subr-wrong-args form "0-1")))) | |
3177 | |
3178 (defun byte-compile-one-or-two-args (form) | |
3179 (case (length (cdr form)) | |
3180 (1 (byte-compile-two-args (append form '(nil)))) | |
3181 (2 (byte-compile-two-args form)) | |
3182 (t (byte-compile-subr-wrong-args form "1-2")))) | |
3183 | |
3184 (defun byte-compile-two-or-three-args (form) | |
3185 (case (length (cdr form)) | |
3186 (2 (byte-compile-three-args (append form '(nil)))) | |
3187 (3 (byte-compile-three-args form)) | |
3188 (t (byte-compile-subr-wrong-args form "2-3")))) | |
3189 | |
3190 ;; from Ben Wing <ben@xemacs.org>: some inlined functions have extra | |
3191 ;; optional args added to them in XEmacs 19.12. Changing the byte | |
3192 ;; interpreter to deal with these args would be wrong and cause | |
3193 ;; incompatibility, so we generate non-inlined calls for those cases. | |
3194 ;; Without the following functions, spurious warnings will be generated; | |
3195 ;; however, they would still compile correctly because | |
3196 ;; `byte-compile-subr-wrong-args' also converts the call to non-inlined. | |
3197 | |
3198 (defun byte-compile-no-args-with-one-extra (form) | |
3199 (case (length (cdr form)) | |
3200 (0 (byte-compile-no-args form)) | |
446 | 3201 (1 (if (eq nil (nth 1 form)) |
3202 (byte-compile-no-args (butlast form)) | |
3203 (byte-compile-normal-call form))) | |
428 | 3204 (t (byte-compile-subr-wrong-args form "0-1")))) |
3205 | |
3206 (defun byte-compile-one-arg-with-one-extra (form) | |
3207 (case (length (cdr form)) | |
3208 (1 (byte-compile-one-arg form)) | |
446 | 3209 (2 (if (eq nil (nth 2 form)) |
3210 (byte-compile-one-arg (butlast form)) | |
3211 (byte-compile-normal-call form))) | |
428 | 3212 (t (byte-compile-subr-wrong-args form "1-2")))) |
3213 | |
3214 (defun byte-compile-two-args-with-one-extra (form) | |
3215 (case (length (cdr form)) | |
3216 (2 (byte-compile-two-args form)) | |
446 | 3217 (3 (if (eq nil (nth 3 form)) |
3218 (byte-compile-two-args (butlast form)) | |
3219 (byte-compile-normal-call form))) | |
428 | 3220 (t (byte-compile-subr-wrong-args form "2-3")))) |
3221 | |
3222 (defun byte-compile-zero-or-one-arg-with-one-extra (form) | |
3223 (case (length (cdr form)) | |
3224 (0 (byte-compile-one-arg (append form '(nil)))) | |
3225 (1 (byte-compile-one-arg form)) | |
446 | 3226 (2 (if (eq nil (nth 2 form)) |
3227 (byte-compile-one-arg (butlast form)) | |
3228 (byte-compile-normal-call form))) | |
428 | 3229 (t (byte-compile-subr-wrong-args form "0-2")))) |
3230 | |
3231 (defun byte-compile-one-or-two-args-with-one-extra (form) | |
3232 (case (length (cdr form)) | |
3233 (1 (byte-compile-two-args (append form '(nil)))) | |
3234 (2 (byte-compile-two-args form)) | |
446 | 3235 (3 (if (eq nil (nth 3 form)) |
3236 (byte-compile-two-args (butlast form)) | |
3237 (byte-compile-normal-call form))) | |
428 | 3238 (t (byte-compile-subr-wrong-args form "1-3")))) |
3239 | |
3240 (defun byte-compile-two-or-three-args-with-one-extra (form) | |
3241 (case (length (cdr form)) | |
3242 (2 (byte-compile-three-args (append form '(nil)))) | |
3243 (3 (byte-compile-three-args form)) | |
446 | 3244 (4 (if (eq nil (nth 4 form)) |
3245 (byte-compile-three-args (butlast form)) | |
3246 (byte-compile-normal-call form))) | |
428 | 3247 (t (byte-compile-subr-wrong-args form "2-4")))) |
3248 | |
3249 (defun byte-compile-no-args-with-two-extra (form) | |
3250 (case (length (cdr form)) | |
3251 (0 (byte-compile-no-args form)) | |
3252 ((1 2) (byte-compile-normal-call form)) | |
3253 (t (byte-compile-subr-wrong-args form "0-2")))) | |
3254 | |
3255 (defun byte-compile-one-arg-with-two-extra (form) | |
3256 (case (length (cdr form)) | |
3257 (1 (byte-compile-one-arg form)) | |
3258 ((2 3) (byte-compile-normal-call form)) | |
3259 (t (byte-compile-subr-wrong-args form "1-3")))) | |
3260 | |
3261 (defun byte-compile-noop (form) | |
3262 (byte-compile-constant nil)) | |
3263 | |
3264 (defun byte-compile-discard () | |
3265 (byte-compile-out 'byte-discard 0)) | |
3266 | |
446 | 3267 (defun byte-compile-max (form) |
3268 (let ((args (cdr form))) | |
428 | 3269 (case (length args) |
446 | 3270 (0 (byte-compile-subr-wrong-args form "1 or more")) |
3271 (1 (byte-compile-form (car args)) | |
3272 (when (not byte-compile-delete-errors) | |
3273 (byte-compile-out 'byte-dup 0) | |
3274 (byte-compile-out 'byte-max 0))) | |
428 | 3275 (t (byte-compile-form (car args)) |
446 | 3276 (dolist (elt (cdr args)) |
3277 (byte-compile-form elt) | |
3278 (byte-compile-out 'byte-max 0)))))) | |
3279 | |
3280 (defun byte-compile-min (form) | |
3281 (let ((args (cdr form))) | |
3282 (case (length args) | |
3283 (0 (byte-compile-subr-wrong-args form "1 or more")) | |
3284 (1 (byte-compile-form (car args)) | |
3285 (when (not byte-compile-delete-errors) | |
3286 (byte-compile-out 'byte-dup 0) | |
3287 (byte-compile-out 'byte-min 0))) | |
3288 (t (byte-compile-form (car args)) | |
3289 (dolist (elt (cdr args)) | |
3290 (byte-compile-form elt) | |
3291 (byte-compile-out 'byte-min 0)))))) | |
428 | 3292 |
3293 | |
3294 ;; more complicated compiler macros | |
3295 | |
3296 (byte-defop-compiler list) | |
3297 (byte-defop-compiler concat) | |
3298 (byte-defop-compiler fset) | |
3299 (byte-defop-compiler insert) | |
3300 (byte-defop-compiler-1 function byte-compile-function-form) | |
446 | 3301 (byte-defop-compiler max) |
3302 (byte-defop-compiler min) | |
3303 (byte-defop-compiler (+ byte-plus) byte-compile-plus) | |
3304 (byte-defop-compiler-1 - byte-compile-minus) | |
3305 (byte-defop-compiler (* byte-mult) byte-compile-mult) | |
3306 (byte-defop-compiler (/ byte-quo) byte-compile-quo) | |
428 | 3307 (byte-defop-compiler nconc) |
3308 (byte-defop-compiler-1 beginning-of-line) | |
3309 | |
3310 (byte-defop-compiler (= byte-eqlsign) byte-compile-arithcompare) | |
3311 (byte-defop-compiler (< byte-lss) byte-compile-arithcompare) | |
3312 (byte-defop-compiler (> byte-gtr) byte-compile-arithcompare) | |
3313 (byte-defop-compiler (<= byte-leq) byte-compile-arithcompare) | |
3314 (byte-defop-compiler (>= byte-geq) byte-compile-arithcompare) | |
3315 | |
3316 (defun byte-compile-arithcompare (form) | |
3317 (case (length (cdr form)) | |
3318 (0 (byte-compile-subr-wrong-args form "1 or more")) | |
549 | 3319 (1 (if byte-compile-delete-errors |
3320 (byte-compile-constant t) | |
3321 (byte-compile-normal-call form))) | |
428 | 3322 (2 (byte-compile-two-args form)) |
3323 (t (byte-compile-normal-call form)))) | |
3324 | |
3325 (byte-defop-compiler /= byte-compile-/=) | |
3326 | |
3327 (defun byte-compile-/= (form) | |
3328 (case (length (cdr form)) | |
3329 (0 (byte-compile-subr-wrong-args form "1 or more")) | |
3330 (1 (byte-compile-constant t)) | |
3331 ;; optimize (/= X Y) to (not (= X Y)) | |
3332 (2 (byte-compile-form-do-effect `(not (= ,@(cdr form))))) | |
3333 (t (byte-compile-normal-call form)))) | |
3334 | |
3335 ;; buffer-substring now has its own function. This used to be | |
3336 ;; 2+1, but now all args are optional. | |
3337 (byte-defop-compiler buffer-substring) | |
3338 | |
3339 (defun byte-compile-buffer-substring (form) | |
3340 ;; buffer-substring used to take exactly two args, but now takes 0-3. | |
3341 ;; convert 0-2 to two args and use special bytecode operand. | |
3342 ;; convert 3 args to a normal call. | |
3343 (case (length (cdr form)) | |
3344 (0 (byte-compile-two-args (append form '(nil nil)))) | |
3345 (1 (byte-compile-two-args (append form '(nil)))) | |
3346 (2 (byte-compile-two-args form)) | |
3347 (3 (byte-compile-normal-call form)) | |
3348 (t (byte-compile-subr-wrong-args form "0-3")))) | |
3349 | |
3350 (defun byte-compile-list (form) | |
3351 (let* ((args (cdr form)) | |
3352 (nargs (length args))) | |
3353 (cond | |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
3354 ((eql nargs 0) |
428 | 3355 (byte-compile-constant nil)) |
3356 ((< nargs 5) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
3357 (mapc 'byte-compile-form args) |
428 | 3358 (byte-compile-out |
3359 (aref [byte-list1 byte-list2 byte-list3 byte-list4] (1- nargs)) | |
3360 0)) | |
3361 ((< nargs 256) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
3362 (mapc 'byte-compile-form args) |
428 | 3363 (byte-compile-out 'byte-listN nargs)) |
3364 (t (byte-compile-normal-call form))))) | |
3365 | |
3366 (defun byte-compile-concat (form) | |
3367 (let* ((args (cdr form)) | |
3368 (nargs (length args))) | |
3369 ;; Concat of one arg is not a no-op if arg is not a string. | |
3370 (cond | |
3371 ((memq nargs '(2 3 4)) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
3372 (mapc 'byte-compile-form args) |
428 | 3373 (byte-compile-out |
3374 (aref [byte-concat2 byte-concat3 byte-concat4] (- nargs 2)) | |
3375 0)) | |
3376 ((eq nargs 0) | |
3377 (byte-compile-form "")) | |
3378 ((< nargs 256) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
3379 (mapc 'byte-compile-form args) |
428 | 3380 (byte-compile-out 'byte-concatN nargs)) |
3381 ((byte-compile-normal-call form))))) | |
3382 | |
446 | 3383 (defun byte-compile-plus (form) |
3384 (let ((args (cdr form))) | |
3385 (case (length args) | |
3386 (0 (byte-compile-constant 0)) | |
3387 (1 (byte-compile-plus (append form '(0)))) | |
3388 (t (byte-compile-form (car args)) | |
3389 (dolist (elt (cdr args)) | |
3390 (case elt | |
3391 (0 (when (not byte-compile-delete-errors) | |
3392 (byte-compile-constant 0) | |
3393 (byte-compile-out 'byte-plus 0))) | |
3394 (+1 (byte-compile-out 'byte-add1 0)) | |
3395 (-1 (byte-compile-out 'byte-sub1 0)) | |
3396 (t | |
3397 (byte-compile-form elt) | |
3398 (byte-compile-out 'byte-plus 0)))))))) | |
3399 | |
428 | 3400 (defun byte-compile-minus (form) |
3401 (let ((args (cdr form))) | |
3402 (case (length args) | |
3403 (0 (byte-compile-subr-wrong-args form "1 or more")) | |
3404 (1 (byte-compile-form (car args)) | |
3405 (byte-compile-out 'byte-negate 0)) | |
3406 (t (byte-compile-form (car args)) | |
3407 (dolist (elt (cdr args)) | |
446 | 3408 (case elt |
3409 (0 (when (not byte-compile-delete-errors) | |
3410 (byte-compile-constant 0) | |
3411 (byte-compile-out 'byte-diff 0))) | |
3412 (+1 (byte-compile-out 'byte-sub1 0)) | |
3413 (-1 (byte-compile-out 'byte-add1 0)) | |
3414 (t | |
3415 (byte-compile-form elt) | |
3416 (byte-compile-out 'byte-diff 0)))))))) | |
3417 | |
3418 (defun byte-compile-mult (form) | |
3419 (let ((args (cdr form))) | |
3420 (case (length args) | |
3421 (0 (byte-compile-constant 1)) | |
3422 (1 (byte-compile-mult (append form '(1)))) | |
3423 (t (byte-compile-form (car args)) | |
3424 (dolist (elt (cdr args)) | |
3425 (case elt | |
3426 (1 (when (not byte-compile-delete-errors) | |
3427 (byte-compile-constant 1) | |
3428 (byte-compile-out 'byte-mult 0))) | |
3429 (-1 (byte-compile-out 'byte-negate 0)) | |
3430 (2 (byte-compile-out 'byte-dup 0) | |
3431 (byte-compile-out 'byte-plus 0)) | |
3432 (t | |
3433 (byte-compile-form elt) | |
3434 (byte-compile-out 'byte-mult 0)))))))) | |
428 | 3435 |
3436 (defun byte-compile-quo (form) | |
3437 (let ((args (cdr form))) | |
3438 (case (length args) | |
3439 (0 (byte-compile-subr-wrong-args form "1 or more")) | |
3440 (1 (byte-compile-constant 1) | |
3441 (byte-compile-form (car args)) | |
3442 (byte-compile-out 'byte-quo 0)) | |
3443 (t (byte-compile-form (car args)) | |
3444 (dolist (elt (cdr args)) | |
446 | 3445 (case elt |
3446 (+1 (when (not byte-compile-delete-errors) | |
3447 (byte-compile-constant 1) | |
3448 (byte-compile-out 'byte-quo 0))) | |
3449 (-1 (byte-compile-out 'byte-negate 0)) | |
3450 (t | |
3451 (when (and (numberp elt) (= elt 0)) | |
3452 (byte-compile-warn "Attempt to divide by zero: %s" form)) | |
3453 (byte-compile-form elt) | |
3454 (byte-compile-out 'byte-quo 0)))))))) | |
428 | 3455 |
3456 (defun byte-compile-nconc (form) | |
3457 (let ((args (cdr form))) | |
3458 (case (length args) | |
3459 (0 (byte-compile-constant nil)) | |
3460 ;; nconc of one arg is a noop, even if that arg isn't a list. | |
3461 (1 (byte-compile-form (car args))) | |
3462 (t (byte-compile-form (car args)) | |
3463 (dolist (elt (cdr args)) | |
3464 (byte-compile-form elt) | |
3465 (byte-compile-out 'byte-nconc 0)))))) | |
3466 | |
3467 (defun byte-compile-fset (form) | |
3468 ;; warn about forms like (fset 'foo '(lambda () ...)) | |
3469 ;; (where the lambda expression is non-trivial...) | |
3470 ;; Except don't warn if the first argument is 'make-byte-code, because | |
3471 ;; I'm sick of getting mail asking me whether that warning is a problem. | |
3472 (let ((fn (nth 2 form)) | |
3473 body) | |
3474 (when (and (eq (car-safe fn) 'quote) | |
3475 (eq (car-safe (setq fn (nth 1 fn))) 'lambda) | |
3476 (not (eq (car-safe (cdr-safe (nth 1 form))) 'make-byte-code))) | |
3477 (setq body (cdr (cdr fn))) | |
3478 (if (stringp (car body)) (setq body (cdr body))) | |
3479 (if (eq 'interactive (car-safe (car body))) (setq body (cdr body))) | |
3480 (if (and (consp (car body)) | |
4719
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3481 (not (eq 'byte-code (car (car body)))) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3482 (memq 'quoted-lambda byte-compile-warnings)) |
428 | 3483 (byte-compile-warn |
3484 "A quoted lambda form is the second argument of fset. This is probably | |
3485 not what you want, as that lambda cannot be compiled. Consider using | |
3486 the syntax (function (lambda (...) ...)) instead.")))) | |
3487 (byte-compile-two-args form)) | |
3488 | |
5089
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
3489 (defun byte-compile-subseq (form) |
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
3490 (byte-compile-two-or-three-args form) |
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
3491 ;; Check that XEmacs supports the substring-subseq equivalence. |
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
3492 (pushnew '(eq 'subseq (symbol-function 'substring)) |
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
3493 byte-compile-checks-on-load :test #'equal)) |
99f8ebc082d9
Make #'substring an alias of #'subseq; give the latter the byte code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4996
diff
changeset
|
3494 |
4743
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3495 (defmacro byte-compile-funarg-n (&rest n) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3496 `#'(lambda (form) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3497 ,@(loop |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3498 for en in n |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3499 collect `(let ((fn (nth ,en form))) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3500 (when (and (eq (car-safe fn) 'quote) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3501 (eq (car-safe (nth 1 fn)) 'lambda) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3502 (or |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3503 (null (memq 'quoted-lambda |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3504 byte-compile-warnings)) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3505 (byte-compile-warn |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3506 "Passing a quoted lambda (arg %d) to #'%s, \ |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3507 forcing function quoting" ,en (car form)))) |
4743
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3508 (setcar fn 'function)))) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3509 (byte-compile-normal-call form))) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3510 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3511 ;; (mapcar '(lambda (x) ..) ..) ==> (mapcar (function (lambda (x) ..)) ..) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3512 ;; for cases where it's guaranteed that first arg will be used as a lambda. |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3513 (defalias 'byte-compile-funarg (byte-compile-funarg-n 1)) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3514 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3515 ;; (sort ... '(lambda (x) ..)) ==> (sort ... (function (lambda (x) ..))) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3516 ;; for cases where it's guaranteed that second arg will be used as a lambda. |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3517 (defalias 'byte-compile-funarg-2 (byte-compile-funarg-n 2)) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3518 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3519 ;; For #'merge, basically. |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3520 (defalias 'byte-compile-funarg-4 (byte-compile-funarg-n 4)) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3521 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3522 ;; For #'call-with-condition-handler, basically. |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3523 (defalias 'byte-compile-funarg-1-2 (byte-compile-funarg-n 1 2)) |
428 | 3524 |
4716
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3525 ;; XEmacs change; don't cons up the list if it's going to be immediately |
4743
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3526 ;; discarded. GNU give a warning in `byte-compile-normal-call' instead, and |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3527 ;; only for #'mapcar. |
4719
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3528 (defun byte-compile-maybe-mapc (form) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3529 (and for-effect |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3530 (or (null (memq 'discarded-consing byte-compile-warnings)) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3531 (byte-compile-warn |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3532 "Discarding the result of #'%s; maybe you meant #'mapc?" |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3533 (car form))) |
4995
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4885
diff
changeset
|
3534 (setq form (cons 'mapc (cdr form)))) |
4716
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3535 (byte-compile-funarg form)) |
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3536 |
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3537 (defun byte-compile-maplist (form) |
4719
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3538 (and for-effect |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3539 (or (null (memq 'discarded-consing byte-compile-warnings)) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3540 (byte-compile-warn |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3541 "Discarding the result of #'maplist; maybe you meant #'mapl?")) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3542 (setq form (cons 'mapl (cdr form)))) |
4716
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3543 (byte-compile-funarg form)) |
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3544 |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3545 ;; For when calls to #'sort or #'mapcar have more than two args, something |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3546 ;; recent XEmacs can handle, but GNU and 21.4 can't. |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3547 (defmacro byte-compile-maybe-add-* (complex max) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3548 `#'(lambda (form) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3549 (when (> (length (cdr form)) ,max) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3550 (when (memq 'callargs byte-compile-warnings) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3551 (byte-compile-warn |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3552 "#'%s called with %d arguments, using #'%s instead" |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3553 (car form) (length (cdr form)) ',complex)) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3554 (setq form (cons ',complex (cdr form)))) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3555 (funcall (or (get ',complex 'byte-compile) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3556 'byte-compile-normal-call) form))) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3557 |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3558 (defalias 'byte-compile-mapcar (byte-compile-maybe-add-* mapcar* 2)) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3559 |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3560 (defalias 'byte-compile-sort (byte-compile-maybe-add-* sort* 2)) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3561 |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3562 (defalias 'byte-compile-fillarray (byte-compile-maybe-add-* fill 2)) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3563 |
428 | 3564 ;; (function foo) must compile like 'foo, not like (symbol-function 'foo). |
3565 ;; Otherwise it will be incompatible with the interpreter, | |
3566 ;; and (funcall (function foo)) will lose with autoloads. | |
3567 | |
3568 (defun byte-compile-function-form (form) | |
5265
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3569 (if (cddr form) |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3570 (byte-compile-normal-call |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3571 `(signal 'wrong-number-of-arguments '(function ,(length (cdr form))))) |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3572 (byte-compile-constant |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3573 (cond ((symbolp (nth 1 form)) |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3574 (nth 1 form)) |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3575 ((byte-compile-lambda (nth 1 form))))))) |
428 | 3576 |
3577 (defun byte-compile-insert (form) | |
3578 (cond ((null (cdr form)) | |
3579 (byte-compile-constant nil)) | |
3580 ((<= (length form) 256) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
3581 (mapc 'byte-compile-form (cdr form)) |
428 | 3582 (if (cdr (cdr form)) |
3583 (byte-compile-out 'byte-insertN (length (cdr form))) | |
3584 (byte-compile-out 'byte-insert 0))) | |
3585 ((memq t (mapcar 'consp (cdr (cdr form)))) | |
3586 (byte-compile-normal-call form)) | |
3587 ;; We can split it; there is no function call after inserting 1st arg. | |
3588 (t | |
3589 (while (setq form (cdr form)) | |
3590 (byte-compile-form (car form)) | |
3591 (byte-compile-out 'byte-insert 0) | |
3592 (when (cdr form) | |
3593 (byte-compile-discard)))))) | |
3594 | |
3595 ;; alas, the old (pre-19.12, and all existing versions of FSFmacs 19) | |
3596 ;; byte compiler will generate incorrect code for | |
3597 ;; (beginning-of-line nil buffer) because it buggily doesn't | |
3598 ;; check the number of arguments passed to beginning-of-line. | |
3599 | |
3600 (defun byte-compile-beginning-of-line (form) | |
3601 (let ((len (length form))) | |
3602 (cond ((> len 3) | |
3603 (byte-compile-subr-wrong-args form "0-2")) | |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
3604 ((or (eql len 3) (not (byte-compile-constp (nth 1 form)))) |
428 | 3605 (byte-compile-normal-call form)) |
3606 (t | |
3607 (byte-compile-form | |
3608 (list 'forward-line | |
3609 (if (integerp (setq form (or (eval (nth 1 form)) 1))) | |
3610 (1- form) | |
3611 (byte-compile-warn | |
3612 "Non-numeric arg to beginning-of-line: %s" form) | |
3613 (list '1- (list 'quote form)))) | |
3614 t) | |
3615 (byte-compile-constant nil))))) | |
3616 | |
3617 | |
3618 (byte-defop-compiler set) | |
3619 (byte-defop-compiler-1 setq) | |
3620 (byte-defop-compiler-1 set-default) | |
3621 (byte-defop-compiler-1 setq-default) | |
3622 | |
3623 (byte-defop-compiler-1 quote) | |
3624 (byte-defop-compiler-1 quote-form) | |
3625 | |
3626 (defun byte-compile-setq (form) | |
3627 (let ((args (cdr form)) var val) | |
3628 (if (null args) | |
3629 ;; (setq), with no arguments. | |
3630 (byte-compile-form nil for-effect) | |
3631 (while args | |
3632 (setq var (pop args)) | |
3633 (if (null args) | |
3634 ;; Odd number of args? Let `set' get the error. | |
3635 (byte-compile-form `(set ',var) for-effect) | |
3636 (setq val (pop args)) | |
5344
2a54dfbe434f
Don't quote keywords, they've been self-quoting for well over a decade.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5301
diff
changeset
|
3637 (byte-compile-form val) |
2a54dfbe434f
Don't quote keywords, they've been self-quoting for well over a decade.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5301
diff
changeset
|
3638 (unless (or args for-effect) |
2a54dfbe434f
Don't quote keywords, they've been self-quoting for well over a decade.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5301
diff
changeset
|
3639 (byte-compile-out 'byte-dup 0)) |
2a54dfbe434f
Don't quote keywords, they've been self-quoting for well over a decade.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5301
diff
changeset
|
3640 (byte-compile-variable-ref 'byte-varset var))))) |
428 | 3641 (setq for-effect nil)) |
3642 | |
3643 (defun byte-compile-set (form) | |
3644 ;; Compile (set 'foo x) as (setq foo x) for trivially better code and so | |
3645 ;; that we get applicable warnings. Compile everything else (including | |
3646 ;; malformed calls) like a normal 2-arg byte-coded function. | |
3647 (let ((symform (nth 1 form)) | |
3648 (valform (nth 2 form)) | |
3649 sym) | |
5344
2a54dfbe434f
Don't quote keywords, they've been self-quoting for well over a decade.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5301
diff
changeset
|
3650 (if (and (eql (length form) 3) |
2a54dfbe434f
Don't quote keywords, they've been self-quoting for well over a decade.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5301
diff
changeset
|
3651 (eql (safe-length symform) 2) |
428 | 3652 (eq (car symform) 'quote) |
5344
2a54dfbe434f
Don't quote keywords, they've been self-quoting for well over a decade.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5301
diff
changeset
|
3653 (symbolp (setq sym (car (cdr symform))))) |
428 | 3654 (byte-compile-setq `(setq ,sym ,valform)) |
3655 (byte-compile-two-args form)))) | |
3656 | |
3657 (defun byte-compile-setq-default (form) | |
3658 (let ((args (cdr form))) | |
3659 (if (null args) | |
3660 ;; (setq-default), with no arguments. | |
3661 (byte-compile-form nil for-effect) | |
3662 ;; emit multiple calls to `set-default' if necessary | |
3663 (while args | |
3664 (byte-compile-form | |
3665 ;; Odd number of args? Let `set-default' get the error. | |
3666 `(set-default ',(pop args) ,@(if args (list (pop args)) nil)) | |
3667 (if args t for-effect))))) | |
3668 (setq for-effect nil)) | |
3669 | |
3670 (defun byte-compile-set-default (form) | |
3671 (let* ((args (cdr form)) | |
3672 (nargs (length args)) | |
3673 (var (car args))) | |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
3674 (when (and (eql (safe-length var) 2) (eq (car var) 'quote)) |
428 | 3675 (let ((sym (nth 1 var))) |
3676 (cond | |
3677 ((not (symbolp sym)) | |
3678 (byte-compile-warn "Attempt to set-globally non-symbol %s" sym)) | |
3679 ((byte-compile-constant-symbol-p sym) | |
3680 (byte-compile-warn "Attempt to set-globally constant symbol %s" sym)) | |
3681 ((let ((cell (assq sym byte-compile-bound-variables))) | |
3682 (and cell | |
3683 (setcdr cell (logior (cdr cell) byte-compile-assigned-bit)) | |
3684 t))) | |
3685 ;; notice calls to set-default/setq-default for variables which | |
3686 ;; have not been declared with defvar/defconst. | |
3687 ((globally-boundp sym)) ; OK | |
3688 ((not (memq 'free-vars byte-compile-warnings))) ; warnings suppressed? | |
3689 ((memq sym byte-compile-free-assignments)) ; already warned about sym | |
3690 (t | |
3691 (byte-compile-warn "assignment to free variable %s" sym) | |
3692 (push sym byte-compile-free-assignments))))) | |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
3693 (if (eql nargs 2) |
428 | 3694 ;; now emit a normal call to set-default |
3695 (byte-compile-normal-call form) | |
3696 (byte-compile-subr-wrong-args form 2)))) | |
3697 | |
3698 | |
3699 (defun byte-compile-quote (form) | |
5265
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3700 (if (cddr form) |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3701 (byte-compile-normal-call |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3702 `(signal 'wrong-number-of-arguments '(quote ,(length (cdr form))))) |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3703 (byte-compile-constant (car (cdr form))))) |
428 | 3704 |
3705 (defun byte-compile-quote-form (form) | |
5265
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3706 (if (cddr form) |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3707 (byte-compile-normal-call |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3708 `(signal 'wrong-number-of-arguments '(quote ,(length (cdr form))))) |
5663ae9a8989
Warn at compile time, error at runtime, with (quote X Y), (function X Y).
Aidan Kehoe <kehoea@parhasard.net>
parents:
5263
diff
changeset
|
3709 (byte-compile-constant (byte-compile-top-level (nth 1 form))))) |
428 | 3710 |
3711 ;;; control structures | |
3712 | |
3713 (defun byte-compile-body (body &optional for-effect) | |
3714 (while (cdr body) | |
3715 (byte-compile-form (car body) t) | |
3716 (setq body (cdr body))) | |
3717 (byte-compile-form (car body) for-effect)) | |
3718 | |
3719 (proclaim-inline byte-compile-body-do-effect) | |
3720 (defun byte-compile-body-do-effect (body) | |
3721 (byte-compile-body body for-effect) | |
3722 (setq for-effect nil)) | |
3723 | |
3724 (proclaim-inline byte-compile-form-do-effect) | |
3725 (defun byte-compile-form-do-effect (form) | |
3726 (byte-compile-form form for-effect) | |
3727 (setq for-effect nil)) | |
3728 | |
3729 (byte-defop-compiler-1 inline byte-compile-progn) | |
3730 (byte-defop-compiler-1 progn) | |
3731 (byte-defop-compiler-1 prog1) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3732 (byte-defop-compiler-1 multiple-value-prog1) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3733 (byte-defop-compiler-1 values) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3734 (byte-defop-compiler-1 values-list) |
428 | 3735 (byte-defop-compiler-1 prog2) |
3736 (byte-defop-compiler-1 if) | |
3737 (byte-defop-compiler-1 cond) | |
3738 (byte-defop-compiler-1 and) | |
3739 (byte-defop-compiler-1 or) | |
3740 (byte-defop-compiler-1 while) | |
3741 (byte-defop-compiler-1 funcall) | |
3742 (byte-defop-compiler-1 apply byte-compile-funarg) | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3743 (byte-defop-compiler-1 mapcar byte-compile-mapcar) |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3744 (byte-defop-compiler-1 mapcar* byte-compile-maybe-mapc) |
428 | 3745 (byte-defop-compiler-1 mapatoms byte-compile-funarg) |
3746 (byte-defop-compiler-1 mapconcat byte-compile-funarg) | |
4743
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3747 (byte-defop-compiler-1 mapc byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3748 (byte-defop-compiler-1 maphash byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3749 (byte-defop-compiler-1 map-char-table byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3750 (byte-defop-compiler-1 mapvector byte-compile-maybe-mapc) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3751 (byte-defop-compiler-1 mapc-internal byte-compile-funarg) |
4716
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3752 (byte-defop-compiler-1 maplist byte-compile-maplist) |
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3753 (byte-defop-compiler-1 mapl byte-compile-funarg) |
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3754 (byte-defop-compiler-1 mapcan byte-compile-funarg) |
dca5bb2adff1
Don't cons with #'mapcar calls where the result is discarded,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4686
diff
changeset
|
3755 (byte-defop-compiler-1 mapcon byte-compile-funarg) |
4719
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3756 (byte-defop-compiler-1 map-database byte-compile-funarg) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3757 (byte-defop-compiler-1 map-extent-children byte-compile-funarg) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3758 (byte-defop-compiler-1 map-extents byte-compile-funarg) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3759 (byte-defop-compiler-1 map-plist byte-compile-funarg) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3760 (byte-defop-compiler-1 map-range-table byte-compile-funarg) |
bd51ab22afa8
Make it possible to silence warnings issued when #'mapcar's result is discarded.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4716
diff
changeset
|
3761 (byte-defop-compiler-1 map-syntax-table byte-compile-funarg) |
4743
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3762 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3763 (byte-defop-compiler-1 remove-if byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3764 (byte-defop-compiler-1 remove-if-not byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3765 (byte-defop-compiler-1 delete-if byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3766 (byte-defop-compiler-1 delete-if-not byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3767 (byte-defop-compiler-1 find-if byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3768 (byte-defop-compiler-1 find-if-not byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3769 (byte-defop-compiler-1 position-if byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3770 (byte-defop-compiler-1 position-if-not byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3771 (byte-defop-compiler-1 count-if byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3772 (byte-defop-compiler-1 count-if-not byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3773 (byte-defop-compiler-1 member-if byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3774 (byte-defop-compiler-1 member-if-not byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3775 (byte-defop-compiler-1 assoc-if byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3776 (byte-defop-compiler-1 assoc-if-not byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3777 (byte-defop-compiler-1 rassoc-if byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3778 (byte-defop-compiler-1 rassoc-if-not byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3779 (byte-defop-compiler-1 reduce byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3780 (byte-defop-compiler-1 some byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3781 (byte-defop-compiler-1 every byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3782 (byte-defop-compiler-1 notany byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3783 (byte-defop-compiler-1 notevery byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3784 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3785 (byte-defop-compiler-1 walk-windows byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3786 (byte-defop-compiler-1 get-window-with-predicate byte-compile-funarg) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3787 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3788 (byte-defop-compiler-1 map byte-compile-funarg-2) |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3789 (byte-defop-compiler-1 map-into byte-compile-funarg-2) |
4743
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3790 (byte-defop-compiler-1 apropos-internal byte-compile-funarg-2) |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3791 (byte-defop-compiler-1 sort byte-compile-sort) |
4743
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3792 (byte-defop-compiler-1 sort* byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3793 (byte-defop-compiler-1 stable-sort byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3794 (byte-defop-compiler-1 substitute-if byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3795 (byte-defop-compiler-1 substitute-if-not byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3796 (byte-defop-compiler-1 nsubstitute-if byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3797 (byte-defop-compiler-1 nsubstitute-if-not byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3798 (byte-defop-compiler-1 subst-if byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3799 (byte-defop-compiler-1 subst-if-not byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3800 (byte-defop-compiler-1 nsubst-if byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3801 (byte-defop-compiler-1 nsubst-if-not byte-compile-funarg-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3802 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3803 (byte-defop-compiler-1 merge byte-compile-funarg-4) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3804 |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3805 (byte-defop-compiler-1 call-with-condition-handler byte-compile-funarg-1-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3806 (byte-defop-compiler-1 mapcar-extents byte-compile-funarg-1-2) |
776bbf454f3a
Be much more comprehensive in our use of byte-compile-funarg.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4719
diff
changeset
|
3807 |
428 | 3808 (byte-defop-compiler-1 let) |
3809 (byte-defop-compiler-1 let*) | |
3810 | |
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
3811 (byte-defop-compiler-1 integerp) |
5301
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
3812 (byte-defop-compiler-1 eql) |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5106
diff
changeset
|
3813 (byte-defop-compiler-1 fillarray) |
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
3814 |
428 | 3815 (defun byte-compile-progn (form) |
3816 (byte-compile-body-do-effect (cdr form))) | |
3817 | |
3818 (defun byte-compile-prog1 (form) | |
3819 (setq form (cdr form)) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3820 ;; #'prog1 never returns multiple values: |
4686
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
3821 (byte-compile-form-do-effect `(or ,(pop form) nil)) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3822 (byte-compile-body form t)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3823 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3824 (defun byte-compile-multiple-value-prog1 (form) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3825 (setq form (cdr form)) |
428 | 3826 (byte-compile-form-do-effect (pop form)) |
3827 (byte-compile-body form t)) | |
3828 | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3829 (defun byte-compile-values (form) |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
3830 (if (eql 2 (length form)) |
4686
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
3831 (if (byte-compile-constp (second form)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
3832 (byte-compile-form-do-effect (second form)) |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
3833 ;; #'or compiles to bytecode, #'values doesn't: |
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
3834 (byte-compile-form-do-effect `(or ,(second form) nil))) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3835 (byte-compile-normal-call form))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3836 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3837 (defun byte-compile-values-list (form) |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
3838 (if (and (eql 2 (length form)) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3839 (or (null (second form)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3840 (and (consp (second form)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3841 (eq (car (second form)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3842 'quote) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3843 (not (symbolp (car-safe (cdr (second form)))))))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3844 (byte-compile-form-do-effect (car-safe (cdr (second form)))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3845 (byte-compile-normal-call form))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3846 |
428 | 3847 (defun byte-compile-prog2 (form) |
3848 (setq form (cdr form)) | |
3849 (byte-compile-form (pop form) t) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
3850 ;; #'prog2 never returns multiple values: |
4686
cdabd56ce1b5
Fix various small issues with the multiple-value implementation.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4683
diff
changeset
|
3851 (byte-compile-form-do-effect `(or ,(pop form) nil)) |
428 | 3852 (byte-compile-body form t)) |
3853 | |
3854 (defmacro byte-compile-goto-if (cond discard tag) | |
3855 `(byte-compile-goto | |
3856 (if ,cond | |
3857 (if ,discard 'byte-goto-if-not-nil 'byte-goto-if-not-nil-else-pop) | |
3858 (if ,discard 'byte-goto-if-nil 'byte-goto-if-nil-else-pop)) | |
3859 ,tag)) | |
3860 | |
3861 (defun byte-compile-if (form) | |
3862 (byte-compile-form (car (cdr form))) | |
3863 (if (null (nthcdr 3 form)) | |
3864 ;; No else-forms | |
3865 (let ((donetag (byte-compile-make-tag))) | |
3866 (byte-compile-goto-if nil for-effect donetag) | |
3867 (byte-compile-form (nth 2 form) for-effect) | |
3868 (byte-compile-out-tag donetag)) | |
3869 (let ((donetag (byte-compile-make-tag)) (elsetag (byte-compile-make-tag))) | |
3870 (byte-compile-goto 'byte-goto-if-nil elsetag) | |
3871 (byte-compile-form (nth 2 form) for-effect) | |
3872 (byte-compile-goto 'byte-goto donetag) | |
3873 (byte-compile-out-tag elsetag) | |
3874 (byte-compile-body (cdr (cdr (cdr form))) for-effect) | |
3875 (byte-compile-out-tag donetag))) | |
3876 (setq for-effect nil)) | |
3877 | |
3878 (defun byte-compile-cond (clauses) | |
3879 (let ((donetag (byte-compile-make-tag)) | |
3880 nexttag clause) | |
3881 (while (setq clauses (cdr clauses)) | |
3882 (setq clause (car clauses)) | |
3883 (cond ((or (eq (car clause) t) | |
3884 (and (eq (car-safe (car clause)) 'quote) | |
3885 (car-safe (cdr-safe (car clause))))) | |
3886 ;; Unconditional clause | |
3887 (setq clause (cons t clause) | |
3888 clauses nil)) | |
3889 ((cdr clauses) | |
3890 (byte-compile-form (car clause)) | |
3891 (if (null (cdr clause)) | |
3892 ;; First clause is a singleton. | |
3893 (byte-compile-goto-if t for-effect donetag) | |
3894 (setq nexttag (byte-compile-make-tag)) | |
3895 (byte-compile-goto 'byte-goto-if-nil nexttag) | |
3896 (byte-compile-body (cdr clause) for-effect) | |
3897 (byte-compile-goto 'byte-goto donetag) | |
3898 (byte-compile-out-tag nexttag))))) | |
3899 ;; Last clause | |
3900 (and (cdr clause) (not (eq (car clause) t)) | |
3901 (progn (byte-compile-form (car clause)) | |
3902 (byte-compile-goto-if nil for-effect donetag) | |
3903 (setq clause (cdr clause)))) | |
3904 (byte-compile-body-do-effect clause) | |
3905 (byte-compile-out-tag donetag))) | |
3906 | |
3907 (defun byte-compile-and (form) | |
3908 (let ((failtag (byte-compile-make-tag)) | |
3909 (args (cdr form))) | |
3910 (if (null args) | |
3911 (byte-compile-form-do-effect t) | |
3912 (while (cdr args) | |
3913 (byte-compile-form (car args)) | |
3914 (byte-compile-goto-if nil for-effect failtag) | |
3915 (setq args (cdr args))) | |
3916 (byte-compile-form-do-effect (car args)) | |
3917 (byte-compile-out-tag failtag)))) | |
3918 | |
3919 (defun byte-compile-or (form) | |
3920 (let ((wintag (byte-compile-make-tag)) | |
3921 (args (cdr form))) | |
3922 (if (null args) | |
3923 (byte-compile-form-do-effect nil) | |
3924 (while (cdr args) | |
3925 (byte-compile-form (car args)) | |
3926 (byte-compile-goto-if t for-effect wintag) | |
3927 (setq args (cdr args))) | |
3928 (byte-compile-form-do-effect (car args)) | |
3929 (byte-compile-out-tag wintag)))) | |
3930 | |
3931 (defun byte-compile-while (form) | |
3932 (let ((endtag (byte-compile-make-tag)) | |
3933 (looptag (byte-compile-make-tag))) | |
3934 (byte-compile-out-tag looptag) | |
3935 (byte-compile-form (car (cdr form))) | |
3936 (byte-compile-goto-if nil for-effect endtag) | |
3937 (byte-compile-body (cdr (cdr form)) t) | |
3938 (byte-compile-goto 'byte-goto looptag) | |
3939 (byte-compile-out-tag endtag) | |
3940 (setq for-effect nil))) | |
3941 | |
3942 (defun byte-compile-funcall (form) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
3943 (mapc 'byte-compile-form (cdr form)) |
428 | 3944 (byte-compile-out 'byte-call (length (cdr (cdr form))))) |
3945 | |
3946 | |
3947 (defun byte-compile-let (form) | |
3948 ;; First compute the binding values in the old scope. | |
3949 (let ((varlist (car (cdr form)))) | |
3950 (while varlist | |
3951 (if (consp (car varlist)) | |
3952 (byte-compile-form (car (cdr (car varlist)))) | |
3953 (byte-compile-push-constant nil)) | |
3954 (setq varlist (cdr varlist)))) | |
3955 (let ((byte-compile-bound-variables | |
3956 (cons 'new-scope byte-compile-bound-variables)) | |
3957 (varlist (reverse (car (cdr form)))) | |
3958 (extra-flags | |
3959 ;; If this let is of the form (let (...) (byte-code ...)) | |
3960 ;; then assume that it is the result of a transformation of | |
3961 ;; ((lambda (...) (byte-code ... )) ...) and thus compile | |
3962 ;; the variable bindings as if they were arglist bindings | |
3963 ;; (which matters for what warnings.) | |
3964 (if (eq 'byte-code (car-safe (nth 2 form))) | |
3965 byte-compile-arglist-bit | |
3966 nil))) | |
3967 (while varlist | |
3968 (byte-compile-variable-ref 'byte-varbind | |
3969 (if (consp (car varlist)) | |
3970 (car (car varlist)) | |
3971 (car varlist)) | |
3972 extra-flags) | |
3973 (setq varlist (cdr varlist))) | |
3974 (byte-compile-body-do-effect (cdr (cdr form))) | |
3975 (if (memq 'unused-vars byte-compile-warnings) | |
3976 ;; done compiling in this scope, warn now. | |
3977 (byte-compile-warn-about-unused-variables)) | |
3978 (byte-compile-out 'byte-unbind (length (car (cdr form)))))) | |
3979 | |
3980 (defun byte-compile-let* (form) | |
3981 (let ((byte-compile-bound-variables | |
3982 (cons 'new-scope byte-compile-bound-variables)) | |
3983 (varlist (copy-sequence (car (cdr form))))) | |
3984 (while varlist | |
3985 (if (atom (car varlist)) | |
3986 (byte-compile-push-constant nil) | |
3987 (byte-compile-form (car (cdr (car varlist)))) | |
3988 (setcar varlist (car (car varlist)))) | |
3989 (byte-compile-variable-ref 'byte-varbind (car varlist)) | |
3990 (setq varlist (cdr varlist))) | |
3991 (byte-compile-body-do-effect (cdr (cdr form))) | |
3992 (if (memq 'unused-vars byte-compile-warnings) | |
3993 ;; done compiling in this scope, warn now. | |
3994 (byte-compile-warn-about-unused-variables)) | |
3995 (byte-compile-out 'byte-unbind (length (car (cdr form)))))) | |
3996 | |
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
3997 ;; We've renamed the integerp bytecode to fixnump, and changed its semantics |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
3998 ;; accordingly. This means #'integerp itself can't be as fast as it used to |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
3999 ;; be, since it no longer has a bytecode to itself. As it happens, though, |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4000 ;; most of the non-core calls to #'integerp are in contexts where it is |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4001 ;; either going to receive a fixnum, or something non-numeric entirely; the |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4002 ;; contexts where it needs to distinguish between an integer and a float are |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4003 ;; very rare. So, we can have (integerp X) compile to: |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4004 ;; |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4005 ;; (or (fixnump X) (and (numberp X) (funcall #'integerp X))) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4006 ;; |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4007 ;; without the multiple evaluation of X, and where #'fixnump and #'numberp |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4008 ;; both have bytecodes. We ignore for-effect, because byte-optimize.el will |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4009 ;; delete this call in its presence. |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4010 ;; |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4011 ;; This approach is byte-code compatible with 21.4 and with earlier 21.5 |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4012 ;; (except that earlier 21.5 with bignum support will confuse Bfixnump and |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4013 ;; Bintegerp; which it did in dealing with byte-compiled code from 21.4 |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4014 ;; anyway). |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4015 |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4016 (defun byte-compile-integerp (form) |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
4017 (if (not (eql (length form) 2)) |
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4018 (byte-compile-subr-wrong-args form 1) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4019 (let ((donetag (byte-compile-make-tag)) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4020 (wintag (byte-compile-make-tag)) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4021 (failtag (byte-compile-make-tag))) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4022 (byte-compile-constant 'integerp) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4023 (byte-compile-form (second form)) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4024 (byte-compile-out 'byte-dup 0) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4025 (byte-compile-out 'byte-fixnump 0) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4026 (byte-compile-goto 'byte-goto-if-not-nil wintag) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4027 (byte-compile-out 'byte-dup 0) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4028 (byte-compile-out 'byte-numberp 0) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4029 (byte-compile-goto 'byte-goto-if-nil failtag) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4030 (byte-compile-out 'byte-call 1) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4031 ;; At this point, the only thing from this function remaining on the |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4032 ;; stack is the return value of the called #'integerp, which reflects |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4033 ;; exactly what we want. Go directly to donetag, do not discard |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4034 ;; anything. |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4035 (byte-compile-goto 'byte-goto donetag) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4036 (byte-compile-out-tag failtag) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4037 (byte-compile-discard) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4038 (byte-compile-discard) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4039 (byte-compile-constant nil) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4040 (byte-compile-goto 'byte-goto donetag) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4041 (byte-compile-out-tag wintag) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4042 (byte-compile-discard) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4043 (byte-compile-discard) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4044 (byte-compile-constant t) |
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4783
diff
changeset
|
4045 (byte-compile-out-tag donetag)))) |
428 | 4046 |
5301
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4047 (defun byte-compile-eql (form) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4048 (if (eql 3 (length form)) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4049 (let ((donetag (byte-compile-make-tag)) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4050 (eqtag (byte-compile-make-tag))) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4051 (mapc 'byte-compile-form (cdr form)) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4052 (byte-compile-out 'byte-dup 0) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4053 (byte-compile-out 'byte-numberp 0) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4054 (byte-compile-goto 'byte-goto-if-nil eqtag) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4055 (byte-compile-out 'byte-dup 0) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4056 (byte-compile-out 'byte-fixnump 0) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4057 (byte-compile-goto 'byte-goto-if-not-nil eqtag) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4058 (byte-compile-out 'byte-equal 0) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4059 (byte-compile-goto 'byte-goto donetag) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4060 (byte-compile-out-tag eqtag) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4061 (byte-compile-out 'byte-eq 0) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4062 (byte-compile-out-tag donetag)) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4063 (byte-compile-subr-wrong-args form 2))) |
ec05a30f7148
Fix a bytecomp.el bug compiling #'eql, which was masked by cl-macs.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5294
diff
changeset
|
4064 |
428 | 4065 ;;(byte-defop-compiler-1 /= byte-compile-negated) |
4066 (byte-defop-compiler-1 atom byte-compile-negated) | |
4067 (byte-defop-compiler-1 nlistp byte-compile-negated) | |
4068 | |
4069 ;;(put '/= 'byte-compile-negated-op '=) | |
4070 (put 'atom 'byte-compile-negated-op 'consp) | |
4071 (put 'nlistp 'byte-compile-negated-op 'listp) | |
4072 | |
4073 (defun byte-compile-negated (form) | |
4074 (byte-compile-form-do-effect (byte-compile-negation-optimizer form))) | |
4075 | |
4076 ;; Even when optimization is off, atom is optimized to (not (consp ...)). | |
4077 (defun byte-compile-negation-optimizer (form) | |
4078 ;; an optimizer for forms where <form1> is less efficient than (not <form2>) | |
4079 (list 'not | |
4080 (cons (or (get (car form) 'byte-compile-negated-op) | |
4081 (error | |
4082 "Compiler error: `%s' has no `byte-compile-negated-op' property" | |
4083 (car form))) | |
4084 (cdr form)))) | |
4085 | |
4905
755ae5b97edb
Change "special form" to "special operator" in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4885
diff
changeset
|
4086 ;;; other tricky macro-like special-operators |
428 | 4087 |
4088 (byte-defop-compiler-1 catch) | |
4089 (byte-defop-compiler-1 unwind-protect) | |
4090 (byte-defop-compiler-1 condition-case) | |
4091 (byte-defop-compiler-1 save-excursion) | |
4092 (byte-defop-compiler-1 save-current-buffer) | |
4093 (byte-defop-compiler-1 save-restriction) | |
4094 (byte-defop-compiler-1 with-output-to-temp-buffer) | |
4095 ;; no track-mouse. | |
4096 | |
5356
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4097 (defvar byte-compile-active-blocks nil) |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4098 |
428 | 4099 (defun byte-compile-catch (form) |
5356
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4100 "Byte-compile and return a `catch' from. |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4101 |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4102 If FORM is the result of macroexpanding a `block' form (the TAG argument is |
5376
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4103 a quoted symbol with a `cl-block-name' property) and there is no |
5356
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4104 corresponding `return-from' within the block--or equivalently, it was |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4105 optimized away--just byte compile and return the BODY." |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4106 (let* ((symbol (car-safe (cdr-safe (nth 1 form)))) |
5376
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4107 (not-present '#:not-present) |
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4108 (block (and symbol (symbolp symbol) |
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4109 (get symbol 'cl-block-name not-present))) |
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4110 (elt (and (not (eq block not-present)) (list block))) |
5356
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4111 (byte-compile-active-blocks |
5376
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4112 (if elt |
5356
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4113 (cons elt byte-compile-active-blocks) |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4114 byte-compile-active-blocks)) |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4115 (body |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4116 (byte-compile-top-level (cons 'progn (cddr form)) |
5377
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4117 (and (not elt) for-effect)))) |
5376
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4118 (if (and elt (not (cdr elt))) |
5356
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4119 ;; A lexical block without any contained return-from clauses: |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4120 (byte-compile-form body) |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4121 ;; A normal catch call, or a lexical block with a contained |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4122 ;; return-from clause. |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4123 (byte-compile-form (car (cdr form))) |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4124 (byte-compile-push-constant body) |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4125 (byte-compile-out 'byte-catch 0)))) |
5353
38e24b8be4ea
Improve the lexical scoping in #'block, #'return-from.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5344
diff
changeset
|
4126 |
428 | 4127 (defun byte-compile-unwind-protect (form) |
4128 (byte-compile-push-constant | |
4129 (byte-compile-top-level-body (cdr (cdr form)) t)) | |
4130 (byte-compile-out 'byte-unwind-protect 0) | |
4131 (byte-compile-form-do-effect (car (cdr form))) | |
4132 (byte-compile-out 'byte-unbind 1)) | |
4133 | |
4134 ;;(defun byte-compile-track-mouse (form) | |
4135 ;; (byte-compile-form | |
4136 ;; (list | |
4137 ;; 'funcall | |
4138 ;; (list 'quote | |
4139 ;; (list 'lambda nil | |
4140 ;; (cons 'track-mouse | |
4141 ;; (byte-compile-top-level-body (cdr form)))))))) | |
4142 | |
4143 (defun byte-compile-condition-case (form) | |
4144 (let* ((var (nth 1 form)) | |
4145 (byte-compile-bound-variables | |
4146 (if var | |
4147 (cons (cons var 0) | |
4148 (cons 'new-scope byte-compile-bound-variables)) | |
4149 (cons 'new-scope byte-compile-bound-variables)))) | |
4150 (or (symbolp var) | |
4151 (byte-compile-warn | |
4152 "%s is not a variable-name or nil (in condition-case)" | |
4153 (prin1-to-string var))) | |
4154 (byte-compile-push-constant var) | |
4155 (byte-compile-push-constant (byte-compile-top-level | |
4156 (nth 2 form) for-effect)) | |
4157 (let ((clauses (cdr (cdr (cdr form)))) | |
4158 compiled-clauses) | |
4159 (while clauses | |
4160 (let* ((clause (car clauses)) | |
4161 (condition (car clause))) | |
4162 (cond ((not (or (symbolp condition) | |
4163 (and (listp condition) | |
4164 (let ((syms condition) (ok t)) | |
4165 (while syms | |
4166 (if (not (symbolp (car syms))) | |
4167 (setq ok nil)) | |
4168 (setq syms (cdr syms))) | |
4169 ok)))) | |
4170 (byte-compile-warn | |
4171 "%s is not a symbol naming a condition or a list of such (in condition-case)" | |
4172 (prin1-to-string condition))) | |
4173 ;; ((not (or (eq condition 't) | |
4174 ;; (and (stringp (get condition 'error-message)) | |
4175 ;; (consp (get condition 'error-conditions))))) | |
4176 ;; (byte-compile-warn | |
4177 ;; "%s is not a known condition name (in condition-case)" | |
4178 ;; condition)) | |
4179 ) | |
4180 (setq compiled-clauses | |
4181 (cons (cons condition | |
4182 (byte-compile-top-level-body | |
4183 (cdr clause) for-effect)) | |
4184 compiled-clauses))) | |
4185 (setq clauses (cdr clauses))) | |
4186 (byte-compile-push-constant (nreverse compiled-clauses))) | |
4187 (if (memq 'unused-vars byte-compile-warnings) | |
4188 ;; done compiling in this scope, warn now. | |
4189 (byte-compile-warn-about-unused-variables)) | |
4190 (byte-compile-out 'byte-condition-case 0))) | |
4191 | |
4192 | |
4193 (defun byte-compile-save-excursion (form) | |
4194 (byte-compile-out 'byte-save-excursion 0) | |
4195 (byte-compile-body-do-effect (cdr form)) | |
4196 (byte-compile-out 'byte-unbind 1)) | |
4197 | |
4198 (defun byte-compile-save-restriction (form) | |
4199 (byte-compile-out 'byte-save-restriction 0) | |
4200 (byte-compile-body-do-effect (cdr form)) | |
4201 (byte-compile-out 'byte-unbind 1)) | |
4202 | |
4203 (defun byte-compile-save-current-buffer (form) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4204 (byte-compile-out 'byte-save-current-buffer 0) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4205 (byte-compile-body-do-effect (cdr form)) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4206 (byte-compile-out 'byte-unbind 1)) |
428 | 4207 |
4208 (defun byte-compile-with-output-to-temp-buffer (form) | |
4209 (byte-compile-form (car (cdr form))) | |
4210 (byte-compile-out 'byte-temp-output-buffer-setup 0) | |
4211 (byte-compile-body (cdr (cdr form))) | |
4212 (byte-compile-out 'byte-temp-output-buffer-show 0)) | |
4213 | |
5391
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4214 (defun byte-compile-symbol-value (form) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4215 (symbol-macrolet ((not-present '#:not-present)) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4216 (let ((cl-load-time-value-form not-present) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4217 (byte-compile-bound-variables byte-compile-bound-variables) gensym) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4218 (and (consp (cadr form)) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4219 (eq 'quote (caadr form)) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4220 (setq gensym (cadadr form)) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4221 (symbolp gensym) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4222 (setq cl-load-time-value-form |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4223 (get gensym 'cl-load-time-value-form not-present))) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4224 (unless (eq cl-load-time-value-form not-present) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4225 (setq byte-compile-bound-variables |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4226 (acons gensym byte-compile-global-bit |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4227 byte-compile-bound-variables) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4228 byte-compile-output-preface |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4229 (byte-compile-top-level |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4230 (if byte-compile-output-preface |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4231 `(progn (setq ,gensym ,cl-load-time-value-form) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4232 ,byte-compile-output-preface) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4233 `(setq ,gensym ,cl-load-time-value-form)) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4234 t 'file))) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4235 (byte-compile-one-arg form)))) |
f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5377
diff
changeset
|
4236 |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4237 (defun byte-compile-multiple-value-call (form) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4238 (if (< (length form) 2) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4239 (progn |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4240 (byte-compile-warn-wrong-args form 1) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4241 (byte-compile-normal-call |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4242 `(signal 'wrong-number-of-arguments '(,(car form) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4243 ,(length (cdr form)))))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4244 (setq form (cdr form)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4245 (byte-compile-form (car form)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4246 (byte-compile-push-constant 0) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4247 (byte-compile-variable-ref 'byte-varref 'multiple-values-limit) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4248 ;; bind-multiple-value-limits leaves two existing values on the stack, |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4249 ;; and pushes a new value, the specpdl_depth() at the time it was |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4250 ;; called. |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4251 (byte-compile-out 'byte-bind-multiple-value-limits 0) |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
4252 (mapc 'byte-compile-form (cdr form)) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4253 ;; Most of the other code puts this sort of value in the program stream, |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4254 ;; not pushing it on the stack. |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4255 (byte-compile-push-constant (+ 3 (length form))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4256 (byte-compile-out 'byte-multiple-value-call (+ 3 (length form))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4257 (pushnew '(subrp (symbol-function 'multiple-value-call)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4258 byte-compile-checks-on-load |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4259 :test #'equal))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4260 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4261 (defun byte-compile-multiple-value-list-internal (form) |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
4262 (if (not (eql 4 (length form))) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4263 (progn |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4264 (byte-compile-warn-wrong-args form 3) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4265 (byte-compile-normal-call |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4266 `(signal 'wrong-number-of-arguments '(,(car form) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4267 ,(length (cdr form)))))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4268 (byte-compile-form (nth 1 form)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4269 (byte-compile-form (nth 2 form)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4270 (byte-compile-out 'byte-bind-multiple-value-limits 0) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4271 (byte-compile-form (nth 3 form)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4272 (byte-compile-out (get (car form) 'byte-opcode) 0) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4273 (pushnew '(subrp (symbol-function 'multiple-value-call)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4274 byte-compile-checks-on-load |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4275 :test #'equal))) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4276 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4277 (defun byte-compile-throw (form) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4278 ;; We can't use byte-compile-two-args for throw because in the event that |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4279 ;; the form does not have two args, it tries to #'funcall it expecting a |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4280 ;; runtime wrong-number-of-arguments error. Now that #'throw is a special |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4281 ;; form, it provokes an invalid-function error instead (or at least it |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4282 ;; should; there's a kludge around for the moment in eval.c that avoids |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4283 ;; that, but this file should not assume that that will always be there). |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5358
diff
changeset
|
4284 (if (not (eql 2 (length (cdr form)))) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4285 (progn |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4286 (byte-compile-warn-wrong-args form 2) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4287 (byte-compile-normal-call |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4288 `(signal 'wrong-number-of-arguments '(,(car form) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4289 ,(length (cdr form)))))) |
5356
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4290 ;; If this form was macroexpanded from `return-from', mark the |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4291 ;; corresponding block as having been referenced. |
5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5353
diff
changeset
|
4292 (let* ((symbol (car-safe (cdr-safe (nth 1 form)))) |
5376
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4293 (not-present '#:not-present) |
5377
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4294 (block (if (and symbol (symbolp symbol)) |
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4295 (get symbol 'cl-block-name not-present) |
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4296 not-present)) |
5376
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4297 (assq (and (not (eq block not-present)) |
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4298 (assq block byte-compile-active-blocks)))) |
5377
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4299 (if assq |
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4300 (setcdr assq t) |
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4301 (if (not (eq block not-present)) |
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4302 ;; No corresponding enclosing block. |
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4303 (byte-compile-warn "return-from: no enclosing block named `%s'" |
eac2e6bd5b2c
Correct some minor problems in my last change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5376
diff
changeset
|
4304 block)))) |
5376
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4305 (mapc 'byte-compile-form (cdr form)) ;; Push the arguments |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4306 (byte-compile-out (get (car form) 'byte-opcode) 0) |
5376
4b529b940e2e
Eliminate unused blocks named nil, too, cl-macs.el, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5374
diff
changeset
|
4307 (pushnew '(null (function-max-args 'throw)) byte-compile-checks-on-load |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4308 :test #'equal))) |
428 | 4309 |
4310 ;;; top-level forms elsewhere | |
4311 | |
4312 (byte-defop-compiler-1 defun) | |
4313 (byte-defop-compiler-1 defmacro) | |
4314 (byte-defop-compiler-1 defvar) | |
442 | 4315 (byte-defop-compiler-1 defvar byte-compile-defvar-or-defconst) |
4316 (byte-defop-compiler-1 defconst byte-compile-defvar-or-defconst) | |
428 | 4317 (byte-defop-compiler-1 autoload) |
4318 ;; According to Mly this can go now that lambda is a macro | |
4319 ;(byte-defop-compiler-1 lambda byte-compile-lambda-form) | |
4320 (byte-defop-compiler-1 defalias) | |
4321 (byte-defop-compiler-1 define-function) | |
4322 | |
4323 (defun byte-compile-defun (form) | |
4324 ;; This is not used for file-level defuns with doc strings. | |
4325 (byte-compile-two-args ; Use this to avoid byte-compile-fset's warning. | |
4326 (list 'fset (list 'quote (nth 1 form)) | |
4327 (byte-compile-byte-code-maker | |
4328 (byte-compile-lambda (cons 'lambda (cdr (cdr form))))))) | |
4329 (byte-compile-discard) | |
4330 (byte-compile-constant (nth 1 form))) | |
4331 | |
4332 (defun byte-compile-defmacro (form) | |
4333 ;; This is not used for file-level defmacros with doc strings. | |
4334 (byte-compile-body-do-effect | |
4335 (list (list 'fset (list 'quote (nth 1 form)) | |
4336 (let ((code (byte-compile-byte-code-maker | |
4337 (byte-compile-lambda | |
4338 (cons 'lambda (cdr (cdr form))))))) | |
4339 (if (eq (car-safe code) 'make-byte-code) | |
4340 (list 'cons ''macro code) | |
4341 (list 'quote (cons 'macro (eval code)))))) | |
4342 (list 'quote (nth 1 form))))) | |
4343 | |
442 | 4344 (defun byte-compile-defvar-or-defconst (form) |
4345 ;; This is not used for file-level defvar/defconsts with doc strings: | |
4346 ;; byte-compile-file-form-defvar-or-defconst will be used in that case. | |
4347 ;; (defvar|defconst VAR [VALUE [DOCSTRING]]) | |
4348 (let ((fun (nth 0 form)) | |
4349 (var (nth 1 form)) | |
428 | 4350 (value (nth 2 form)) |
4351 (string (nth 3 form))) | |
442 | 4352 (when (> (length form) 4) |
4353 (byte-compile-warn | |
4354 "%s %s called with %d arguments, but accepts only %s" | |
4355 fun var (length (cdr form)) 3)) | |
4356 (when (memq 'free-vars byte-compile-warnings) | |
4357 (push (cons var byte-compile-global-bit) byte-compile-bound-variables)) | |
428 | 4358 (byte-compile-body-do-effect |
442 | 4359 (list |
4360 ;; Put the defined variable in this library's load-history entry | |
444 | 4361 ;; just as a real defvar would, but only in top-level forms with values. |
4362 (when (and (> (length form) 2) | |
4363 (null byte-compile-current-form)) | |
442 | 4364 `(push ',var current-load-list)) |
4365 (when (> (length form) 3) | |
4366 (when (and string (not (stringp string))) | |
4367 (byte-compile-warn "Third arg to %s %s is not a string: %s" | |
4368 fun var string)) | |
4369 `(put ',var 'variable-documentation ,string)) | |
4370 (if (cdr (cdr form)) ; `value' provided | |
4371 (if (eq fun 'defconst) | |
4372 ;; `defconst' sets `var' unconditionally. | |
4373 `(setq ,var ,value) | |
4374 ;; `defvar' sets `var' only when unbound. | |
1672 | 4375 `(if (not (default-boundp ',var)) (set-default ',var ,value)))) |
442 | 4376 `',var)))) |
428 | 4377 |
4378 (defun byte-compile-autoload (form) | |
4379 (and (byte-compile-constp (nth 1 form)) | |
4380 (byte-compile-constp (nth 5 form)) | |
4381 (memq (eval (nth 5 form)) '(t macro)) ; macro-p | |
4382 (not (fboundp (eval (nth 1 form)))) | |
4383 (byte-compile-warn | |
4384 "The compiler ignores `autoload' except at top level. You should | |
4385 probably put the autoload of the macro `%s' at top-level." | |
4386 (eval (nth 1 form)))) | |
4387 (byte-compile-normal-call form)) | |
4388 | |
4389 ;; Lambda's in valid places are handled as special cases by various code. | |
4390 ;; The ones that remain are errors. | |
4391 ;; According to Mly this can go now that lambda is a macro | |
4392 ;(defun byte-compile-lambda-form (form) | |
4393 ; (byte-compile-warn | |
4394 ; "`lambda' used in function position is invalid: probably you mean #'%s" | |
4395 ; (let ((print-escape-newlines t) | |
4396 ; (print-level 4) | |
4397 ; (print-length 4)) | |
4398 ; (prin1-to-string form))) | |
4399 ; (byte-compile-normal-call | |
4400 ; (list 'signal ''error | |
4401 ; (list 'quote (list "`lambda' used in function position" form))))) | |
4402 | |
4403 ;; Compile normally, but deal with warnings for the function being defined. | |
4404 (defun byte-compile-defalias (form) | |
4405 (if (and (consp (cdr form)) (consp (nth 1 form)) | |
4406 (eq (car (nth 1 form)) 'quote) | |
4407 (consp (cdr (nth 1 form))) | |
4408 (symbolp (nth 1 (nth 1 form))) | |
4409 (consp (nthcdr 2 form)) | |
4410 (consp (nth 2 form)) | |
4411 (eq (car (nth 2 form)) 'quote) | |
4412 (consp (cdr (nth 2 form))) | |
4413 (symbolp (nth 1 (nth 2 form)))) | |
4414 (progn | |
4415 (byte-compile-defalias-warn (nth 1 (nth 1 form)) | |
4416 (nth 1 (nth 2 form))) | |
4417 (setq byte-compile-function-environment | |
4418 (cons (cons (nth 1 (nth 1 form)) | |
4419 (nth 1 (nth 2 form))) | |
4420 byte-compile-function-environment)))) | |
4421 (byte-compile-normal-call form)) | |
4422 | |
4423 (defun byte-compile-define-function (form) | |
4424 (byte-compile-defalias form)) | |
4425 | |
4426 ;; Turn off warnings about prior calls to the function being defalias'd. | |
4427 ;; This could be smarter and compare those calls with | |
4428 ;; the function it is being aliased to. | |
4429 (defun byte-compile-defalias-warn (new alias) | |
4430 (let ((calls (assq new byte-compile-unresolved-functions))) | |
4431 (if calls | |
4432 (setq byte-compile-unresolved-functions | |
4433 (delq calls byte-compile-unresolved-functions))))) | |
4434 | |
4435 ;;; tags | |
4436 | |
4437 ;; Note: Most operations will strip off the 'TAG, but it speeds up | |
4438 ;; optimization to have the 'TAG as a part of the tag. | |
4439 ;; Tags will be (TAG . (tag-number . stack-depth)). | |
4440 (defun byte-compile-make-tag () | |
4441 (list 'TAG (setq byte-compile-tag-number (1+ byte-compile-tag-number)))) | |
4442 | |
4443 | |
4444 (defun byte-compile-out-tag (tag) | |
4445 (push tag byte-compile-output) | |
4446 (if (cdr (cdr tag)) | |
4447 (progn | |
4448 ;; ## remove this someday | |
4449 (and byte-compile-depth | |
4450 (not (= (cdr (cdr tag)) byte-compile-depth)) | |
4451 (error "Compiler bug: depth conflict at tag %d" (car (cdr tag)))) | |
4452 (setq byte-compile-depth (cdr (cdr tag)))) | |
4453 (setcdr (cdr tag) byte-compile-depth))) | |
4454 | |
4455 (defun byte-compile-goto (opcode tag) | |
4456 (push (cons opcode tag) byte-compile-output) | |
4457 (setcdr (cdr tag) (if (memq opcode byte-goto-always-pop-ops) | |
4458 (1- byte-compile-depth) | |
4459 byte-compile-depth)) | |
4460 (setq byte-compile-depth (and (not (eq opcode 'byte-goto)) | |
4461 (1- byte-compile-depth)))) | |
4462 | |
4463 (defun byte-compile-out (opcode offset) | |
4464 (push (cons opcode offset) byte-compile-output) | |
4465 (case opcode | |
4466 (byte-call | |
4467 (setq byte-compile-depth (- byte-compile-depth offset))) | |
4468 (byte-return | |
4469 ;; This is actually an unnecessary case, because there should be | |
4470 ;; no more opcodes behind byte-return. | |
4471 (setq byte-compile-depth nil)) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4472 (byte-multiple-value-call |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4639
diff
changeset
|
4473 (setq byte-compile-depth (- byte-compile-depth offset))) |
428 | 4474 (t |
4475 (setq byte-compile-depth (+ byte-compile-depth | |
4476 (or (aref byte-stack+-info | |
4477 (symbol-value opcode)) | |
4478 (- (1- offset)))) | |
4479 byte-compile-maxdepth (max byte-compile-depth | |
4480 byte-compile-maxdepth)))) | |
4481 ;;(if (< byte-compile-depth 0) (error "Compiler error: stack underflow")) | |
4482 ) | |
4483 | |
4484 | |
4485 ;;; call tree stuff | |
4486 | |
4487 (defun byte-compile-annotate-call-tree (form) | |
4488 (let (entry) | |
4489 ;; annotate the current call | |
4490 (if (setq entry (assq (car form) byte-compile-call-tree)) | |
4491 (or (memq byte-compile-current-form (nth 1 entry)) ;callers | |
4492 (setcar (cdr entry) | |
4493 (cons byte-compile-current-form (nth 1 entry)))) | |
4494 (push (list (car form) (list byte-compile-current-form) nil) | |
4495 byte-compile-call-tree)) | |
4496 ;; annotate the current function | |
4497 (if (setq entry (assq byte-compile-current-form byte-compile-call-tree)) | |
4498 (or (memq (car form) (nth 2 entry)) ;called | |
4499 (setcar (cdr (cdr entry)) | |
4500 (cons (car form) (nth 2 entry)))) | |
4501 (push (list byte-compile-current-form nil (list (car form))) | |
4502 byte-compile-call-tree)))) | |
4503 | |
4504 ;; Renamed from byte-compile-report-call-tree | |
4505 ;; to avoid interfering with completion of byte-compile-file. | |
4506 ;;;###autoload | |
4507 (defun display-call-tree (&optional filename) | |
4508 "Display a call graph of a specified file. | |
4509 This lists which functions have been called, what functions called | |
4510 them, and what functions they call. The list includes all functions | |
4511 whose definitions have been compiled in this Emacs session, as well as | |
4512 all functions called by those functions. | |
4513 | |
4514 The call graph does not include macros, inline functions, or | |
4515 primitives that the byte-code interpreter knows about directly \(eq, | |
4516 cons, etc.\). | |
4517 | |
4518 The call tree also lists those functions which are not known to be called | |
4519 \(that is, to which no calls have been compiled\), and which cannot be | |
4520 invoked interactively." | |
4521 (interactive) | |
4522 (message "Generating call tree...") | |
4523 (with-output-to-temp-buffer "*Call-Tree*" | |
4524 (set-buffer "*Call-Tree*") | |
4525 (erase-buffer) | |
4526 (message "Generating call tree... (sorting on %s)" | |
4527 byte-compile-call-tree-sort) | |
4528 (insert "Call tree for " | |
4529 (cond ((null byte-compile-current-file) (or filename "???")) | |
4530 ((stringp byte-compile-current-file) | |
4531 byte-compile-current-file) | |
4532 (t (buffer-name byte-compile-current-file))) | |
4533 " sorted on " | |
4534 (prin1-to-string byte-compile-call-tree-sort) | |
4535 ":\n\n") | |
4536 (if byte-compile-call-tree-sort | |
4537 (setq byte-compile-call-tree | |
4538 (sort byte-compile-call-tree | |
4539 (cond | |
4540 ((eq byte-compile-call-tree-sort 'callers) | |
4541 #'(lambda (x y) (< (length (nth 1 x)) | |
4542 (length (nth 1 y))))) | |
4543 ((eq byte-compile-call-tree-sort 'calls) | |
4544 #'(lambda (x y) (< (length (nth 2 x)) | |
4545 (length (nth 2 y))))) | |
4546 ((eq byte-compile-call-tree-sort 'calls+callers) | |
4547 #'(lambda (x y) (< (+ (length (nth 1 x)) | |
4548 (length (nth 2 x))) | |
4549 (+ (length (nth 1 y)) | |
4550 (length (nth 2 y)))))) | |
4551 ((eq byte-compile-call-tree-sort 'name) | |
4552 #'(lambda (x y) (string< (car x) | |
4553 (car y)))) | |
4554 (t (error | |
4555 "`byte-compile-call-tree-sort': `%s' - unknown sort mode" | |
4556 byte-compile-call-tree-sort)))))) | |
4557 (message "Generating call tree...") | |
4558 (let ((rest byte-compile-call-tree) | |
4559 (b (current-buffer)) | |
4560 f p | |
4561 callers calls) | |
4562 (while rest | |
4563 (prin1 (car (car rest)) b) | |
4564 (setq callers (nth 1 (car rest)) | |
4565 calls (nth 2 (car rest))) | |
4566 (insert "\t" | |
4567 (cond ((not (fboundp (setq f (car (car rest))))) | |
4568 (if (null f) | |
4569 " <top level>";; shouldn't insert nil then, actually -sk | |
4570 " <not defined>")) | |
4571 ((subrp (setq f (symbol-function f))) | |
4572 " <subr>") | |
4573 ((symbolp f) | |
4574 (format " ==> %s" f)) | |
4575 ((compiled-function-p f) | |
4576 "<compiled function>") | |
4577 ((not (consp f)) | |
4578 "<malformed function>") | |
4579 ((eq 'macro (car f)) | |
4580 (if (or (compiled-function-p (cdr f)) | |
4581 (assq 'byte-code (cdr (cdr (cdr f))))) | |
4582 " <compiled macro>" | |
4583 " <macro>")) | |
4584 ((assq 'byte-code (cdr (cdr f))) | |
4585 "<compiled lambda>") | |
4586 ((eq 'lambda (car f)) | |
4587 "<function>") | |
4588 (t "???")) | |
4589 (format " (%d callers + %d calls = %d)" | |
4590 ;; Does the optimizer eliminate common subexpressions?-sk | |
4591 (length callers) | |
4592 (length calls) | |
4593 (+ (length callers) (length calls))) | |
4594 "\n") | |
4595 (if callers | |
4596 (progn | |
4597 (insert " called by:\n") | |
4598 (setq p (point)) | |
4599 (insert " " (if (car callers) | |
4600 (mapconcat 'symbol-name callers ", ") | |
4601 "<top level>")) | |
4602 (let ((fill-prefix " ")) | |
4603 (fill-region-as-paragraph p (point))))) | |
4604 (if calls | |
4605 (progn | |
4606 (insert " calls:\n") | |
4607 (setq p (point)) | |
4608 (insert " " (mapconcat 'symbol-name calls ", ")) | |
4609 (let ((fill-prefix " ")) | |
4610 (fill-region-as-paragraph p (point))))) | |
4611 (insert "\n") | |
4612 (setq rest (cdr rest))) | |
4613 | |
4614 (message "Generating call tree...(finding uncalled functions...)") | |
4615 (setq rest byte-compile-call-tree) | |
4616 (let ((uncalled nil)) | |
4617 (while rest | |
4618 (or (nth 1 (car rest)) | |
4619 (null (setq f (car (car rest)))) | |
4620 (byte-compile-fdefinition f t) | |
4621 (commandp (byte-compile-fdefinition f nil)) | |
4622 (setq uncalled (cons f uncalled))) | |
4623 (setq rest (cdr rest))) | |
4624 (if uncalled | |
4625 (let ((fill-prefix " ")) | |
4626 (insert "Noninteractive functions not known to be called:\n ") | |
4627 (setq p (point)) | |
4628 (insert (mapconcat 'symbol-name (nreverse uncalled) ", ")) | |
4629 (fill-region-as-paragraph p (point))))) | |
4630 ) | |
4631 (message "Generating call tree...done.") | |
4632 )) | |
4633 | |
4634 | |
4635 ;;; by crl@newton.purdue.edu | |
4636 ;;; Only works noninteractively. | |
4637 ;;;###autoload | |
4638 (defun batch-byte-compile () | |
4639 "Run `byte-compile-file' on the files remaining on the command line. | |
4640 Use this from the command line, with `-batch'; | |
4641 it won't work in an interactive Emacs. | |
4642 Each file is processed even if an error occurred previously. | |
444 | 4643 For example, invoke \"xemacs -batch -f batch-byte-compile $emacs/ ~/*.el\"." |
428 | 4644 ;; command-line-args-left is what is left of the command line (from |
4645 ;; startup.el) | |
4646 (defvar command-line-args-left) ;Avoid 'free variable' warning | |
4647 (if (not noninteractive) | |
4648 (error "`batch-byte-compile' is to be used only with -batch")) | |
4649 (let ((error nil)) | |
4650 (while command-line-args-left | |
442 | 4651 (if (null (batch-byte-compile-one-file)) |
4652 (setq error t))) | |
428 | 4653 (message "Done") |
4654 (kill-emacs (if error 1 0)))) | |
4655 | |
442 | 4656 ;;;###autoload |
4657 (defun batch-byte-compile-one-file () | |
4658 "Run `byte-compile-file' on a single file remaining on the command line. | |
4659 Use this from the command line, with `-batch'; | |
4660 it won't work in an interactive Emacs." | |
4661 ;; command-line-args-left is what is left of the command line (from | |
4662 ;; startup.el) | |
4663 (defvar command-line-args-left) ;Avoid 'free variable' warning | |
4664 (if (not noninteractive) | |
4665 (error "`batch-byte-compile-one-file' is to be used only with -batch")) | |
4666 (let (error | |
4667 (file-to-process (car command-line-args-left))) | |
4668 (setq command-line-args-left (cdr command-line-args-left)) | |
4669 (if (file-directory-p (expand-file-name file-to-process)) | |
4670 (let ((files (directory-files file-to-process)) | |
4671 source dest) | |
4672 (while files | |
4673 (if (and (string-match emacs-lisp-file-regexp (car files)) | |
4674 (not (auto-save-file-name-p (car files))) | |
4675 (setq source (expand-file-name | |
4676 (car files) | |
4677 file-to-process)) | |
4678 (setq dest (byte-compile-dest-file source)) | |
4679 (file-exists-p dest) | |
4680 (file-newer-than-file-p source dest)) | |
4681 (if (null (batch-byte-compile-1 source)) | |
4682 (setq error t))) | |
4683 (setq files (cdr files))) | |
4684 (null error)) | |
4685 (batch-byte-compile-1 file-to-process)))) | |
4686 | |
428 | 4687 (defun batch-byte-compile-1 (file) |
4688 (condition-case err | |
4689 (progn (byte-compile-file file) t) | |
4690 (error | |
4691 (princ ">>Error occurred processing ") | |
4692 (princ file) | |
4693 (princ ": ") | |
4694 (if (fboundp 'display-error) ; XEmacs 19.8+ | |
4695 (display-error err nil) | |
4696 (princ (or (get (car err) 'error-message) (car err))) | |
4783
e29fcfd8df5f
Eliminate most core code byte-compile warnings.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
4697 (mapc #'(lambda (x) (princ " ") (prin1 x)) (cdr err))) |
428 | 4698 (princ "\n") |
4699 nil))) | |
4700 | |
4701 ;;;###autoload | |
4702 (defun batch-byte-recompile-directory-norecurse () | |
4703 "Same as `batch-byte-recompile-directory' but without recursion." | |
4704 (setq byte-recompile-directory-recursively nil) | |
4705 (batch-byte-recompile-directory)) | |
4706 | |
4707 ;;;###autoload | |
4708 (defun batch-byte-recompile-directory () | |
4709 "Runs `byte-recompile-directory' on the dirs remaining on the command line. | |
4710 Must be used only with `-batch', and kills Emacs on completion. | |
4711 For example, invoke `xemacs -batch -f batch-byte-recompile-directory .'." | |
4712 ;; command-line-args-left is what is left of the command line (startup.el) | |
4713 (defvar command-line-args-left) ;Avoid 'free variable' warning | |
4714 (if (not noninteractive) | |
4715 (error "batch-byte-recompile-directory is to be used only with -batch")) | |
4716 (or command-line-args-left | |
4717 (setq command-line-args-left '("."))) | |
4718 (let ((byte-recompile-directory-ignore-errors-p t)) | |
4719 (while command-line-args-left | |
4720 (byte-recompile-directory (car command-line-args-left)) | |
4721 (setq command-line-args-left (cdr command-line-args-left)))) | |
4722 (kill-emacs 0)) | |
4723 | |
4724 (make-obsolete 'elisp-compile-defun 'compile-defun) | |
4725 (make-obsolete 'byte-compile-report-call-tree 'display-call-tree) | |
4726 | |
4727 ;; other make-obsolete calls in obsolete.el. | |
4728 | |
4729 (provide 'byte-compile) | |
4730 (provide 'bytecomp) | |
4731 | |
4732 | |
4733 ;;; report metering (see the hacks in bytecode.c) | |
4734 | |
4735 (if (boundp 'byte-code-meter) | |
4736 (defun byte-compile-report-ops () | |
4737 (defvar byte-code-meter) | |
4738 (with-output-to-temp-buffer "*Meter*" | |
4739 (set-buffer "*Meter*") | |
4740 (let ((i 0) n op off) | |
4741 (while (< i 256) | |
4742 (setq n (aref (aref byte-code-meter 0) i) | |
4743 off nil) | |
4744 (if t ;(not (zerop n)) | |
4745 (progn | |
4746 (setq op i) | |
4747 (setq off nil) | |
4748 (cond ((< op byte-nth) | |
4749 (setq off (logand op 7)) | |
4750 (setq op (logand op 248))) | |
4751 ((>= op byte-constant) | |
4752 (setq off (- op byte-constant) | |
4753 op byte-constant))) | |
4754 (setq op (aref byte-code-vector op)) | |
4755 (insert (format "%-4d" i)) | |
4756 (insert (symbol-name op)) | |
4757 (if off (insert " [" (int-to-string off) "]")) | |
4758 (indent-to 40) | |
4759 (insert (int-to-string n) "\n"))) | |
4760 (setq i (1+ i))))))) | |
4761 | |
4762 | |
4763 ;; To avoid "lisp nesting exceeds max-lisp-eval-depth" when bytecomp compiles | |
4764 ;; itself, compile some of its most used recursive functions (at load time). | |
4765 ;; | |
4766 (eval-when-compile | |
4767 (or (compiled-function-p (symbol-function 'byte-compile-form)) | |
4768 (let ((byte-optimize nil) ; do it fast | |
4769 (byte-compile-warnings nil)) | |
5503
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4770 (map nil (if noninteractive |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4771 #'byte-compile |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4772 #'(lambda (x) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4773 (message "compiling %s..." x) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4774 (byte-compile x) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4775 (message "compiling %s...done" x))) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4776 '(byte-compile-normal-call |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4777 byte-compile-form |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4778 byte-compile-body |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4779 ;; Inserted some more than necessary, to speed it up. |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4780 byte-compile-top-level |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4781 byte-compile-out-toplevel |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4782 byte-compile-constant |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4783 byte-compile-variable-ref))))) |
7b5946dbfb96
Drop support for generating code appropriate for Emacs 19, bytecomp.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
4784 |
428 | 4785 |
4683
0cc9d22c3732
Be more reliable about loading cl-macs at byte-compile time, cl.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
4786 (run-hooks 'bytecomp-load-hook) |
0cc9d22c3732
Be more reliable about loading cl-macs at byte-compile time, cl.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
4787 |
428 | 4788 ;;; bytecomp.el ends here |