diff options
author | chriseth <chris@ethereum.org> | 2017-12-20 21:12:52 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-01-13 00:21:52 +0800 |
commit | 937b95cbe5bcef6c1324c380f37629e5a2a5811a (patch) | |
tree | d47456481248f24a90dfa1ae69097fe5f80ec53e /libjulia | |
parent | 0c20b6da6b6c5f8fa72c389648b5da54c13945f9 (diff) | |
download | dexon-solidity-937b95cbe5bcef6c1324c380f37629e5a2a5811a.tar.gz dexon-solidity-937b95cbe5bcef6c1324c380f37629e5a2a5811a.tar.zst dexon-solidity-937b95cbe5bcef6c1324c380f37629e5a2a5811a.zip |
Use explicit visit function for the walker.
Diffstat (limited to 'libjulia')
-rw-r--r-- | libjulia/optimiser/ASTWalker.cpp | 14 | ||||
-rw-r--r-- | libjulia/optimiser/ASTWalker.h | 26 |
2 files changed, 25 insertions, 15 deletions
diff --git a/libjulia/optimiser/ASTWalker.cpp b/libjulia/optimiser/ASTWalker.cpp index 499b4bf2..6386b29d 100644 --- a/libjulia/optimiser/ASTWalker.cpp +++ b/libjulia/optimiser/ASTWalker.cpp @@ -44,31 +44,31 @@ void ASTWalker::operator()(FunctionCall const& _funCall) void ASTWalker::operator()(ExpressionStatement const& _statement) { - boost::apply_visitor(*this, _statement.expression); + visit(_statement.expression); } void ASTWalker::operator()(Assignment const& _assignment) { for (auto const& name: _assignment.variableNames) (*this)(name); - boost::apply_visitor(*this, *_assignment.value); + visit(*_assignment.value); } void ASTWalker::operator()(VariableDeclaration const& _varDecl) { if (_varDecl.value) - boost::apply_visitor(*this, *_varDecl.value); + visit(*_varDecl.value); } void ASTWalker::operator()(If const& _if) { - boost::apply_visitor(*this, *_if.condition); + visit(*_if.condition); (*this)(_if.body); } void ASTWalker::operator()(Switch const& _switch) { - boost::apply_visitor(*this, *_switch.expression); + visit(*_switch.expression); for (auto const& _case: _switch.cases) { if (_case.value) @@ -85,7 +85,7 @@ void ASTWalker::operator()(FunctionDefinition const& _fun) void ASTWalker::operator()(ForLoop const& _for) { (*this)(_for.pre); - boost::apply_visitor(*this, *_for.condition); + visit(*_for.condition); (*this)(_for.post); (*this)(_for.body); } @@ -107,7 +107,7 @@ void ASTModifier::operator()(FunctionCall& _funCall) void ASTModifier::operator()(ExpressionStatement& _statement) { - boost::apply_visitor(*this, _statement.expression); + visit(_statement.expression); } void ASTModifier::operator()(Assignment& _assignment) diff --git a/libjulia/optimiser/ASTWalker.h b/libjulia/optimiser/ASTWalker.h index 4652a353..dbf8194b 100644 --- a/libjulia/optimiser/ASTWalker.h +++ b/libjulia/optimiser/ASTWalker.h @@ -58,12 +58,21 @@ public: virtual void operator()(ForLoop const&); 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: template <class T> void walkVector(T const& _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()(Block& _block); -protected: - template <class T> - void walkVector(T&& _statements) - { - for (auto& st: _statements) - visit(st); - } virtual void visit(Statement& _st) { boost::apply_visitor(*this, _st); @@ -104,6 +106,14 @@ protected: { boost::apply_visitor(*this, _e); } + +protected: + template <class T> + void walkVector(T&& _statements) + { + for (auto& st: _statements) + visit(st); + } }; } |