mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-06 04:10:47 -08:00
Avoid using EVAL to speed up the macroexpansion process.
This commit is contained in:
parent
f36f53a933
commit
8e49187cf5
2 changed files with 37 additions and 55 deletions
|
|
@ -109,11 +109,11 @@ ECL 0.9i
|
|||
effect as SI::SET-BUFFERING-MODE's argument.
|
||||
|
||||
- ECL can be built against locally installed copies of the Boehm-Weiser
|
||||
garbage collector, as far as they are recent. This has been checked with
|
||||
OpenBSD & Ubuntu. You may need to supply appropiate LDFLAGS & CFLAGS for the
|
||||
garbage collector, if they are recent. This has been checked with OpenBSD &
|
||||
Ubuntu. You may need to supply appropiate LDFLAGS & CFLAGS for the
|
||||
configuration to detect the headers.
|
||||
|
||||
- ECL now can compile files with constants that do not print readably, such as
|
||||
- ECL can now compile files with constants that do not print readably, such as
|
||||
CLOS objects. In those cases, MAKE-LOAD-FORM is used to recreate these
|
||||
constants. The only case where this fail is when the "unreadable" constant
|
||||
is part of a circular structure (contributed by Brian Spilsbury).
|
||||
|
|
@ -130,6 +130,8 @@ ECL 0.9i
|
|||
console program, and :WINDOWS, to build a Windows program. The second case makes
|
||||
only sense when the program contains some GUI (M. Goffioul).
|
||||
|
||||
- The compiler is slightly faster by avoiding use of EVAL.
|
||||
|
||||
* MOP compatibility:
|
||||
|
||||
- SLOT-VALUE, SLOT-BOUNDP, etc, together with MOP SLOT*-USING-CLASS generic
|
||||
|
|
|
|||
|
|
@ -115,62 +115,42 @@
|
|||
; (throw *cmperr-tag* '*cmperr-tag*) DEBUG
|
||||
)
|
||||
|
||||
(defun cmp-eval (form &aux (throw-flag t))
|
||||
(unwind-protect
|
||||
(prog1
|
||||
(cmp-toplevel-eval form)
|
||||
(setq throw-flag nil))
|
||||
(when throw-flag
|
||||
(let ((*print-case* :upcase))
|
||||
(print-current-form)
|
||||
(format t "~&;;; The form ~s was not evaluated successfully.~
|
||||
~%;;; You are recommended to compile again.~%"
|
||||
form)))))
|
||||
(defmacro with-cmp-protection (main-form error-form)
|
||||
`(let* ((sys::*ihs-base* sys::*ihs-top*)
|
||||
(sys::*ihs-top* (sys::ihs-top 'cmp-toplevel-eval))
|
||||
(*break-enable* *compiler-break-enable*)
|
||||
(sys::*break-hidden-packages*
|
||||
(cons (find-package 'compiler)
|
||||
sys::*break-hidden-packages*))
|
||||
(throw-flag t))
|
||||
(unwind-protect
|
||||
(multiple-value-prog1 ,main-form
|
||||
(setf throw-flag nil))
|
||||
(when throw-flag ,error-form))))
|
||||
|
||||
(defun cmp-eval (form)
|
||||
(with-cmp-protection (eval form)
|
||||
(let ((*print-case* :upcase))
|
||||
(print-current-form)
|
||||
(format t "~&;;; The form ~s was not evaluated successfully.~
|
||||
~%;;; You are recommended to compile again.~%"
|
||||
form))))
|
||||
|
||||
(defun cmp-macroexpand (form)
|
||||
;; Obtain the local macro/function environment for expansion.
|
||||
(let ((env (and *funs* (cons nil *funs*)))
|
||||
(throw-flag t))
|
||||
(unwind-protect
|
||||
(prog1
|
||||
(cmp-toplevel-eval `(macroexpand ',form ',env))
|
||||
(setq throw-flag nil))
|
||||
(when throw-flag
|
||||
(let ((*print-case* :upcase))
|
||||
(print-current-form)
|
||||
(format t
|
||||
"~&;;; The macro form ~s was not expanded successfully.~
|
||||
~%;;; You are recommended to compile again.~%"
|
||||
form))))))
|
||||
(defun cmp-macroexpand (form &optional (env (and *funs* (cons nil *funs*))))
|
||||
(with-cmp-protection (macroexpand form env)
|
||||
(let ((*print-case* :upcase))
|
||||
(print-current-form)
|
||||
(format t "~&;;; The macro form ~S was not expanded successfully.~
|
||||
~%;;; You are recommended to compile again.~%" form))))
|
||||
|
||||
(defun cmp-expand-macro (fd form &optional (env (and *funs* (cons nil *funs*))))
|
||||
(let ((throw-flag t))
|
||||
(unwind-protect
|
||||
(let ((new-form (cmp-toplevel-eval
|
||||
`(funcall *macroexpand-hook* ',fd ',form ',env))))
|
||||
(setq throw-flag nil)
|
||||
(values new-form (not (eql new-form form))))
|
||||
(if throw-flag
|
||||
(let ((*print-case* :upcase))
|
||||
(print-current-form)
|
||||
(format t
|
||||
"~&;;; The macro form (~s ...) was not expanded successfully.~
|
||||
~%;;; You are recommended to compile again.~%"
|
||||
fname))))))
|
||||
|
||||
(defun cmp-toplevel-eval (form)
|
||||
(let*
|
||||
#-:CCL
|
||||
((sys::*ihs-base* sys::*ihs-top*)
|
||||
(sys::*ihs-top* (sys::ihs-top 'cmp-toplevel-eval))
|
||||
(*break-enable* *compiler-break-enable*)
|
||||
(sys::*break-hidden-packages*
|
||||
(cons (find-package 'compiler)
|
||||
sys::*break-hidden-packages*)))
|
||||
#+:CCL
|
||||
((*break-on-errors* *compiler-break-enable*))
|
||||
(eval form)))
|
||||
(with-cmp-protection
|
||||
(let ((new-form (funcall *macroexpand-hook* fd form env)))
|
||||
(values new-form (not (eql new-form form))))
|
||||
(let ((*print-case* :upcase))
|
||||
(print-current-form)
|
||||
(format t "~&;;; The macro form ~S was not expanded successfully.~
|
||||
~%;;; You are recommended to compile again.~%" form))))
|
||||
|
||||
(defun si::compiler-clear-compiler-properties (symbol)
|
||||
#-:CCL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue