diff options
author | Bad Diode <bd@badd10de.dev> | 2021-10-22 10:34:25 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-10-22 10:34:25 +0200 |
commit | 33372512fc32c26913c8385637d20f6d98c8376c (patch) | |
tree | 9aa30e3e376d4769e858c37c912866dfdb4b4a62 /src/bytecode/chunk.h | |
parent | eeff5e273f22aa28e81ab080e9ffdce85ac394b8 (diff) | |
download | bdl-33372512fc32c26913c8385637d20f6d98c8376c.tar.gz bdl-33372512fc32c26913c8385637d20f6d98c8376c.zip |
Add constants operation
Diffstat (limited to 'src/bytecode/chunk.h')
-rw-r--r-- | src/bytecode/chunk.h | 22 |
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 | |||
7 | typedef struct Chunk { | ||
8 | u8 *code; | ||
9 | Object *constants; | ||
10 | } Chunk; | ||
11 | |||
12 | |||
13 | size_t add_constant(Chunk chunk, Object obj); | ||
14 | |||
15 | size_t | ||
16 | add_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 | ||