~maelkum/viuavm

1f57b4bf388fd3e0a16771eb0e9147d7b8767202 — Marek Marecki 5 days ago 93fe887
Stringify boxed versions of unboxed types
2 files changed, 35 insertions(+), 4 deletions(-)

M new/include/viua/vm/types.h
M new/src/vm/types.cpp
M new/include/viua/vm/types.h => new/include/viua/vm/types.h +16 -4
@@ 33,7 33,9 @@
 * the instrucpection interfaces provided by Viua.
 */
namespace viua::vm::types {
struct Signed_integer : Value {
struct Signed_integer
        : Value
        , traits::To_string {
    using value_type = int64_t;
    value_type value{};



@@ 41,8 43,11 @@ struct Signed_integer : Value {
    {}

    auto type_name() const -> std::string override;
    auto to_string() const -> std::string override;
};
struct Unsigned_integer : Value {
struct Unsigned_integer
        : Value
        , traits::To_string {
    using value_type = uint64_t;
    value_type value{};



@@ 50,8 55,11 @@ struct Unsigned_integer : Value {
    {}

    auto type_name() const -> std::string override;
    auto to_string() const -> std::string override;
};
struct Float_single : Value {
struct Float_single
        : Value
        , traits::To_string {
    using value_type = float;
    value_type value{};



@@ 59,8 67,11 @@ struct Float_single : Value {
    {}

    auto type_name() const -> std::string override;
    auto to_string() const -> std::string override;
};
struct Float_double : Value {
struct Float_double
        : Value
        , traits::To_string {
    using value_type = double;
    value_type value{};



@@ 68,6 79,7 @@ struct Float_double : Value {
    {}

    auto type_name() const -> std::string override;
    auto to_string() const -> std::string override;
};
}  // namespace viua::vm::types


M new/src/vm/types.cpp => new/src/vm/types.cpp +19 -0
@@ 19,18 19,37 @@ auto Signed_integer::type_name() const -> std::string
{
    return "int";
}
auto Signed_integer::to_string() const -> std::string
{
    return std::to_string(value);
}

auto Unsigned_integer::type_name() const -> std::string
{
    return "uint";
}
auto Unsigned_integer::to_string() const -> std::string
{
    return std::to_string(value);
}

auto Float_single::type_name() const -> std::string
{
    return "float";
}
auto Float_single::to_string() const -> std::string
{
    return std::to_string(value);
}

auto Float_double::type_name() const -> std::string
{
    return "double";
}
auto Float_double::to_string() const -> std::string
{
    return std::to_string(value);
}
}  // namespace viua::vm::types

namespace viua::vm::types {