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:
2025-08-21 16:14:22 -05:00
commit 44c7626cd7
13 changed files with 286 additions and 0 deletions

15
include/memory.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef clox_memory_h
#define clox_memory_h
#include "common.h"
#define GROW_CAPACITY(capacity) ((capacity) < 8 ? 8 : (capacity) * 2)
#define GROW_ARRAY(type, pointer, oldCount, newCount) \
(type *)reallocate(pointer, sizeof(type) * (oldCount), \
sizeof(type) * (newCount))
#define FREE_ARRAY(type, pointer, oldCount) \
reallocate(pointer, sizeof(type) * oldCount, 0);
void *reallocate(void *pointer, size_t oldSize, size_t newSize);
#endif /* clox_memory_h */