;; 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
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))
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)))
(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
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)))
;; (insert "foo")
;; (buffer-string)))
+(defun comp-tests-lambda-return-f ()
+ (lambda (x) (1+ x)))
+
;;;;;;;;;;;;;;;;;;;;
;; Tromey's tests ;;
;;;;;;;;;;;;;;;;;;;;
(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 ;;
;;;;;;;;;;;;;;;;;;;;