VM basics (#5)
Co-authored-by: Andre Wagner <WagnerAndre@JohnDeere.com> Reviewed-on: https://192.168.5.48/andre/tyche/pulls/5
This commit was merged in pull request #5.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "../common/overloaded.hh"
|
||||
|
||||
namespace tyche {
|
||||
namespace tyche::vm {
|
||||
|
||||
Type Value::type() const
|
||||
{
|
||||
@@ -11,6 +11,18 @@ Type Value::type() const
|
||||
[](int32_t) { return Type::Integer; },
|
||||
[](float) { return Type::Float; },
|
||||
[](std::string const&) { return Type::String; },
|
||||
[](Function const&) { return Type::Function; },
|
||||
}, value_);
|
||||
}
|
||||
|
||||
std::string Value::to_string() const
|
||||
{
|
||||
return std::visit(overloaded {
|
||||
[](std::monostate) { return std::string("nil"); },
|
||||
[](int32_t i) { return std::to_string(i); },
|
||||
[](float f) { return std::to_string(f); },
|
||||
[](std::string const& s) { return s; },
|
||||
[](Function const& f) { return "@" + std::to_string(f.f_id); }
|
||||
}, value_);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user