comparison lisp/emacs-lisp/bytecomp.el @ 83159:38500c0c86ab

Merged in changes from CVS trunk. Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399 Tweak directory permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401 More build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403 Yet more build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-405 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-406 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-407 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-199
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 14 Jun 2004 20:00:54 +0000
parents 14e5707213a6 36284d653673
children b15f799f66b5
comparison
equal deleted inserted replaced
83158:f948c9fd910c 83159:38500c0c86ab
1006 (let* ((new (get (car form) 'byte-obsolete-info)) 1006 (let* ((new (get (car form) 'byte-obsolete-info))
1007 (handler (nth 1 new)) 1007 (handler (nth 1 new))
1008 (when (nth 2 new))) 1008 (when (nth 2 new)))
1009 (byte-compile-set-symbol-position (car form)) 1009 (byte-compile-set-symbol-position (car form))
1010 (if (memq 'obsolete byte-compile-warnings) 1010 (if (memq 'obsolete byte-compile-warnings)
1011 (byte-compile-warn "%s is an obsolete function%s; %s" (car form) 1011 (byte-compile-warn "`%s' is an obsolete function%s; %s" (car form)
1012 (if when (concat " since " when) "") 1012 (if when (concat " since " when) "")
1013 (if (stringp (car new)) 1013 (if (stringp (car new))
1014 (car new) 1014 (car new)
1015 (format "use %s instead." (car new))))) 1015 (format "use `%s' instead." (car new)))))
1016 (funcall (or handler 'byte-compile-normal-call) form))) 1016 (funcall (or handler 'byte-compile-normal-call) form)))
1017 1017
1018 ;; Compiler options 1018 ;; Compiler options
1019 1019
1020 ;; (defvar byte-compiler-valid-options 1020 ;; (defvar byte-compiler-valid-options
2074 2074
2075 (put 'defsubst 'byte-hunk-handler 'byte-compile-file-form-defsubst) 2075 (put 'defsubst 'byte-hunk-handler 'byte-compile-file-form-defsubst)
2076 (defun byte-compile-file-form-defsubst (form) 2076 (defun byte-compile-file-form-defsubst (form)
2077 (when (assq (nth 1 form) byte-compile-unresolved-functions) 2077 (when (assq (nth 1 form) byte-compile-unresolved-functions)
2078 (setq byte-compile-current-form (nth 1 form)) 2078 (setq byte-compile-current-form (nth 1 form))
2079 (byte-compile-warn "defsubst %s was used before it was defined" 2079 (byte-compile-warn "defsubst `%s' was used before it was defined"
2080 (nth 1 form))) 2080 (nth 1 form)))
2081 (byte-compile-file-form 2081 (byte-compile-file-form
2082 (macroexpand form byte-compile-macro-environment)) 2082 (macroexpand form byte-compile-macro-environment))
2083 ;; Return nil so the form is not output twice. 2083 ;; Return nil so the form is not output twice.
2084 nil) 2084 nil)
2204 (if (and (memq 'redefine byte-compile-warnings) 2204 (if (and (memq 'redefine byte-compile-warnings)
2205 ;; don't warn when compiling the stubs in byte-run... 2205 ;; don't warn when compiling the stubs in byte-run...
2206 (not (assq (nth 1 form) 2206 (not (assq (nth 1 form)
2207 byte-compile-initial-macro-environment))) 2207 byte-compile-initial-macro-environment)))
2208 (byte-compile-warn 2208 (byte-compile-warn
2209 "%s defined multiple times, as both function and macro" 2209 "`%s' defined multiple times, as both function and macro"
2210 (nth 1 form))) 2210 (nth 1 form)))
2211 (setcdr that-one nil)) 2211 (setcdr that-one nil))
2212 (this-one 2212 (this-one
2213 (when (and (memq 'redefine byte-compile-warnings) 2213 (when (and (memq 'redefine byte-compile-warnings)
2214 ;; hack: don't warn when compiling the magic internal 2214 ;; hack: don't warn when compiling the magic internal
2215 ;; byte-compiler macros in byte-run.el... 2215 ;; byte-compiler macros in byte-run.el...
2216 (not (assq (nth 1 form) 2216 (not (assq (nth 1 form)
2217 byte-compile-initial-macro-environment))) 2217 byte-compile-initial-macro-environment)))
2218 (byte-compile-warn "%s %s defined multiple times in this file" 2218 (byte-compile-warn "%s `%s' defined multiple times in this file"
2219 (if macrop "macro" "function") 2219 (if macrop "macro" "function")
2220 (nth 1 form)))) 2220 (nth 1 form))))
2221 ((and (fboundp name) 2221 ((and (fboundp name)
2222 (eq (car-safe (symbol-function name)) 2222 (eq (car-safe (symbol-function name))
2223 (if macrop 'lambda 'macro))) 2223 (if macrop 'lambda 'macro)))
2224 (when (memq 'redefine byte-compile-warnings) 2224 (when (memq 'redefine byte-compile-warnings)
2225 (byte-compile-warn "%s %s being redefined as a %s" 2225 (byte-compile-warn "%s `%s' being redefined as a %s"
2226 (if macrop "function" "macro") 2226 (if macrop "function" "macro")
2227 (nth 1 form) 2227 (nth 1 form)
2228 (if macrop "macro" "function"))) 2228 (if macrop "macro" "function")))
2229 ;; shadow existing definition 2229 ;; shadow existing definition
2230 (set this-kind 2230 (set this-kind
2693 ((symbolp (car form)) 2693 ((symbolp (car form))
2694 (let* ((fn (car form)) 2694 (let* ((fn (car form))
2695 (handler (get fn 'byte-compile))) 2695 (handler (get fn 'byte-compile)))
2696 (byte-compile-set-symbol-position fn) 2696 (byte-compile-set-symbol-position fn)
2697 (when (byte-compile-const-symbol-p fn) 2697 (when (byte-compile-const-symbol-p fn)
2698 (byte-compile-warn "%s called as a function" fn)) 2698 (byte-compile-warn "`%s' called as a function" fn))
2699 (if (and handler 2699 (if (and handler
2700 (or (not (byte-compile-version-cond 2700 (or (not (byte-compile-version-cond
2701 byte-compile-compatibility)) 2701 byte-compile-compatibility))
2702 (not (get (get fn 'byte-opcode) 'emacs19-opcode)))) 2702 (not (get (get fn 'byte-opcode) 'emacs19-opcode))))
2703 (funcall handler form) 2703 (funcall handler form)
2728 (when (symbolp var) 2728 (when (symbolp var)
2729 (byte-compile-set-symbol-position var)) 2729 (byte-compile-set-symbol-position var))
2730 (if (or (not (symbolp var)) 2730 (if (or (not (symbolp var))
2731 (byte-compile-const-symbol-p var (not (eq base-op 'byte-varref)))) 2731 (byte-compile-const-symbol-p var (not (eq base-op 'byte-varref))))
2732 (byte-compile-warn 2732 (byte-compile-warn
2733 (cond ((eq base-op 'byte-varbind) "attempt to let-bind %s %s") 2733 (cond ((eq base-op 'byte-varbind) "attempt to let-bind %s `%s'")
2734 ((eq base-op 'byte-varset) "variable assignment to %s %s") 2734 ((eq base-op 'byte-varset) "variable assignment to %s `%s'")
2735 (t "variable reference to %s %s")) 2735 (t "variable reference to %s `%s'"))
2736 (if (symbolp var) "constant" "nonvariable") 2736 (if (symbolp var) "constant" "nonvariable")
2737 (prin1-to-string var)) 2737 (prin1-to-string var))
2738 (if (and (get var 'byte-obsolete-variable) 2738 (if (and (get var 'byte-obsolete-variable)
2739 (memq 'obsolete byte-compile-warnings) 2739 (memq 'obsolete byte-compile-warnings)
2740 (not (eq var byte-compile-not-obsolete-var))) 2740 (not (eq var byte-compile-not-obsolete-var)))
2741 (let* ((ob (get var 'byte-obsolete-variable)) 2741 (let* ((ob (get var 'byte-obsolete-variable))
2742 (when (cdr ob))) 2742 (when (cdr ob)))
2743 (byte-compile-warn "%s is an obsolete variable%s; %s" var 2743 (byte-compile-warn "`%s' is an obsolete variable%s; %s" var
2744 (if when (concat " since " when) "") 2744 (if when (concat " since " when) "")
2745 (if (stringp (car ob)) 2745 (if (stringp (car ob))
2746 (car ob) 2746 (car ob)
2747 (format "use %s instead." (car ob)))))) 2747 (format "use `%s' instead." (car ob))))))
2748 (if (memq 'free-vars byte-compile-warnings) 2748 (if (memq 'free-vars byte-compile-warnings)
2749 (if (eq base-op 'byte-varbind) 2749 (if (eq base-op 'byte-varbind)
2750 (push var byte-compile-bound-variables) 2750 (push var byte-compile-bound-variables)
2751 (or (boundp var) 2751 (or (boundp var)
2752 (memq var byte-compile-bound-variables) 2752 (memq var byte-compile-bound-variables)
2753 (if (eq base-op 'byte-varset) 2753 (if (eq base-op 'byte-varset)
2754 (or (memq var byte-compile-free-assignments) 2754 (or (memq var byte-compile-free-assignments)
2755 (progn 2755 (progn
2756 (byte-compile-warn "assignment to free variable %s" var) 2756 (byte-compile-warn "assignment to free variable `%s'" var)
2757 (push var byte-compile-free-assignments))) 2757 (push var byte-compile-free-assignments)))
2758 (or (memq var byte-compile-free-references) 2758 (or (memq var byte-compile-free-references)
2759 (progn 2759 (progn
2760 (byte-compile-warn "reference to free variable %s" var) 2760 (byte-compile-warn "reference to free variable `%s'" var)
2761 (push var byte-compile-free-references)))))))) 2761 (push var byte-compile-free-references))))))))
2762 (let ((tmp (assq var byte-compile-variables))) 2762 (let ((tmp (assq var byte-compile-variables)))
2763 (unless tmp 2763 (unless tmp
2764 (setq tmp (list var)) 2764 (setq tmp (list var))
2765 (push tmp byte-compile-variables)) 2765 (push tmp byte-compile-variables))
2956 (byte-defop-compiler-1 interactive byte-compile-noop) 2956 (byte-defop-compiler-1 interactive byte-compile-noop)
2957 2957
2958 2958
2959 (defun byte-compile-subr-wrong-args (form n) 2959 (defun byte-compile-subr-wrong-args (form n)
2960 (byte-compile-set-symbol-position (car form)) 2960 (byte-compile-set-symbol-position (car form))
2961 (byte-compile-warn "%s called with %d arg%s, but requires %s" 2961 (byte-compile-warn "`%s' called with %d arg%s, but requires %s"
2962 (car form) (length (cdr form)) 2962 (car form) (length (cdr form))
2963 (if (= 1 (length (cdr form))) "" "s") n) 2963 (if (= 1 (length (cdr form))) "" "s") n)
2964 ;; get run-time wrong-number-of-args error. 2964 ;; get run-time wrong-number-of-args error.
2965 (byte-compile-normal-call form)) 2965 (byte-compile-normal-call form))
2966 2966
3122 (if (stringp (car body)) (setq body (cdr body))) 3122 (if (stringp (car body)) (setq body (cdr body)))
3123 (if (eq 'interactive (car-safe (car body))) (setq body (cdr body))) 3123 (if (eq 'interactive (car-safe (car body))) (setq body (cdr body)))
3124 (if (and (consp (car body)) 3124 (if (and (consp (car body))
3125 (not (eq 'byte-code (car (car body))))) 3125 (not (eq 'byte-code (car (car body)))))
3126 (byte-compile-warn 3126 (byte-compile-warn
3127 "A quoted lambda form is the second argument of fset. This is probably 3127 "A quoted lambda form is the second argument of `fset'. This is probably
3128 not what you want, as that lambda cannot be compiled. Consider using 3128 not what you want, as that lambda cannot be compiled. Consider using
3129 the syntax (function (lambda (...) ...)) instead."))))) 3129 the syntax (function (lambda (...) ...)) instead.")))))
3130 (byte-compile-two-args form)) 3130 (byte-compile-two-args form))
3131 3131
3132 (defun byte-compile-funarg (form) 3132 (defun byte-compile-funarg (form)
3505 (if var (cons var byte-compile-bound-variables) 3505 (if var (cons var byte-compile-bound-variables)
3506 byte-compile-bound-variables))) 3506 byte-compile-bound-variables)))
3507 (byte-compile-set-symbol-position 'condition-case) 3507 (byte-compile-set-symbol-position 'condition-case)
3508 (unless (symbolp var) 3508 (unless (symbolp var)
3509 (byte-compile-warn 3509 (byte-compile-warn
3510 "%s is not a variable-name or nil (in condition-case)" var)) 3510 "`%s' is not a variable-name or nil (in condition-case)" var))
3511 (byte-compile-push-constant var) 3511 (byte-compile-push-constant var)
3512 (byte-compile-push-constant (byte-compile-top-level 3512 (byte-compile-push-constant (byte-compile-top-level
3513 (nth 2 form) for-effect)) 3513 (nth 2 form) for-effect))
3514 (let ((clauses (cdr (cdr (cdr form)))) 3514 (let ((clauses (cdr (cdr (cdr form))))
3515 compiled-clauses) 3515 compiled-clauses)
3523 (if (not (symbolp (car syms))) 3523 (if (not (symbolp (car syms)))
3524 (setq ok nil)) 3524 (setq ok nil))
3525 (setq syms (cdr syms))) 3525 (setq syms (cdr syms)))
3526 ok)))) 3526 ok))))
3527 (byte-compile-warn 3527 (byte-compile-warn
3528 "%s is not a condition name or list of such (in condition-case)" 3528 "`%s' is not a condition name or list of such (in condition-case)"
3529 (prin1-to-string condition))) 3529 (prin1-to-string condition)))
3530 ;; ((not (or (eq condition 't) 3530 ;; ((not (or (eq condition 't)
3531 ;; (and (stringp (get condition 'error-message)) 3531 ;; (and (stringp (get condition 'error-message))
3532 ;; (consp (get condition 'error-conditions))))) 3532 ;; (consp (get condition 'error-conditions)))))
3533 ;; (byte-compile-warn 3533 ;; (byte-compile-warn
3534 ;; "%s is not a known condition name (in condition-case)" 3534 ;; "`%s' is not a known condition name (in condition-case)"
3535 ;; condition)) 3535 ;; condition))
3536 ) 3536 )
3537 (setq compiled-clauses 3537 (setq compiled-clauses
3538 (cons (cons condition 3538 (cons (cons condition
3539 (byte-compile-top-level-body 3539 (byte-compile-top-level-body
3625 (byte-compile-set-symbol-position fun) 3625 (byte-compile-set-symbol-position fun)
3626 (when (or (> (length form) 4) 3626 (when (or (> (length form) 4)
3627 (and (eq fun 'defconst) (null (cddr form)))) 3627 (and (eq fun 'defconst) (null (cddr form))))
3628 (let ((ncall (length (cdr form)))) 3628 (let ((ncall (length (cdr form))))
3629 (byte-compile-warn 3629 (byte-compile-warn
3630 "%s called with %d argument%s, but %s %s" 3630 "`%s' called with %d argument%s, but %s %s"
3631 fun ncall 3631 fun ncall
3632 (if (= 1 ncall) "" "s") 3632 (if (= 1 ncall) "" "s")
3633 (if (< ncall 2) "requires" "accepts only") 3633 (if (< ncall 2) "requires" "accepts only")
3634 "2-3"))) 3634 "2-3")))
3635 (when (memq 'free-vars byte-compile-warnings) 3635 (when (memq 'free-vars byte-compile-warnings)
3642 ;; just as a real defvar would, but only in top-level forms. 3642 ;; just as a real defvar would, but only in top-level forms.
3643 (when (and (cddr form) (null byte-compile-current-form)) 3643 (when (and (cddr form) (null byte-compile-current-form))
3644 `(push ',var current-load-list)) 3644 `(push ',var current-load-list))
3645 (when (> (length form) 3) 3645 (when (> (length form) 3)
3646 (when (and string (not (stringp string))) 3646 (when (and string (not (stringp string)))
3647 (byte-compile-warn "third arg to %s %s is not a string: %s" 3647 (byte-compile-warn "third arg to `%s %s' is not a string: %s"
3648 fun var string)) 3648 fun var string))
3649 `(put ',var 'variable-documentation ,string)) 3649 `(put ',var 'variable-documentation ,string))
3650 (if (cddr form) ; `value' provided 3650 (if (cddr form) ; `value' provided
3651 (let ((byte-compile-not-obsolete-var var)) 3651 (let ((byte-compile-not-obsolete-var var))
3652 (if (eq fun 'defconst) 3652 (if (eq fun 'defconst)