aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/chunk.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-25 12:37:25 +0200
committerBad Diode <bd@badd10de.dev>2021-10-25 12:37:25 +0200
commitb9644b4ccda5abee01fd0704ddc42b08b68e5b5d (patch)
treeed7d94f6f6ca242574234305c8574797cc6d22b0 /src/bytecode/chunk.c
parente2c284b57641b5feec9a8d04313b0cd6d556e860 (diff)
downloadbdl-b9644b4ccda5abee01fd0704ddc42b08b68e5b5d.tar.gz
bdl-b9644b4ccda5abee01fd0704ddc42b08b68e5b5d.zip
Change chunk to store a name
Diffstat (limited to 'src/bytecode/chunk.c')
-rw-r--r--src/bytecode/chunk.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bytecode/chunk.c b/src/bytecode/chunk.c
index 3dc2421..8b87d0d 100644
--- a/src/bytecode/chunk.c
+++ b/src/bytecode/chunk.c
@@ -2,11 +2,13 @@
2#include "objects.h" 2#include "objects.h"
3 3
4Chunk * 4Chunk *
5chunk_init(void) { 5chunk_init(StringView name) {
6 Chunk *chunk = malloc(sizeof(Chunk)); 6 Chunk *chunk = malloc(sizeof(Chunk));
7 array_init(chunk->code, 0); 7 array_init(chunk->code, 0);
8 array_init(chunk->constants, 0); 8 array_init(chunk->constants, 0);
9 array_init(chunk->lines, 0); 9 array_init(chunk->lines, 0);
10 array_init(chunk->name, name.n);
11 array_insert(chunk->name, name.start, name.n);
10 return chunk; 12 return chunk;
11} 13}
12 14
@@ -19,6 +21,7 @@ chunk_free(Chunk *chunk) {
19 } 21 }
20 array_free(chunk->constants); 22 array_free(chunk->constants);
21 array_free(chunk->lines); 23 array_free(chunk->lines);
24 array_free(chunk->name);
22 free(chunk); 25 free(chunk);
23} 26}
24 27