Skip to content

Commit

Permalink
[Wasm] Remove STL visitability from recursive wasm::MatchBase visitor.
Browse files Browse the repository at this point in the history
Using the STL visit method, the recursive calls would be overwritten.
Instead inherit from `RecursiveConstMatchBaseVisitorBase` and
implement the recursion explicitly.
  • Loading branch information
lucagretscher committed Mar 18, 2024
1 parent 5b55781 commit af9e7a9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/backend/WasmOperator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,12 +1126,12 @@ M_DECLARE_VISITOR(ConstMatchBaseVisitor, const MatchBase, M_WASM_VISITABLE_MATCH

/** A generic base class for implementing recursive `wasm::MatchBase` visitors. */
template<bool C>
struct TheRecursiveMatchBaseVisitor : std::conditional_t<C, ConstMatchBaseVisitor, MatchBaseVisitor>
struct TheRecursiveMatchBaseVisitorBase : std::conditional_t<C, ConstMatchBaseVisitor, MatchBaseVisitor>
{
using super = std::conditional_t<C, ConstMatchBaseVisitor, MatchBaseVisitor>;
template<typename T> using Const = typename super::template Const<T>;

virtual ~TheRecursiveMatchBaseVisitor() { }
virtual ~TheRecursiveMatchBaseVisitorBase() { }

using super::operator();
void operator()(Const<MatchLeaf>&) override { /* nothing to be done */ }
Expand All @@ -1140,9 +1140,7 @@ struct TheRecursiveMatchBaseVisitor : std::conditional_t<C, ConstMatchBaseVisito
void operator()(Const<MatchMultipleChildren> &M) override { for (auto &c : M.children) (*this)(*c); }
};

using RecursiveConstMatchBaseVisitor = TheRecursiveMatchBaseVisitor<true>;

M_MAKE_STL_VISITABLE(RecursiveConstMatchBaseVisitor, const MatchBase, M_WASM_VISITABLE_MATCH_LIST)
using RecursiveConstMatchBaseVisitorBase = TheRecursiveMatchBaseVisitorBase<true>;

#undef M_WASM_VISITABLE_MATCH_LIST

Expand Down

0 comments on commit af9e7a9

Please sign in to comment.