diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-07-17 06:39:26 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-07-17 06:39:26 -0700 |
commit | d3fd04b03a9fb48ba8d0323d7ac1f45c2645c7b1 (patch) | |
tree | e7992cafaf6f9f7bf57a06179d4459b387595739 /share | |
parent | e7c14e74668d15f0403c868847779d795d167c8a (diff) | |
download | txr-d3fd04b03a9fb48ba8d0323d7ac1f45c2645c7b1.tar.gz txr-d3fd04b03a9fb48ba8d0323d7ac1f45c2645c7b1.tar.bz2 txr-d3fd04b03a9fb48ba8d0323d7ac1f45c2645c7b1.zip |
compile-file: incremental expansion of top-level forms.
Harmonizing with the previous change to eval, the
compiler should also handle those situations.
* share/txr/stdlib/compiler.tl (compile-file): do not perform
a full expansion on each object that it reads from the file
before passing it into the top-level walk. Rather, the
raw form is passed into the top-level walk. It is partially
expanded with macro-expand, and this is repated at each
descent of the recursion. Only forms which are not top-level
forms are then fully expanded before compilation, by not
passing the t argument to compile-toplevel.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/compiler.tl | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 5b194263..34f29c03 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -1599,27 +1599,28 @@ ((starts-with "#!" line))) (put-line line out-stream) (seek-stream in-stream 0 :from-start)) - (labels ((compile-form (form) - (unless (atom form) - (caseq (car form) - (progn [mapdo compile-form (cdr form)]) - (compile-only (let ((*eval* nil)) - [mapdo compile-form (cdr form)])) - (eval-only (let ((*emit* nil)) - [mapdo compile-form (cdr form)])) - (t (when (and (or *eval* *emit*) - (not (constantp form))) - (let* ((vm-desc (compile-toplevel form t)) - (flat-vd (list-from-vm-desc vm-desc))) - (when *eval* - (sys:vm-execute-toplevel vm-desc)) - (when *emit* - out.(add flat-vd))))))))) + (labels ((compile-form (unex-form) + (let ((form (macroexpand unex-form))) + (unless (atom form) + (caseq (car form) + (progn [mapdo compile-form (cdr form)]) + (compile-only (let ((*eval* nil)) + [mapdo compile-form (cdr form)])) + (eval-only (let ((*emit* nil)) + [mapdo compile-form (cdr form)])) + (t (when (and (or *eval* *emit*) + (not (constantp form))) + (let* ((vm-desc (compile-toplevel form)) + (flat-vd (list-from-vm-desc vm-desc))) + (when *eval* + (sys:vm-execute-toplevel vm-desc)) + (when *emit* + out.(add flat-vd)))))))))) (prinl %tlo-ver% out-stream) (unwind-protect (whilet ((obj (read in-stream *stderr* err-ret)) ((neq obj err-ret))) - (compile-form (sys:expand* obj))) + (compile-form obj)) (let ((*print-circle* t) (*package* (sys:make-anon-package))) (prinl out.(get) out-stream) |