This commit is contained in:
Andre Wagner
2026-05-01 16:39:49 -05:00
parent bebaed1998
commit 0bc40cc562
9 changed files with 147 additions and 18 deletions

View File

@@ -10,9 +10,10 @@ using FunctionId = uint32_t;
enum class Type : uint8_t
{
Nil = 0, Integer, Float, String, Array, Table, Function, NativePointer,
Nil = 0, Integer, Float, String, Array, Table, Function, NativePointer, COUNT
};
std::string type_name(Type type);
class Value {
struct Function { FunctionId f_id; };
@@ -26,6 +27,8 @@ public:
static Value CreateString(std::string const& str) { return Value(str); }
static Value CreateFunctionId(FunctionId f_id) { return Value(Function { f_id }); }
static Value CreateIntegerFromBool(bool b) { return CreateInteger(b ? 1 : 0); }
[[nodiscard]] Type type() const;
[[nodiscard]] int32_t as_integer() const { return std::get<int32_t>(value_); }