roza/lib/Value.hpp

42 lines
828 B
C++
Raw Permalink Normal View History

2023-08-30 18:06:26 +00:00
#ifndef roza_VALUE_HPP
#define roza_VALUE_HPP
#include "commons.hpp"
#include "SrcLoc.hpp"
#include "Type.hpp"
namespace roza
{
2023-09-01 20:38:12 +00:00
class Fun;
2023-08-30 18:06:26 +00:00
class Value
{
public:
explicit Value(int value, SrcLoc loc);
2023-08-31 09:07:03 +00:00
explicit Value(bool value, SrcLoc loc);
2023-09-01 20:38:12 +00:00
explicit Value(std::shared_ptr<Fun> value, SrcLoc loc);
2023-08-30 18:06:26 +00:00
virtual ~Value();
2023-08-30 22:31:19 +00:00
SrcLoc loc() const { return m_loc; }
2023-08-31 09:07:03 +00:00
2023-08-30 22:31:19 +00:00
int as_int() const { return m_int_val; }
2023-08-31 09:07:03 +00:00
bool as_bool() const { return m_bool_val; }
2023-09-01 20:38:12 +00:00
std::shared_ptr<Fun> as_fun() const { return m_fun_val; }
2023-08-31 09:07:03 +00:00
2023-08-30 18:06:26 +00:00
std::shared_ptr<Type> type() const { return m_type; }
std::string string() const;
2023-08-31 09:37:13 +00:00
bool equals(Value const& rhs) const;
2023-08-30 18:06:26 +00:00
private:
std::shared_ptr<Type> m_type;
int m_int_val;
2023-08-31 09:07:03 +00:00
bool m_bool_val;
2023-09-01 20:38:12 +00:00
std::shared_ptr<Fun> m_fun_val;
2023-08-30 18:06:26 +00:00
SrcLoc m_loc;
2023-09-01 20:38:12 +00:00
2023-08-30 18:06:26 +00:00
};
}
#endif