Changeset 15427
- Timestamp:
- 10/20/20 06:45:27 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/clos.lisp
r15085 r15427 2752 2752 (defun compute-method-function (lambda-expression) 2753 2753 (let ((lambda-list (allow-other-keys (cadr lambda-expression))) 2754 (body (cddr lambda-expression)) 2755 (*call-next-method-p* nil) 2756 (*next-method-p-p* nil)) 2754 (body (cddr lambda-expression))) 2757 2755 (multiple-value-bind (body declarations) (parse-body body) 2758 2756 (let ((ignorable-vars '())) … … 2762 2760 (push var ignorable-vars))) 2763 2761 (push `(declare (ignorable ,@ignorable-vars)) declarations)) 2764 (walk-form body) 2765 (cond ((or *call-next-method-p* *next-method-p-p*) 2766 `(lambda (args next-emfun) 2767 (flet ((call-next-method (&rest cnm-args) 2768 (if (null next-emfun) 2769 (error "No next method for generic function.") 2770 (funcall next-emfun (or cnm-args args)))) 2771 (next-method-p () 2772 (not (null next-emfun)))) 2773 (declare (ignorable (function call-next-method) 2774 (function next-method-p))) 2775 (apply #'(lambda ,lambda-list ,@declarations ,@body) args)))) 2776 ((null (intersection lambda-list '(&rest &optional &key &allow-other-keys &aux))) 2762 (if (null (intersection lambda-list '(&rest &optional &key &allow-other-keys &aux))) 2777 2763 ;; Required parameters only. 2778 2764 (case (length lambda-list) 2779 2765 (1 2780 2766 `(lambda (args next-emfun) 2781 (declare (ignore next-emfun))2782 2767 (let ((,(%car lambda-list) (%car args))) 2783 2768 (declare (ignorable ,(%car lambda-list))) 2784 ,@declarations ,@body))) 2769 ,@declarations 2770 (flet ((call-next-method (&rest cnm-args) 2771 (if (null next-emfun) 2772 (error "No next method for generic function.") 2773 (funcall next-emfun (or cnm-args args)))) 2774 (next-method-p () 2775 (not (null next-emfun)))) 2776 (declare (ignorable (function call-next-method) 2777 (function next-method-p))) 2778 ,@body)))) 2779 2785 2780 (2 2786 2781 `(lambda (args next-emfun) 2787 (declare (ignore next-emfun))2788 2782 (let ((,(%car lambda-list) (%car args)) 2789 2783 (,(%cadr lambda-list) (%cadr args))) 2790 2784 (declare (ignorable ,(%car lambda-list) 2791 2785 ,(%cadr lambda-list))) 2792 ,@declarations ,@body))) 2786 ,@declarations 2787 (flet ((call-next-method (&rest cnm-args) 2788 (if (null next-emfun) 2789 (error "No next method for generic function.") 2790 (funcall next-emfun (or cnm-args args)))) 2791 (next-method-p () 2792 (not (null next-emfun)))) 2793 (declare (ignorable (function call-next-method) 2794 (function next-method-p))) 2795 2796 ,@body)))) 2793 2797 (3 2794 2798 `(lambda (args next-emfun) 2795 (declare (ignore next-emfun))2796 2799 (let ((,(%car lambda-list) (%car args)) 2797 2800 (,(%cadr lambda-list) (%cadr args)) … … 2800 2803 ,(%cadr lambda-list) 2801 2804 ,(%caddr lambda-list))) 2802 ,@declarations ,@body))) 2805 ,@declarations 2806 (flet ((call-next-method (&rest cnm-args) 2807 (if (null next-emfun) 2808 (error "No next method for generic function.") 2809 (funcall next-emfun (or cnm-args args)))) 2810 (next-method-p () 2811 (not (null next-emfun)))) 2812 (declare (ignorable (function call-next-method) 2813 (function next-method-p))) 2814 ,@body)))) 2803 2815 (t 2804 2816 `(lambda (args next-emfun) 2805 (declare (ignore next-emfun)) 2806 (apply #'(lambda ,lambda-list ,@declarations ,@body) args))))) 2807 (t 2817 (apply #'(lambda ,lambda-list 2818 ,@declarations 2819 (flet ((call-next-method (&rest cnm-args) 2820 (if (null next-emfun) 2821 (error "No next method for generic function.") 2822 (funcall next-emfun (or cnm-args args)))) 2823 (next-method-p () 2824 (not (null next-emfun)))) 2825 (declare (ignorable (function call-next-method) 2826 (function next-method-p))) 2827 ,@body)) 2828 args)))) 2808 2829 `(lambda (args next-emfun) 2809 (declare (ignore next-emfun)) 2810 (apply #'(lambda ,lambda-list ,@declarations ,@body) args))))))) 2830 (apply #'(lambda ,lambda-list 2831 ,@declarations 2832 (flet ((call-next-method (&rest cnm-args) 2833 (if (null next-emfun) 2834 (error "No next method for generic function.") 2835 (funcall next-emfun (or cnm-args args)))) 2836 (next-method-p () 2837 (not (null next-emfun)))) 2838 (declare (ignorable (function call-next-method) 2839 (function next-method-p))) 2840 2841 ,@body)) 2842 args)))))) 2811 2843 2812 2844 (defun compute-method-fast-function (lambda-expression) … … 2819 2851 (*next-method-p-p* nil)) 2820 2852 (multiple-value-bind (body declarations) (parse-body body) 2853 ;;; N.b. The WALK-FORM check is bogus for "hidden" 2854 ;;; macroizations of CALL-NEXT-METHOD and NEXT-METHOD-P but 2855 ;;; the presence of FAST-FUNCTION slots in our CLOS is 2856 ;;; currently necessary to bootstrap CLOS in a way I didn't 2857 ;;; manage to easily untangle. 2821 2858 (walk-form body) 2822 2859 (when (or *call-next-method-p* *next-method-p-p*) 2823 2860 (return-from compute-method-fast-function nil)) 2824 (let ((decls `(declare (ignorable ,@lambda-list)))) 2825 (setf lambda-expression 2826 (list* (car lambda-expression) 2827 (cadr lambda-expression) 2828 decls 2829 (cddr lambda-expression)))) 2830 (case (length lambda-list) 2831 (1 2832 ;; `(lambda (args next-emfun) 2833 ;; (let ((,(%car lambda-list) (%car args))) 2834 ;; (declare (ignorable ,(%car lambda-list))) 2835 ;; ,@declarations ,@body))) 2836 lambda-expression) 2837 (2 2838 ;; `(lambda (args next-emfun) 2839 ;; (let ((,(%car lambda-list) (%car args)) 2840 ;; (,(%cadr lambda-list) (%cadr args))) 2841 ;; (declare (ignorable ,(%car lambda-list) 2842 ;; ,(%cadr lambda-list))) 2843 ;; ,@declarations ,@body))) 2844 lambda-expression) 2845 ;; (3 2846 ;; `(lambda (args next-emfun) 2847 ;; (let ((,(%car lambda-list) (%car args)) 2848 ;; (,(%cadr lambda-list) (%cadr args)) 2849 ;; (,(%caddr lambda-list) (%caddr args))) 2850 ;; (declare (ignorable ,(%car lambda-list) 2851 ;; ,(%cadr lambda-list) 2852 ;; ,(%caddr lambda-list))) 2853 ;; ,@declarations ,@body))) 2854 (t 2855 nil)))))) 2861 (let ((declaration `(declare (ignorable ,@lambda-list)))) 2862 ;;; 2020-10-19 refactored this expression from previous code 2863 ;;; that was only declaring a fast function for one or two 2864 ;;; element values of lamba-list 2865 (if (< 0 (length lambda-list) 3) 2866 `(lambda ,(cadr lambda-expression) 2867 ,declaration 2868 (flet ((call-next-method (&rest args) 2869 (declare (ignore args)) 2870 (error "No next method for generic function")) 2871 (next-method-p () nil)) 2872 (declare (ignorable (function call-next-method) 2873 (function next-method-p))) 2874 ,@body)) 2875 nil)))))) 2876 2856 2877 2857 2878 (declaim (notinline make-method-lambda)) … … 2902 2923 :qualifiers ',qualifiers 2903 2924 :specializers (canonicalize-specializers ,specializers-form) 2904 ,@( ifdocumentation `(:documentation ,documentation))2925 ,@(when documentation `(:documentation ,documentation)) 2905 2926 :function (function ,method-function) 2906 ,@( iffast-function `(:fast-function (function ,fast-function)))2927 ,@(when fast-function `(:fast-function (function ,fast-function))) 2907 2928 ))))) 2908 2929
Note: See TracChangeset
for help on using the changeset viewer.