lox/clox/chunk.h
Adnan Ioricce 9b87a0d9c0 [Chapter18&TypesOfValues] - Following up chapter 18
- A bug was found when trying to run the following expression:
- ```lox
!(5 - 4 > 3 * 2 == !nil)
```
2024-10-18 13:24:47 -03:00

38 lines
561 B
C

#ifndef clox_chunk_h
#define clox_chunk_h
#include "common.h"
#include "value.h"
typedef enum {
OP_CONSTANT,
OP_NIL,
OP_TRUE,
OP_FALSE,
OP_EQUAL,
OP_GREATER,
OP_LESS,
OP_RETURN,
OP_NEGATE,
OP_ADD,
OP_SUBTRACT,
OP_MULTIPLY,
OP_DIVIDE,
OP_NOT,
} 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