- (let ((singlep (subsetp '(-0.0f0 0.0f0) members))
- (doublep (subsetp '(-0.0d0 0.0d0) members))
- #!+long-float
- (longp (subsetp '(-0.0l0 0.0l0) members)))
- (if (or singlep doublep #!+long-float longp)
- (let (union-types)
- (when singlep
- (push (ctype-of 0.0f0) union-types)
- (setf members (set-difference members '(-0.0f0 0.0f0))))
- (when doublep
- (push (ctype-of 0.0d0) union-types)
- (setf members (set-difference members '(-0.0d0 0.0d0))))
- #!+long-float
- (when longp
- (push (ctype-of 0.0l0) union-types)
- (setf members (set-difference members '(-0.0l0 0.0l0))))
- (aver (not (null union-types)))
- (make-union-type t
- (if (null members)
- union-types
- (cons (%make-member-type members)
- union-types))))
- (%make-member-type members))))
+ (let ((unpaired nil)
+ (union-types nil))
+ (do ((tail (cdr fp-zeroes) (cdr tail))
+ (zero (car fp-zeroes) (car tail)))
+ ((not zero))
+ (macrolet ((frob (c)
+ `(let ((neg (neg-fp-zero zero)))
+ (if (member neg tail)
+ (push (ctype-of ,c) union-types)
+ (push zero unpaired)))))
+ (etypecase zero
+ (single-float (frob 0.0f0))
+ (double-float (frob 0.0d0))
+ #!+long-float
+ (long-float (frob 0.0l0)))))
+ ;; The actual member-type contains the XSET (with no FP zeroes),
+ ;; and a list of unpaired zeroes.
+ (let ((member-type (unless (and (xset-empty-p xset) (not unpaired))
+ (%make-member-type xset unpaired))))
+ (cond (union-types
+ (make-union-type t (if member-type
+ (cons member-type union-types)
+ union-types)))
+ (member-type
+ member-type)
+ (t
+ *empty-type*)))))
+
+(defun member-type-size (type)
+ (+ (length (member-type-fp-zeroes type))
+ (xset-count (member-type-xset type))))
+
+(defun member-type-member-p (x type)
+ (if (fp-zero-p x)
+ (and (member x (member-type-fp-zeroes type)) t)
+ (xset-member-p x (member-type-xset type))))
+
+(defun mapcar-member-type-members (function type)
+ (declare (function function))
+ (collect ((results))
+ (map-xset (lambda (x)
+ (results (funcall function x)))
+ (member-type-xset type))
+ (dolist (zero (member-type-fp-zeroes type))
+ (results (funcall function zero)))
+ (results)))
+
+(defun mapc-member-type-members (function type)
+ (declare (function function))
+ (map-xset function (member-type-xset type))
+ (dolist (zero (member-type-fp-zeroes type))
+ (funcall function zero)))
+
+(defun member-type-members (type)
+ (append (member-type-fp-zeroes type)
+ (xset-members (member-type-xset type))))