template <typename T> T accept(IVisitor<T> &&v) const { return accept(&v); }
public:
- struct Mutator
+ /**
+ * @brief Instr mutator interface
+ *
+ * WARN Use this interface only for coco-internal classes
+ * (to minimize changes upon Instr extension)
+ */
+ struct IMutator
{
- virtual ~Mutator() = default;
+ virtual ~IMutator() = default;
#define INSTR(Name) virtual void mutate(Name *) = 0;
#include "coco/IR/Instr.lst"
#undef INSTR
};
-public:
- struct DefaultMutator : public Mutator
+ struct Mutator : public IMutator
{
- virtual ~DefaultMutator() = default;
+ virtual ~Mutator() = default;
#define INSTR(Name) \
void mutate(Name *) override { throw std::runtime_error{"NYI"}; }
#undef INSTR
};
+ // Deprecated. Use Mutator instead
+ using DefaultMutator = Mutator;
+
public:
- void accept(Mutator *m)
+ void accept(IMutator *m)
{
#define INSTR(Name) \
if (auto ins = as##Name()) \
throw std::runtime_error{"unreachable"};
}
- void accept(Mutator &m) { return accept(&m); }
- void accept(Mutator &&m) { return accept(&m); }
+ void accept(IMutator &m) { return accept(&m); }
+ void accept(IMutator &&m) { return accept(&m); }
public:
/** @brief Returns a set of bags that Instr reads during execution */