Add initial implementation of types and values.

This commit is contained in:
2018-04-12 23:54:58 -07:00
parent d146b71e56
commit af87c6646d
5 changed files with 101 additions and 1 deletions

10
src/type.c Normal file
View File

@@ -0,0 +1,10 @@
#include "type.h"
libab_result libab_type_init(libab_type* type, libab_basetype* base) {
type->base = base;
return libab_ref_vec_init(&type->params);
}
void libab_type_free(libab_type* type) {
libab_ref_vec_free(&type->params);
}

15
src/value.c Normal file
View File

@@ -0,0 +1,15 @@
#include "value.h"
void libab_value_init(libab_value* value, void* data, libab_ref* type) {
value->data = data;
libab_ref_copy(type, &value->type);
}
void libab_value_free(libab_value* value) {
void (*free_function)(void*);
libab_type* value_type;
libab_ref_free(&value->type);
value_type = libab_ref_get(&value->type);
free_function = value_type->base->free_function;
if(free_function) free_function(value->data);
}