gcl.git - GNU Common Lisp

index : gcl.git
GNU Common Lisp
summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamm Maguire <camm@debian.org>2014年09月19日 13:39:25 -0400
committerCamm Maguire <camm@debian.org>2014年09月19日 13:39:25 -0400
commit28d939cf5ffb65d7752acc6b9774e614328f0737 (patch)
tree6a3667691d82aae7c9062f3f09efae98c6367b1e
parent42de72426235d65a6897ed861166fe6ca1ddc169 (diff)
downloadgcl-28d939cf5ffb65d7752acc6b9774e614328f0737.tar.gz
only cmp-expand-macro when necessary
Diffstat
-rwxr-xr-xgcl/cmpnew/gcl_cmputil.lsp 65
1 files changed, 24 insertions, 41 deletions
diff --git a/gcl/cmpnew/gcl_cmputil.lsp b/gcl/cmpnew/gcl_cmputil.lsp
index 3f12f30fc..c28d9872b 100755
--- a/gcl/cmpnew/gcl_cmputil.lsp
+++ b/gcl/cmpnew/gcl_cmputil.lsp
@@ -175,56 +175,39 @@
; 'setf
; args)))))
-(defun cmp-macroexpand (form &aux env)
- ;;Obtain the local macro environment for expansion.
- (dolist (v *funs*)
- (if (consp v) (push (list (car v) 'macro (cadr v)) env)))
- (if env (setq env (list nil (nreverse env) nil)))
- (let ((x (multiple-value-list
- (cmp-toplevel-eval `(macroexpand ',form ',env)))))
- (if (car x)
- (let ((*print-case* :upcase))
- (incf *error-count*)
- (print-current-form)
- (format t
- ";;; The macro form ~s was not expanded successfully.~%"
- form)
- `(error "Macro-expansion of ~s failed at compile time." ',form))
- (cadr x))))
+(defun macro-def-p (form &aux (fname (when (consp form) (car form))))
+ (when (symbolp fname)
+ (or (member-if (lambda (x) (when (consp x) (eq (car x) fname))) *funs*)
+ (macro-function fname))))
-(defun cmp-macroexpand-1 (form &aux env)
+(defun do-macro-expansion (how form &aux env)
(dolist (v *funs*)
- (if (consp v) (push (list (car v) 'macro (cadr v)) env)))
- (let ((x (multiple-value-list (cmp-toplevel-eval `(macroexpand-1 ',form
- ',env)))))
+ (when (consp v)
+ (push (list (car v) 'macro (cadr v)) env)))
+ (when env (setq env (list nil (nreverse env) nil)))
+ (let ((x (multiple-value-list (cmp-toplevel-eval `(,@how ',form ',env)))))
(if (car x)
(let ((*print-case* :upcase))
(incf *error-count*)
(print-current-form)
- (format t
- ";;; The macro form ~s was not expanded successfully.~%"
- form)
+ (format t ";;; The macro form ~s was not expanded successfully.~%" form)
`(error "Macro-expansion of ~s failed at compile time." ',form))
(cadr x))))
-(defun cmp-expand-macro (fd fname args &aux env)
- (dolist (v *funs*)
- (if (consp v) (push (list (car v) 'macro (cadr v)) env)))
- (and *record-call-info* (add-macro-callee fname))
- (if env (setq env (list nil (nreverse env) nil)))
- (let ((x (multiple-value-list
- (cmp-toplevel-eval
- `(funcall *macroexpand-hook* ',fd ',(cons fname args) ',env)))))
- (if (car x)
- (let ((*print-case* :upcase))
- (incf *error-count*)
- (print-current-form)
- (format t
- ";;; The macro form (~s ...) was not expanded successfully.~%"
- fname)
- `(error "Macro-expansion of ~s failed at compile time."
- ',(cons fname args)))
- (cadr x))))
+(defun cmp-macroexpand (form)
+ (if (macro-def-p form)
+ (do-macro-expansion '(macroexpand) form)
+ form))
+
+(defun cmp-macroexpand-1 (form)
+ (if (macro-def-p form)
+ (do-macro-expansion '(macroexpand-1) form)
+ form))
+
+(defun cmp-expand-macro (fd fname args &aux env (form (cons fname args)))
+ (if (macro-def-p form)
+ (do-macro-expansion `(funcall *macroexpand-hook* ',fd) form)
+ form))
(defvar *compiler-break-enable* nil)
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月05日 07:36:28 +0000

AltStyle によって変換されたページ (->オリジナル) /