comparison lisp/emacs-lisp/bytecomp.el @ 83395:b31326248cf6

Merged from miles@gnu.org--gnu-2005 (patch 142-148, 615-628) Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-615 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-616 Add lisp/mh-e/.arch-inventory * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-617 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-618 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-619 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-620 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-622 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-623 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-624 Update from CVS: lisp/smerge-mode.el: Add 'tools' to file keywords. * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-625 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-626 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-627 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-628 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-142 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-143 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-144 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-145 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-146 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-147 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-148 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-435
author Karoly Lorentey <lorentey@elte.hu>
date Tue, 01 Nov 2005 06:23:08 +0000
parents 532e0a9335a9 3f882faaa9ae
children 55e22205ba88
comparison
equal deleted inserted replaced
83394:7d093d9d4479 83395:b31326248cf6
906 ;; to that symbol's character position. Similarly, if we encounter a 906 ;; to that symbol's character position. Similarly, if we encounter a
907 ;; variable reference, like in (1+ foo), we remove `foo' from the 907 ;; variable reference, like in (1+ foo), we remove `foo' from the
908 ;; list. If our current position is after the symbol's position, we 908 ;; list. If our current position is after the symbol's position, we
909 ;; assume we've already passed that point, and look for the next 909 ;; assume we've already passed that point, and look for the next
910 ;; occurrence of the symbol. 910 ;; occurrence of the symbol.
911 ;;
912 ;; This function should not be called twice for the same occurrence of
913 ;; a symbol, and it should not be called for symbols generated by the
914 ;; byte compiler itself; because rather than just fail looking up the
915 ;; symbol, we may find an occurrence of the symbol further ahead, and
916 ;; then `byte-compile-last-position' as advanced too far.
917 ;;
911 ;; So your're probably asking yourself: Isn't this function a 918 ;; So your're probably asking yourself: Isn't this function a
912 ;; gross hack? And the answer, of course, would be yes. 919 ;; gross hack? And the answer, of course, would be yes.
913 (defun byte-compile-set-symbol-position (sym &optional allow-previous) 920 (defun byte-compile-set-symbol-position (sym &optional allow-previous)
914 (when byte-compile-read-position 921 (when byte-compile-read-position
915 (let (last entry) 922 (let (last entry)
2302 (princ `(if macro-declaration-function 2309 (princ `(if macro-declaration-function
2303 (funcall macro-declaration-function 2310 (funcall macro-declaration-function
2304 ',name ',declaration)) 2311 ',name ',declaration))
2305 outbuffer))))) 2312 outbuffer)))))
2306 2313
2307 (let* ((new-one (byte-compile-lambda (cons 'lambda (nthcdr 2 form)))) 2314 (let* ((new-one (byte-compile-lambda (nthcdr 2 form) t))
2308 (code (byte-compile-byte-code-maker new-one))) 2315 (code (byte-compile-byte-code-maker new-one)))
2309 (if this-one 2316 (if this-one
2310 (setcdr this-one new-one) 2317 (setcdr this-one new-one)
2311 (set this-kind 2318 (set this-kind
2312 (cons (cons name new-one) (symbol-value this-kind)))) 2319 (cons (cons name new-one) (symbol-value this-kind))))
2498 2505
2499 2506
2500 ;; Byte-compile a lambda-expression and return a valid function. 2507 ;; Byte-compile a lambda-expression and return a valid function.
2501 ;; The value is usually a compiled function but may be the original 2508 ;; The value is usually a compiled function but may be the original
2502 ;; lambda-expression. 2509 ;; lambda-expression.
2503 (defun byte-compile-lambda (fun) 2510 ;; When ADD-LAMBDA is non-nil, the symbol `lambda' is added as head
2504 (unless (eq 'lambda (car-safe fun)) 2511 ;; of the list FUN and `byte-compile-set-symbol-position' is not called.
2505 (error "Not a lambda list: %S" fun)) 2512 ;; Use this feature to avoid calling `byte-compile-set-symbol-position'
2506 (byte-compile-set-symbol-position 'lambda) 2513 ;; for symbols generated by the byte compiler itself.
2514 (defun byte-compile-lambda (fun &optional add-lambda)
2515 (if add-lambda
2516 (setq fun (cons 'lambda fun))
2517 (unless (eq 'lambda (car-safe fun))
2518 (error "Not a lambda list: %S" fun))
2519 (byte-compile-set-symbol-position 'lambda))
2507 (byte-compile-check-lambda-list (nth 1 fun)) 2520 (byte-compile-check-lambda-list (nth 1 fun))
2508 (let* ((arglist (nth 1 fun)) 2521 (let* ((arglist (nth 1 fun))
2509 (byte-compile-bound-variables 2522 (byte-compile-bound-variables
2510 (nconc (and (memq 'free-vars byte-compile-warnings) 2523 (nconc (and (memq 'free-vars byte-compile-warnings)
2511 (delq '&rest (delq '&optional (copy-sequence arglist)))) 2524 (delq '&rest (delq '&optional (copy-sequence arglist))))
2753 That command is designed for interactive use only" fn)) 2766 That command is designed for interactive use only" fn))
2754 (if (and handler 2767 (if (and handler
2755 (or (not (byte-compile-version-cond 2768 (or (not (byte-compile-version-cond
2756 byte-compile-compatibility)) 2769 byte-compile-compatibility))
2757 (not (get (get fn 'byte-opcode) 'emacs19-opcode)))) 2770 (not (get (get fn 'byte-opcode) 'emacs19-opcode))))
2758 (progn 2771 (funcall handler form)
2759 (byte-compile-set-symbol-position fn)
2760 (funcall handler form))
2761 (when (memq 'callargs byte-compile-warnings) 2772 (when (memq 'callargs byte-compile-warnings)
2762 (if (memq fn '(custom-declare-group custom-declare-variable custom-declare-face)) 2773 (if (memq fn '(custom-declare-group custom-declare-variable custom-declare-face))
2763 (byte-compile-nogroup-warn form)) 2774 (byte-compile-nogroup-warn form))
2764 (byte-compile-callargs-warn form)) 2775 (byte-compile-callargs-warn form))
2765 (byte-compile-normal-call form)) 2776 (byte-compile-normal-call form))
3669 (progn 3680 (progn
3670 (byte-compile-two-args ; Use this to avoid byte-compile-fset's warning. 3681 (byte-compile-two-args ; Use this to avoid byte-compile-fset's warning.
3671 (list 'fset 3682 (list 'fset
3672 (list 'quote (nth 1 form)) 3683 (list 'quote (nth 1 form))
3673 (byte-compile-byte-code-maker 3684 (byte-compile-byte-code-maker
3674 (byte-compile-lambda (cons 'lambda (cdr (cdr form))))))) 3685 (byte-compile-lambda (cdr (cdr form)) t))))
3675 (byte-compile-discard)) 3686 (byte-compile-discard))
3676 ;; We prefer to generate a defalias form so it will record the function 3687 ;; We prefer to generate a defalias form so it will record the function
3677 ;; definition just like interpreting a defun. 3688 ;; definition just like interpreting a defun.
3678 (byte-compile-form 3689 (byte-compile-form
3679 (list 'defalias 3690 (list 'defalias
3680 (list 'quote (nth 1 form)) 3691 (list 'quote (nth 1 form))
3681 (byte-compile-byte-code-maker 3692 (byte-compile-byte-code-maker
3682 (byte-compile-lambda (cons 'lambda (cdr (cdr form)))))) 3693 (byte-compile-lambda (cdr (cdr form)) t)))
3683 t)) 3694 t))
3684 (byte-compile-constant (nth 1 form))) 3695 (byte-compile-constant (nth 1 form)))
3685 3696
3686 (defun byte-compile-defmacro (form) 3697 (defun byte-compile-defmacro (form)
3687 ;; This is not used for file-level defmacros with doc strings. 3698 ;; This is not used for file-level defmacros with doc strings.
3688 (byte-compile-body-do-effect 3699 (byte-compile-body-do-effect
3689 (list (list 'fset (list 'quote (nth 1 form)) 3700 (list (list 'fset (list 'quote (nth 1 form))
3690 (let ((code (byte-compile-byte-code-maker 3701 (let ((code (byte-compile-byte-code-maker
3691 (byte-compile-lambda 3702 (byte-compile-lambda (cdr (cdr form)) t))))
3692 (cons 'lambda (cdr (cdr form)))))))
3693 (if (eq (car-safe code) 'make-byte-code) 3703 (if (eq (car-safe code) 'make-byte-code)
3694 (list 'cons ''macro code) 3704 (list 'cons ''macro code)
3695 (list 'quote (cons 'macro (eval code)))))) 3705 (list 'quote (cons 'macro (eval code))))))
3696 (list 'quote (nth 1 form))))) 3706 (list 'quote (nth 1 form)))))
3697 3707