emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cc-vars.el


From: Dave Love
Subject: Re: cc-vars.el
Date: 19 Nov 2002 16:59:18 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Miles Bader <address@hidden> writes:

> _That_ sort of change is pretty easy, and has the advantage of working
> even with old compilers that don't special case it (they'll just emit a
> warning like before, but the generated code will be the same).

Exactly.  This was it.  I think it was the only diff needed, but I'm
not sure it didn't depend on another change.

As far as I remember, someone didn't like it because it wasn't
general, i.e. it doesn't work with all conditionals.  I don't think
that matters if it's documented.

*** bytecomp.el 23 Jul 2001 16:02:49 -0000      2.84
--- bytecomp.el 19 Nov 2002 11:29:15 -0000
*************** If FORM is a lambda or a macro, byte-com
*** 3213,3231 ****
  
  (defun byte-compile-if (form)
    (byte-compile-form (car (cdr form)))
!   (if (null (nthcdr 3 form))
!       ;; No else-forms
!       (let ((donetag (byte-compile-make-tag)))
!       (byte-compile-goto-if nil for-effect donetag)
!       (byte-compile-form (nth 2 form) for-effect)
!       (byte-compile-out-tag donetag))
!     (let ((donetag (byte-compile-make-tag)) (elsetag (byte-compile-make-tag)))
!       (byte-compile-goto 'byte-goto-if-nil elsetag)
!       (byte-compile-form (nth 2 form) for-effect)
!       (byte-compile-goto 'byte-goto donetag)
!       (byte-compile-out-tag elsetag)
!       (byte-compile-body (cdr (cdr (cdr form))) for-effect)
!       (byte-compile-out-tag donetag)))
    (setq for-effect nil))
  
  (defun byte-compile-cond (clauses)
--- 3213,3258 ----
  
  (defun byte-compile-if (form)
    (byte-compile-form (car (cdr form)))
!   ;; Check whether we have `(if (fboundp ...' or `(if (boundp ...'
!   (let* ((clause (nth 1 form))
!        (fbound (if (eq 'fboundp (car-safe clause))
!                    (and (eq 'quote (car-safe (nth 1 clause)))
!                         (nth 1 (nth 1 clause))))) ; the relevant symbol
!        (bound (if (eq 'boundp (car-safe clause))
!                   (and (eq 'quote (car-safe (nth 1 clause)))
!                        (nth 1 (nth 1 clause)))))) ; the relevant symbol
!     (if (null (nthcdr 3 form))
!       ;; No else-forms
!       (let ((donetag (byte-compile-make-tag)))
!         (byte-compile-goto-if nil for-effect donetag)
!         (cond (bound (let ((byte-compile-bound-variables
!                             (cons bound
!                                   byte-compile-bound-variables)))
!                        (byte-compile-form (nth 2 form) for-effect)))
!               (fbound (byte-compile-form (nth 2 form) for-effect)
!                       (setq byte-compile-unresolved-functions
!                             (delq (assq fbound
!                                         byte-compile-unresolved-functions)
!                                   byte-compile-unresolved-functions)))
!               (t (byte-compile-form (nth 2 form) for-effect)))
!         (byte-compile-out-tag donetag))
!       (let ((donetag (byte-compile-make-tag))
!           (elsetag (byte-compile-make-tag)))
!       (byte-compile-goto 'byte-goto-if-nil elsetag)
!       (cond (bound (let ((byte-compile-bound-variables
!                           (cons bound
!                                 byte-compile-bound-variables)))
!                      (byte-compile-form (nth 2 form) for-effect)))
!             (fbound (byte-compile-form (nth 2 form) for-effect)
!                     (setq byte-compile-unresolved-functions
!                           (delq (assq fbound
!                                       byte-compile-unresolved-functions)
!                                 byte-compile-unresolved-functions)))
!             (t (byte-compile-form (nth 2 form) for-effect)))
!       (byte-compile-goto 'byte-goto donetag)
!       (byte-compile-out-tag elsetag)
!       (byte-compile-body (cdr (cdr (cdr form))) for-effect)
!       (byte-compile-out-tag donetag))))
    (setq for-effect nil))
  
  (defun byte-compile-cond (clauses)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]