clox/src/value.c
2024-08-31 15:54:46 -05:00

29 lines
669 B
C

#include <stdio.h>
#include "../include/memory.h"
#include "../include/value.h"
void initValueArray(ValueArray *array){
array->values = NULL;
array->cap = 0;
array->len = 0;
}
void writeValueArray(ValueArray *array, Value value){
if(array->cap < array->len+1){
int oldCap = array->cap;
array->cap = GROW_CAP(oldCap);
array->values = GROW_ARRAY(Value,array->values,oldCap, array->cap);
}
array->values[array->len] = value;
array->len ++;
}
void freeValueArray(ValueArray *array){
FREE_ARRAY(Value, array->values,array->cap);
initValueArray(array);
}
void printValue(Value value){
printf("%g",value);
}