X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Flate-target-error.lisp;h=320a8c2e82f728dc42cb9bdf94a4ddd859c2c394;hb=3bd7a97d1b11a2b0aee086ef211cae807f3dfc35;hp=8fc3f3271a4ae75ea76e09f29fc31bacd08f9b7f;hpb=79953929196409f21fe505b29b15d2a9281884b7;p=sbcl.git diff --git a/src/code/late-target-error.lisp b/src/code/late-target-error.lisp index 8fc3f32..320a8c2 100644 --- a/src/code/late-target-error.lisp +++ b/src/code/late-target-error.lisp @@ -17,6 +17,8 @@ ;;;; the CONDITION class +(/show0 "late-target-error.lisp 20") + (eval-when (:compile-toplevel :load-toplevel :execute) (def!struct (condition-class (:include slot-class) @@ -42,7 +44,7 @@ (defun make-condition-class (&rest rest) (apply #'bare-make-condition-class - (rename-keyword-args '((:name :%name)) rest))) + (rename-key-args '((:name :%name)) rest))) ) ; EVAL-WHEN @@ -52,15 +54,13 @@ condition-class make-condition-class) (:copier nil)) - - (function-name nil) ;; actual initargs supplied to MAKE-CONDITION (actual-initargs (required-argument) :type list) - ;; plist mapping slot names to any values that were assigned or + ;; a plist mapping slot names to any values that were assigned or ;; defaulted after creation (assigned-slots () :type list)) -(defstruct condition-slot +(defstruct (condition-slot (:copier nil)) (name (required-argument) :type symbol) ;; list of all applicable initargs (initargs (required-argument) :type list) @@ -77,19 +77,6 @@ ;; If ALLOCATION is :CLASS, this is a cons whose car holds the value. (cell nil :type (or cons null))) -(eval-when (#-sb-xc :compile-toplevel :load-toplevel :execute) - ;; the appropriate initialization value for the CPL slot of a - ;; CONDITION, calculated by looking at the INHERITS information in - ;; the LAYOUT of the CONDITION - (defun condition-class-cpl-from-layout (condition) - (declare (type condition condition)) - (let* ((class (sb!xc:find-class condition)) - (layout (class-layout class)) - (superset (map 'list #'identity (layout-inherits layout)))) - (delete-if (lambda (superclass) - (not (typep superclass 'condition-class))) - superset)))) - ;;; KLUDGE: It's not clear to me why CONDITION-CLASS has itself listed ;;; in its CPL, while other classes derived from CONDITION-CLASS don't ;;; have themselves listed in their CPLs. This behavior is inherited @@ -130,10 +117,15 @@ parent-types))))) (cond-layout (info :type :compiler-layout 'condition)) (olayout (info :type :compiler-layout name)) + ;; FIXME: Does this do the right thing in case of multiple + ;; inheritance? A quick look at DEFINE-CONDITION didn't make + ;; it obvious what ANSI intends to be done in the case of + ;; multiple inheritance, so it's not actually clear what the + ;; right thing is.. (new-inherits - (concatenate 'simple-vector - (layout-inherits cond-layout) - (mapcar #'class-layout cpl)))) + (order-layout-inherits (concatenate 'simple-vector + (layout-inherits cond-layout) + (mapcar #'class-layout cpl))))) (if (and olayout (not (mismatch (layout-inherits olayout) new-inherits))) olayout @@ -217,6 +209,8 @@ (if (eq val *empty-condition-slot*) (let ((actual-initargs (condition-actual-initargs condition)) (slot (find-condition-class-slot class name))) + (unless slot + (error "missing slot ~S of ~S" name condition)) (dolist (initarg (condition-slot-initargs slot)) (let ((val (getf actual-initargs initarg @@ -310,19 +304,10 @@ (setf (sb!xc:find-class name) class) - ;; Initialize CPL slot from layout. - (collect ((cpl)) - (cpl class) - (let ((inherits (layout-inherits layout))) - (do ((i (1- (length inherits)) (1- i))) - ((minusp i)) - (let ((super (sb!xc:find-class - (sb!xc:class-name - (layout-class (svref inherits i)))))) - (when (typep super 'condition-class) - (cpl super))))) - (setf (condition-class-cpl class) (cpl)))) - + ;; Initialize CPL slot. + (setf (condition-class-cpl class) + (remove-if-not #'condition-class-p + (std-compute-class-precedence-list class)))) (values)) ) ; EVAL-WHEN @@ -543,8 +528,10 @@ (define-condition style-warning (warning) ()) (defun simple-condition-printer (condition stream) - (apply #'format stream (simple-condition-format-control condition) - (simple-condition-format-arguments condition))) + (apply #'format + stream + (simple-condition-format-control condition) + (simple-condition-format-arguments condition))) (define-condition simple-condition () ((format-control :reader simple-condition-format-control @@ -556,35 +543,22 @@ (define-condition simple-warning (simple-condition warning) ()) -(defun print-simple-error (condition stream) - (format stream - "~&~@" - (condition-function-name condition) - (simple-condition-format-control condition) - (simple-condition-format-arguments condition))) - -(define-condition simple-error (simple-condition error) () - ;; This is the condition type used by ERROR and CERROR when - ;; a format-control string is supplied as the first argument. - (:report print-simple-error)) +(define-condition simple-error (simple-condition error) ()) (define-condition storage-condition (serious-condition) ()) -;;; FIXME: Should we really be reporting CONDITION-FUNCTION-NAME data -;;; on an ad hoc basis, for some conditions and not others? Why not -;;; standardize it somehow? perhaps by making the debugger report it? - (define-condition type-error (error) ((datum :reader type-error-datum :initarg :datum) (expected-type :reader type-error-expected-type :initarg :expected-type)) (:report (lambda (condition stream) (format stream - "~@." - (condition-function-name condition) + "~@" (type-error-datum condition) (type-error-expected-type condition))))) +(define-condition simple-type-error (simple-condition type-error) ()) + (define-condition program-error (error) ()) (define-condition parse-error (error) ()) (define-condition control-error (error) ()) @@ -595,7 +569,7 @@ (:report (lambda (condition stream) (format stream - "END-OF-FILE on ~S" + "end of file on ~S" (stream-error-stream condition))))) (define-condition file-error (error) @@ -603,8 +577,12 @@ (:report (lambda (condition stream) (format stream - "~&~@" - (condition-function-name condition) + "~@" + (file-error-pathname condition) + ;; FIXME: ANSI's FILE-ERROR doesn't have FORMAT-CONTROL and + ;; FORMAT-ARGUMENTS, and the inheritance here doesn't seem + ;; to give us FORMAT-CONTROL or FORMAT-ARGUMENTS either. + ;; So how does this work? (serious-condition-format-control condition) (serious-condition-format-arguments condition))))) @@ -618,16 +596,14 @@ (:report (lambda (condition stream) (format stream - "error in ~S: The variable ~S is unbound." - (condition-function-name condition) + "The variable ~S is unbound." (cell-error-name condition))))) (define-condition undefined-function (cell-error) () (:report (lambda (condition stream) (format stream - "error in ~S: The function ~S is undefined." - (condition-function-name condition) + "The function ~S is undefined." (cell-error-name condition))))) (define-condition arithmetic-error (error) @@ -661,8 +637,6 @@ (format stream "~S cannot be printed readably." obj))))) (define-condition reader-error (parse-error stream-error) - ;; FIXME: Do we need FORMAT-CONTROL and FORMAT-ARGUMENTS when - ;; we have an explicit :REPORT function? I thought we didn't.. ((format-control :reader reader-error-format-control :initarg :format-control) @@ -714,8 +688,7 @@ (:report (lambda (condition stream) (format stream - "error in ~S: ~S: index too large" - (condition-function-name condition) + "The index ~S is too large." (type-error-datum condition))))) (define-condition io-timeout (stream-error) @@ -724,7 +697,7 @@ (lambda (condition stream) (declare (type stream stream)) (format stream - "IO-TIMEOUT ~(~A~)ing ~S" + "I/O timeout ~(~A~)ing ~S" (io-timeout-direction condition) (stream-error-stream condition))))) @@ -752,7 +725,7 @@ (:report (lambda (condition stream) (format stream - "unexpected EOF on ~S ~A" + "unexpected end of file on ~S ~A" (stream-error-stream condition) (reader-eof-error-context condition))))) @@ -794,3 +767,6 @@ (define-nil-returning-restart use-value (value) "Transfer control and VALUE to a restart named USE-VALUE, or return NIL if none exists.")) + +(/show0 "late-target-error.lisp end of file") +