From 928a58ad7977c0e2e445fd9c16db5726cda789e0 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 23 Oct 2021 13:01:10 +0200 Subject: Add (buggy) initial compilation of arithmetic ops --- src/bytecode/chunk.h | 5 +++++ 1 file changed, 5 insertions(+) mode change 100644 => 100755 src/bytecode/chunk.h (limited to 'src/bytecode/chunk.h') diff --git a/src/bytecode/chunk.h b/src/bytecode/chunk.h old mode 100644 new mode 100755 index e3c7383..81fc4cc --- 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) { size_t add_constant(Chunk *chunk, Object obj) { + // FIXME?: Since we are using a single byte to store constant indices, we + // can only have 256 stored constants. If we need more we may need to add + // another instruction OP_CONSTANT_16 to have at least two bytes for + // constants. Alternatively, we could make that the default. Either way, for + // now it's fine. size_t pos = array_size(chunk->constants); array_push(chunk->constants, obj); return pos; -- cgit v1.2.1