comparison lisp/emacs-lisp/byte-opt.el @ 36999:642a94733741

(byte-optimize-while) (byte-optimize-form-code-walker): Diagnose too few arguments for `if' and `while'.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 26 Mar 2001 13:04:11 +0000
parents f1c913d16f4c
children 4a5ea0885c7b
comparison
equal deleted inserted replaced
36998:8628eb0b28c7 36999:642a94733741
1 ;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler. 1 ;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler.
2 2
3 ;;; Copyright (c) 1991, 1994, 2000 Free Software Foundation, Inc. 3 ;;; Copyright (c) 1991, 1994, 2000, 2001 Free Software Foundation, Inc.
4 4
5 ;; Author: Jamie Zawinski <jwz@lucid.com> 5 ;; Author: Jamie Zawinski <jwz@lucid.com>
6 ;; Hallvard Furuseth <hbf@ulrik.uio.no> 6 ;; Hallvard Furuseth <hbf@ulrik.uio.no>
7 ;; Maintainer: FSF 7 ;; Maintainer: FSF
8 ;; Keywords: internal 8 ;; Keywords: internal
443 (cons 443 (cons
444 (byte-optimize-form (nth 1 form) nil) 444 (byte-optimize-form (nth 1 form) nil)
445 (byte-optimize-body (cdr (cdr form)) for-effect)))) 445 (byte-optimize-body (cdr (cdr form)) for-effect))))
446 446
447 ((eq fn 'if) 447 ((eq fn 'if)
448 (when (< (length form) 3)
449 (byte-compile-warn "Too few arguments for `if'"))
448 (cons fn 450 (cons fn
449 (cons (byte-optimize-form (nth 1 form) nil) 451 (cons (byte-optimize-form (nth 1 form) nil)
450 (cons 452 (cons
451 (byte-optimize-form (nth 2 form) for-effect) 453 (byte-optimize-form (nth 2 form) for-effect)
452 (byte-optimize-body (nthcdr 3 form) for-effect))))) 454 (byte-optimize-body (nthcdr 3 form) for-effect)))))
1012 (nth 3 form)))) 1014 (nth 3 form))))
1013 (t 1015 (t
1014 (list 'progn clause nil))))) 1016 (list 'progn clause nil)))))
1015 1017
1016 (defun byte-optimize-while (form) 1018 (defun byte-optimize-while (form)
1019 (when (< (length form) 2)
1020 (byte-compile-warn "Too few arguments for `while'"))
1017 (if (nth 1 form) 1021 (if (nth 1 form)
1018 form)) 1022 form))
1019 1023
1020 (put 'and 'byte-optimizer 'byte-optimize-and) 1024 (put 'and 'byte-optimizer 'byte-optimize-and)
1021 (put 'or 'byte-optimizer 'byte-optimize-or) 1025 (put 'or 'byte-optimizer 'byte-optimize-or)