diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-04-18 21:04:54 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-04-18 21:04:54 -0700 |
commit | 632703656926b0ac6461538d3cbf35fb95df72dc (patch) | |
tree | c29c526757ea59828c1e7bcc86474767e02a5476 /share | |
parent | 3a9346cb299151cce4d46ebcf20c0f4bb76c697a (diff) | |
download | txr-632703656926b0ac6461538d3cbf35fb95df72dc.tar.gz txr-632703656926b0ac6461538d3cbf35fb95df72dc.tar.bz2 txr-632703656926b0ac6461538d3cbf35fb95df72dc.zip |
compiler: don't expand top-level forms twice.
* share/txr/stdlib/compiler.tl (usr:compile-toplevel): Support
optional parameter indicating that no expansion is required.
(usr:compile-file): Call compile-toplevel with a t argument
for the new expanded-p parameter, so no further expansion
takes place.
* txr.1: Document new optional parameter of compile-toplevel.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/compiler.tl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 1ac0c3af..5ae8fb93 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -1382,12 +1382,16 @@ (add ^(,pars.rest)))))) ,*lm-body)))) -(defun usr:compile-toplevel (exp) +(defun usr:compile-toplevel (exp : (expanded-p nil)) (let ((co (new compiler)) (as (new assembler))) (let* ((oreg co.(alloc-treg)) - (xexp (prog1 (expand* exp) (unless *load-recursive* - (release-deferred-warnings)))) + (xexp (if expanded-p + exp + (unwind-protect + (expand* exp) + (unless *load-recursive* + (release-deferred-warnings))))) (frag co.(compile oreg (new env co co) xexp))) co.(free-treg oreg) co.(check-treg-leak) @@ -1471,7 +1475,7 @@ [mapdo compile-form (cdr form)])) (t (when (and (or *eval* *emit*) (not (constantp form))) - (let* ((vm-desc (compile-toplevel form)) + (let* ((vm-desc (compile-toplevel form t)) (flat-vd (list-from-vm-desc vm-desc))) (when *eval* (sys:vm-execute-toplevel vm-desc)) |