2023-09-20 11:31:35 +00:00
|
|
|
#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-21 19:17:39 +00:00
|
|
|
class Program;
|
|
|
|
|
|
|
|
using constant_t = std::variant<int,
|
|
|
|
float,
|
|
|
|
bool,
|
|
|
|
std::string,
|
|
|
|
size_t,
|
|
|
|
std::shared_ptr<Program>
|
|
|
|
>;
|
2023-09-20 11:31:35 +00:00
|
|
|
|
|
|
|
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
|