From 42f020977e7c83d24cc7a81f0a75c51da4ca099b Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Mon, 29 Jun 2026 20:43:00 +0200 Subject: [PATCH] feat: introduce more integer thing types Closes: #31 --- furc/src/main.cpp | 2 +- furvm/include/furvm/thing.hpp | 42 ++++++++++++++++++++++++++++++----- furvm/src/main.cpp | 2 +- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/furc/src/main.cpp b/furc/src/main.cpp index 313892f..d370a17 100644 --- a/furc/src/main.cpp +++ b/furc/src/main.cpp @@ -68,7 +68,7 @@ int main(void) { file.close(); furvmMod->set_native_function("print", - [](furvm::executor& executor) { std::cout << executor.load_thing(0)->get() << '\n'; }); + [](furvm::executor& executor) { std::cout << executor.load_thing(0)->integer() << '\n'; }); furvm::executor_h executor = context->emplace_executor(context); executor->push_frame(furvmMod, *furvmMod->function_at("main")); diff --git a/furvm/include/furvm/thing.hpp b/furvm/include/furvm/thing.hpp index eda6f28..58f5419 100644 --- a/furvm/include/furvm/thing.hpp +++ b/furvm/include/furvm/thing.hpp @@ -27,13 +27,31 @@ struct thing_type { std::uint64_t value; }; -using int_t = std::int32_t; /**< A 4-byte integer. */ +using byte_t = std::int8_t; /**< A 1-byte integer. */ +using short_t = std::int16_t; /**< A 2-byte integer. */ +using int_t = std::int32_t; /**< A 4-byte integer. */ +using long_t = std::int64_t; /**< An 8-byte integer. */ + +/** + * @brief A 1-byte integer thing type. + */ +static constexpr thing_type ByteType = { thing_type_t::Primitive, sizeof(byte_t) }; + +/** + * @brief A 2-byte integer thing type. + */ +static constexpr thing_type ShortType = { thing_type_t::Primitive, sizeof(short_t) }; /** * @brief A 4-byte integer thing type. */ static constexpr thing_type IntType = { thing_type_t::Primitive, sizeof(int_t) }; +/** + * @brief An 8-byte integer thing type. + */ +static constexpr thing_type LongType = { thing_type_t::Primitive, sizeof(long_t) }; + template