1
0
Fork 0
forked from fun/fun

Added EXIT opcode to make it possible to return exit codes to the shell. (0.21.4)

This commit is contained in:
Johannes Findeisen 2025-10-04 13:02:29 +02:00
commit 9ac42c6ed1
8 changed files with 96 additions and 5 deletions

View file

@ -139,6 +139,8 @@ void vm_reset(VM *vm) {
}
// Clear output buffer
vm_clear_output(vm);
// Reset exit code
vm->exit_code = 0;
}
void vm_dump_globals(VM *vm) {
@ -180,6 +182,7 @@ void vm_init(VM *vm) {
vm->fp = -1;
vm->output_count = 0;
vm->instr_count = 0;
vm->exit_code = 0;
for (int i = 0; i < MAX_GLOBALS; ++i)
vm->globals[i] = make_nil();
}
@ -280,6 +283,7 @@ void vm_run(VM *vm, Bytecode *entry) {
#include "vm/core/call.c"
#include "vm/core/dup.c"
#include "vm/core/halt.c"
#include "vm/core/exit.c"
#include "vm/core/jump.c"
#include "vm/core/jump_if_false.c"
#include "vm/core/load_const.c"