diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-22 12:37:37 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-22 12:37:37 +0200 |
commit | 3b136ffdebf135cc0d285573edd7bdfefb99bb00 (patch) | |
tree | b66f9cf7410c43c6967b69002e0998d87f880f97 /src/bytecode/main.c | |
parent | 9286c148f601072dded92233a328a8867ff7ab0c (diff) | |
download | bdl-3b136ffdebf135cc0d285573edd7bdfefb99bb00.tar.gz bdl-3b136ffdebf135cc0d285573edd7bdfefb99bb00.zip |
Add unary arithmetic operations for numbers
Diffstat (limited to 'src/bytecode/main.c')
-rw-r--r-- | src/bytecode/main.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/bytecode/main.c b/src/bytecode/main.c index 5081d95..66089c0 100644 --- a/src/bytecode/main.c +++ b/src/bytecode/main.c | |||
@@ -38,10 +38,16 @@ process_source(const StringView *source) { | |||
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | 40 | ||
41 | // Push some test instructions. | 41 | size_t const_a = add_constant(vm.chunk, 7); |
42 | size_t const_idx = add_constant(vm.chunk, 7); | ||
43 | add_code(vm.chunk, OP_CONSTANT, 1, 1); | 42 | add_code(vm.chunk, OP_CONSTANT, 1, 1); |
44 | add_code(vm.chunk, const_idx, 1, 1); | 43 | add_code(vm.chunk, const_a, 1, 1); |
44 | size_t const_b = add_constant(vm.chunk, 2); | ||
45 | add_code(vm.chunk, OP_CONSTANT, 1, 2); | ||
46 | add_code(vm.chunk, const_b, 1, 2); | ||
47 | |||
48 | // Arithmetic. | ||
49 | add_code(vm.chunk, OP_MOD, 1, 3); | ||
50 | |||
45 | add_code(vm.chunk, OP_RETURN, 1, 1); | 51 | add_code(vm.chunk, OP_RETURN, 1, 1); |
46 | 52 | ||
47 | vm_interpret(vm); | 53 | vm_interpret(vm); |