emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ee03a733757 3/3: * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p


From: Andrea Corallo
Subject: master ee03a733757 3/3: * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): New function.
Date: Wed, 10 Apr 2024 12:26:06 -0400 (EDT)

branch: master
commit ee03a73375796feea94bb066cff7d7de680cae32
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>

    * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): New function.
---
 lisp/emacs-lisp/comp-cstr.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 73d445eb3f4..5a3b7b48cc4 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -941,6 +941,17 @@ Non memoized version of `comp-cstr-intersection-no-mem'."
          (null (neg cstr))
          (equal (typeset cstr) '(cons)))))
 
+(define-inline comp-cstr-type-p (cstr type)
+  "Return t if CSTR is certainly of type TYPE."
+  (if-let ((pred (get type 'cl-deftype-satisfies)))
+      (with-comp-cstr-accessors
+        (and (null (range cstr))
+             (null (neg cstr))
+             (and (or (null (typeset cstr))
+                      (equal (typeset cstr) `(,type)))
+                  (cl-every pred (valset cstr)))))
+    (error "Unknown predicate for type %s" type)))
+
 ;; Move to comp.el?
 (defsubst comp-cstr-cl-tag-p (cstr)
   "Return non-nil if CSTR is a CL tag."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]