X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fcombin.lisp;h=8128f53478e3b64bd0a6125c465300b0b694542a;hb=HEAD;hp=b2743d33becbecc32c06f61aaa7135c1e1da9c91;hpb=832f3b5652ae1b4a8888829cd4a1b391a8ca9952;p=sbcl.git diff --git a/src/pcl/combin.lisp b/src/pcl/combin.lisp index b2743d3..8128f53 100644 --- a/src/pcl/combin.lisp +++ b/src/pcl/combin.lisp @@ -36,9 +36,9 @@ (let* ((pv-wrappers (when pv-table (pv-wrappers-from-all-wrappers pv-table wrappers))) - (pv-cell (when (and pv-table pv-wrappers) - (pv-table-lookup pv-table pv-wrappers)))) - (values mf t fmf pv-cell)) + (pv (when (and pv-table pv-wrappers) + (pv-table-lookup pv-table pv-wrappers)))) + (values mf t fmf pv)) (values (or mf (if (listp method) (bug "early method with no method-function") @@ -105,7 +105,7 @@ ;; or aren't to prevent the leaky next methods bug. (let* ((cm-args (cdr form)) (fmf-p (and (null no-fmf-p) - (or (not (eq *boot-state* 'complete)) + (or (not (eq **boot-state** 'complete)) (gf-fast-method-function-p generic-function)) (null (cddr cm-args)))) (method (car cm-args)) @@ -120,7 +120,7 @@ (defun make-emf-from-method (method cm-args &optional gf fmf-p method-alist wrappers) - (multiple-value-bind (mf real-mf-p fmf pv-cell) + (multiple-value-bind (mf real-mf-p fmf pv) (get-method-function method method-alist wrappers) (if fmf (let* ((next-methods (car cm-args)) @@ -132,10 +132,10 @@ (default (cons nil nil)) (value (method-plist-value method :constant-value default))) (if (eq value default) - (make-fast-method-call :function fmf :pv-cell pv-cell + (make-fast-method-call :function fmf :pv pv :next-method-call next :arg-info arg-info) (make-constant-fast-method-call - :function fmf :pv-cell pv-cell :next-method-call next + :function fmf :pv pv :next-method-call next :arg-info arg-info :value value))) (if real-mf-p (flet ((frob-cm-arg (arg) @@ -216,52 +216,52 @@ (defun expand-effective-method-function (gf effective-method &optional env) (declare (ignore env)) - (multiple-value-bind (nreq applyp metatypes nkeys arg-info) + (multiple-value-bind (nreq applyp) (get-generic-fun-info gf) - (declare (ignore nreq nkeys arg-info)) - (let ((ll (make-fast-method-call-lambda-list metatypes applyp)) + (let ((ll (make-fast-method-call-lambda-list nreq applyp)) (check-applicable-keywords (when (and applyp (gf-requires-emf-keyword-checks gf)) '((check-applicable-keywords)))) (error-p (or (eq (first effective-method) '%no-primary-method) (eq (first effective-method) '%invalid-qualifiers))) (mc-args-p - (when (eq *boot-state* 'complete) + (when (eq **boot-state** 'complete) ;; Otherwise the METHOD-COMBINATION slot is not bound. (let ((combin (generic-function-method-combination gf))) (and (long-method-combination-p combin) - (long-method-combination-args-lambda-list combin)))))) + (long-method-combination-args-lambda-list combin))))) + (name `(emf ,(generic-function-name gf)))) (cond (error-p - `(lambda (.pv-cell. .next-method-call. &rest .args.) - (declare (ignore .pv-cell. .next-method-call.)) - (declare (ignorable .args.)) - (flet ((%no-primary-method (gf args) - (apply #'no-primary-method gf args)) - (%invalid-qualifiers (gf combin method) - (invalid-qualifiers gf combin method))) - (declare (ignorable #'%no-primary-method #'%invalid-qualifiers)) - ,effective-method))) + `(named-lambda ,name (.pv. .next-method-call. &rest .args.) + (declare (ignore .pv. .next-method-call.)) + (declare (ignorable .args.)) + (flet ((%no-primary-method (gf args) + (call-no-primary-method gf args)) + (%invalid-qualifiers (gf combin method) + (invalid-qualifiers gf combin method))) + (declare (ignorable #'%no-primary-method #'%invalid-qualifiers)) + ,effective-method))) (mc-args-p - (let* ((required - ;; FIXME: Ick. Shared idiom, too, with stuff in cache.lisp - (let (req) - (dotimes (i (length metatypes) (nreverse req)) - (push (dfun-arg-symbol i) req)))) + (let* ((required (make-dfun-required-args nreq)) (gf-args (if applyp - `(list* ,@required .dfun-rest-arg.) + `(list* ,@required + (sb-c::%listify-rest-args + .dfun-more-context. + (the (and unsigned-byte fixnum) + .dfun-more-count.))) `(list ,@required)))) - `(lambda ,ll - (declare (ignore .pv-cell. .next-method-call.)) - (let ((.gf-args. ,gf-args)) - (declare (ignorable .gf-args.)) - ,@check-applicable-keywords - ,effective-method)))) + `(named-lambda ,name ,ll + (declare (ignore .pv. .next-method-call.)) + (let ((.gf-args. ,gf-args)) + (declare (ignorable .gf-args.)) + ,@check-applicable-keywords + ,effective-method)))) (t - `(lambda ,ll - (declare (ignore ,@(if error-p ll '(.pv-cell. .next-method-call.)))) - ,@check-applicable-keywords - ,effective-method)))))) + `(named-lambda ,name ,ll + (declare (ignore ,@(if error-p ll '(.pv. .next-method-call.)))) + ,@check-applicable-keywords + ,effective-method)))))) (defun expand-emf-call-method (gf form metatypes applyp env) (declare (ignore gf metatypes applyp env)) @@ -310,7 +310,7 @@ (call-method (let ((gensym (get-effective-method-gensym))) (values (make-emf-call - metatypes applyp gensym + (length metatypes) applyp gensym (make-effective-method-fun-type generic-function form method-alist-p wrappers-p)) (list gensym)))) @@ -319,13 +319,14 @@ (type (make-effective-method-list-fun-type generic-function form method-alist-p wrappers-p))) (values `(dolist (emf ,gensym nil) - ,(make-emf-call metatypes applyp 'emf type)) + ,(make-emf-call (length metatypes) applyp 'emf type)) (list gensym)))) (check-applicable-keywords - (values `(check-applicable-keywords - .dfun-rest-arg. .keyargs-start. .valid-keys.) + (values `(check-applicable-keywords .keyargs-start. + .valid-keys. + .dfun-more-context. + .dfun-more-count.) '(.keyargs-start. .valid-keys.))) - (t (default-code-converter form)))) @@ -406,20 +407,14 @@ (defun gf-requires-emf-keyword-checks (generic-function) (member '&key (gf-lambda-list generic-function))) -(defvar *in-precompute-effective-methods-p* nil) - (defun standard-compute-effective-method (generic-function combin applicable-methods) (collect ((before) (primary) (after) (around)) - (flet ((invalid (gf combin m) - (if *in-precompute-effective-methods-p* - (return-from standard-compute-effective-method - `(%invalid-qualifiers ',gf ',combin ',m)) - (invalid-qualifiers gf combin m)))) + (flet ((invalid (gf combin m) (invalid-qualifiers gf combin m))) (dolist (m applicable-methods) (let ((qualifiers (if (listp m) (early-method-qualifiers m) - (method-qualifiers m)))) + (safe-method-qualifiers m)))) (cond ((null qualifiers) (primary m)) ((cdr qualifiers) (invalid generic-function combin m)) @@ -488,34 +483,41 @@ (aver any-keyp) (values (if allowp t keys) nopt))))) -(defun check-applicable-keywords (args start valid-keys) +(defun check-applicable-keywords (start valid-keys more-context more-count) (let ((allow-other-keys-seen nil) (allow-other-keys nil) - (args (nthcdr start args))) - (collect ((invalid)) - (loop - (when (null args) - (when (and (invalid) (not allow-other-keys)) - (error 'simple-program-error - :format-control "~@= i more-count) + (when (and (invalid) (not allow-other-keys)) + (error 'simple-program-error + :format-control "~@" - :format-arguments (list (length (invalid)) (invalid) valid-keys))) - (return)) - (let ((key (pop args))) - (cond - ((not (symbolp key)) - (error 'simple-program-error - :format-control "~@" - :format-arguments (list key))) - ((null args) (sb-c::%odd-key-args-error)) - ((eq key :allow-other-keys) - ;; only the leftmost :ALLOW-OTHER-KEYS has any effect - (unless allow-other-keys-seen - (setq allow-other-keys-seen t - allow-other-keys (car args)))) - ((eq t valid-keys)) - ((not (memq key valid-keys)) (invalid key)))) - (pop args))))) + :format-arguments (list (length (invalid)) (invalid) valid-keys))) + (return)) + (let ((key (current-value))) + (incf i) + (cond + ((not (symbolp key)) + (error 'simple-program-error + :format-control "~@" + :format-arguments (list key))) + ((= i more-count) + (sb-c::%odd-key-args-error)) + ((eq key :allow-other-keys) + ;; only the leftmost :ALLOW-OTHER-KEYS has any effect + (unless allow-other-keys-seen + (setq allow-other-keys-seen t + allow-other-keys (current-value)))) + ((eq t valid-keys)) + ((not (memq key valid-keys)) (invalid key)))) + (incf i)))))) ;;;; the STANDARD method combination type. This is coded by hand ;;;; (rather than with DEFINE-METHOD-COMBINATION) for bootstrapping