diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-23 13:01:10 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-23 13:01:10 +0200 |
commit | 928a58ad7977c0e2e445fd9c16db5726cda789e0 (patch) | |
tree | cfa97b293213550253b268c59100e37f9246b4f1 /src/bytecode/chunk.h | |
parent | 9bb350e99370009a18df3c3b8f512d2c11168978 (diff) | |
download | bdl-928a58ad7977c0e2e445fd9c16db5726cda789e0.tar.gz bdl-928a58ad7977c0e2e445fd9c16db5726cda789e0.zip |
Add (buggy) initial compilation of arithmetic ops
Diffstat (limited to 'src/bytecode/chunk.h')
-rwxr-xr-x[-rw-r--r--] | src/bytecode/chunk.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bytecode/chunk.h b/src/bytecode/chunk.h index e3c7383..81fc4cc 100644..100755 --- a/src/bytecode/chunk.h +++ b/src/bytecode/chunk.h | |||
@@ -46,6 +46,11 @@ add_code(Chunk *chunk, u8 byte, size_t line, size_t col) { | |||
46 | 46 | ||
47 | size_t | 47 | size_t |
48 | add_constant(Chunk *chunk, Object obj) { | 48 | add_constant(Chunk *chunk, Object obj) { |
49 | // FIXME?: Since we are using a single byte to store constant indices, we | ||
50 | // can only have 256 stored constants. If we need more we may need to add | ||
51 | // another instruction OP_CONSTANT_16 to have at least two bytes for | ||
52 | // constants. Alternatively, we could make that the default. Either way, for | ||
53 | // now it's fine. | ||
49 | size_t pos = array_size(chunk->constants); | 54 | size_t pos = array_size(chunk->constants); |
50 | array_push(chunk->constants, obj); | 55 | array_push(chunk->constants, obj); |
51 | return pos; | 56 | return pos; |