X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fmacros.lisp;h=296aeb422b4eca6a47eaacf59ddbd510f95dd8a5;hb=644a1ff36dd578321fd0592aa47748e8af741542;hp=44b51bb758c2858cdbbd32e9a6f7f6a1f63de1d5;hpb=4eb1a6d3ad2b7dcc19ac0ec979a1eb1eb049659a;p=sbcl.git diff --git a/src/pcl/macros.lisp b/src/pcl/macros.lisp index 44b51bb..296aeb4 100644 --- a/src/pcl/macros.lisp +++ b/src/pcl/macros.lisp @@ -29,11 +29,14 @@ (/show "starting pcl/macros.lisp") (declaim (declaration - ;; These three nonstandard declarations seem to be used - ;; privately within PCL itself to pass information around, - ;; so we can't just delete them. - %class + ;; As of sbcl-0.7.0.6, SBCL actively uses this declaration + ;; to propagate information needed to set up nice debug + ;; names (as seen e.g. in BACKTRACE) for method functions. %method-name + ;; These nonstandard declarations seem to be used privately + ;; within PCL itself to pass information around, so we can't + ;; just delete them. + %class %method-lambda-list ;; This declaration may also be used within PCL to pass ;; information around, I'm not sure. -- WHN 2000-12-30 @@ -41,42 +44,6 @@ (/show "done with DECLAIM DECLARATION") -;;; FIXME: This looks like SBCL's PARSE-BODY, and should be shared. -(eval-when (:compile-toplevel :load-toplevel :execute) - -(defun extract-declarations (body &optional environment) - ;;(declare (values documentation declarations body)) - (let (documentation - declarations - form) - (when (and (stringp (car body)) - (cdr body)) - (setq documentation (pop body))) - (block outer - (loop - (when (null body) (return-from outer nil)) - (setq form (car body)) - (when (block inner - (loop (cond ((not (listp form)) - (return-from outer nil)) - ((eq (car form) 'declare) - (return-from inner t)) - (t - (multiple-value-bind (newform macrop) - (macroexpand-1 form environment) - (if (or (not (eq newform form)) macrop) - (setq form newform) - (return-from outer nil))))))) - (pop body) - (dolist (declaration (cdr form)) - (push declaration declarations))))) - (values documentation - (and declarations `((declare ,.(nreverse declarations)))) - body))) -) ; EVAL-WHEN - -(/show "done with EVAL-WHEN (..) DEFUN EXTRACT-DECLARATIONS") - (defun get-declaration (name declarations &optional default) (dolist (d declarations default) (dolist (form (cdr d)) @@ -85,33 +52,16 @@ (/show "pcl/macros.lisp 85") -(defmacro collecting-once (&key initial-value) - `(let* ((head ,initial-value) - (tail ,(and initial-value `(last head)))) - (values #'(lambda (value) - (if (null head) - (setq head (setq tail (list value))) - (unless (memq value head) - (setq tail - (cdr (rplacd tail (list value))))))) - #'(lambda nil head)))) - -(/show "pcl/macros.lisp 98") - -(defmacro doplist ((key val) plist &body body &environment env) - (multiple-value-bind (doc decls bod) - (extract-declarations body env) - (declare (ignore doc)) - `(let ((.plist-tail. ,plist) ,key ,val) - ,@decls - (loop (when (null .plist-tail.) (return nil)) - (setq ,key (pop .plist-tail.)) - (when (null .plist-tail.) - (error "malformed plist, odd number of elements")) - (setq ,val (pop .plist-tail.)) - (progn ,@bod))))) - -(/show "pcl/macros.lisp 113") +(defmacro doplist ((key val) plist &body body) + `(let ((.plist-tail. ,plist) ,key ,val) + (loop (when (null .plist-tail.) (return nil)) + (setq ,key (pop .plist-tail.)) + (when (null .plist-tail.) + (error "malformed plist, odd number of elements")) + (setq ,val (pop .plist-tail.)) + (progn ,@body)))) + +(/show "pcl/macros.lisp 101") (defmacro dolist-carefully ((var list improper-list-handler) &body body) `(let ((,var nil) @@ -125,11 +75,9 @@ ;;;; FIND-CLASS ;;;; -;;;; This is documented in the CLOS specification. FIXME: Except that -;;;; SBCL deviates from the spec by having CL:FIND-CLASS distinct from -;;;; PCL:FIND-CLASS, alas. +;;;; This is documented in the CLOS specification. -(/show "pcl/macros.lisp 132") +(/show "pcl/macros.lisp 119") (defvar *find-class* (make-hash-table :test 'eq)) @@ -139,9 +87,6 @@ (defmacro find-class-cell-predicate (cell) `(cadr ,cell)) -(defmacro find-class-cell-make-instance-function-keys (cell) - `(cddr ,cell)) - (defmacro make-find-class-cell (class-name) (declare (ignore class-name)) '(list* nil #'constantly-nil nil)) @@ -160,8 +105,8 @@ (defun find-class-from-cell (symbol cell &optional (errorp t)) (or (find-class-cell-class cell) (and *create-classes-from-internal-structure-definitions-p* - (structure-type-p symbol) - (find-structure-class symbol)) + (or (structure-type-p symbol) (condition-type-p symbol)) + (ensure-non-standard-class symbol)) (cond ((null errorp) nil) ((legal-class-name-p symbol) (error "There is no class named ~S." symbol)) @@ -174,8 +119,7 @@ (find-class-cell-predicate cell)) (defun legal-class-name-p (x) - (and (symbolp x) - (not (keywordp x)))) + (symbolp x)) (defun find-class (symbol &optional (errorp t) environment) (declare (ignore environment)) @@ -197,11 +141,8 @@ ;;; (DECLAIM (TYPE (MEMBER NIL :EARLY :BRAID :COMPLETE) *BOOT-STATE*)) (defvar *boot-state* nil) -(/show "pcl/macros.lisp 199") +(/show "pcl/macros.lisp 187") -;;; Note that in SBCL as in CMU CL, -;;; COMMON-LISP:FIND-CLASS /= SB-PCL:FIND-CLASS. -;;; (Yes, this is a KLUDGE!) (define-compiler-macro find-class (&whole form symbol &optional (errorp t) environment) (declare (ignore environment)) @@ -216,31 +157,33 @@ (or (find-class-cell-class ,class-cell) ,(if errorp `(find-class-from-cell ',symbol ,class-cell t) - `(and (sb-kernel:class-cell-class - ',(sb-kernel:find-class-cell symbol)) + `(and (classoid-cell-classoid + ',(find-classoid-cell symbol)) (find-class-from-cell ',symbol ,class-cell nil)))))) form)) -(defun (setf find-class) (new-value symbol) - (if (legal-class-name-p symbol) - (let ((cell (find-class-cell symbol))) - (setf (find-class-cell-class cell) new-value) - (when (or (eq *boot-state* 'complete) - (eq *boot-state* 'braid)) - (when (and new-value (class-wrapper new-value)) - (setf (find-class-cell-predicate cell) - (fdefinition (class-predicate-name new-value)))) - (when (and new-value (not (forward-referenced-class-p new-value))) - - (dolist (keys+aok (find-class-cell-make-instance-function-keys - cell)) - (update-initialize-info-internal - (initialize-info new-value (car keys+aok) nil (cdr keys+aok)) - 'make-instance-function)))) - new-value) - (error "~S is not a legal class name." symbol))) - -(/show "pcl/macros.lisp 242") +(defun (setf find-class) (new-value name &optional errorp environment) + (declare (ignore errorp environment)) + (cond ((legal-class-name-p name) + (with-single-package-locked-error + (:symbol name "using ~A as the class-name argument in ~ + (SETF FIND-CLASS)")) + (let ((cell (find-class-cell name))) + (setf (find-class-cell-class cell) new-value) + (when (and (eq *boot-state* 'complete) (null new-value)) + (setf (find-classoid name) nil)) + (when (or (eq *boot-state* 'complete) + (eq *boot-state* 'braid)) + (when (and new-value (class-wrapper new-value) + (class-predicate-name new-value)) + (setf (find-class-cell-predicate cell) + (fdefinition (class-predicate-name new-value)))) + (update-ctors 'setf-find-class :class new-value :name name)) + new-value)) + (t + (error "~S is not a legal class name." name)))) + +(/show "pcl/macros.lisp 230") (defun (setf find-class-predicate) (new-value symbol) @@ -251,44 +194,7 @@ (defun find-wrapper (symbol) (class-wrapper (find-class symbol))) -(defmacro gathering1 (gatherer &body body) - `(gathering ((.gathering1. ,gatherer)) - (macrolet ((gather1 (x) `(gather ,x .gathering1.))) - ,@body))) - -(defmacro vectorizing (&key (size 0)) - `(let* ((limit ,size) - (result (make-array limit)) - (index 0)) - (values #'(lambda (value) - (if (= index limit) - (error "vectorizing more elements than promised") - (progn - (setf (svref result index) value) - (incf index) - value))) - #'(lambda () result)))) - -(/show "pcl/macros.lisp 271") - -;;; These are augmented definitions of LIST-ELEMENTS and LIST-TAILS from -;;; iterate.lisp. These versions provide the extra :BY keyword which can -;;; be used to specify the step function through the list. -(defmacro *list-elements (list &key (by #'cdr)) - `(let ((tail ,list)) - #'(lambda (finish) - (if (endp tail) - (funcall finish) - (prog1 (car tail) - (setq tail (funcall ,by tail))))))) - -(defmacro *list-tails (list &key (by #'cdr)) - `(let ((tail ,list)) - #'(lambda (finish) - (prog1 (if (endp tail) - (funcall finish) - tail) - (setq tail (funcall ,by tail)))))) +(/show "pcl/macros.lisp 241") (defmacro function-funcall (form &rest args) `(funcall (the function ,form) ,@args)) @@ -296,11 +202,11 @@ (defmacro function-apply (form &rest args) `(apply (the function ,form) ,@args)) -(/show "pcl/macros.lisp 299") +(/show "pcl/macros.lisp 249") (defun get-setf-fun-name (name) `(setf ,name)) (defsetf slot-value set-slot-value) - + (/show "finished with pcl/macros.lisp")