diff options
| author | Andrea Corallo | 2022-08-24 23:31:28 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2023-05-23 16:39:06 +0200 |
| commit | d03dd07774acfa690e5b63a7dbf81fb319aeedf4 (patch) | |
| tree | b73781db55596ad7ff2adc2fdc37c2b662f7d741 | |
| parent | f4de81af8fc54ef278cdb76fbc5885ed7d05b2d7 (diff) | |
| download | emacs-d03dd07774acfa690e5b63a7dbf81fb319aeedf4.tar.gz emacs-d03dd07774acfa690e5b63a7dbf81fb319aeedf4.zip | |
comp: Make use of predicates in propagation for non builtin types
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-ctxt): Add `pred-type-h'
slot.
* lisp/emacs-lisp/comp.el (comp-known-predicate-p)
(comp-pred-to-cstr): Update.
| -rw-r--r-- | lisp/emacs-lisp/comp-cstr.el | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/comp.el | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index 869b0619160..35e9ac45919 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el | |||
| @@ -107,6 +107,14 @@ Integer values are handled in the `range' slot.") | |||
| 107 | (mapcar #'comp--cl-class-hierarchy (comp--all-classes))) | 107 | (mapcar #'comp--cl-class-hierarchy (comp--all-classes))) |
| 108 | :type list | 108 | :type list |
| 109 | :documentation "Type hierarchy.") | 109 | :documentation "Type hierarchy.") |
| 110 | (pred-type-h (cl-loop with h = (make-hash-table :test #'eq) | ||
| 111 | for class-name in (comp--all-classes) | ||
| 112 | for pred = (get class-name 'cl-deftype-satisfies) | ||
| 113 | when pred | ||
| 114 | do (puthash pred class-name h) | ||
| 115 | finally return h) | ||
| 116 | :type hash-table | ||
| 117 | :documentation "Hash pred -> type.") | ||
| 110 | (union-typesets-mem (make-hash-table :test #'equal) :type hash-table | 118 | (union-typesets-mem (make-hash-table :test #'equal) :type hash-table |
| 111 | :documentation "Serve memoization for | 119 | :documentation "Serve memoization for |
| 112 | `comp-union-typesets'.") | 120 | `comp-union-typesets'.") |
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 289c5bf2ac4..fe72f0e73a4 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el | |||
| @@ -641,11 +641,14 @@ Useful to hook into pass checkers.") | |||
| 641 | 641 | ||
| 642 | (defun comp-known-predicate-p (predicate) | 642 | (defun comp-known-predicate-p (predicate) |
| 643 | "Return t if PREDICATE is known." | 643 | "Return t if PREDICATE is known." |
| 644 | (when (gethash predicate comp-known-predicates-h) t)) | 644 | (when (or (gethash predicate comp-known-predicates-h) |
| 645 | (gethash predicate (comp-cstr-ctxt-pred-type-h comp-ctxt))) | ||
| 646 | t)) | ||
| 645 | 647 | ||
| 646 | (defun comp-pred-to-cstr (predicate) | 648 | (defun comp-pred-to-cstr (predicate) |
| 647 | "Given PREDICATE, return the corresponding constraint." | 649 | "Given PREDICATE, return the corresponding constraint." |
| 648 | (gethash predicate comp-known-predicates-h)) | 650 | (or (gethash predicate comp-known-predicates-h) |
| 651 | (gethash predicate (comp-cstr-ctxt-pred-type-h comp-ctxt)))) | ||
| 649 | 652 | ||
| 650 | (defconst comp-symbol-values-optimizable '(most-positive-fixnum | 653 | (defconst comp-symbol-values-optimizable '(most-positive-fixnum |
| 651 | most-negative-fixnum) | 654 | most-negative-fixnum) |