0.8.9.6.netbsd.2:
[sbcl.git] / src / code / early-type.lisp
index 048b61a..6f34191 100644 (file)
 
 (!begin-collecting-cold-init-forms)
 
-;;; Has the type system been properly initialized? (I.e. is it OK to
-;;; use it?)
-(defvar *type-system-initialized* #+sb-xc-host nil) ; (set in cold load)
-\f
 ;;;; representations of types
 
 ;;; A HAIRY-TYPE represents anything too weird to be described
                      :rest rest
                      :allowp allowp))
 
-;;; FIXME: ANSI VALUES has a short form (without lambda list
-;;; keywords), which should be translated into a long one.
 (defun make-values-type (&key (args nil argsp)
                          required optional rest allowp)
   (if argsp
                     :enumerable enumerable))
 
 ;;; An ARRAY-TYPE is used to represent any array type, including
-;;; things such as SIMPLE-STRING.
+;;; things such as SIMPLE-BASE-STRING.
 (defstruct (array-type (:include ctype
                                 (class-info (type-class-or-lose 'array)))
                        (:constructor %make-array-type)
          (eq cdr-type *empty-type*))
       *empty-type*
       (%make-cons-type car-type cdr-type)))
+
+(defun cons-type-length-info (type)
+  (declare (type cons-type type))
+  (do ((min 1 (1+ min))
+       (cdr (cons-type-cdr-type type) (cons-type-cdr-type cdr)))
+      ((not (cons-type-p cdr))
+       (cond
+        ((csubtypep cdr (specifier-type 'null))
+         (values min t))
+        ((csubtypep *universal-type* cdr)
+         (values min nil))
+        ((type/= (type-intersection (specifier-type 'cons) cdr) *empty-type*)
+         (values min nil))
+        ((type/= (type-intersection (specifier-type 'null) cdr) *empty-type*)
+         (values min t))
+        (t (values min :maybe))))
+    ()))
+       
 \f
 ;;;; type utilities
 
                   (fun (info :type :translator (car lspec))))
              (cond (fun
                     (funcall fun lspec))
-                   ((or (and (consp spec) (symbolp (car spec)))
-                        (symbolp spec))
+                   ((or (and (consp spec) (symbolp (car spec))
+                             (not (info :type :builtin (car spec))))
+                        (and (symbolp spec) (not (info :type :builtin spec))))
                     (when (and *type-system-initialized*
                                 (not (eq (info :type :kind spec)
                                          :forthcoming-defclass-type)))
   (let ((def (cond ((symbolp form)
                     (info :type :expander form))
                    ((and (consp form) (symbolp (car form)))
-                    (info :type :expander (car form)))
+                   (info :type :expander (car form)))
                    (t nil))))
     (if def
         (type-expand (funcall def (if (consp form) form (list form))))