aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/chunk.h
blob: 29dd99dcc997e23ecfb0ea42a9c04568d16d1d13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef BDL_CHUNK_H
#define BDL_CHUNK_H

#include "objects.h"
#include "darray.h"

typedef struct Chunk {
    u8 *code;
    Object *constants;
} Chunk;


size_t add_constant(Chunk chunk, Object obj);

size_t
add_constant(Chunk chunk, Object obj) {
    size_t pos = array_size(chunk.constants);
    array_push(chunk.constants, obj);
    return pos;
}

#endif // BDL_CHUNK_H