aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/chunk.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-23 13:01:10 +0200
committerBad Diode <bd@badd10de.dev>2021-10-23 13:01:10 +0200
commit928a58ad7977c0e2e445fd9c16db5726cda789e0 (patch)
treecfa97b293213550253b268c59100e37f9246b4f1 /src/bytecode/chunk.h
parent9bb350e99370009a18df3c3b8f512d2c11168978 (diff)
downloadbdl-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.h5
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
47size_t 47size_t
48add_constant(Chunk *chunk, Object obj) { 48add_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;