From c4efb49a27f05284d28eac7f60b28495c68f63fb Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 29 Dec 2020 13:29:02 +0100 Subject: Constrain mvars under compare and branch with built-in predicates * lisp/emacs-lisp/comp.el (comp-emit-assume): Update. (comp-known-predicate-p): New function. (comp-add-cond-cstrs): Extend to pattern match predicate calls. * lisp/emacs-lisp/comp-cstr.el (comp-cstr-null-p) (comp-pred-to-cstr): New function. * test/src/comp-tests.el (comp-tests-type-spec-tests): Add a number of tests and fix comments. --- lisp/emacs-lisp/comp-cstr.el | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lisp/emacs-lisp/comp-cstr.el') diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 8a8e22e030d..ce702422932 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -137,6 +137,13 @@ Integer values are handled in the `range' slot.") (null (valset cstr)) (null (range cstr))))) +(defsubst comp-cstr-null-p (x) + "Return t if CSTR is equivalent to the `null' type specifier, nil otherwise." + (with-comp-cstr-accessors + (and (null (typeset x)) + (null (range x)) + (equal (valset x) '(nil))))) + (defun comp-cstrs-homogeneous (cstrs) "Check if constraints CSTRS are all homogeneously negated or non-negated. Return `pos' if they are all positive, `neg' if they are all @@ -167,6 +174,10 @@ Return them as multiple value." :range '((1 . 1))) "Represent the integer immediate one (1).") +(defun comp-pred-to-cstr (predicate) + "Given PREDICATE return the correspondig constraint." + (comp-type-to-cstr (get predicate 'cl-satisfies-deftype))) + ;;; Value handling. -- cgit v1.2.3