1
0
Fork 0
forked from fun/fun

Jump into REPL when executing with --repl-on-error and an error occurs, when the REPL is builtin you will have access to the full stack then. (0.25.0)

This commit is contained in:
Johannes Findeisen 2025-10-06 04:10:36 +02:00
commit c71857a068
9 changed files with 309 additions and 7 deletions

View file

@ -49,7 +49,7 @@ typedef struct {
Value locals[MAX_FRAME_LOCALS];
} Frame;
typedef struct {
struct VM {
Value stack[STACK_SIZE];
int sp;
@ -68,7 +68,11 @@ typedef struct {
int exit_code; // process exit code set by OP_EXIT
int trace_enabled; // when non-zero, print executed ops and stack
} VM;
int repl_on_error; // when non-zero, enter REPL on runtime error (preserve stack)
int (*on_error_repl)(struct VM *vm); // optional hook to run REPL on error
};
typedef struct VM VM;
// initialize VM (zero state)
void vm_init(VM *vm);