Mercurial > hg > xemacs-beta
comparison lisp/bytecomp-runtime.el @ 4990:8f0cf4fd3d2c
Automatic merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 06 Feb 2010 04:01:46 -0600 |
parents | 018e13fdeaeb |
children | 0d43872986b6 |
comparison
equal
deleted
inserted
replaced
4989:d2ec55325515 | 4990:8f0cf4fd3d2c |
---|---|
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 ;; Copyright (C) 2002, 2010 Ben Wing. |
5 | 5 |
6 ;; Author: Jamie Zawinski <jwz@jwz.org> | 6 ;; Author: Jamie Zawinski <jwz@jwz.org> |
7 ;; Author: Hallvard Furuseth <hbf@ulrik.uio.no> | 7 ;; Author: Hallvard Furuseth <hbf@ulrik.uio.no> |
8 ;; Maintainer: XEmacs Development Team | 8 ;; Maintainer: XEmacs Development Team |
9 ;; Keywords: internal, dumped | 9 ;; Keywords: internal, dumped |
491 SYMBOL must be quoted and can be a list of SYMBOLS. See also | 491 SYMBOL must be quoted and can be a list of SYMBOLS. See also |
492 `with-obsolete-variable'." | 492 `with-obsolete-variable'." |
493 `(with-byte-compiler-warnings-suppressed 'obsolete ,@body)) | 493 `(with-byte-compiler-warnings-suppressed 'obsolete ,@body)) |
494 | 494 |
495 | 495 |
496 | |
497 (defmacro error-unless-tests-match (test &optional source) | |
498 "Signal an error unless TEST matches when being compiled and loaded. | |
499 This is for use in a file that will be byte-compiled. Unless TEST has the | |
500 same nilness or non-nilness when the file is compiled and loaded, an error | |
501 will be signalled. SOURCE is the name of the source file." | |
502 (let ((source (eval source))) | |
503 `(unless (eq (not ,test) ,(not (eval test))) | |
504 (error ,(format "This file was compiled with `%s' %s, | |
505 but it was %s when run. This file needs to be compiled with | |
506 the same value for the expression as when it is run. Please delete | |
507 %s and rebuild." | |
508 test (if (eval test) "true" "false") | |
509 (if (eval test) "false" "true") | |
510 (cond | |
511 ((null source) "the .elc for this file") | |
512 ((string-match "\.elc$" source) source) | |
513 ((string-match "\.el$" source) (concat source "c")) | |
514 (t (concat source ".elc")))))))) | |
515 | |
516 (defun byte-compile-file-being-compiled () | |
517 "When byte-compiling a file, return the name of the file being compiled. | |
518 Return nil otherwise." | |
519 (or | |
520 ;;The first of these, but not the second, seems to work noninteractively; | |
521 ;;vice-versa interactively. This is because interactively a *Compile Log* | |
522 ;;buffer is created and byte-compile-log-1 inserts a "Compiling file ..." | |
523 ;;message into thelog buffer, and then sets byte-compile-current-file to | |
524 ;;nil to indicate that the message shouldn't be printed again. | |
525 (and-boundp 'byte-compile-current-file byte-compile-current-file) | |
526 (and-boundp 'byte-compile-log-buffer | |
527 (with-current-buffer byte-compile-log-buffer | |
528 (save-excursion | |
529 (and (re-search-backward "Compiling file \\(.*\\) at " nil t) | |
530 (match-string 1))))))) | |
531 | |
532 | |
533 (defmacro compiled-if (test if &rest else) | |
534 "Like a regular `if' statement but the TEST will be evalled at compile time. | |
535 If TEST doesn't match at compile time and load time, an error will be | |
536 signalled." | |
537 (let ((being-compiled (byte-compile-file-being-compiled))) | |
538 `(progn | |
539 (error-unless-tests-match ,test ,being-compiled) | |
540 ,(if (eval test) | |
541 if | |
542 `(progn ,else))))) | |
543 | |
544 (defmacro compiled-when (test &rest when) | |
545 "Like a regular `when' statement but the TEST will be evalled at compile time. | |
546 See `compiled-if'." | |
547 `(compiled-if ,test (progn ,@when))) | |
548 | |
549 | |
496 ;;; Interface to file-local byte-compiler parameters. | 550 ;;; Interface to file-local byte-compiler parameters. |
497 ;;; Redefined in bytecomp.el. | 551 ;;; Redefined in bytecomp.el. |
498 | 552 |
499 ;;; The great RMS speaketh: | 553 ;;; The great RMS speaketh: |
500 ;;; | 554 ;;; |