Commit 96f0f567 authored by Paul's avatar Paul
Browse files

Formatting

parent d3f83759
...@@ -186,21 +186,23 @@ matcher_result match_instruction(program& p, instruction_ref ins, M&& m) ...@@ -186,21 +186,23 @@ matcher_result match_instruction(program& p, instruction_ref ins, M&& m)
return result; return result;
} }
template<class... Ms> template <class... Ms>
void find_matches(program& p, Ms&&... ms) void find_matches(program& p, Ms&&... ms)
{ {
for(auto ins:iterator_for(p)) for(auto ins : iterator_for(p))
{ {
bool match = false; bool match = false;
each_args([&](auto&& m) { each_args(
if(match) [&](auto&& m) {
return; if(match)
auto r = match_instruction(p, ins, m.matcher()); return;
if(r.result == p.end()) auto r = match_instruction(p, ins, m.matcher());
return; if(r.result == p.end())
m.apply(r); return;
match = true; m.apply(r);
}, ms...); match = true;
},
ms...);
} }
} }
......
...@@ -314,24 +314,15 @@ void match_bind1() ...@@ -314,24 +314,15 @@ void match_bind1()
struct match_find_sum struct match_find_sum
{ {
migraph::instruction_ref ins; migraph::instruction_ref ins;
auto matcher() const auto matcher() const { return matchers::name("sum"); }
{
return matchers::name("sum");
}
void apply(matchers::matcher_result r) const void apply(matchers::matcher_result r) const { EXPECT(bool{r.result == ins}); }
{
EXPECT(bool{r.result == ins});
}
}; };
struct match_find_literal struct match_find_literal
{ {
migraph::instruction_ref ins; migraph::instruction_ref ins;
auto matcher() const auto matcher() const { return matchers::name("@literal"); }
{
return matchers::name("@literal");
}
void apply(matchers::matcher_result r) const void apply(matchers::matcher_result r) const
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment