35 lines
637 B
C++
35 lines
637 B
C++
|
#ifndef fk_CONSTANT_HPP
|
||
|
#define fk_CONSTANT_HPP
|
||
|
|
||
|
#include "commons.hpp"
|
||
|
#include "types.hpp"
|
||
|
#include "Loc.hpp"
|
||
|
|
||
|
namespace fk
|
||
|
{
|
||
|
FK_ERROR(constant_error);
|
||
|
|
||
|
using constant_t = std::variant<int, float, bool, std::string>;
|
||
|
|
||
|
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
|