roza/lib/Value.cpp

26 lines
431 B
C++

#include "Value.hpp"
namespace roza
{
/*explicit*/ Value::Value(int value, SrcLoc loc)
: m_type { std::make_shared<Type>(BaseType::TY_INT) }
, m_int_val { value }
, m_loc { loc }
{
}
/*virtual*/ Value::~Value()
{
}
std::string Value::string() const
{
if (m_type->equals(TY_INT))
{
return std::to_string(m_int_val);
}
assert("cannot stringify unknown value " && 0);
}
}