emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7215c63fc0f 1/5: * Make 'comp--compute-function-types' a pass


From: Andrea Corallo
Subject: master 7215c63fc0f 1/5: * Make 'comp--compute-function-types' a pass
Date: Wed, 21 Feb 2024 11:43:22 -0500 (EST)

branch: master
commit 7215c63fc0f9d7f48ac20578d310a8b3d86b0eae
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>

    * 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.
---
 lisp/emacs-lisp/comp.el | 61 +++++++++++++++++++++++++++----------------------
 1 file 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]