X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/c4231c6faf4e1b4650b075c641b0bb8c053739e4..66a27d2fc7c1ad4e97de76d4982168a0fed9920a:/src/visit.h 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 +// struct with callback functions for all relevant types +// tree can be walked selectively by providing only +// needed callbacks struct Visitor { std::function ctx)> onType = [](auto, auto){}; std::function 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;