X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fearly-type.lisp;h=c4fe88a07e7e91934e73334a1e5dff0416742ffe;hb=77360ee4a1f94c41b807be7ad0e8687199fceef1;hp=480a7780f8f8661b4cce35af3433cf66d55aa9f8;hpb=5eb97830eca716fef626c6e12429c99c9b97e3c8;p=sbcl.git diff --git a/src/code/early-type.lisp b/src/code/early-type.lisp index 480a778..c4fe88a 100644 --- a/src/code/early-type.lisp +++ b/src/code/early-type.lisp @@ -93,7 +93,7 @@ ;; the Common Lisp type-specifier (specifier nil :type t)) -(define-type-class hairy) +(!define-type-class hairy) ;;; An UNKNOWN-TYPE is a type not known to the type system (not yet ;;; defined). We make this distinction since we don't want to complain @@ -120,7 +120,7 @@ (:include args-type (class-info (type-class-or-lose 'values))))) -(define-type-class values) +(!define-type-class values) (defstruct (function-type (:include args-type @@ -175,9 +175,9 @@ ;; FIXME: I'm bewildered by FOO-P names for things not intended to ;; interpreted as truth values. Perhaps rename this COMPLEXNESS? (complexp :real :type (member :real :complex nil)) - ;; The upper and lower bounds on the value. If null, there is no bound. If - ;; a list of a number, the bound is exclusive. Integer types never have - ;; exclusive bounds. + ;; The upper and lower bounds on the value, or NIL if there is no + ;; bound. If a list of a number, the bound is exclusive. Integer + ;; types never have exclusive bounds. (low nil :type (or number cons null)) (high nil :type (or number cons null))) @@ -207,15 +207,43 @@ ;;; A UNION-TYPE represents a use of the OR type specifier which can't ;;; be canonicalized to something simpler. Canonical form: -;;; 1. There is never more than one Member-Type component. -;;; 2. There are never any Union-Type components. +;;; 1. There is never more than one MEMBER-TYPE component. +;;; 2. There are never any UNION-TYPE components. (defstruct (union-type (:include ctype (class-info (type-class-or-lose 'union))) (:constructor %make-union-type (enumerable types))) ;; The types in the union. (types nil :type list)) - -;;; Note that the type Name has been (re)defined, updating the + +;;; Return TYPE converted to canonical form for a situation where the +;;; type '* is equivalent to type T. +(defun type-*-to-t (type) + (if (type= type *wild-type*) + *universal-type* + type)) + +;;; A CONS-TYPE is used to represent a CONS type. +(defstruct (cons-type (:include ctype + (:class-info (type-class-or-lose 'cons))) + (:constructor + ;; ANSI says that for CAR and CDR subtype + ;; specifiers '* is equivalent to T. In order + ;; to avoid special cases in SUBTYPEP and + ;; possibly elsewhere, we slam all CONS-TYPE + ;; objects into canonical form w.r.t. this + ;; equivalence at creation time. + make-cons-type (car-raw-type + cdr-raw-type + &aux + (car-type (type-*-to-t car-raw-type)) + (cdr-type (type-*-to-t cdr-raw-type))))) + ;; the CAR and CDR element types (to support ANSI (CONS FOO BAR) types) + ;; + ;; FIXME: Most or all other type structure slots could also be :READ-ONLY. + (car-type (required-argument) :type ctype :read-only t) + (cdr-type (required-argument) :type ctype :read-only t)) + +;;; Note that the type NAME has been (re)defined, updating the ;;; undefined warnings and VALUES-SPECIFIER-TYPE cache. (defun %note-type-defined (name) (declare (symbol name)) @@ -223,29 +251,10 @@ (when (boundp 'sb!kernel::*values-specifier-type-cache-vector*) (values-specifier-type-cache-clear)) (values)) - - -;;; MNA: cons compound-type patch -;;; FIXIT: all commented out -;;;; Cons types: - -;;; The Cons-Type is used to represent cons types. -;;; -;; (defstruct (cons-type (:include ctype -;; (:class-info (type-class-or-lose 'cons))) -;; (:print-function %print-type)) -;; ;; -;; ;; The car element type. -;; (car-type *wild-type* :type ctype) -;; ;; -;; ;; The cdr element type. -;; (cdr-type *wild-type* :type ctype)) - -;; (define-type-class cons) - -;;;; KLUDGE: not clear this really belongs here, but where? ;;; Is X a fixnum in the target Lisp? +;;; +;;; KLUDGE: not clear this really belongs in early-type.lisp, but where? (defun target-fixnump (x) (and (integerp x) (<= sb!vm:*target-most-negative-fixnum*