diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-04-03 06:16:35 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-04-03 06:16:35 -0700 |
commit | eb25dece0352e65855499ca13f01585875693e28 (patch) | |
tree | 77e40849f0e186736110d85c80f8294f872b4e81 | |
parent | 1f6d6acb5b8ed75776249d3032477050ebb92a9a (diff) | |
download | txr-eb25dece0352e65855499ca13f01585875693e28.tar.gz txr-eb25dece0352e65855499ca13f01585875693e28.tar.bz2 txr-eb25dece0352e65855499ca13f01585875693e28.zip |
eval/compile: special ops compile-only & eval-only.
These forms will be specially recognized by the file compiler
when they appear as top-level forms. eval-only will mean this:
only execute this form (possibly after compiling it);
do not emit any compiled code into the output file.
compile-only will mean: only emit the compiled code into the
output file; do not execute it.
* eval.c (eval_init): Register special operators compile-only
and eval-only. In the interpreter, these are equivalent to
progn and so route to op_progn.
* share/txr/stdlib/compiler.tl (compiler compile): Similarly
to interpreter, handle compile-only and eval-only as progn.
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | share/txr/stdlib/compiler.tl | 2 |
2 files changed, 3 insertions, 1 deletions
@@ -6062,6 +6062,8 @@ void eval_init(void) reg_op(prof_s, op_prof); reg_op(switch_s, op_switch); reg_op(intern(lit("upenv"), system_package), op_upenv); + reg_op(intern(lit("compile-only"), user_package), op_progn); + reg_op(intern(lit("eval-only"), user_package), op_progn); reg_mac(defvar_s, func_n2(me_def_variable)); reg_mac(defparm_s, func_n2(me_def_variable)); diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 907055ad..04ba74ac 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -216,7 +216,7 @@ (fun me.(comp-fun oreg env form)) (sys:for-op me.(comp-for oreg env form)) (sys:each-op me.(compile oreg env (expand-each form env))) - (progn me.(comp-progn oreg env (cdr form))) + ((progn eval-only compile-only) me.(comp-progn oreg env (cdr form))) (and me.(comp-and-or oreg env form)) (or me.(comp-and-or oreg env form)) (prog1 me.(comp-prog1 oreg env form)) |