~maelkum/viuavm

43b87f452084a321f9c75020956afae5dc807fe6 — Marek Marecki 5 days ago 1f57b4b
Stringify pointers

The stringification should only be done for VALID pointers in the final
implementation, but for the purposes of this prototype assume all
pointers are valid.
2 files changed, 12 insertions(+), 1 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 +4 -1
@@ 92,7 92,9 @@ struct Float_double
 * area which is a register.
 */
namespace viua::vm::types {
struct Pointer : Value {
struct Pointer
        : Value
        , traits::To_string {
    using value_type = Value*;
    value_type value;



@@ 100,6 102,7 @@ struct Pointer : Value {
    {}

    auto type_name() const -> std::string override;
    auto to_string() const -> std::string override;
};

struct String

M new/src/vm/types.cpp => new/src/vm/types.cpp +8 -0
@@ 57,6 57,14 @@ auto Pointer::type_name() const -> std::string
{
    return ('*' + value->type_name());
}
auto Pointer::to_string() const -> std::string
{
    return value->as_trait<traits::To_string, std::string>(
        [](traits::To_string const& ts) -> std::string {
            return ts.to_string();
        },
        type_name());
}

auto String::type_name() const -> std::string
{