From 7a1dd1a0c404e10fa1c41006486fde3488c4e69a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 3 Apr 2018 06:16:35 -0700 Subject: 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. --- eval.c | 2 ++ share/txr/stdlib/compiler.tl | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index 6880a457..73efc9e3 100644 --- a/eval.c +++ b/eval.c @@ -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)) -- cgit v1.2.3