#ifndef jk_VALUE_HPP #define jk_VALUE_HPP #include "commons.hpp" namespace jk { class Type; class Function; class Code; class Value { public: static std::shared_ptr make_nil(); static std::shared_ptr make_int(int val); static std::shared_ptr make_bool(bool val); static std::shared_ptr make_function(std::shared_ptr val); static std::shared_ptr make_code(std::shared_ptr val); static std::shared_ptr make_ref(size_t val); explicit Value() = default; virtual ~Value() = default; int as_int() const { return *m_int_val; } int as_bool() const { return *m_bool_val; } size_t as_ref() const { return *m_ref_val; } std::shared_ptr as_function() const; std::shared_ptr as_code() const; std::weak_ptr type() const; std::string string() const; private: std::shared_ptr m_type; std::optional m_int_val; std::optional m_bool_val; std::shared_ptr m_function_val; std::shared_ptr m_code_val; std::optional m_ref_val; }; } #endif