#ifndef TSL_VALUE_H #define TSL_VALUE_H #include "forward_decl.h" #include #include #include "string_view.h" #include "std_gc/list.h" #include "std_gc/hash_map.h" typedef enum { TSL_TYPE_NULL, TSL_TYPE_NUMBER, TSL_TYPE_STRING, TSL_TYPE_STRING_VIEW, TSL_TYPE_BOOL, TSL_TYPE_LIST, TSL_TYPE_MAP, TSL_TYPE_FUNCTION, TSL_TYPE_USERDATA } TslType; /* TODO: Support BigInt */ typedef double TslNumber; typedef enum { TSL_FALSE, TSL_TRUE } TslBool; typedef struct { uint8_t *data; size_t size; } TslString; /* This is an index to the function */ typedef int TslFunction; struct TslValue { union { TslNumber number; TslString *string; TslStringView string_view; TslBool boolean; TslBool null; TslList *list; TslHashMap *map; TslFunction function; void *userdata; } data; uint8_t type; }; 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 */