mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use explicit visit function for the walker.
This commit is contained in:
parent
0c20b6da6b
commit
937b95cbe5
@ -44,31 +44,31 @@ void ASTWalker::operator()(FunctionCall const& _funCall)
|
|||||||
|
|
||||||
void ASTWalker::operator()(ExpressionStatement const& _statement)
|
void ASTWalker::operator()(ExpressionStatement const& _statement)
|
||||||
{
|
{
|
||||||
boost::apply_visitor(*this, _statement.expression);
|
visit(_statement.expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTWalker::operator()(Assignment const& _assignment)
|
void ASTWalker::operator()(Assignment const& _assignment)
|
||||||
{
|
{
|
||||||
for (auto const& name: _assignment.variableNames)
|
for (auto const& name: _assignment.variableNames)
|
||||||
(*this)(name);
|
(*this)(name);
|
||||||
boost::apply_visitor(*this, *_assignment.value);
|
visit(*_assignment.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTWalker::operator()(VariableDeclaration const& _varDecl)
|
void ASTWalker::operator()(VariableDeclaration const& _varDecl)
|
||||||
{
|
{
|
||||||
if (_varDecl.value)
|
if (_varDecl.value)
|
||||||
boost::apply_visitor(*this, *_varDecl.value);
|
visit(*_varDecl.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTWalker::operator()(If const& _if)
|
void ASTWalker::operator()(If const& _if)
|
||||||
{
|
{
|
||||||
boost::apply_visitor(*this, *_if.condition);
|
visit(*_if.condition);
|
||||||
(*this)(_if.body);
|
(*this)(_if.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTWalker::operator()(Switch const& _switch)
|
void ASTWalker::operator()(Switch const& _switch)
|
||||||
{
|
{
|
||||||
boost::apply_visitor(*this, *_switch.expression);
|
visit(*_switch.expression);
|
||||||
for (auto const& _case: _switch.cases)
|
for (auto const& _case: _switch.cases)
|
||||||
{
|
{
|
||||||
if (_case.value)
|
if (_case.value)
|
||||||
@ -85,7 +85,7 @@ void ASTWalker::operator()(FunctionDefinition const& _fun)
|
|||||||
void ASTWalker::operator()(ForLoop const& _for)
|
void ASTWalker::operator()(ForLoop const& _for)
|
||||||
{
|
{
|
||||||
(*this)(_for.pre);
|
(*this)(_for.pre);
|
||||||
boost::apply_visitor(*this, *_for.condition);
|
visit(*_for.condition);
|
||||||
(*this)(_for.post);
|
(*this)(_for.post);
|
||||||
(*this)(_for.body);
|
(*this)(_for.body);
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ void ASTModifier::operator()(FunctionCall& _funCall)
|
|||||||
|
|
||||||
void ASTModifier::operator()(ExpressionStatement& _statement)
|
void ASTModifier::operator()(ExpressionStatement& _statement)
|
||||||
{
|
{
|
||||||
boost::apply_visitor(*this, _statement.expression);
|
visit(_statement.expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTModifier::operator()(Assignment& _assignment)
|
void ASTModifier::operator()(Assignment& _assignment)
|
||||||
|
@ -58,12 +58,21 @@ public:
|
|||||||
virtual void operator()(ForLoop const&);
|
virtual void operator()(ForLoop const&);
|
||||||
virtual void operator()(Block const& _block);
|
virtual void operator()(Block const& _block);
|
||||||
|
|
||||||
|
virtual void visit(Statement const& _st)
|
||||||
|
{
|
||||||
|
boost::apply_visitor(*this, _st);
|
||||||
|
}
|
||||||
|
virtual void visit(Expression const& _e)
|
||||||
|
{
|
||||||
|
boost::apply_visitor(*this, _e);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <class T>
|
template <class T>
|
||||||
void walkVector(T const& _statements)
|
void walkVector(T const& _statements)
|
||||||
{
|
{
|
||||||
for (auto const& st: _statements)
|
for (auto const& st: _statements)
|
||||||
boost::apply_visitor(*this, st);
|
visit(st);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,13 +98,6 @@ public:
|
|||||||
virtual void operator()(ForLoop&);
|
virtual void operator()(ForLoop&);
|
||||||
virtual void operator()(Block& _block);
|
virtual void operator()(Block& _block);
|
||||||
|
|
||||||
protected:
|
|
||||||
template <class T>
|
|
||||||
void walkVector(T&& _statements)
|
|
||||||
{
|
|
||||||
for (auto& st: _statements)
|
|
||||||
visit(st);
|
|
||||||
}
|
|
||||||
virtual void visit(Statement& _st)
|
virtual void visit(Statement& _st)
|
||||||
{
|
{
|
||||||
boost::apply_visitor(*this, _st);
|
boost::apply_visitor(*this, _st);
|
||||||
@ -104,6 +106,14 @@ protected:
|
|||||||
{
|
{
|
||||||
boost::apply_visitor(*this, _e);
|
boost::apply_visitor(*this, _e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
template <class T>
|
||||||
|
void walkVector(T&& _statements)
|
||||||
|
{
|
||||||
|
for (auto& st: _statements)
|
||||||
|
visit(st);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user