Merge pull request #5132 from ethereum/genericVisitor

Generic visitor.
This commit is contained in:
chriseth
2018-10-10 16:01:20 +02:00
committed by GitHub
2 changed files with 130 additions and 25 deletions
+2 -25
View File
@@ -22,6 +22,8 @@
#include <libsolidity/interface/Exceptions.h>
#include <libdevcore/Visitor.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
@@ -35,31 +37,6 @@ namespace solidity
namespace assembly
{
template <class...>
struct GenericVisitor{};
template <class Visitable, class... Others>
struct GenericVisitor<Visitable, Others...>: public GenericVisitor<Others...>
{
using GenericVisitor<Others...>::operator ();
explicit GenericVisitor(
std::function<void(Visitable&)> _visitor,
std::function<void(Others&)>... _otherVisitors
):
GenericVisitor<Others...>(_otherVisitors...),
m_visitor(_visitor)
{}
void operator()(Visitable& _v) const { m_visitor(_v); }
std::function<void(Visitable&)> m_visitor;
};
template <>
struct GenericVisitor<>: public boost::static_visitor<> {
void operator()() const {}
};
struct Scope
{
using YulType = std::string;