From b9644b4ccda5abee01fd0704ddc42b08b68e5b5d Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Mon, 25 Oct 2021 12:37:25 +0200 Subject: Change chunk to store a name --- src/bytecode/chunk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/bytecode/chunk.c') 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 @@ #include "objects.h" Chunk * -chunk_init(void) { +chunk_init(StringView name) { Chunk *chunk = malloc(sizeof(Chunk)); array_init(chunk->code, 0); array_init(chunk->constants, 0); array_init(chunk->lines, 0); + array_init(chunk->name, name.n); + array_insert(chunk->name, name.start, name.n); return chunk; } @@ -19,6 +21,7 @@ chunk_free(Chunk *chunk) { } array_free(chunk->constants); array_free(chunk->lines); + array_free(chunk->name); free(chunk); } -- cgit v1.2.1