summaryrefslogtreecommitdiffstats
path: root/match.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 /match.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 'match.c')
-rw-r--r--match.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/match.c b/match.c
index 10fd1770..15bb7e79 100644
--- a/match.c
+++ b/match.c
@@ -4310,7 +4310,11 @@ static val v_load(match_files_ctx *c)
} else {
uw_set_match_context(cons(c->spec, c->bindings));
- if (!read_eval_stream(stream, std_error)){
+ if (txr_lisp_p == chr('o') && !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 if (!read_eval_stream(stream, std_error)) {
close_stream(stream, nil);
sem_error(specline, lit("load: ~a contains errors"), path, nao);
}