aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/chunk.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytecode/chunk.h')
-rw-r--r--src/bytecode/chunk.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bytecode/chunk.h b/src/bytecode/chunk.h
new file mode 100644
index 0000000..29dd99d
--- /dev/null
+++ b/src/bytecode/chunk.h
@@ -0,0 +1,22 @@
1#ifndef BDL_CHUNK_H
2#define BDL_CHUNK_H
3
4#include "objects.h"
5#include "darray.h"
6
7typedef struct Chunk {
8 u8 *code;
9 Object *constants;
10} Chunk;
11
12
13size_t add_constant(Chunk chunk, Object obj);
14
15size_t
16add_constant(Chunk chunk, Object obj) {
17 size_t pos = array_size(chunk.constants);
18 array_push(chunk.constants, obj);
19 return pos;
20}
21
22#endif // BDL_CHUNK_H