// // Created by 李晓明 on 2023/6/14. // #ifndef CLOX__CHUNK_H_ #define CLOX__CHUNK_H_ #include "common.h" typedef enum { OP_RETURN, } OpCode; //============================================================================ // Dynamic array of instructions 扩容步骤 //1. Allocate a new array with more capacity. //2. Copy the existing elements from the old array to the new one. //3. Store the new capacity. //4. Delete the old array. //5. Update code to point to the new array. //6. Store the element in the new array now that there is room. //7. Update the count. //============================================================================ typedef struct { int count; // 使用量 int capacity; // 容量 uint8_t *code;// unsigned char* } Chunk; void initChunk(Chunk *chunk); void freeChunk(Chunk* chunk); void writeChunk(Chunk *chunk, uint8_t byte); #endif//CLOX__CHUNK_H_