diff options
| author | Richard M. Stallman | 1994-06-29 18:06:09 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-06-29 18:06:09 +0000 |
| commit | 5286a84274ebfd70d0659739f8ff4e4fd532c9a7 (patch) | |
| tree | c6889417fb5726fb88b14c66919d94f0b2a5e543 | |
| parent | 88153c473ed8a29eed6c21c7bbcafbcafe620f97 (diff) | |
| download | emacs-5286a84274ebfd70d0659739f8ff4e4fd532c9a7.tar.gz emacs-5286a84274ebfd70d0659739f8ff4e4fd532c9a7.zip | |
(byte-compile-callargs-warn): Handle function defnition
that is not a lambda expression or byte code function.
(byte-compile-arglist-warn): Likewise.
(byte-compile-defalias): New function, used to compile defalias.
(byte-compile-defalias-warn): New function.
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index a6dcdd89043..b36bc6d6d78 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -834,7 +834,7 @@ otherwise pop it") | |||
| 834 | (defun byte-compile-fdefinition (name macro-p) | 834 | (defun byte-compile-fdefinition (name macro-p) |
| 835 | (let* ((list (if macro-p | 835 | (let* ((list (if macro-p |
| 836 | byte-compile-macro-environment | 836 | byte-compile-macro-environment |
| 837 | byte-compile-function-environment)) | 837 | byte-compile-function-environment)) |
| 838 | (env (cdr (assq name list)))) | 838 | (env (cdr (assq name list)))) |
| 839 | (or env | 839 | (or env |
| 840 | (let ((fn name)) | 840 | (let ((fn name)) |
| @@ -899,7 +899,9 @@ otherwise pop it") | |||
| 899 | (sig (and def (byte-compile-arglist-signature | 899 | (sig (and def (byte-compile-arglist-signature |
| 900 | (if (eq 'lambda (car-safe def)) | 900 | (if (eq 'lambda (car-safe def)) |
| 901 | (nth 1 def) | 901 | (nth 1 def) |
| 902 | (aref def 0))))) | 902 | (if (compiled-function-p def) |
| 903 | (aref def 0) | ||
| 904 | '(&rest def)))))) | ||
| 903 | (ncall (length (cdr form)))) | 905 | (ncall (length (cdr form)))) |
| 904 | (if sig | 906 | (if sig |
| 905 | (if (or (< ncall (car sig)) | 907 | (if (or (< ncall (car sig)) |
| @@ -932,7 +934,9 @@ otherwise pop it") | |||
| 932 | (let ((sig1 (byte-compile-arglist-signature | 934 | (let ((sig1 (byte-compile-arglist-signature |
| 933 | (if (eq 'lambda (car-safe old)) | 935 | (if (eq 'lambda (car-safe old)) |
| 934 | (nth 1 old) | 936 | (nth 1 old) |
| 935 | (aref old 0)))) | 937 | (if (compiled-function-p old) |
| 938 | (aref old 0) | ||
| 939 | '(&rest def))))) | ||
| 936 | (sig2 (byte-compile-arglist-signature (nth 2 form)))) | 940 | (sig2 (byte-compile-arglist-signature (nth 2 form)))) |
| 937 | (or (byte-compile-arglist-signatures-congruent-p sig1 sig2) | 941 | (or (byte-compile-arglist-signatures-congruent-p sig1 sig2) |
| 938 | (byte-compile-warn "%s %s used to take %s %s, now takes %s" | 942 | (byte-compile-warn "%s %s used to take %s %s, now takes %s" |
| @@ -2771,6 +2775,7 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2771 | (byte-defop-compiler-1 defconst byte-compile-defvar) | 2775 | (byte-defop-compiler-1 defconst byte-compile-defvar) |
| 2772 | (byte-defop-compiler-1 autoload) | 2776 | (byte-defop-compiler-1 autoload) |
| 2773 | (byte-defop-compiler-1 lambda byte-compile-lambda-form) | 2777 | (byte-defop-compiler-1 lambda byte-compile-lambda-form) |
| 2778 | (byte-defop-compiler-1 defalias) | ||
| 2774 | 2779 | ||
| 2775 | (defun byte-compile-defun (form) | 2780 | (defun byte-compile-defun (form) |
| 2776 | ;; This is not used for file-level defuns with doc strings. | 2781 | ;; This is not used for file-level defuns with doc strings. |
| @@ -2827,6 +2832,34 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2827 | (defun byte-compile-lambda-form (form) | 2832 | (defun byte-compile-lambda-form (form) |
| 2828 | (error "`lambda' used as function name is invalid")) | 2833 | (error "`lambda' used as function name is invalid")) |
| 2829 | 2834 | ||
| 2835 | ;; Compile normally, but deal with warnings for the function being defined. | ||
| 2836 | (defun byte-compile-defalias (form) | ||
| 2837 | (if (and (consp (cdr form)) (consp (nth 1 form)) | ||
| 2838 | (eq (car (nth 1 form)) 'quote) | ||
| 2839 | (consp (cdr (nth 1 form))) | ||
| 2840 | (symbolp (nth 1 (nth 1 form))) | ||
| 2841 | (consp (nthcdr 2 form)) | ||
| 2842 | (consp (nth 2 form)) | ||
| 2843 | (eq (car (nth 2 form)) 'quote) | ||
| 2844 | (consp (cdr (nth 2 form))) | ||
| 2845 | (symbolp (nth 1 (nth 2 form)))) | ||
| 2846 | (progn | ||
| 2847 | (byte-compile-defalias-warn (nth 1 (nth 1 form)) | ||
| 2848 | (nth 1 (nth 2 form))) | ||
| 2849 | (setq byte-compile-function-environment | ||
| 2850 | (cons (cons (nth 1 (nth 1 form)) | ||
| 2851 | (nth 1 (nth 2 form))) | ||
| 2852 | byte-compile-function-environment)))) | ||
| 2853 | (byte-compile-normal-call form))) | ||
| 2854 | |||
| 2855 | ;; Turn off warnings about prior calls to the function being defalias'd. | ||
| 2856 | ;; This could be smarter and compare those calls with | ||
| 2857 | ;; the function it is being aliased to. | ||
| 2858 | (defun byte-compile-defalias-warn (new alias) | ||
| 2859 | (let ((calls (assq new byte-compile-unresolved-functions))) | ||
| 2860 | (if calls | ||
| 2861 | (setq byte-compile-unresolved-functions | ||
| 2862 | (delq calls byte-compile-unresolved-functions))))) | ||
| 2830 | 2863 | ||
| 2831 | ;;; tags | 2864 | ;;; tags |
| 2832 | 2865 | ||