abouttreesummaryrefslogcommitdiff
path: root/src/visit.h
diff options
context:
space:
mode:
authorPatrick Schönberger2021-08-12 10:32:51 +0200
committerPatrick Schönberger2021-08-12 10:32:51 +0200
commit66a27d2fc7c1ad4e97de76d4982168a0fed9920a (patch)
treeca3f0e5d740214bc7ecd85949a278e64e49898b7 /src/visit.h
parentc4231c6faf4e1b4650b075c641b0bb8c053739e4 (diff)
downloadtoc-66a27d2fc7c1ad4e97de76d4982168a0fed9920a.tar.gz
toc-66a27d2fc7c1ad4e97de76d4982168a0fed9920a.zip
comments
Diffstat (limited to 'src/visit.h')
-rw-r--r--src/visit.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/visit.h b/src/visit.h
index 1175a86..646ac61 100644
--- a/src/visit.h
+++ b/src/visit.h
@@ -4,6 +4,9 @@
#include <functional>
+// struct with callback functions for all relevant types
+// tree can be walked selectively by providing only
+// needed callbacks
struct Visitor {
std::function<void(const Type &, const std::shared_ptr<Context> ctx)> onType = [](auto, auto){};
std::function<void(const Expr &, const std::shared_ptr<Context> ctx)> onExpr = [](auto, auto){};
@@ -20,6 +23,7 @@ struct Visitor {
#define VISIT(XS) for (auto x : XS) visit(x);
+// simply walk IR by recursively calling functions for all children
struct Visit {
private:
Visitor v;