diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-26 08:55:12 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-26 08:55:12 +0200 |
commit | 9f1f2ff307bb3da8bfc6809ae05be589e1e37ed9 (patch) | |
tree | e58427f27162f673903c480e7858d77c3a9f6b23 /src/bytecode/vm.h | |
parent | 46356365270b71be94097b3c408d5f35a9ebd6ed (diff) | |
download | bdl-9f1f2ff307bb3da8bfc6809ae05be589e1e37ed9.tar.gz bdl-9f1f2ff307bb3da8bfc6809ae05be589e1e37ed9.zip |
Add OP_DROP and improve error reporting
Diffstat (limited to 'src/bytecode/vm.h')
-rwxr-xr-x | src/bytecode/vm.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bytecode/vm.h b/src/bytecode/vm.h index 63eedfa..d654e2c 100755 --- a/src/bytecode/vm.h +++ b/src/bytecode/vm.h | |||
@@ -64,7 +64,8 @@ vm_reset(VM *vm) { | |||
64 | .value = ERR_WRONG_ARG_TYPE, \ | 64 | .value = ERR_WRONG_ARG_TYPE, \ |
65 | .line = frame->chunk->lines[vm->pc - frame->chunk->code - 1].line, \ | 65 | .line = frame->chunk->lines[vm->pc - frame->chunk->code - 1].line, \ |
66 | .col = frame->chunk->lines[vm->pc - frame->chunk->code - 1].col, \ | 66 | .col = frame->chunk->lines[vm->pc - frame->chunk->code - 1].col, \ |
67 | }) | 67 | }); \ |
68 | return | ||
68 | 69 | ||
69 | #define SYMBOL_NOT_FOUND_ERR() \ | 70 | #define SYMBOL_NOT_FOUND_ERR() \ |
70 | error_push((Error){ \ | 71 | error_push((Error){ \ |
@@ -268,6 +269,9 @@ vm_interpret(VM *vm) { | |||
268 | array_head(vm->frames)->size--; | 269 | array_head(vm->frames)->size--; |
269 | frame = &vm->frames[array_size(vm->frames) - 1]; | 270 | frame = &vm->frames[array_size(vm->frames) - 1]; |
270 | } break; | 271 | } break; |
272 | case OP_DROP: { | ||
273 | array_head(vm->stack)->size = 0; | ||
274 | } break; | ||
271 | default: { | 275 | default: { |
272 | error_push((Error){ | 276 | error_push((Error){ |
273 | .type = ERR_TYPE_RUNTIME, | 277 | .type = ERR_TYPE_RUNTIME, |