clox/include/chunk.h

27 lines
438 B
C
Raw Normal View History

2024-08-31 17:41:43 +00:00
#ifndef CHUNK_INCLUDED
#define CHUNK_INCLUDED
#include "common.h"
2024-08-31 20:54:46 +00:00
#include "value.h"
2024-08-31 17:41:43 +00:00
typedef enum {
2024-08-31 20:54:46 +00:00
OP_CONSTANT,
2024-08-31 17:41:43 +00:00
OP_RETURN,
OP_COUNT,
}OpCode;
typedef struct {
int len;
int cap;
uint8_t* code;
2024-08-31 20:54:46 +00:00
int *lines;
ValueArray constants;
2024-08-31 17:41:43 +00:00
} Chunk;
void initChunk(Chunk *chunk);
void freeChunk(Chunk *chunk);
2024-08-31 20:54:46 +00:00
void writeChunk(Chunk *chunk, uint8_t byte,int line);
int addConstant(Chunk *chunk, Value value);
2024-08-31 17:41:43 +00:00
#endif