From f705a45d43d69ca4f29bd496d091f7237bdc31ff Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 7 Nov 2018 11:18:02 +0100 Subject: [Yul] Implements a pass to rewrite for-loop's pre block into the parent's Block. --- libyul/optimiser/ForLoopInitRewriter.cpp | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 libyul/optimiser/ForLoopInitRewriter.cpp (limited to 'libyul/optimiser/ForLoopInitRewriter.cpp') diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp new file mode 100644 index 00000000..0decf5e2 --- /dev/null +++ b/libyul/optimiser/ForLoopInitRewriter.cpp @@ -0,0 +1,43 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +#include +#include +#include +#include + +using namespace std; +using namespace dev; +using namespace dev::yul; + +void ForLoopInitRewriter::operator()(Block& _block) +{ + iterateReplacing( + _block.statements, + [](Statement& _stmt) -> boost::optional> + { + if (_stmt.type() == typeid(ForLoop)) + { + auto& forLoop = boost::get(_stmt); + vector rewrite; + swap(rewrite, forLoop.pre.statements); + rewrite.emplace_back(move(forLoop)); + return rewrite; + } + return {}; + } + ); +} -- cgit v1.2.3 From 0f4ed52a719af90b52a15eb6709f46f03d4108b9 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 23 Nov 2018 11:18:57 +0100 Subject: Rewrite header paths to adapt to recent `git mv` of libsolidity/inlineasm to libyul --- libyul/optimiser/ForLoopInitRewriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libyul/optimiser/ForLoopInitRewriter.cpp') diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp index 0decf5e2..b5e59884 100644 --- a/libyul/optimiser/ForLoopInitRewriter.cpp +++ b/libyul/optimiser/ForLoopInitRewriter.cpp @@ -15,7 +15,7 @@ along with solidity. If not, see . */ #include -#include +#include #include #include -- cgit v1.2.3 From ec47c8946ba5f78563b7eca2512b3cee68db45b4 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 21 Nov 2018 12:42:34 +0100 Subject: Isolating libyul library API into its own namespace `yul`. --- libyul/optimiser/ForLoopInitRewriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libyul/optimiser/ForLoopInitRewriter.cpp') diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp index b5e59884..80d39248 100644 --- a/libyul/optimiser/ForLoopInitRewriter.cpp +++ b/libyul/optimiser/ForLoopInitRewriter.cpp @@ -21,7 +21,7 @@ using namespace std; using namespace dev; -using namespace dev::yul; +using namespace yul; void ForLoopInitRewriter::operator()(Block& _block) { -- cgit v1.2.3