dst)
-(defun comp-cstr-union-homogeneous (dst &rest srcs)
+(defun comp-cstr-union-homogeneous (range dst &rest srcs)
"Combine SRCS by union set operation setting the result in DST.
+Do range propagation when RANGE is non-nil.
All SRCS constraints must be homogeneously negated or non-negated.
DST is returned."
(apply #'comp-cstr-union-homogeneous-no-range dst srcs)
(when (cl-notany (lambda (x)
(comp-subtype-p 'integer x))
(comp-cstr-typeset dst))
- ;; TODO memoize?
- (apply #'comp-range-union
- (mapcar #'comp-cstr-range srcs))))
+ (if range
+ (apply #'comp-range-union
+ (mapcar #'comp-cstr-range srcs))
+ '((- . +)))))
dst)
(cl-defun comp-cstr-union-1-no-mem (range &rest srcs)
;; Check first if we are in the simple case of all input non-negate
;; or negated so we don't have to cons.
(when-let ((res (comp-cstrs-homogeneous srcs)))
- (apply #'comp-cstr-union-homogeneous dst srcs)
+ (apply #'comp-cstr-union-homogeneous range dst srcs)
(cl-return-from comp-cstr-union-1-no-mem dst))
;; Some are negated and some are not
(cl-multiple-value-bind (positives negatives) (comp-split-pos-neg srcs)
- (let* ((pos (apply #'comp-cstr-union-homogeneous
+ (let* ((pos (apply #'comp-cstr-union-homogeneous range
(make-comp-cstr) positives))
;; We'll always use neg as result as this is almost
;; always necessary for describing open intervals
;; resulting from negated constraints.
- (neg (apply #'comp-cstr-union-homogeneous
+ (neg (apply #'comp-cstr-union-homogeneous range
(make-comp-cstr :neg t) negatives)))
;; Type propagation.
(when (and (typeset pos)
(cl-return-from comp-cstr-intersection-no-mem dst)))
(when-let ((res (comp-cstrs-homogeneous srcs)))
(if (eq res 'neg)
- (apply #'comp-cstr-union-homogeneous dst srcs)
+ (apply #'comp-cstr-union-homogeneous t dst srcs)
(apply #'comp-cstr-intersection-homogeneous dst srcs))
(cl-return-from comp-cstr-intersection-no-mem dst))