From 0593f478762437e2a8618f3f874a26424e4590b4 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 29 Dec 2020 19:41:28 +0100 Subject: [PATCH] * Add more function type specifiers * lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Add more type specifiers. --- lisp/emacs-lisp/comp.el | 244 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 239 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index bf266256f70..7e5a9ec951c 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -184,7 +184,11 @@ Useful to hook into pass checkers.") ;; FIXME this probably should not be here but... good for now. (defconst comp-known-type-specifiers - `((cons (function (t t) cons)) + `( + ;; pure-fns + (cons (function (t t) cons)) + (car (function (list) t)) + (cdr (function (list) t)) (1+ (function ((or number marker)) number)) (1- (function ((or number marker)) number)) (+ (function (&rest (or number marker)) number)) @@ -194,7 +198,7 @@ Useful to hook into pass checkers.") (% (function ((or number marker) (or number marker)) number)) (concat (function (&rest sequence) string)) (regexp-opt (function (list) string)) - (string-to-char (function (string) integer)) + (string-to-char (function (string) fixnum)) (symbol-name (function (symbol) string)) (eq (function (t t) boolean)) (eql (function (t t) boolean)) @@ -234,16 +238,15 @@ Useful to hook into pass checkers.") (string< (function ((or string symbol) (or string symbol)) boolean)) (string-lessp (function ((or string symbol) (or string symbol)) boolean)) (string-search (function (string string &optional integer) integer)) - (string-to-char (function (string) integer)) (string-to-number (function (string &optional integer) number)) (string-to-syntax (function (string) cons)) - (substring (function ((or string vector) &optional integer integer) (or string vector))) + (substring (function ((or string vector) &optional integer integer) + (or string vector))) (sxhash (function (t) integer)) (sxhash-equal (function (t) integer)) (sxhash-eq (function (t) integer)) (sxhash-eql (function (t) integer)) (symbol-function (function (symbol) t)) - (symbol-name (function (symbol) string)) (symbol-plist (function (symbol) list)) (symbol-value (function (symbol) t)) (string-make-unibyte (function (string) string)) @@ -262,6 +265,237 @@ Useful to hook into pass checkers.") (vconcat (function (&rest sequence) vector)) ;; TODO all window-* :x (zerop (function (number) boolean)) + ;; side-effect-free-fns + (acos (function (number) float)) + (append (function (&rest list) list)) + (asin (function (number) float)) + (atan (function (number &optional number) float)) + (boundp (function (symbol) boolean)) + (buffer-file-name (function (&optional buffer) string)) + (buffer-local-variables (function (&optional buffer) list)) + (buffer-modified-p (function (&optional buffer) boolean)) + (buffer-substring (function ((or integer marker) (or integer marker)) string)) + (byte-code-function-p (function (t) boolean)) + (capitalize (function (or integer string) (or integer string))) + (car-less-than-car (function (list list) boolean)) + (char-after (function (&optional (or marker integer)) fixnum)) + (char-before (function (&optional (or marker integer)) fixnum)) + (char-equal (function (integer integer) boolean)) + (char-to-string (function (fixnum) string)) + (char-width (function (fixnum) fixnum)) + (compare-strings (function (string (or integer marker null) + (or integer marker null) + string (or integer marker null) + (or integer marker null) + &optional t) + (or (member t) fixnum))) + (coordinates-in-window-p (function (cons window) boolean)) + (copy-alist (function (list) list)) + (copy-sequence (function (sequence) sequence)) + (copy-marker (function (&optional (or integer marker) boolean) marker)) + (cos (function (number) float)) + (count-lines (function ((or integer marker) (or integer marker) &optional t) + integer)) + (current-time-string (function (&optional string boolean) string)) + (current-time-zone (function (&optional string boolean) cons)) + (decode-char (function (cons t) (or fixnum null))) + (decode-time (function (&optional string symbol symbol) cons)) + (default-boundp (function (symbol) boolean)) + (default-value (function (symbol) t)) + (documentation (function ((or function symbol subr) &optional t) + (or null string))) + (downcase (function ((or fixnum string)) (or fixnum string))) + (encode-char (function (fixnum symbol) (or fixnum null))) + (exp (function (number) float)) + (expt (function (number number) float)) + (encode-time (function (cons &rest t) cons)) + (error-message-string (function (list) string)) + (fboundp (function (symbol) boolean)) + (featurep (function (symbol &optional symbol) boolean)) + (file-directory-p (function (string) boolean)) + (file-exists-p (function (string) boolean)) + (file-locked-p (function (string) boolean)) + (file-name-absolute-p (function (string) boolean)) + (file-newer-than-file-p (function (string string) boolean)) + (file-readable-p (function (string) boolean)) + (file-symlink-p (function (string) boolean)) + (file-writable-p (function (string) boolean)) + (float-time (function (&optional cons) float)) + (format (function (string &rest t) string)) + (format-time-string (function (string &optional cons symbol) string)) + (frame-first-window (function ((or frame window)) window)) + (frame-root-window (function (&optional (or frame window)) window)) + (frame-selected-window (function (&optional (or frame window)) window)) + (frame-visible-p (function (frame) boolean)) + (get (function (symbol symbol) t)) + (gethash (function (t hash-table &optional t) t)) + (get-buffer (function ((or buffer string)) (or buffer null))) + (get-buffer-window (function (&optional (or buffer string) + (or symbol (integer 0 0))) + (or null window))) + (getenv (function (string &optional frame) (or null string))) + (get-file-buffer (function (string) (or null buffer))) + (hash-table-count (function (hash-table) integer)) + (int-to-string (function (number) string)) + (intern-soft (function (string &optional vector) symbol)) + (keymap-parent (function (cons) (or cons null))) + (length< (function (sequence fixnum) boolean)) + (length> (function (sequence fixnum) boolean)) + (length= (function (sequence fixnum) boolean)) + (line-beginning-position (function (&optional integer) integer)) + (line-end-position (function (&optional integer) integer)) + (local-variable-if-set-p (function (symbol &optional buffer) boolean)) + (local-variable-p (function (symbol &optional buffer) boolean)) + (locale-info (function ((member codeset days months paper)) + (or null string))) + (log (function (number number) float)) + (log10 (function (number) float)) + ;; (lsh (function ((integer ,most-negative-fixnum *) integer) integer)) ? + (lsh (function (integer integer) integer)) + (make-byte-code (function ((or fixnum list) string vector integer &optional + string t &rest t) + vector)) + (make-list (function (integer t) list)) + (make-string (function (integer fixnum &optional t) string)) + (make-symbol (function (string) symbol)) + (marker-buffer (function (marker) buffer)) + (minibuffer-selected-window (function () window)) + (minibuffer-window (function (&optional frame) window)) + (multibyte-char-to-unibyte (function (fixnum) fixnum)) + (next-window (function (&optional window t t) window)) + (number-to-string (function (number) string)) + (parse-colon-path (function (string) cons)) + (previous-window (function (&optional window t t) window)) + (prin1-to-string (function (t &optional t) string)) + (propertize (function (string &rest t) string)) + (degrees-to-radians (function (number) float)) + (radians-to-degrees (function (number) float)) + (read-from-string (function (string &ptional integer integer) cons)) + (region-beginning (function () integer)) + (region-end (function () integer)) + (reverse (function (sequence) sequence)) + (sin (function (number) float)) + (string (function (&rest fixnum) strng)) + (get-largest-window (function (&optional t t t) window)) + (get-lru-window (function (&optional t t t) window)) + (one-window-p (function (&optional t t) boolean)) + (regexp-quote (function (string) string)) + (proper-list-p (function (t) integer)) + (nth (function (integer list) t)) + (nthcdr (function (integer list) list)) + (last (function (list &optional integer) list)) + (length (function (sequence) integer)) + (memq (function (t list) list)) + (memql (function (t list) list)) + (member (function (t list) list)) + (assq (function (t list) list)) + (rassq (function (t list) list)) + (rassoc (function (t list) list)) + (plist-get (function (list t) t)) + (lax-plist-get (function (list t) t)) + (plist-member (function (list t) list)) + (aref (function (array fixnum) t)) + (elt (function (sequence integer) t)) + (bool-vector-subsetp (function (bool-vector bool-vector) boolean)) + (bool-vector-not (function (bool-vector &optional bool-vector) bool-vector)) + (bool-vector-count-population (function (bool-vector) fixnum)) + (bool-vector-count-consecutive (function (bool-vector bool-vector integer) + fixnum)) + ;; side-effect-and-error-free-fns + (arrayp (function (t) boolean)) + (atom (function (t) boolean)) + (bignump (function (t) boolean)) + (bobp (function () boolean)) + (bolp (function () boolean)) + (bool-vector-p (function (t) boolean)) + (buffer-end (function ((or number marker)) integer)) + (buffer-list (function (&optional frame) list)) + (buffer-size (function (&optional buffer) integer)) + (buffer-string (function () string)) + (bufferp (function (t) boolean)) + (car-safe (function (t) t)) + (case-table-p (function (t) boolean)) + (cdr-safe (function (t) t)) + (char-or-string-p (function (t) boolean)) + (characterp (function (t &optional t) boolean)) + (charsetp (function (t) boolean)) + (commandp (function (t &optional t) boolean)) + (consp (function (t) boolean)) + (current-buffer (function () buffer)) + (current-global-map (function () cons)) + (current-indentation (function () integer)) + (current-local-map (function () cons)) + (current-minor-mode-maps (function () cons)) + (current-time (function () cons)) + (eobp (function () boolean)) + (eolp (function () boolean)) + (equal (function (t t) boolean)) + (eventp (function (t) boolean)) + (fixnump (function (t) boolean)) + (floatp (function (t) boolean)) + (following-char (function () fixnum)) + (framep (function (t) boolean)) + (hash-table-p (function (t) boolean)) + (identity (function (t) t)) + (ignore (function (&rest t) null)) + (integerp (function (t) boolean)) + (integer-or-marker-p (function (t) boolean)) + (interactive-p (function () boolean)) + (invocation-directory (function () string)) + (invocation-name (function () string)) + (keymapp (function (t) boolean)) + (keywordp (function (t) boolean)) + (list (function (&rest t) list)) + (listp (function (t) boolean)) + (make-marker (function () marker)) + (mark (function (&optional t) (or integer null))) + (mark-marker (function () marker)) + (markerp (function (t) boolean)) + (max-char (function () fixnum)) + (memory-limit (function () integer)) + (mouse-movement-p (function (t) boolean)) + (natnump (function (t) boolean)) + (nlistp (function (t) boolean)) + (not (function (t) boolean)) + (null (function (t) boolean)) + (number-or-marker-p (function (t) boolean)) + (numberp (function (t) boolean)) + (overlayp (function (t) boolean)) + (point (function () integer)) + (point-marker (function () marker)) + (point-min (function () integer)) + (point-max (function () integer)) + (preceding-char (function () fixnum)) + (processp (function (t) boolean)) + (recent-keys (function (&optional (or cons null)) vector)) + (recursion-depth (function () integer)) + (safe-length (function (t) integer)) + (selected-frame (function () frame)) + (selected-window (function () window)) + (sequencep (function (t) boolean)) + (standard-case-table (function () char-table)) + (standard-syntax-table (function () char-table)) + (stringp (function (t) boolean)) + (subrp (function (t) boolean)) + (symbolp (function (t) boolean)) + (syntax-table (function () char-table)) + (syntax-table-p (function (t) boolean)) + (this-command-keys (function () string)) + (this-command-keys-vector (function () vector)) + (this-single-command-keys (function () vector)) + (this-single-command-raw-keys (function () vector)) + (type-of (function (t) symbol)) + (user-real-login-name (function () string)) + (user-real-uid (function () integer)) + (user-uid (function () integer)) + (vector (function (&rest t) vector)) + (vectorp (function (t) boolean)) + (visible-frame-list (function () list)) + (wholenump (function (t) boolean)) + (window-configuration-p (function (t) boolean)) + (window-live-p (function (t) boolean)) + (window-valid-p (function (t) boolean)) + (windowp (function (t) boolean)) ;; Type hints (comp-hint-fixnum (function (t) fixnum)) (comp-hint-cons (function (t) cons)) -- 2.39.5