fakir/src/Constant.hpp

35 lines
645 B
C++
Raw Normal View History

#ifndef fk_CONSTANT_HPP
#define fk_CONSTANT_HPP
#include "commons.hpp"
#include "types.hpp"
#include "Loc.hpp"
namespace fk
{
FK_ERROR(constant_error);
2023-09-20 15:17:13 +00:00
using constant_t = std::variant<int, float, bool, std::string, size_t>;
class Constant
{
public:
explicit Constant(Type type, constant_t value, Loc const& loc);
virtual ~Constant();
Type type() const { return m_type; }
constant_t value() const { return m_value; }
Loc loc() const { return m_loc; }
std::string string() const;
bool equals(Constant const& rhs) const;
private:
Type m_type;
constant_t m_value;
Loc m_loc;
};
}
#endif