fix lambda handling and add a test for that

This commit is contained in:
Andrea Corallo 2019-09-08 15:40:56 +02:00
parent 06ad745813
commit 555450c7b1
4 changed files with 16 additions and 18 deletions

View 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)
@ -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)))

View 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)))