summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2023-05-30 15:30:11 +0200
committerAndrea Corallo <akrl@sdf.org>2023-06-04 13:06:39 +0200
commit53dc1f3fe0aa9b932e6413007e7a6d39c00f1721 (patch)
tree23a024675820025741830511e7b507b7b0138441 /lisp/emacs-lisp
parent9ed24bfb04f5a878689e09914f1c4b28105ac85e (diff)
downloademacs-53dc1f3fe0aa9b932e6413007e7a6d39c00f1721.tar.gz
emacs-53dc1f3fe0aa9b932e6413007e7a6d39c00f1721.tar.bz2
emacs-53dc1f3fe0aa9b932e6413007e7a6d39c00f1721.zip
Print know function types in C-h f
* lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Improve comment. (comp-funciton-type-spec): New function. * lisp/help-fns.el (help-fns--signature): Update to make use of `comp-funciton-type-spec'.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/comp.el28
1 files changed, 24 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index da551ae2fd9..86707dd3516 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -277,10 +277,10 @@ Useful to hook into pass checkers.")
;; FIXME this probably should not be here but... good for now.
(defconst comp-known-type-specifiers
`(
- ;; Functions we can trust not to be or if redefined should expose
- ;; the same type. Vast majority of these is either pure or
- ;; primitive, the original list is the union of pure +
- ;; side-effect-free-fns + side-effect-and-error-free-fns:
+ ;; Functions we can trust not to be redefined or if redefined
+ ;; should expose the same type. The vast majority of these is
+ ;; either pure or primitive, the original list is the union of
+ ;; pure + side-effect-free-fns + side-effect-and-error-free-fns:
(% (function ((or number marker) (or number marker)) number))
(* (function (&rest (or number marker)) number))
(+ (function (&rest (or number marker)) number))
@@ -4447,6 +4447,26 @@ of (commands) to run simultaneously."
(delete-directory subdir))))))
(message "Cache cleared"))
+;;;###autoload
+(defun comp-funciton-type-spec (function)
+ "Given FUNCTION gives its type specifier.
+Return a cons with its car being the function specifier and its
+cdr being a symbol.
+
+If the symbol is `inferred' the type specifier is automatically
+inferred from the code itself by the native compiler, if it is
+`know' the type specifier comes from
+`comp-known-type-specifiers'."
+ (let ((kind 'know)
+ type-spec )
+ (when-let ((res (gethash function comp-known-func-cstr-h)))
+ (setf type-spec (comp-cstr-to-type-spec res)))
+ (unless type-spec
+ (setf kind 'inferred
+ type-spec (subr-type (symbol-function function))))
+ (when type-spec
+ (cons type-spec kind))))
+
(provide 'comp)
;; LocalWords: limplified limplification limplify Limple LIMPLE libgccjit elc eln