Files
clox/include/chunk.h
Daniel Henry 8df0ffb7e5 Finish Chapter 15
Implement a basic VM that is capable of simple math.

Signed-off-by: Daniel Henry <iamdanhenry@gmail.com>
2025-08-21 20:30:02 -05:00

31 lines
500 B
C

#ifndef clox_chunk_h
#define clox_chunk_h
#include "common.h"
#include "value.h"
typedef enum {
OP_CONSTANT,
OP_ADD,
OP_SUBTRACT,
OP_MULTIPLY,
OP_DIVIDE,
OP_NEGATE,
OP_RETURN,
} OpCode;
typedef struct {
int count;
int capacity;
uint8_t *code;
int *lines;
ValueArray constants;
} Chunk;
void initChunk(Chunk *chunk);
void freeChunk(Chunk *chunk);
void writeChunk(Chunk *chunk, uint8_t byte, int line);
int addConstant(Chunk *chunk, Value value);
#endif /* clox_chunk_h */