1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-28 14:17:42 +00:00

Make compilation simpler.

This commit is contained in:
bakpakin
2017-07-09 15:35:17 -04:00
parent 8810c65f00
commit 1878ece2af
4 changed files with 42 additions and 59 deletions

View File

@@ -83,14 +83,10 @@ static char *gst_getline() {
/* Compile and run an ast */
static int debug_compile_and_run(Gst *vm, GstValue ast, int64_t flags) {
GstCompiler c;
GstValue func;
/* Try to compile generated AST */
gst_compiler(&c, vm);
func = gst_wrap_function(gst_compiler_compile(&c, ast));
GstValue func = gst_compile(vm, vm->env, ast);
/* Check for compilation errors */
if (c.error.type != GST_NIL) {
printf_flags(flags, "31", "compiler error: %s\n", (const char *)gst_to_string(vm, c.error));
if (func.type != GST_FUNCTION) {
printf_flags(flags, "31", "compiler error: %s\n", (const char *)gst_to_string(vm, func));
return 1;
}
/* Execute function */