crafting-interpreters/clox/src/chunk.h

31 lines
481 B
C
Raw Normal View History

2021-07-08 11:24:24 +02:00
#ifndef clox_chunk_h
#define clox_chunk_h
#include "common.h"
#include "value.h"
typedef enum {
OP_CONSTANT,
2021-07-30 08:56:42 +02:00
OP_ADD,
OP_SUBTRACT,
OP_MULTIPLY,
OP_DIVIDE,
2021-07-30 08:38:20 +02:00
OP_NEGATE,
2021-07-08 11:24:24 +02:00
OP_RETURN,
} OpCode;
typedef struct {
int count;
int capacity;
2021-07-30 08:38:20 +02:00
uint8_t *code;
int *lines;
2021-07-08 11:24:24 +02:00
ValueArray constants;
} Chunk;
2021-07-30 08:38:20 +02:00
void initChunk(Chunk *chunk);
void freeChunk(Chunk *chunk);
void writeChunk(Chunk *chunk, uint8_t byte, int line);
int addConstant(Chunk *chunk, Value value);
2021-07-08 11:24:24 +02:00
#endif