diff options
| author | Eshel Yaron | 2025-10-01 06:54:13 +0200 |
|---|---|---|
| committer | Eshel Yaron | 2025-10-01 07:48:58 +0200 |
| commit | 8c2f783591070fea2fecdb6b2f8a01e71b814a40 (patch) | |
| tree | 08b9788db68ff47581f7f5e17680f6618066f91e | |
| parent | 409abfe96e59a36be3124c3762b47d39cbd88e38 (diff) | |
| download | emacs-8c2f783591070fea2fecdb6b2f8a01e71b814a40.tar.gz emacs-8c2f783591070fea2fecdb6b2f8a01e71b814a40.zip | |
(elisp-scope-get-symbol-type-property): Revise inheritance handling.
| -rw-r--r-- | lisp/emacs-lisp/elisp-scope.el | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lisp/emacs-lisp/elisp-scope.el b/lisp/emacs-lisp/elisp-scope.el index 7c8edff8593..6576705dd2e 100644 --- a/lisp/emacs-lisp/elisp-scope.el +++ b/lisp/emacs-lisp/elisp-scope.el | |||
| @@ -29,10 +29,7 @@ | |||
| 29 | 29 | ||
| 30 | (require 'cl-lib) | 30 | (require 'cl-lib) |
| 31 | 31 | ||
| 32 | (defvar elisp-scope--symbol-type-property-cache (make-hash-table)) | ||
| 33 | |||
| 34 | (defun elisp-scope--define-symbol-type (name parents props) | 32 | (defun elisp-scope--define-symbol-type (name parents props) |
| 35 | (clrhash elisp-scope--symbol-type-property-cache) | ||
| 36 | (put name 'elisp-scope-parent-types parents) | 33 | (put name 'elisp-scope-parent-types parents) |
| 37 | (put name 'elisp-scope-type-properties props)) | 34 | (put name 'elisp-scope-type-properties props)) |
| 38 | 35 | ||
| @@ -42,25 +39,23 @@ | |||
| 42 | 39 | ||
| 43 | ;;;###autoload | 40 | ;;;###autoload |
| 44 | (defun elisp-scope-get-symbol-type-property (type prop) | 41 | (defun elisp-scope-get-symbol-type-property (type prop) |
| 45 | (with-memoization (alist-get prop (gethash type elisp-scope--symbol-type-property-cache)) | 42 | (seq-some |
| 46 | (named-let loop ((current type) | 43 | (lambda (c) (plist-get (get c 'elisp-scope-type-properties) prop)) |
| 47 | (parents (get type 'elisp-scope-parent-types)) | 44 | (elisp-scope--all-reachable-symbol-types type))) |
| 48 | (more nil) | 45 | |
| 49 | (done nil)) | 46 | (defvar elisp-scope--all-reachable-symbol-types-cache (make-hash-table)) |
| 50 | (or (plist-get (get current 'elisp-scope-type-properties) prop) | 47 | |
| 51 | (when-let* ((next (car parents))) | 48 | (defun elisp-scope--all-reachable-symbol-types (symbol-type) |
| 52 | (loop (car parents) (get next 'elisp-scope-parent-types) (append (cdr parents) more) done)) | 49 | (with-memoization (gethash symbol-type elisp-scope--all-reachable-symbol-types-cache) |
| 53 | (when-let* ((next (car more))) | 50 | (cons symbol-type |
| 54 | (loop next (let (res) | 51 | (let* ((parents (get symbol-type 'elisp-scope-parent-types)) |
| 55 | (dolist (per (get next 'elisp-scope-parent-types)) | 52 | (aps (mapcar #'elisp-scope--all-reachable-symbol-types parents))) |
| 56 | (unless (memq per done) | 53 | (if (cdr aps) |
| 57 | (push per res))) | 54 | (merge-ordered-lists (nconc aps (list parents))) |
| 58 | (nreverse res)) | 55 | (car aps)))))) |
| 59 | (cdr more) done)))))) | ||
| 60 | 56 | ||
| 61 | ;;;###autoload | 57 | ;;;###autoload |
| 62 | (defun elisp-scope-set-symbol-type-property (type prop value) | 58 | (defun elisp-scope-set-symbol-type-property (type prop value) |
| 63 | (clrhash elisp-scope--symbol-type-property-cache) | ||
| 64 | (put type 'elisp-scope-type-properties | 59 | (put type 'elisp-scope-type-properties |
| 65 | (plist-put (get type 'elisp-scope-type-properties) prop value))) | 60 | (plist-put (get type 'elisp-scope-type-properties) prop value))) |
| 66 | 61 | ||