fakir/src/Constant.hpp

43 lines
894 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);
class Program;
using constant_t = std::variant<int,
float,
bool,
std::string,
size_t,
std::shared_ptr<Program>
>;
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