\r
#include <functional>\r
\r
+// struct with callback functions for all relevant types\r
+// tree can be walked selectively by providing only\r
+// needed callbacks\r
struct Visitor {\r
std::function<void(const Type &, const std::shared_ptr<Context> ctx)> onType = [](auto, auto){};\r
std::function<void(const Expr &, const std::shared_ptr<Context> ctx)> onExpr = [](auto, auto){};\r
\r
#define VISIT(XS) for (auto x : XS) visit(x);\r
\r
+// simply walk IR by recursively calling functions for all children\r
struct Visit {\r
private:\r
Visitor v;\r