summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp.el
diff options
context:
space:
mode:
authorAndrea Corallo <acorallo@gnu.org>2024-02-21 11:18:06 +0100
committerAndrea Corallo <acorallo@gnu.org>2024-02-21 17:42:58 +0100
commit7215c63fc0f9d7f48ac20578d310a8b3d86b0eae (patch)
tree360066f1f112b29f35463f0d62a6b389114438ee /lisp/emacs-lisp/comp.el
parent8987e1b093b07756d18c861d1c7febb85fe88bef (diff)
downloademacs-7215c63fc0f9d7f48ac20578d310a8b3d86b0eae.tar.gz
emacs-7215c63fc0f9d7f48ac20578d310a8b3d86b0eae.tar.bz2
emacs-7215c63fc0f9d7f48ac20578d310a8b3d86b0eae.zip
* Make 'comp--compute-function-types' a pass
* lisp/emacs-lisp/comp.el (comp-passes): Add comp--compute-function-types. (comp--compute-function-types): New function. (comp--compute-function-type): Move it. (comp--final): Update it.
Diffstat (limited to 'lisp/emacs-lisp/comp.el')
-rw-r--r--lisp/emacs-lisp/comp.el61
1 files changed, 34 insertions, 27 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 593291a379e..b27cf2b6620 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -165,6 +165,7 @@ Can be one of: `d-default', `d-impure' or `d-ephemeral'. See `comp-ctxt'.")
comp--tco
comp--fwprop
comp--remove-type-hints
+ comp--compute-function-types
comp--final)
"Passes to be executed in order.")
@@ -2994,32 +2995,7 @@ These are substituted with a normal `set' op."
(comp-ctxt-funcs-h comp-ctxt)))
-;;; Final pass specific code.
-
-(defun comp--args-to-lambda-list (args)
- "Return a lambda list for ARGS."
- (cl-loop
- with res
- repeat (comp-args-base-min args)
- do (push t res)
- finally
- (if (comp-args-p args)
- (cl-loop
- with n = (- (comp-args-max args) (comp-args-min args))
- initially (unless (zerop n)
- (push '&optional res))
- repeat n
- do (push t res))
- (cl-loop
- with n = (- (comp-nargs-nonrest args) (comp-nargs-min args))
- initially (unless (zerop n)
- (push '&optional res))
- repeat n
- do (push t res)
- finally (when (comp-nargs-rest args)
- (push '&rest res)
- (push 't res))))
- (cl-return (reverse res))))
+;;; Function types pass specific code.
(defun comp--compute-function-type (_ func)
"Compute type specifier for `comp-func' FUNC.
@@ -3047,6 +3023,38 @@ Set it into the `type' slot."
;; Fix it up.
(setf (comp-cstr-imm (comp-func-type func)) type))))
+(defun comp--compute-function-types (_)
+ ""
+ (maphash #'comp--compute-function-type (comp-ctxt-funcs-h comp-ctxt)))
+
+
+;;; Final pass specific code.
+
+(defun comp--args-to-lambda-list (args)
+ "Return a lambda list for ARGS."
+ (cl-loop
+ with res
+ repeat (comp-args-base-min args)
+ do (push t res)
+ finally
+ (if (comp-args-p args)
+ (cl-loop
+ with n = (- (comp-args-max args) (comp-args-min args))
+ initially (unless (zerop n)
+ (push '&optional res))
+ repeat n
+ do (push t res))
+ (cl-loop
+ with n = (- (comp-nargs-nonrest args) (comp-nargs-min args))
+ initially (unless (zerop n)
+ (push '&optional res))
+ repeat n
+ do (push t res)
+ finally (when (comp-nargs-rest args)
+ (push '&rest res)
+ (push 't res))))
+ (cl-return (reverse res))))
+
(defun comp--finalize-container (cont)
"Finalize data container CONT."
(setf (comp-data-container-l cont)
@@ -3149,7 +3157,6 @@ Prepare every function for final compilation and drive the C back-end."
(defun comp--final (_)
"Final pass driving the C back-end for code emission."
- (maphash #'comp--compute-function-type (comp-ctxt-funcs-h comp-ctxt))
(unless comp-dry-run
;; Always run the C side of the compilation as a sub-process
;; unless during bootstrap or async compilation (bug#45056). GCC