frontend: implement function compilation

This commit is contained in:
2026-05-30 19:53:49 +01:00
parent 28abb4d2d3
commit 0697d889c5
+27 -6
View File
@@ -107,15 +107,34 @@ int main(int argc, const char **argv)
printf("----\n"); printf("----\n");
bshell_scriptblock_clear_text(block); bshell_scriptblock_clear_text(block);
bshell_compile(node, block); switch (node->n_type) {
print_scriptblock(block, 0); case BSHELL_AST_FUNC: {
bshell_function *func = NULL;
fx_value result = bshell_runtime_eval_global(rt, block); bshell_compile_function(node, &func);
if (result.v_type != NULL) { print_function(func);
format_value_default(&result, fx_stdout); bshell_runtime_define_function(rt, func);
bshell_function_unref(func);
break;
} }
default: {
bshell_compile(node, block);
print_scriptblock(block, 0);
fx_value result = bshell_runtime_eval_global(rt, block);
if (result.v_type != NULL) {
format_value_default(&result, fx_stdout);
}
break;
}
}
bshell_ast_node_destroy(node);
} }
bshell_runtime_destroy(rt);
bshell_scriptblock_unref(block);
bshell_parse_ctx_cleanup(&parse); bshell_parse_ctx_cleanup(&parse);
bshell_lex_ctx_cleanup(&lex); bshell_lex_ctx_cleanup(&lex);
@@ -129,5 +148,7 @@ int main(int argc, const char **argv)
bshell_file_close(file); bshell_file_close(file);
} }
bshell_cleanup_all_verbs();
return 0; return 0;
} }