#undef INSTR
public:
- template <typename T> struct Visitor
+ /**
+ * @brief Instr visitor interface
+ *
+ * WARN Use this interface only for coco-internal classes
+ * (to minimize changes upon Instr extension)
+ */
+ template <typename T> struct IVisitor
{
- virtual ~Visitor() = default;
+ virtual ~IVisitor() = default;
#define INSTR(Name) virtual T visit(const Name *) = 0;
#include "coco/IR/Instr.lst"
#undef INSTR
};
-public:
- template <typename T> struct DefaultVisitor : public Visitor<T>
+ template <typename T> struct Visitor : public IVisitor<T>
{
- virtual ~DefaultVisitor() = default;
+ virtual ~Visitor() = default;
#define INSTR(Name) \
T visit(const Name *) override { throw std::runtime_error{"NYI"}; }
#undef INSTR
};
+ // Deprecated. Use Visitor instead
+ template <typename T> using DefaultVisitor = Visitor<T>;
+
public:
- template <typename T> T accept(Visitor<T> *v) const
+ template <typename T> T accept(IVisitor<T> *v) const
{
#define INSTR(Name) \
if (auto ins = as##Name()) \
throw std::runtime_error{"unreachable"};
}
- template <typename T> T accept(Visitor<T> &v) const { return accept(&v); }
- template <typename T> T accept(Visitor<T> &&v) const { return accept(&v); }
+ template <typename T> T accept(IVisitor<T> &v) const { return accept(&v); }
+ template <typename T> T accept(IVisitor<T> &&v) const { return accept(&v); }
public:
struct Mutator