50 lines
692 B
C++
50 lines
692 B
C++
export module kym;
|
|
|
|
import core;
|
|
import core.lalgebra;
|
|
|
|
export namespace kym {
|
|
enum class value_type {
|
|
nil,
|
|
boolean,
|
|
integer,
|
|
scalar,
|
|
vector2,
|
|
vector3,
|
|
object,
|
|
};
|
|
|
|
struct value {
|
|
value_type type;
|
|
|
|
union {
|
|
bool boolean;
|
|
|
|
core::i64 integer;
|
|
|
|
core::f64 scalar;
|
|
|
|
core::vector2 vector2;
|
|
|
|
core::vector3 vector3;
|
|
|
|
void * object;
|
|
} as;
|
|
|
|
core::optional<core::u16> as_u16() const {
|
|
if ((this->type == value_type::integer) &&
|
|
(this->as.integer >= 0) && (this->as.integer <= core::u16_max)) {
|
|
|
|
return static_cast<core::u16>(this->as.integer);
|
|
}
|
|
|
|
return {};
|
|
}
|
|
};
|
|
|
|
value nil = {
|
|
.type = value_type::nil,
|
|
.as = {.object = nullptr},
|
|
};
|
|
};
|