Mercurial > emacs
comparison lisp/emacs-lisp/bytecomp.el @ 64179:09328bd431d2
(byte-compile-maybe-guarded): Check for (featurep 'xemacs) and turn
off warnings in what it guards. Use unwind-protect to ensure
byte-compile-unresolved-functions is updated.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 08 Jul 2005 22:49:47 +0000 |
parents | 18a818a2ee7c |
children | 3b6714810ffc fbb2bea03df9 |
comparison
equal
deleted
inserted
replaced
64178:0b1f11faf0b2 | 64179:09328bd431d2 |
---|---|
3349 (if ,discard 'byte-goto-if-nil 'byte-goto-if-nil-else-pop)) | 3349 (if ,discard 'byte-goto-if-nil 'byte-goto-if-nil-else-pop)) |
3350 ,tag)) | 3350 ,tag)) |
3351 | 3351 |
3352 (defmacro byte-compile-maybe-guarded (condition &rest body) | 3352 (defmacro byte-compile-maybe-guarded (condition &rest body) |
3353 "Execute forms in BODY, potentially guarded by CONDITION. | 3353 "Execute forms in BODY, potentially guarded by CONDITION. |
3354 CONDITION is the test in an `if' form or in a `cond' clause. | 3354 CONDITION is a variable whose value is a test in an `if' or `cond'. |
3355 BODY is to compile the first arm of the if or the body of the | 3355 BODY is the code to compile first arm of the if or the body of the |
3356 cond clause. If CONDITION is of the form `(foundp 'foo)' | 3356 cond clause. If CONDITION's value is of the form `(foundp 'foo)' |
3357 or `(boundp 'foo)', the relevant warnings from BODY about foo | 3357 or `(boundp 'foo)', the relevant warnings from BODY about foo |
3358 being undefined will be suppressed." | 3358 being undefined will be suppressed. |
3359 | |
3360 If CONDITION's value is `(featurep 'xemacs)', that suppresses all | |
3361 warnings during execution of BODY." | |
3359 (declare (indent 1) (debug t)) | 3362 (declare (indent 1) (debug t)) |
3360 `(let* ((fbound | 3363 `(let* ((fbound |
3361 (if (eq 'fboundp (car-safe ,condition)) | 3364 (if (eq 'fboundp (car-safe ,condition)) |
3362 (and (eq 'quote (car-safe (nth 1 ,condition))) | 3365 (and (eq 'quote (car-safe (nth 1 ,condition))) |
3363 ;; Ignore if the symbol is already on the | 3366 ;; Ignore if the symbol is already on the |
3371 (nth 1 (nth 1 ,condition))))) | 3374 (nth 1 (nth 1 ,condition))))) |
3372 ;; Maybe add to the bound list. | 3375 ;; Maybe add to the bound list. |
3373 (byte-compile-bound-variables | 3376 (byte-compile-bound-variables |
3374 (if bound | 3377 (if bound |
3375 (cons bound byte-compile-bound-variables) | 3378 (cons bound byte-compile-bound-variables) |
3376 byte-compile-bound-variables))) | 3379 byte-compile-bound-variables)) |
3377 (progn ,@body) | 3380 (byte-compile-warnings |
3378 ;; Maybe remove the function symbol from the unresolved list. | 3381 (if (equal ,condition '(featurep 'xemacs)) |
3379 (if fbound | 3382 nil byte-compile-warnings))) |
3380 (setq byte-compile-unresolved-functions | 3383 (unwind-protect |
3381 (delq (assq fbound byte-compile-unresolved-functions) | 3384 (progn ,@body) |
3382 byte-compile-unresolved-functions))))) | 3385 ;; Maybe remove the function symbol from the unresolved list. |
3386 (if fbound | |
3387 (setq byte-compile-unresolved-functions | |
3388 (delq (assq fbound byte-compile-unresolved-functions) | |
3389 byte-compile-unresolved-functions)))))) | |
3383 | 3390 |
3384 (defun byte-compile-if (form) | 3391 (defun byte-compile-if (form) |
3385 (byte-compile-form (car (cdr form))) | 3392 (byte-compile-form (car (cdr form))) |
3386 ;; Check whether we have `(if (fboundp ...' or `(if (boundp ...' | 3393 ;; Check whether we have `(if (fboundp ...' or `(if (boundp ...' |
3387 ;; and avoid warnings about the relevent symbols in the consequent. | 3394 ;; and avoid warnings about the relevent symbols in the consequent. |
3418 ((cdr clauses) | 3425 ((cdr clauses) |
3419 (byte-compile-form (car clause)) | 3426 (byte-compile-form (car clause)) |
3420 (if (null (cdr clause)) | 3427 (if (null (cdr clause)) |
3421 ;; First clause is a singleton. | 3428 ;; First clause is a singleton. |
3422 (byte-compile-goto-if t for-effect donetag) | 3429 (byte-compile-goto-if t for-effect donetag) |
3423 (setq nexttag (byte-compile-make-tag)) | 3430 (setq nexttag (byte-compile-make-tag)) |
3424 (byte-compile-goto 'byte-goto-if-nil nexttag) | 3431 (byte-compile-goto 'byte-goto-if-nil nexttag) |
3425 (byte-compile-maybe-guarded (car clause) | 3432 (byte-compile-maybe-guarded (car clause) |
3426 (byte-compile-body (cdr clause) for-effect)) | 3433 (byte-compile-body (cdr clause) for-effect)) |
3427 (byte-compile-goto 'byte-goto donetag) | 3434 (byte-compile-goto 'byte-goto donetag) |
3428 (byte-compile-out-tag nexttag))))) | 3435 (byte-compile-out-tag nexttag))))) |
3429 ;; Last clause | 3436 ;; Last clause |
3430 (let ((guard (car clause))) | 3437 (let ((guard (car clause))) |
3431 (and (cdr clause) (not (eq guard t)) | 3438 (and (cdr clause) (not (eq guard t)) |
3432 (progn (byte-compile-form guard) | 3439 (progn (byte-compile-form guard) |
3433 (byte-compile-goto-if nil for-effect donetag) | 3440 (byte-compile-goto-if nil for-effect donetag) |