template <typename T> T accept(IVisitor<T> &&v) const { return accept(&v); }
public:
- /**
- * @brief Instr mutator interface
- *
- * WARN Use this interface only for coco-internal classes
- * (to minimize changes upon Instr extension)
- */
- struct IMutator
- {
- virtual ~IMutator() = default;
-
-#define INSTR(Name) virtual void mutate(Name *) = 0;
-#include "coco/IR/Instr.lst"
-#undef INSTR
- };
-
- struct Mutator : public IMutator
- {
- virtual ~Mutator() = default;
-
-#define INSTR(Name) \
- void mutate(Name *) override { throw std::runtime_error{"NYI"}; }
-#include "coco/IR/Instr.lst"
-#undef INSTR
- };
-
-public:
- void accept(IMutator *m)
- {
-#define INSTR(Name) \
- if (auto ins = as##Name()) \
- { \
- return m->mutate(ins); \
- }
-#include "coco/IR/Instr.lst"
-#undef INSTR
- throw std::runtime_error{"unreachable"};
- }
-
- void accept(IMutator &m) { return accept(&m); }
- void accept(IMutator &&m) { return accept(&m); }
-
-public:
const InstrIndex &index(void) const { return _index; }
private: