]> git.eshelyaron.com Git - emacs.git/commitdiff
fix lambda handling and add a test for that
authorAndrea Corallo <akrl@sdf.org>
Sun, 8 Sep 2019 13:40:56 +0000 (15:40 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:37:45 +0000 (11:37 +0100)
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/comp.el
test/src/comp-test-funcs.el
test/src/comp-tests.el

index 3d4b76b988b5887c0d526b9266232cfc5b364f97..f82993956b7b605300c98e78f621087cbb4d5f94 100644 (file)
@@ -565,9 +565,8 @@ Each element is (INDEX . VALUE)")
 
 ;; These are use by comp.el to spill data out of here
 (defvar byte-native-compiling nil)
-(defvar byte-to-native-names nil)
-(defvar byte-to-native-lap-output nil)
-(defvar byte-to-native-bytecode-output nil)
+(defvar byte-last-lap nil)
+(defvar byte-to-native-output nil)
 (defvar byte-to-native-top-level-forms nil)
 
 \f
@@ -2274,9 +2273,8 @@ QUOTED says that we have to put a quote before the
 list that represents a doc string reference.
 `defvaralias', `autoload' and `custom-declare-variable' need that."
   (when byte-native-compiling
-      ;; Spill output for the native compiler here
-    (push name byte-to-native-names)
-    (push (apply #'vector form) byte-to-native-bytecode-output))
+    ;; Spill output for the native compiler here
+    (push (list name byte-last-lap (apply #'vector form)) byte-to-native-output))
   ;; We need to examine byte-compile-dynamic-docstrings
   ;; in the input buffer (now current), not in the output buffer.
   (let ((dynamic-docstrings byte-compile-dynamic-docstrings))
@@ -3131,7 +3129,7 @@ for symbols generated by the byte compiler itself."
                        byte-compile-vector byte-compile-maxdepth)))
         (when byte-native-compiling
           ;; Spill output for the native compiler here
-          (push byte-compile-output byte-to-native-lap-output))
+          (setq byte-last-lap byte-compile-output))
         out))
      ;; it's a trivial function
      ((cdr body) (cons 'progn (nreverse body)))
index 3ea500416de0587f761045313c9afad34cede832..39f00c5792180663dcfc75ba1629e495faa1cf5b 100644 (file)
@@ -281,23 +281,18 @@ Put PREFIX in front of it."
 (defun comp-spill-lap-functions-file (filename)
   "Byte compile FILENAME spilling data from the byte compiler."
   (byte-compile-file filename)
-  (cl-assert (= (length byte-to-native-names)
-                (length byte-to-native-lap-output)
-                (length byte-to-native-bytecode-output)))
   (setf (comp-ctxt-top-level-defvars comp-ctxt)
         (mapcar (lambda (x)
                   (if (eq (car x) 'defvar)
                       (cdr x)
                     (cl-assert nil)))
                 byte-to-native-top-level-forms))
-  (cl-loop for function-name in byte-to-native-names
-           for lap in byte-to-native-lap-output
-           for bytecode in byte-to-native-bytecode-output
+  (cl-loop for (name lap bytecode) in byte-to-native-output
            for lambda-list = (aref bytecode 0)
-           for func = (make-comp-func :symbol-name function-name
+           for func = (make-comp-func :symbol-name name
                                       :byte-func bytecode
                                       :c-func-name (comp-c-func-name
-                                                    function-name
+                                                    name
                                                     "F")
                                       :args (comp-decrypt-lambda-list lambda-list)
                                       :lap lap
@@ -311,9 +306,8 @@ Put PREFIX in front of it."
 If INPUT is a symbol this is the function-name to be compiled.
 If INPUT is a string this is the file path to be compiled."
   (let ((byte-native-compiling t)
-        (byte-to-native-names ())
-        (byte-to-native-lap-output ())
-        (byte-to-native-bytecode-output ())
+        (byte-last-lap nil)
+        (byte-to-native-output ())
         (byte-to-native-top-level-forms ()))
     (cl-typecase input
       (symbol (list (comp-spill-lap-function input)))
index 6d7311088ad20770854949c3fb5a14e9cb9dcd21..609147e7e289b9804c7558b548bc2ad12e49f0de 100644 (file)
 ;;     (insert "foo")
 ;;     (buffer-string)))
 
+(defun comp-tests-lambda-return-f ()
+  (lambda (x) (1+ x)))
+
 ;;;;;;;;;;;;;;;;;;;;
 ;; Tromey's tests ;;
 ;;;;;;;;;;;;;;;;;;;;
index ea1aab6e4c920cebef4f9c6146675664b75f362f..47ae7899c691cef0e8d19f110403f87ba62fd791 100644 (file)
 (ert-deftest comp-tests-buffer ()
   (should (string= (comp-tests-buff0-f) "foo")))
 
+(ert-deftest comp-tests-lambda-return ()
+  (should (= (funcall (comp-tests-lambda-return-f) 3) 4)))
+
 ;;;;;;;;;;;;;;;;;;;;
 ;; Tromey's tests ;;
 ;;;;;;;;;;;;;;;;;;;;