diff options
Diffstat (limited to 'include/value.h')
-rw-r--r-- | include/value.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/include/value.h b/include/value.h index e26cc4a..d9c6354 100644 --- a/include/value.h +++ b/include/value.h @@ -1,9 +1,12 @@ #ifndef TSL_VALUE_H #define TSL_VALUE_H +#include "forward_decl.h" #include <stddef.h> #include <stdint.h> #include "string_view.h" +#include "std_gc/list.h" +#include "std_gc/hash_map.h" typedef enum { TSL_TYPE_NULL, @@ -13,6 +16,7 @@ typedef enum { TSL_TYPE_BOOL, TSL_TYPE_LIST, TSL_TYPE_MAP, + TSL_TYPE_FUNCTION, TSL_TYPE_USERDATA } TslType; @@ -29,32 +33,29 @@ typedef struct { size_t size; } TslString; -/* TODO: Implement this */ -typedef struct { - void *data; - size_t size; -} TslList; - -/* TODO: Implement this */ -typedef struct { - void *data; -} TslMap; +/* This is an index to the function */ +typedef int TslFunction; -typedef struct { +struct TslValue { union { TslNumber number; TslString *string; TslStringView string_view; TslBool boolean; + TslBool null; TslList *list; - TslMap *map; + TslHashMap *map; + TslFunction function; void *userdata; } data; uint8_t type; -} TslValue; +}; uint64_t tsl_value_hash(const TslValue *value); /* Returns 1 if equal, otherwise returns 0 */ int tsl_value_equals(const TslValue *lhs, const TslValue *rhs); +/* This should be called before setting/modifying the data of the value */ +void tsl_value_clear(TslValue *self); + #endif /* TSL_VALUE_H */ |