roza/lib/Value.hpp

35 lines
654 B
C++

#ifndef roza_VALUE_HPP
#define roza_VALUE_HPP
#include "commons.hpp"
#include "SrcLoc.hpp"
#include "Type.hpp"
namespace roza
{
class Value
{
public:
explicit Value(int value, SrcLoc loc);
explicit Value(bool value, SrcLoc loc);
virtual ~Value();
SrcLoc loc() const { return m_loc; }
int as_int() const { return m_int_val; }
bool as_bool() const { return m_bool_val; }
std::shared_ptr<Type> type() const { return m_type; }
std::string string() const;
bool equals(Value const& rhs) const;
private:
std::shared_ptr<Type> m_type;
int m_int_val;
bool m_bool_val;
SrcLoc m_loc;
};
}
#endif