Finish Chapter 14
Implements code chunks, a couple of basic opcodes, constants, and basic execution of those opcodes. Signed-off-by: Daniel Henry <iamdanhenry@gmail.com>
This commit is contained in:
25
include/chunk.h
Normal file
25
include/chunk.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef clox_chunk_h
|
||||
#define clox_chunk_h
|
||||
|
||||
#include "common.h"
|
||||
#include "value.h"
|
||||
|
||||
typedef enum {
|
||||
OP_CONSTANT,
|
||||
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 */
|
||||
Reference in New Issue
Block a user