summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-04 20:01:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-04 20:01:02 -0700
commit274cb70971d6a2cebcd887350b4b8602b32743d7 (patch)
tree07344e7330788fa23d35ad34b0a6bf48dcd97661 /eval.c
parent5484325557ee4201fd04772049145ad95ff7dbc4 (diff)
downloadtxr-274cb70971d6a2cebcd887350b4b8602b32743d7.tar.gz
txr-274cb70971d6a2cebcd887350b4b8602b32743d7.tar.bz2
txr-274cb70971d6a2cebcd887350b4b8602b32743d7.zip
Implement compiled file loading.
* eval.c (load): If open_txr_file indicates compiled file by setting txr_lisp_p to character #\o, use read_compiled_file. * match.c (v_load): Likewise. * parser.c (open_txr_file): Recognize the .tlo suffix, and also try to open a .tlo version of an unsuffixed file before trying it as .tl. Indicate a .tlo file by setting txr_lisp_p to the character #\o rather than t. (read_file_common): New static function, made from contents of read_eval_stream. Will either evaluate forms or load compiled code by instantiating virtual machine descriptions and performing their top-level execution. (read_eval_stream): Now a wrapper for read_file_common. (read_compiled_file): New function. * parser.h (read_compiled_file): Declared. * txr.c (help): List new --compiled option. (txr_main): If --compiled is specified, set txr_lisp_p to #\o to load as compiled code. Update error message that -c is not compatible with --lisp or --compiled. If txr_lisp_p is #\o, then use read_compiled_file.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index e16e8075..152006f3 100644
--- a/eval.c
+++ b/eval.c
@@ -4157,11 +4157,17 @@ val load(val target)
env_vbind(dyn_env, load_recursive_s, t);
env_vbind(dyn_env, package_s, cur_package);
- if (txr_lisp_p) {
+ if (txr_lisp_p == t) {
if (!read_eval_stream(stream, std_error)) {
close_stream(stream, nil);
uw_throwf(error_s, lit("load: ~a contains errors"), path, nao);
}
+ } else if (txr_lisp_p == chr('o')) {
+ if (!read_compiled_file(stream, std_error)) {
+ close_stream(stream, nil);
+ uw_throwf(error_s, lit("load: unable to load compiled file ~a"),
+ path, nao);
+ }
} else {
int gc = gc_state(0);
parser_t parser;