#ifndef MK_VALUE_H #define MK_VALUE_H #include "commons.h" #include "native.h" #include "array.h" #define TYPE_KIND(G) \ G(TY_INT), G(TY_FLOAT), G(TY_BOOL), \ G(TY_STRING), G(TY_SYMBOL), G(TY_REF), \ G(TY_NATIVE), G(TY_LAZY), G(TY_ARRAY) MK_ENUM_H(TypeKind, TYPE_KIND); union value_data { int integer; float real; bool boolean; char* str; char* sym; size_t ref; struct native* native; struct node* lazy; struct array* array; }; struct value { union value_data data; TypeKind type; int line; }; void value_init_int(struct value* self, int value, int line); void value_init_float(struct value* self, float value, int line); void value_init_bool(struct value* self, bool value, int line); void value_init_string(struct value* self, char const* value, int line); void value_init_symbol(struct value* self, char const* value, int line); void value_init_ref(struct value* self, size_t value, int line); void value_init_native(struct value* self, struct native* value, int line); void value_init_lazy(struct value* self, struct node* value, int line); void value_init_array(struct value* self, struct vec* new_values, int line); size_t value_str(struct value* self, char* buffer, size_t size, struct moka* moka); bool value_is_eqv(struct value* self, struct value* rhs, struct moka* moka); void value_free(struct value* self); #endif