diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-04-04 20:01:02 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-04-04 20:01:02 -0700 |
commit | 274cb70971d6a2cebcd887350b4b8602b32743d7 (patch) | |
tree | 07344e7330788fa23d35ad34b0a6bf48dcd97661 /match.c | |
parent | 5484325557ee4201fd04772049145ad95ff7dbc4 (diff) | |
download | txr-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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); } |