clox/include/chunk.h
2024-09-02 17:15:41 -05:00

34 lines
592 B
C

#ifndef CHUNK_INCLUDED
#define CHUNK_INCLUDED
#include "common.h"
#include "value.h"
typedef enum {
OP_CONSTANT_LONG,
OP_CONSTANT,
OP_ADD,
OP_SUBTRACT,
OP_MULTIPLY,
OP_DIVIDE,
OP_NEGATE,
OP_RETURN,
OP_COUNT,
}OpCode;
typedef struct {
int len;
int cap;
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);
void writeConstant(Chunk *chunk, Value value,int line);
int addConstant(Chunk *chunk, Value value);
#endif