Mercurial > hg > xemacs-beta
comparison lisp/bytecomp-runtime.el @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | 7039e6323819 |
children | 79940b592197 |
comparison
equal
deleted
inserted
replaced
770:336a418893b5 | 771:943eaba38521 |
---|---|
1 ;;; bytecomp-runtime.el --- byte-compiler support for inlining | 1 ;;; bytecomp-runtime.el --- byte-compiler support for inlining |
2 | 2 |
3 ;; Copyright (C) 1992, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1992, 1997 Free Software Foundation, Inc. |
4 ;; Copyright (C) 2002 Ben Wing. | |
4 | 5 |
5 ;; Author: Jamie Zawinski <jwz@jwz.org> | 6 ;; Author: Jamie Zawinski <jwz@jwz.org> |
6 ;; Author: Hallvard Furuseth <hbf@ulrik.uio.no> | 7 ;; Author: Hallvard Furuseth <hbf@ulrik.uio.no> |
7 ;; Maintainer: XEmacs Development Team | 8 ;; Maintainer: XEmacs Development Team |
8 ;; Keywords: internal, dumped | 9 ;; Keywords: internal, dumped |
201 ;; arguments, and I find it extremely confusing to deal with cases | 202 ;; arguments, and I find it extremely confusing to deal with cases |
202 ;; such as `throw' requiring a quoted argument but `block' an unquoted | 203 ;; such as `throw' requiring a quoted argument but `block' an unquoted |
203 ;; one. | 204 ;; one. |
204 | 205 |
205 (put 'with-boundp 'lisp-indent-function 1) | 206 (put 'with-boundp 'lisp-indent-function 1) |
206 (defmacro with-boundp (symbols &rest body) | 207 (defmacro with-boundp (variables &rest body) |
207 "Evaluate BODY, but do not issue bytecomp warnings about SYMBOLS undefined. | 208 "Evaluate BODY, but do not issue bytecomp warnings about VARIABLES undefined. |
208 SYMBOLS can be a symbol or a list of symbols and must be quoted. When | 209 VARIABLES can be a symbol or a list of symbols and must be quoted. When |
209 compiling this file, the warning `reference to free variable SYMBOL' | 210 compiling this file, the warnings `reference to free variable VARIABLE' and |
210 will not occur. This is a clean way to avoid such warnings. See also | 211 `assignment to free variable VARIABLE' will not occur anywhere in BODY, for |
211 `declare-boundp' and `if-boundp'." | 212 any of the listed variables. This is a clean way to avoid such warnings. |
212 (setq symbols (eval symbols)) | 213 See also `declare-boundp', `if-boundp', `when-boundp', and |
213 (unless (consp symbols) | 214 `globally-declare-boundp'." |
214 (setq symbols (list symbols))) | 215 (setq variables (eval variables)) |
216 (unless (consp variables) | |
217 (setq variables (list variables))) | |
215 `(progn | 218 `(progn |
216 (declare (special ,@symbols)) | 219 (declare (special ,@variables)) |
217 ,@body)) | 220 ,@body)) |
218 | 221 |
219 (put 'if-boundp 'lisp-indent-function 2) | 222 (put 'if-boundp 'lisp-indent-function 2) |
220 (defmacro if-boundp (symbol then &rest else) | 223 (defmacro if-boundp (variable then &rest else) |
221 "Equivalent to (if (boundp SYMBOL) THEN ELSE) but handles bytecomp warnings. | 224 "Equivalent to (if (boundp VARIABLE) THEN ELSE) but handles bytecomp warnings. |
222 When compiling this file, the warning `reference to free variable SYMBOL' | 225 VARIABLE should be a quoted symbol. When compiling this file, the warnings |
223 will not occur. This is a clean way to avoid such warnings. See also | 226 `reference to free variable VARIABLE' and `assignment to free variable |
224 `with-boundp' and `declare-boundp'." | 227 VARIABLE' will not occur anywhere in the if-statement. This is a clean way |
225 `(with-boundp ,symbol | 228 to avoid such warnings. See also `when-boundp', `declare-boundp', |
226 (if (boundp ,symbol) ,then ,@else))) | 229 `with-boundp' and `globally-declare-boundp'." |
227 | 230 `(with-boundp ,variable |
228 (defmacro declare-boundp (symbol) | 231 (if (boundp ,variable) ,then ,@else))) |
229 "Evaluate SYMBOL without bytecomp warnings about the symbol. | 232 |
233 (put 'when-boundp 'lisp-indent-function 1) | |
234 (defmacro when-boundp (variable &rest body) | |
235 "Equivalent to (when (boundp VARIABLE) BODY) but handles bytecomp warnings. | |
236 VARIABLE should be a quoted symbol. When compiling this file, the warnings | |
237 `reference to free variable VARIABLE' and `assignment to free variable | |
238 VARIABLE' will not occur anywhere in the when-statement. This is a clean | |
239 way to avoid such warnings. See also `if-boundp', `declare-boundp', | |
240 `with-boundp' and `globally-declare-boundp'." | |
241 `(with-boundp ,variable | |
242 (when (boundp ,variable) ,@body))) | |
243 | |
244 (defmacro declare-boundp (variable) | |
245 "Evaluate VARIABLE without bytecomp warnings about the symbol. | |
246 | |
230 Sample usage is | 247 Sample usage is |
231 | 248 |
232 (declare-boundp gpm-minor-mode) | 249 (declare-boundp gpm-minor-mode) |
233 | 250 |
234 which is equivalent to | 251 which is equivalent to |
235 | 252 |
236 (with-fboundp 'gpm-minor-mode | 253 (with-boundp 'gpm-minor-mode |
237 gpm-minor-mode)" | 254 gpm-minor-mode)" |
238 `(with-boundp ',symbol ,symbol)) | 255 `(with-boundp ',variable ,variable)) |
239 | 256 |
240 (defmacro globally-declare-boundp (symbol) | 257 (defmacro globally-declare-boundp (variables) |
241 "Declare that all free uses of SYMBOL in this file are valid. | 258 "Declare that all free uses of VARIABLES in this file are valid. |
242 SYMBOL can also be a list of symbols. SYMBOL must be quoted. | 259 VARIABLES can be a symbol or a list of symbols and must be quoted. |
243 | 260 |
244 When compiling this file, the warning `reference to free variable | 261 When compiling this file, the warnings `reference to free variable |
245 SYMBOL' will not occur regardless of where calls to SYMBOL occur in | 262 VARIABLE' and `assignment to free variable VARIABLE' will not occur |
246 the file. | 263 regardless of where references to VARIABLE occur in the file. |
247 | 264 |
248 In general, you should *NOT* use this; use `declare-boundp', | 265 In general, you should *NOT* use this; use `declare-boundp', `if-boundp', |
249 `if-boundp', or `with-boundp' to wrap individual uses, as necessary. | 266 `when-boundp', or `with-boundp' to wrap individual uses, as necessary. |
250 That way, you're more likely to remember to put in the explicit checks | 267 That way, you're more likely to remember to put in the explicit checks for |
251 for the variable's existence that are usually necessary. However, | 268 the variable's existence that are usually necessary. However, |
252 `globally-declare-boundp' is better in some circumstances, such as | 269 `globally-declare-boundp' is better in some circumstances, such as when |
253 when writing an ELisp package that makes integral use of | 270 writing an ELisp package that makes integral use of optionally-compiled-in |
254 optionally-compiled-in functionality (typically, an interface onto a | 271 functionality (typically, an interface onto a system library) and checks |
255 system library) and checks for the existence of the functionality at | 272 for the existence of the functionality at some entry point to the package. |
256 some entry point to the package. See `globally-declare-fboundp' for | 273 See `globally-declare-fboundp' for more information." |
257 more information." | 274 (setq variables (eval variables)) |
258 (setq symbol (eval symbol)) | 275 (if (not (consp variables)) |
259 (if (not (consp symbol)) | 276 (setq variables (list variables))) |
260 (setq symbol (list symbol))) | |
261 `(progn | 277 `(progn |
262 ;; (defvar FOO) has no side effects. | 278 ;; (defvar FOO) has no side effects. |
263 ,@(mapcar #'(lambda (sym) `(defvar ,sym)) symbol))) | 279 ,@(mapcar #'(lambda (sym) `(defvar ,sym)) variables))) |
264 | 280 |
265 (defun byte-compile-with-fboundp (form) | 281 (defun byte-compile-with-fboundp (form) |
266 (byte-compile-form (cons 'progn (cdr (cdr form)))) | 282 (byte-compile-form (cons 'progn (cdr (cdr form)))) |
267 ;; Unfortunately, byte-compile-unresolved-functions is used not only | 283 ;; Unfortunately, byte-compile-unresolved-functions is used not only |
268 ;; for unresolved-function warnings, but also in connection with the | 284 ;; for unresolved-function warnings, but also in connection with the |
305 | 321 |
306 (put 'with-fboundp-1 'byte-compile 'byte-compile-with-fboundp) | 322 (put 'with-fboundp-1 'byte-compile 'byte-compile-with-fboundp) |
307 (defalias 'with-fboundp-1 'progn) | 323 (defalias 'with-fboundp-1 'progn) |
308 | 324 |
309 (put 'with-fboundp 'lisp-indent-function 1) | 325 (put 'with-fboundp 'lisp-indent-function 1) |
310 (defmacro with-fboundp (symbol &rest body) | 326 (defmacro with-fboundp (functions &rest body) |
311 "Evaluate BODY, but do not issue bytecomp warnings about SYMBOL. | 327 "Evaluate BODY, but do not issue bytecomp warnings about FUNCTIONS undefined. |
312 SYMBOL must be quoted. When compiling this file, the warning `the | 328 FUNCTIONS can be a symbol or a list of symbols and must be quoted. When |
313 function SYMBOL is not known to be defined' will not occur. This is a | 329 compiling this file, the warning `the function FUNCTION is not known to be |
314 clean way to avoid such warnings. See also `declare-fboundp', | 330 defined' will not occur anywhere in BODY, for any of the listed functions. |
315 `if-fboundp', and `globally-declare-fboundp'." | 331 This is a clean way to avoid such warnings. See also `declare-fboundp', |
316 `(with-fboundp-1 ,symbol ,@body)) | 332 `if-fboundp', `when-fboundp', and `globally-declare-fboundp'." |
333 `(with-fboundp-1 ,functions ,@body)) | |
317 | 334 |
318 (put 'if-fboundp 'lisp-indent-function 2) | 335 (put 'if-fboundp 'lisp-indent-function 2) |
319 (defmacro if-fboundp (symbol then &rest else) | 336 (defmacro if-fboundp (function then &rest else) |
320 "Equivalent to (if (fboundp SYMBOL) THEN ELSE) but handles bytecomp warnings. | 337 "Equivalent to (if (fboundp FUNCTION) THEN ELSE) but handles bytecomp warnings. |
321 When compiling this file, the warning `the function SYMBOL is not | 338 FUNCTION should be a quoted symbol. When compiling this file, the warning |
322 known to be defined' will not occur. This is a clean way to avoid | 339 `the function FUNCTION is not known to be defined' will not occur anywhere |
323 such warnings. See also `declare-fboundp', `with-fboundp', and | 340 in the if-statement. This is a clean way to avoid such warnings. See also |
341 `when-fboundp', `declare-fboundp', `with-fboundp', and | |
324 `globally-declare-fboundp'." | 342 `globally-declare-fboundp'." |
325 `(with-fboundp ,symbol | 343 `(with-fboundp ,function |
326 (if (fboundp ,symbol) ,then ,@else))) | 344 (if (fboundp ,function) ,then ,@else))) |
345 | |
346 (put 'when-fboundp 'lisp-indent-function 1) | |
347 (defmacro when-fboundp (function &rest body) | |
348 "Equivalent to (when (fboundp FUNCTION) BODY) but handles bytecomp warnings. | |
349 FUNCTION should be a quoted symbol. When compiling this file, the warning | |
350 `the function FUNCTION is not known to be defined' will not occur anywhere | |
351 in the when-statement. This is a clean way to avoid such warnings. See | |
352 also `if-fboundp', `declare-fboundp', `with-fboundp', and | |
353 `globally-declare-fboundp'." | |
354 `(with-fboundp ,function | |
355 (when (fboundp ,function) ,@body))) | |
327 | 356 |
328 (defmacro declare-fboundp (form) | 357 (defmacro declare-fboundp (form) |
329 "Execute FORM (a function call) without bytecomp warnings about the call. | 358 "Execute FORM (a function call) without bytecomp warnings about the call. |
330 Sample usage is | 359 Sample usage is |
331 | 360 |
335 | 364 |
336 (with-fboundp 'x-keysym-on-keyboard-sans-modifiers-p | 365 (with-fboundp 'x-keysym-on-keyboard-sans-modifiers-p |
337 (x-keysym-on-keyboard-sans-modifiers-p 'backspace))" | 366 (x-keysym-on-keyboard-sans-modifiers-p 'backspace))" |
338 `(with-fboundp ',(car form) ,form)) | 367 `(with-fboundp ',(car form) ,form)) |
339 | 368 |
340 (defmacro globally-declare-fboundp (symbol) | 369 (defmacro globally-declare-fboundp (functions) |
341 "Declare that all calls to function SYMBOL in this file are valid. | 370 "Declare that all calls to function FUNCTIONS in this file are valid. |
342 SYMBOL can also be a list of symbols. SYMBOL must be quoted. | 371 FUNCTIONS can be a symbol or a list of symbols and must be quoted. |
343 | 372 |
344 When compiling this file, the warning `the function SYMBOL is not | 373 When compiling this file, the warning `the function FUNCTION is not known |
345 known to be defined' will not occur regardless of where calls to | 374 to be defined' will not occur regardless of where calls to FUNCTION occur |
346 SYMBOL occur in the file. | 375 in the file. |
347 | 376 |
348 In general, you should *NOT* use this; use `declare-fboundp', | 377 In general, you should *NOT* use this; use `declare-fboundp', `if-fboundp', |
349 `if-fboundp', or `with-fboundp' to wrap individual uses, as necessary. | 378 `when-fboundp', or `with-fboundp' to wrap individual uses, as necessary. |
350 That way, you're more likely to remember to put in the explicit checks | 379 That way, you're more likely to remember to put in the explicit checks for |
351 for the function's existence that are usually necessary. However, | 380 the function's existence that are usually necessary. However, |
352 `globally-declare-fboundp' is better in some circumstances, such as | 381 `globally-declare-fboundp' is better in some circumstances, such as when |
353 when writing an ELisp package that makes integral use of | 382 writing an ELisp package that makes integral use of optionally-compiled-in |
354 optionally-compiled-in functionality (typically, an interface onto a | 383 functionality (typically, an interface onto a system library) and checks |
355 system library) and checks for the existence of the functionality at | 384 for the existence of the functionality at some entry point to the package. |
356 some entry point to the package. The file `ldap.el' is a good | 385 The file `ldap.el' is a good example: It provides a layer on top of the |
357 example: It provides a layer on top of the optional LDAP ELisp | 386 optional LDAP ELisp primitives, makes calls to them throughout its code, |
358 primitives, makes calls to them throughout its code, and verifies the | 387 and verifies the presence of LDAP support at load time. Putting calls to |
359 presence of LDAP support at load time. Putting calls to | |
360 `declare-fboundp' throughout the code would be a major annoyance." | 388 `declare-fboundp' throughout the code would be a major annoyance." |
361 (when (cl-compiling-file) | 389 (when (cl-compiling-file) |
362 (setq symbol (eval symbol)) | 390 (setq functions (eval functions)) |
363 (if (not (consp symbol)) | 391 (if (not (consp functions)) |
364 (setq symbol (list symbol))) | 392 (setq functions (list functions))) |
365 ;; Another hack. This works because the autoload environment is | 393 ;; Another hack. This works because the autoload environment is |
366 ;; currently used ONLY to suppress warnings, and the actual | 394 ;; currently used ONLY to suppress warnings, and the actual |
367 ;; autoload definition is not used. (NOTE: With this definition, | 395 ;; autoload definition is not used. (NOTE: With this definition, |
368 ;; we will get spurious "multiple autoloads for %s" warnings if we | 396 ;; we will get spurious "multiple autoloads for %s" warnings if we |
369 ;; have an autoload later in the file for any functions in SYMBOL. | 397 ;; have an autoload later in the file for any functions in FUNCTIONS. |
370 ;; This is not something that code should ever do, though.) | 398 ;; This is not something that code should ever do, though.) |
371 (setq byte-compile-autoload-environment | 399 (setq byte-compile-autoload-environment |
372 (append (mapcar #'(lambda (sym) (cons sym nil)) symbol) | 400 (append (mapcar #'(lambda (sym) (cons sym nil)) functions) |
373 byte-compile-autoload-environment))) | 401 byte-compile-autoload-environment))) |
374 nil) | 402 nil) |
375 | 403 |
376 (defun byte-compile-with-byte-compiler-warnings-suppressed (form) | 404 (defun byte-compile-with-byte-compiler-warnings-suppressed (form) |
377 (let ((byte-compile-warnings byte-compile-warnings) | 405 (let ((byte-compile-warnings byte-compile-warnings) |
399 NOTE: You should *NOT* under normal circumstances be using this! | 427 NOTE: You should *NOT* under normal circumstances be using this! |
400 There are better ways of avoiding most of these warnings. In particular: | 428 There are better ways of avoiding most of these warnings. In particular: |
401 | 429 |
402 -- use (declare (special ...)) if you are making use of | 430 -- use (declare (special ...)) if you are making use of |
403 dynamically-scoped variables. | 431 dynamically-scoped variables. |
404 -- use `with-fboundp', `declare-fboundp', `if-fboundp', or | 432 -- use `if-fboundp', `when-fboundp', `declare-fboundp', `with-fboundp', or |
405 `globally-declare-fboundp' to avoid warnings about undefined | 433 `globally-declare-fboundp' to avoid warnings about undefined functions |
406 functions when you know the function actually exists. | 434 when you know the function actually exists. |
407 -- use `with-boundp', `declare-boundp', or `if-boundp' to avoid | 435 -- use `if-boundp', `when-boundp', `declare-boundp', `with-boundp', or |
408 warnings about undefined variables when you know the variable | 436 `globally-declare-boundp' to avoid warnings about undefined variables |
409 actually exists. | 437 when you know the variable actually exists. |
410 -- use `with-obsolete-variable' or `with-obsolete-function' if you | 438 -- use `with-obsolete-variable' or `with-obsolete-function' if you |
411 are purposely using such a variable or function." | 439 are purposely using such a variable or function." |
412 `(with-byte-compiler-warnings-suppressed-1 ,type ,@body)) | 440 `(with-byte-compiler-warnings-suppressed-1 ,type ,@body)) |
413 | 441 |
414 ;; #### These should be more clever. You could (e.g.) try fletting | 442 ;; #### These should be more clever. You could (e.g.) try fletting |