#ifndef BDL_CHUNK_H #define BDL_CHUNK_H #include "darray.h" #include "string_view.h" typedef struct Object Object; typedef struct LineInfo { size_t line; size_t col; } LineInfo; typedef struct Chunk { // Program code. u8 *code; // Compile time constants. Object *constants; // Contains debugging information for every code operation. LineInfo *lines; // Chunk name. char *name; // Number of locals and parameters. size_t n_params; size_t n_locals; } Chunk; #define NEW_CHUNK(NAME) chunk_init((StringView){(NAME), sizeof(NAME) - 1}) Chunk * chunk_init(StringView name); void add_code(Chunk *chunk, u8 byte, size_t line, size_t col); size_t add_constant(Chunk *chunk, Object obj); void chunk_free(Chunk *chunk); #endif // BDL_CHUNK_H