comparison lisp/emacs-lisp/bytecomp.el @ 91204:53108e6cea98

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
author Miles Bader <miles@gnu.org>
date Thu, 06 Dec 2007 09:51:45 +0000
parents 880960b70474 fd5b69abce98
children 606f2d163a64
comparison
equal deleted inserted replaced
91203:db40129142b2 91204:53108e6cea98
1051 ;; to tell inner calls to displaying-byte-compile-warnings 1051 ;; to tell inner calls to displaying-byte-compile-warnings
1052 ;; not to bind warning-series. 1052 ;; not to bind warning-series.
1053 (defun byte-compile-warning-series (&rest ignore) 1053 (defun byte-compile-warning-series (&rest ignore)
1054 nil) 1054 nil)
1055 1055
1056 ;; (compile-mode) will cause this to be loaded.
1057 (declare-function compilation-forget-errors "compile" ())
1058
1056 ;; Log the start of a file in *Compile-Log*, and mark it as done. 1059 ;; Log the start of a file in *Compile-Log*, and mark it as done.
1057 ;; Return the position of the start of the page in the log buffer. 1060 ;; Return the position of the start of the page in the log buffer.
1058 ;; But do nothing in batch mode. 1061 ;; But do nothing in batch mode.
1059 (defun byte-compile-log-file () 1062 (defun byte-compile-log-file ()
1060 (and (not (equal byte-compile-current-file byte-compile-last-logged-file)) 1063 (and (not (equal byte-compile-current-file byte-compile-last-logged-file))
1256 (defun byte-compile-callargs-warn (form) 1259 (defun byte-compile-callargs-warn (form)
1257 (let* ((def (or (byte-compile-fdefinition (car form) nil) 1260 (let* ((def (or (byte-compile-fdefinition (car form) nil)
1258 (byte-compile-fdefinition (car form) t))) 1261 (byte-compile-fdefinition (car form) t)))
1259 (sig (if (and def (not (eq def t))) 1262 (sig (if (and def (not (eq def t)))
1260 (byte-compile-arglist-signature 1263 (byte-compile-arglist-signature
1261 (if (eq 'lambda (car-safe def)) 1264 (if (memq (car-safe def) '(declared lambda))
1262 (nth 1 def) 1265 (nth 1 def)
1263 (if (byte-code-function-p def) 1266 (if (byte-code-function-p def)
1264 (aref def 0) 1267 (aref def 0)
1265 '(&rest def)))) 1268 '(&rest def))))
1266 (if (and (fboundp (car form)) 1269 (if (and (fboundp (car form))
2272 (defun byte-compile-file-form-custom-declare-variable (form) 2275 (defun byte-compile-file-form-custom-declare-variable (form)
2273 (when (byte-compile-warning-enabled-p 'callargs) 2276 (when (byte-compile-warning-enabled-p 'callargs)
2274 (byte-compile-nogroup-warn form)) 2277 (byte-compile-nogroup-warn form))
2275 (when (byte-compile-warning-enabled-p 'free-vars) 2278 (when (byte-compile-warning-enabled-p 'free-vars)
2276 (push (nth 1 (nth 1 form)) byte-compile-bound-variables)) 2279 (push (nth 1 (nth 1 form)) byte-compile-bound-variables))
2280 ;; Don't compile the expression because it may be displayed to the user.
2281 ;; (when (eq (car-safe (nth 2 form)) 'quote)
2282 ;; ;; (nth 2 form) is meant to evaluate to an expression, so if we have the
2283 ;; ;; final value already, we can byte-compile it.
2284 ;; (setcar (cdr (nth 2 form))
2285 ;; (byte-compile-top-level (cadr (nth 2 form)) nil 'file)))
2277 (let ((tail (nthcdr 4 form))) 2286 (let ((tail (nthcdr 4 form)))
2278 (while tail 2287 (while tail
2279 ;; If there are any (function (lambda ...)) expressions, compile 2288 (unless (keywordp (car tail)) ;No point optimizing keywords.
2280 ;; those functions. 2289 ;; Compile the keyword arguments.
2281 (if (and (consp (car tail)) 2290 (setcar tail (byte-compile-top-level (car tail) nil 'file)))
2282 (eq (car (car tail)) 'function)
2283 (consp (nth 1 (car tail))))
2284 (setcar tail (byte-compile-lambda (nth 1 (car tail))))
2285 ;; Likewise for a bare lambda.
2286 (if (and (consp (car tail))
2287 (eq (car (car tail)) 'lambda))
2288 (setcar tail (byte-compile-lambda (car tail)))))
2289 (setq tail (cdr tail)))) 2291 (setq tail (cdr tail))))
2290 form) 2292 form)
2291 2293
2292 (put 'require 'byte-hunk-handler 'byte-compile-file-form-require) 2294 (put 'require 'byte-hunk-handler 'byte-compile-file-form-require)
2293 (defun byte-compile-file-form-require (form) 2295 (defun byte-compile-file-form-require (form)
2815 (setq body (byte-compile-top-level (cons 'progn body) for-effect t)) 2817 (setq body (byte-compile-top-level (cons 'progn body) for-effect t))
2816 (cond ((eq (car-safe body) 'progn) 2818 (cond ((eq (car-safe body) 'progn)
2817 (cdr body)) 2819 (cdr body))
2818 (body 2820 (body
2819 (list body)))) 2821 (list body))))
2822
2823 (put 'declare-function 'byte-hunk-handler 'byte-compile-declare-function)
2824 (defun byte-compile-declare-function (form)
2825 (push (cons (nth 1 form)
2826 (if (and (> (length form) 3)
2827 (listp (nth 3 form)))
2828 (list 'declared (nth 3 form))
2829 t)) ; arglist not specified
2830 byte-compile-function-environment)
2831 ;; We are stating that it _will_ be defined at runtime.
2832 (setq byte-compile-noruntime-functions
2833 (delq (nth 1 form) byte-compile-noruntime-functions))
2834 nil)
2835
2820 2836
2821 ;; This is the recursive entry point for compiling each subform of an 2837 ;; This is the recursive entry point for compiling each subform of an
2822 ;; expression. 2838 ;; expression.
2823 ;; If for-effect is non-nil, byte-compile-form will output a byte-discard 2839 ;; If for-effect is non-nil, byte-compile-form will output a byte-discard
2824 ;; before terminating (ie no value will be left on the stack). 2840 ;; before terminating (ie no value will be left on the stack).
3494 (if ,discard 'byte-goto-if-nil 'byte-goto-if-nil-else-pop)) 3510 (if ,discard 'byte-goto-if-nil 'byte-goto-if-nil-else-pop))
3495 ,tag)) 3511 ,tag))
3496 3512
3497 ;; Return the list of items in CONDITION-PARAM that match PRED-LIST. 3513 ;; Return the list of items in CONDITION-PARAM that match PRED-LIST.
3498 ;; Only return items that are not in ONLY-IF-NOT-PRESENT. 3514 ;; Only return items that are not in ONLY-IF-NOT-PRESENT.
3499 (defun byte-compile-find-bound-condition (condition-param 3515 (defun byte-compile-find-bound-condition (condition-param
3500 pred-list 3516 pred-list
3501 &optional only-if-not-present) 3517 &optional only-if-not-present)
3502 (let ((result nil) 3518 (let ((result nil)
3503 (nth-one nil) 3519 (nth-one nil)
3504 (cond-list 3520 (cond-list
3505 (if (memq (car-safe condition-param) pred-list) 3521 (if (memq (car-safe condition-param) pred-list)
3506 ;; The condition appears by itself. 3522 ;; The condition appears by itself.
3507 (list condition-param) 3523 (list condition-param)
3508 ;; If the condition is an `and', look for matches among the 3524 ;; If the condition is an `and', look for matches among the
3509 ;; `and' arguments. 3525 ;; `and' arguments.
3510 (when (eq 'and (car-safe condition-param)) 3526 (when (eq 'and (car-safe condition-param))
3511 (cdr condition-param))))) 3527 (cdr condition-param)))))
3512 3528
3513 (dolist (crt cond-list) 3529 (dolist (crt cond-list)
3514 (when (and (memq (car-safe crt) pred-list) 3530 (when (and (memq (car-safe crt) pred-list)
3515 (eq 'quote (car-safe (setq nth-one (nth 1 crt)))) 3531 (eq 'quote (car-safe (setq nth-one (nth 1 crt))))
3516 ;; Ignore if the symbol is already on the unresolved 3532 ;; Ignore if the symbol is already on the unresolved
3517 ;; list. 3533 ;; list.
3529 being undefined will be suppressed. 3545 being undefined will be suppressed.
3530 3546
3531 If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs), 3547 If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs),
3532 that suppresses all warnings during execution of BODY." 3548 that suppresses all warnings during execution of BODY."
3533 (declare (indent 1) (debug t)) 3549 (declare (indent 1) (debug t))
3534 `(let* ((fbound-list (byte-compile-find-bound-condition 3550 `(let* ((fbound-list (byte-compile-find-bound-condition
3535 ,condition (list 'fboundp) 3551 ,condition (list 'fboundp)
3536 byte-compile-unresolved-functions)) 3552 byte-compile-unresolved-functions))
3537 (bound-list (byte-compile-find-bound-condition 3553 (bound-list (byte-compile-find-bound-condition
3538 ,condition (list 'boundp 'default-boundp))) 3554 ,condition (list 'boundp 'default-boundp)))
3539 ;; Maybe add to the bound list. 3555 ;; Maybe add to the bound list.
3540 (byte-compile-bound-variables 3556 (byte-compile-bound-variables
3541 (if bound-list 3557 (if bound-list
3542 (append bound-list byte-compile-bound-variables) 3558 (append bound-list byte-compile-bound-variables)
4262 "Run `byte-recompile-directory' on the dirs remaining on the command line. 4278 "Run `byte-recompile-directory' on the dirs remaining on the command line.
4263 Must be used only with `-batch', and kills Emacs on completion. 4279 Must be used only with `-batch', and kills Emacs on completion.
4264 For example, invoke `emacs -batch -f batch-byte-recompile-directory .'. 4280 For example, invoke `emacs -batch -f batch-byte-recompile-directory .'.
4265 4281
4266 Optional argument ARG is passed as second argument ARG to 4282 Optional argument ARG is passed as second argument ARG to
4267 `batch-recompile-directory'; see there for its possible values 4283 `byte-recompile-directory'; see there for its possible values
4268 and corresponding effects." 4284 and corresponding effects."
4269 ;; command-line-args-left is what is left of the command line (startup.el) 4285 ;; command-line-args-left is what is left of the command line (startup.el)
4270 (defvar command-line-args-left) ;Avoid 'free variable' warning 4286 (defvar command-line-args-left) ;Avoid 'free variable' warning
4271 (if (not noninteractive) 4287 (if (not noninteractive)
4272 (error "batch-byte-recompile-directory is to be used only with -batch")) 4288 (error "batch-byte-recompile-directory is to be used only with -batch"))