better error handliung
This commit is contained in:
parent
aebe586a05
commit
f76c4f9af9
7 changed files with 80 additions and 43 deletions
14
src/vm.h
14
src/vm.h
|
|
@ -8,6 +8,7 @@
|
|||
#include "dictionary.h"
|
||||
#include "gc.h"
|
||||
#include "object.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
enum {
|
||||
OP_NOP = 0,
|
||||
|
|
@ -62,14 +63,17 @@ typedef struct Vm {
|
|||
Bc *chunk;
|
||||
Dt *dictionary;
|
||||
Ar arena;
|
||||
jmp_buf error;
|
||||
} Vm;
|
||||
|
||||
enum {
|
||||
VM_ERR_STACK_OVERFLOW = 1,
|
||||
VM_ERR_STACK_UNDERFLOW,
|
||||
VM_ERR_TYPE,
|
||||
VM_ERR_RUNTIME
|
||||
};
|
||||
|
||||
V vm_init(Vm *);
|
||||
V vm_deinit(Vm *);
|
||||
|
||||
V vm_push(Vm *, O);
|
||||
O vm_pop(Vm *);
|
||||
O vm_peek(Vm *);
|
||||
|
||||
I vm_run(Vm *, Bc *, I);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue