[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 57fd0f47f69 2/3: Maintain byte-compile-form-stack in cconv-conver
From: |
Mattias Engdegård |
Subject: |
master 57fd0f47f69 2/3: Maintain byte-compile-form-stack in cconv-convert (bug#67483) |
Date: |
Thu, 21 Dec 2023 07:20:41 -0500 (EST) |
branch: master
commit 57fd0f47f6955505195f77a55d29334ded88889c
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Maintain byte-compile-form-stack in cconv-convert (bug#67483)
* lisp/emacs-lisp/macroexp.el (macroexp--with-extended-form-stack):
New.
* lisp/emacs-lisp/cconv.el (cconv-closure-convert, cconv-convert):
Push forms onto byte-compile-form-stack.
---
lisp/emacs-lisp/cconv.el | 6 ++++--
lisp/emacs-lisp/macroexp.el | 12 ++++++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index 0879c2ee63c..136560f3ef4 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -123,7 +123,8 @@ using dynamic scoping.
Returns a form where all lambdas don't have any free variables."
(let ((cconv--dynbound-variables dynbound-vars)
(cconv-freevars-alist '())
- (cconv-var-classification '()))
+ (cconv-var-classification '())
+ (byte-compile-form-stack byte-compile-form-stack))
;; Analyze form - fill these variables with new information.
(cconv-analyze-form form '())
(setq cconv-freevars-alist (nreverse cconv-freevars-alist))
@@ -328,6 +329,7 @@ places where they originally did not directly appear."
;; to find the number of a specific variable in the environment vector,
;; so we never touch it(unless we enter to the other closure).
;;(if (listp form) (print (car form)) form)
+ (macroexp--with-extended-form-stack form
(pcase form
(`(,(and letsym (or 'let* 'let)) ,binders . ,body)
@@ -624,7 +626,7 @@ places where they originally did not directly appear."
(byte-compile-warn-x form "Malformed function `%S'" func)
nil))
- (_ (or (cdr (assq form env)) form))))
+ (_ (or (cdr (assq form env)) form)))))
(defvar byte-compile-lexical-variables)
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 615a6622ce6..2a646be9725 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -39,6 +39,18 @@ of `byte-compile-form', etc., and manually popped off at its
end.
This is to preserve the data in it in the event of a
condition-case handling a signaled error.")
+(defmacro macroexp--with-extended-form-stack (expr &rest body)
+ "Evaluate BODY with EXPR pushed onto `byte-compile-form-stack'."
+ (declare (indent 1))
+ ;; FIXME: We really should just be using a simple dynamic let-binding here,
+ ;; but these explicit push and pop make the extended stack value visible
+ ;; to error handlers. Remove that need for that!
+ `(progn
+ (push ,expr byte-compile-form-stack)
+ (prog1
+ (progn ,@body)
+ (pop byte-compile-form-stack))))
+
;; Bound by the top-level `macroexpand-all', and modified to include any
;; macros defined by `defmacro'.
(defvar macroexpand-all-environment nil)