]> git.eshelyaron.com Git - emacs.git/commitdiff
rework args structures
authorAndrea Corallo <andrea_corallo@yahoo.it>
Sun, 11 Aug 2019 12:54:13 +0000 (14:54 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:33:59 +0000 (11:33 +0100)
lisp/emacs-lisp/comp.el
src/comp.c

index 9bf60d1f3cb5db97626b2caa7634451e595b8b13..a35fbd0fec54c3a66e777412ca845706678d3038 100644 (file)
             finally return h)
     "Hash table lap-op -> stack adjustment."))
 
-(cl-defstruct comp-args
+(cl-defstruct comp-args-gen
   (min nil :type number
-       :documentation "Minimum number of arguments allowed.")
-  (max nil
+       :documentation "Minimum number of arguments allowed."))
+
+(cl-defstruct (comp-args (:include comp-args-gen))
+  (max nil :type number
        :documentation "Maximum number of arguments allowed.
-To be used when ncall-conv is nil.")
-  (ncall-conv nil :type boolean
-              :documentation "If t the signature is:
-(ptrdiff_t nargs, Lisp_Object *args)."))
+To be used when ncall-conv is nil."))
+
+(cl-defstruct (comp-nargs (:include comp-args-gen))
+  "Describe args when the functin signature is of kind:
+(ptrdiff_t nargs, Lisp_Object *args)."
+  (nonrest nil :type number
+           :documentation "Number of non rest arguments."))
 
 (cl-defstruct (comp-block (:copier nil))
   "A basic block."
@@ -109,7 +114,7 @@ into it.")
              :documentation "Byte compiled version.")
   (lap () :type list
        :documentation "Lap assembly representation.")
-  (args nil :type 'comp-args)
+  (args nil :type 'comp-args-gen)
   (frame-size nil :type 'number)
   (blocks (make-hash-table) :type 'hash-table
           :documentation "Key is the basic block symbol value is a comp-block
@@ -203,8 +208,8 @@ BODY is evaluate only if `comp-debug' is non nil."
              (< nonrest 9)) ;; SUBR_MAX_ARGS
         (make-comp-args :min mandatory
                         :max nonrest)
-      (make-comp-args :min mandatory
-                      :ncall-conv t))))
+      (make-comp-nargs :min mandatory
+                       :nonrest nonrest))))
 
 (defun comp-spill-lap (func)
   "Byte compile and spill the LAP rapresentation for FUNC."
@@ -703,13 +708,13 @@ the annotation emission."
          (comp-pass (make-comp-limplify
                      :sp -1
                      :frame (comp-new-frame frame-size)))
-         (args-min (comp-args-min (comp-func-args func)))
+         (args-min (comp-args-gen-min (comp-func-args func)))
          (comp-block ()))
     ;; Prologue
     (comp-emit-block 'entry)
     (comp-emit-annotation (concat "Lisp function: "
                                   (symbol-name (comp-func-symbol-name func))))
-    (if (not (comp-args-ncall-conv (comp-func-args func)))
+    (if (comp-args-p (comp-func-args func))
       (cl-loop for i below (comp-args-max (comp-func-args func))
                do (cl-incf (comp-sp))
                do (comp-emit `(setpar ,(comp-slot) ,i)))
index a4793a36ada0e5804198e48907314f243fb874e2..881a78b3d75aec3104549a1f899dc56b46656afb 100644 (file)
@@ -2247,8 +2247,7 @@ DEFUN ("comp-add-func-to-ctxt", Fcomp_add_func_to_ctxt, Scomp_add_func_to_ctxt,
   char *c_name = (char *) SDATA (FUNCALL1 (comp-func-c-func-name, func));
   Lisp_Object args = FUNCALL1 (comp-func-args, func);
   EMACS_INT frame_size = XFIXNUM (FUNCALL1 (comp-func-frame-size, func));
-  /* EMACS_INT min_args = XFIXNUM (FUNCALL1 (comp-args-min, args)); */
-  bool ncall = !NILP (FUNCALL1 (comp-args-ncall-conv, args));
+  bool ncall = (FUNCALL1 (comp-nargs-p, args));
 
   if (!ncall)
     {
@@ -2373,8 +2372,8 @@ DEFUN ("comp-compile-and-load-ctxt", Fcomp_compile_and_load_ctxt,
       x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS;
       x->s.function.a0 = gcc_jit_result_get_code(gcc_res, c_name);
       eassert (x->s.function.a0);
-      x->s.min_args = XFIXNUM (FUNCALL1 (comp-args-min, args));
-      if (NILP (FUNCALL1 (comp-args-ncall-conv, args)))
+      x->s.min_args = XFIXNUM (FUNCALL1 (comp-args-gen-min, args));
+      if (FUNCALL1 (comp-args-p, args))
        x->s.max_args = XFIXNUM (FUNCALL1 (comp-args-max, args));
       else
        x->s.max_args = MANY;