30 lines
470 B
C++
30 lines
470 B
C++
|
#ifndef jk_VALUE_HPP
|
||
|
#define jk_VALUE_HPP
|
||
|
|
||
|
#include "commons.hpp"
|
||
|
|
||
|
namespace jk
|
||
|
{
|
||
|
class Type;
|
||
|
|
||
|
class Value
|
||
|
{
|
||
|
public:
|
||
|
static std::shared_ptr<Value> make_nil();
|
||
|
static std::shared_ptr<Value> make_int(int val);
|
||
|
|
||
|
explicit Value() = default;
|
||
|
virtual ~Value() = default;
|
||
|
|
||
|
int as_int() const { return *m_int_val; }
|
||
|
|
||
|
std::weak_ptr<Type> type() const;
|
||
|
|
||
|
private:
|
||
|
std::shared_ptr<Type> m_type;
|
||
|
std::optional<int> m_int_val;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif
|