summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp-common.el
diff options
context:
space:
mode:
authorAndrea Corallo <acorallo@gnu.org>2024-02-23 15:56:47 +0100
committerAndrea Corallo <acorallo@gnu.org>2024-04-29 19:27:23 +0200
commitd8c941df7d8167fdec8cad562c095e27203f7818 (patch)
tree51792d0c0833b5871837c4806df39f9fd3fe9829 /lisp/emacs-lisp/comp-common.el
parent1c7b8099839f62ddfaa5a0f87c29bcd905095dee (diff)
downloademacs-d8c941df7d8167fdec8cad562c095e27203f7818.tar.gz
emacs-d8c941df7d8167fdec8cad562c095e27203f7818.tar.bz2
emacs-d8c941df7d8167fdec8cad562c095e27203f7818.zip
Make use of Lisp function declarations
* lisp/emacs-lisp/comp.el (comp-primitive-func-cstr-h): Rename. (comp--get-function-cstr): Define new function. (comp--add-call-cstr, comp--fwprop-call): Update. * lisp/emacs-lisp/comp-common.el (comp-function-type-spec): Update. * lisp/help-fns.el (help-fns--signature): Mention when a type is declared. * lisp/emacs-lisp/comp.el (comp-primitive-func-cstr-h): Rename.
Diffstat (limited to 'lisp/emacs-lisp/comp-common.el')
-rw-r--r--lisp/emacs-lisp/comp-common.el29
1 files changed, 17 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/comp-common.el b/lisp/emacs-lisp/comp-common.el
index 62fd28f772e..cfaf843a3fd 100644
--- a/lisp/emacs-lisp/comp-common.el
+++ b/lisp/emacs-lisp/comp-common.el
@@ -532,22 +532,27 @@ Account for `native-comp-eln-load-path' and `comp-native-version-dir'."
(defun comp-function-type-spec (function)
"Return the type specifier of FUNCTION.
-This function returns a cons cell whose car is the function
-specifier, and cdr is a symbol, either `inferred' or `know'.
-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 )
+This function returns a cons cell whose car is the function specifier,
+and cdr is a symbol, either `inferred' or `declared'. If the symbol is
+`inferred', the type specifier is automatically inferred from the code
+itself by the native compiler; if it is `declared', the type specifier
+comes from `comp-known-type-specifiers' or the function type declaration
+itself."
+ (let ((kind 'declared)
+ type-spec)
(when-let ((res (assoc function comp-known-type-specifiers)))
+ ;; Declared primitive
(setf type-spec (cadr res)))
(let ((f (and (symbolp function)
(symbol-function function))))
- (when (and f
- (null type-spec)
- (subr-native-elisp-p f))
- (setf kind 'inferred
- type-spec (subr-type f))))
+ (when (and f (null type-spec))
+ (if-let ((delc-type (function-get function 'declared-type)))
+ ;; Declared Lisp function
+ (setf type-spec (car delc-type))
+ (when (subr-native-elisp-p f)
+ ;; Native compiled inferred
+ (setf kind 'inferred
+ type-spec (subr-type f))))))
(when type-spec
(cons type-spec kind))))