diff options
| author | Andrea Corallo | 2024-03-03 16:33:53 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2024-03-03 17:49:14 +0100 |
| commit | 8d11b7e4275affdf66f28ec4a719fc8124252a3d (patch) | |
| tree | b8bb56d67d2725ea95fdb5923633da32e184a88d | |
| parent | 7f8717c6fd3e19b41048ce9a391d59540886cdee (diff) | |
| download | emacs-8d11b7e4275affdf66f28ec4a719fc8124252a3d.tar.gz emacs-8d11b7e4275affdf66f28ec4a719fc8124252a3d.zip | |
* Fix 'cl--typeof-types' computation
* lisp/emacs-lisp/cl-preloaded.el (cl--supertypes-lane)
(cl--supertypes-lanes-res): Define vars.
(cl--supertypes-for-typeof-types-rec): Define function.
(cl--supertypes-for-typeof-types): Reimplement.
| -rw-r--r-- | lisp/emacs-lisp/cl-preloaded.el | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el index b2b921192ff..512cf31ead5 100644 --- a/lisp/emacs-lisp/cl-preloaded.el +++ b/lisp/emacs-lisp/cl-preloaded.el | |||
| @@ -98,17 +98,24 @@ Each element has the form (TYPE . SUPERTYPES) where TYPE is one of | |||
| 98 | the symbols returned by `type-of', and SUPERTYPES is the list of its | 98 | the symbols returned by `type-of', and SUPERTYPES is the list of its |
| 99 | supertypes from the most specific to least specific.") | 99 | supertypes from the most specific to least specific.") |
| 100 | 100 | ||
| 101 | (defvar cl--supertypes-lane nil) | ||
| 102 | (defvar cl--supertypes-lanes-res nil) | ||
| 103 | |||
| 104 | (defun cl--supertypes-for-typeof-types-rec (type) | ||
| 105 | ;; Walk recursively the DAG upwards, when the top is reached collect | ||
| 106 | ;; the current lane in `cl--supertypes-lanes-res'. | ||
| 107 | (push type cl--supertypes-lane) | ||
| 108 | (if-let ((parents (gethash type cl--direct-supertypes-of-type))) | ||
| 109 | (dolist (parent parents) | ||
| 110 | (cl--supertypes-for-typeof-types-rec parent)) | ||
| 111 | (push (reverse (cdr cl--supertypes-lane)) ;; Don't include `t'. | ||
| 112 | cl--supertypes-lanes-res )) | ||
| 113 | (pop cl--supertypes-lane)) | ||
| 114 | |||
| 101 | (defun cl--supertypes-for-typeof-types (type) | 115 | (defun cl--supertypes-for-typeof-types (type) |
| 102 | (cl-loop with agenda = (list type) | 116 | (let (cl--supertypes-lane cl--supertypes-lanes-res) |
| 103 | while agenda | 117 | (cl--supertypes-for-typeof-types-rec type) |
| 104 | for element = (car agenda) | 118 | (merge-ordered-lists cl--supertypes-lanes-res))) |
| 105 | unless (or (eq element t) ;; no t in `cl--typeof-types'. | ||
| 106 | (memq element res)) | ||
| 107 | append (list element) into res | ||
| 108 | do (cl-loop for c in (gethash element cl--direct-supertypes-of-type) | ||
| 109 | do (setq agenda (append agenda (list c)))) | ||
| 110 | do (setq agenda (cdr agenda)) | ||
| 111 | finally (cl-return res))) | ||
| 112 | 119 | ||
| 113 | (maphash (lambda (type _) | 120 | (maphash (lambda (type _) |
| 114 | (push (cl--supertypes-for-typeof-types type) cl--typeof-types)) | 121 | (push (cl--supertypes-for-typeof-types type) cl--typeof-types)) |