diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-08-16 06:06:36 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-08-16 06:06:36 -0700 |
commit | 9f620308e05af59d0f5ec31a75e5bdf76135e455 (patch) | |
tree | 97104ca39fd7359f12f578477c01f45a6fb33669 | |
parent | 63704bd63b83a524215cefd0be3f72282c4378d7 (diff) | |
download | txr-9f620308e05af59d0f5ec31a75e5bdf76135e455.tar.gz txr-9f620308e05af59d0f5ec31a75e5bdf76135e455.tar.bz2 txr-9f620308e05af59d0f5ec31a75e5bdf76135e455.zip |
compile-file: include load-time as top-level form.
* share/txr/stdlib/compiler.tl (usr:compile-file): recognize
sys:load-time-lit as a top-level form and recurse through to
compiling its constituent form. We check the flag whether the
syntax had already been processed by the evaluator, though
that currently cannot possibly happen for a form that has just
been parsed from a file by compile-file itself.
* txr.1: Defintion of top-level form (from compile-file POV)
updated. Documentation of load-time updated.
-rw-r--r-- | share/txr/stdlib/compiler.tl | 4 | ||||
-rw-r--r-- | txr.1 | 23 |
2 files changed, 22 insertions, 5 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 5d7a9daa..8756dba3 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -1704,6 +1704,10 @@ [mapdo compile-form (cdr form)])) (eval-only (let ((*emit* nil)) [mapdo compile-form (cdr form)])) + (sys:load-time-lit + (if (cadr form) + (compile-form ^(quote ,(caddr form))) + (compile-form (caddr form)))) (t (when (and (or *eval* *emit*) (not (constantp form))) (let* ((vm-desc (compile-toplevel form)) @@ -66408,11 +66408,15 @@ If a .code eval-only form is top-level form, then each of its constituent forms is also a top-level form. -.IP 5. +.IP 5 +If a +.code load-time +form is top-level form, then its argument is a top-level form. +.IP 6. When a form is identified as a top-level form by the above rule 1, its constituents are considered under rules 2-4 only after the form is fully macro-expanded. -.IP 6. +.IP 7. No other forms are top-level forms. .RE @@ -67220,8 +67224,8 @@ form, if any. If a .code load-time -form appears in an expression which is compiled, it arranges for -the compiled version of +form appears in a non-top-level expression which is compiled, the +compiler arranges for the compiled version of .meta form to be executed when compiled version of the entire expression is executed. This execution occurs early, before the execution of @@ -67236,6 +67240,15 @@ Whenever the value of that form is required, the compiled code references it from the data vector as if it were a true literal. +When a +.code load-time +top-level form is processed by +.codn compile-file , +it has no unusual semantics; the effect is that it is replaced by +its argument +.metn form , +which is in that case also considered a top-level form. + The implications of the translation scheme may be understood separately from the perspective of code processed with .codn compile-toplevel , @@ -67263,7 +67276,7 @@ in the compiled version of the function. A .code load-time -form appearing in an expression inside a file that is processed by +form appearing as a non-top-level form inside a file that is processed by .code compile-file is compiled along with that form and deposited into the object file. When the object file is loaded, each compiled top-level form is executed. |