export module kym; import coral; import coral.math; export namespace kym { enum class value_type { nil, boolean, integer, scalar, vector2, vector3, object, }; struct value { value_type type{value_type::nil}; value() = default; value(bool boolean) { this->data[1] = 0xff * boolean; this->type = value_type::boolean; } value(coral::i64 integer) { (*reinterpret_cast(this->data)) = (*reinterpret_cast(&integer)); this->type = value_type::integer; } value(coral::f64 scalar) { (*reinterpret_cast(this->data)) = (*reinterpret_cast(&scalar)); this->type = value_type::scalar; } value(coral::vector2 vector2) { (*reinterpret_cast(this->data)) = (*reinterpret_cast(&vector2)); this->type = value_type::vector2; } value(coral::vector3 const & vector3) { coral::copy(this->data, coral::as_bytes(&vector3)); this->type = value_type::vector3; } coral::optional to_integer() const { if (this->type == value_type::integer) return (*reinterpret_cast(&this->data)); return {}; } private: coral::u8 data[12]{0}; }; };