mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11210 from anurag-git/issue_10738-2
Use range-v3 loops(transform)
This commit is contained in:
commit
6d6112a81b
@ -26,7 +26,7 @@
|
||||
|
||||
#include <libsolutil/Algorithms.h>
|
||||
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::langutil;
|
||||
@ -344,7 +344,7 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
|
||||
{
|
||||
errorString = "Data location must be " +
|
||||
util::joinHumanReadable(
|
||||
allowedDataLocations | boost::adaptors::transformed(locationToString),
|
||||
allowedDataLocations | ranges::views::transform(locationToString),
|
||||
", ",
|
||||
" or "
|
||||
);
|
||||
|
@ -42,11 +42,11 @@
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/range/adaptor/sliced.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
|
||||
#include <range/v3/view/enumerate.hpp>
|
||||
#include <range/v3/view/reverse.hpp>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
#include <limits>
|
||||
#include <unordered_set>
|
||||
@ -227,7 +227,7 @@ string richIdentifier(Type const* _type)
|
||||
|
||||
string identifierList(vector<Type const*> const& _list)
|
||||
{
|
||||
return identifierList(_list | boost::adaptors::transformed(richIdentifier));
|
||||
return identifierList(_list | ranges::views::transform(richIdentifier));
|
||||
}
|
||||
|
||||
string identifierList(Type const* _type)
|
||||
@ -2374,7 +2374,7 @@ string StructType::signatureInExternalFunction(bool _structsByName) const
|
||||
else
|
||||
{
|
||||
TypePointers memberTypes = memoryMemberTypes();
|
||||
auto memberTypeStrings = memberTypes | boost::adaptors::transformed([&](Type const* _t) -> string
|
||||
auto memberTypeStrings = memberTypes | ranges::views::transform([&](Type const* _t) -> string
|
||||
{
|
||||
solAssert(_t, "Parameter should have external type.");
|
||||
auto t = _t->interfaceType(_structsByName);
|
||||
@ -3439,7 +3439,7 @@ string FunctionType::externalSignature() const
|
||||
|
||||
solAssert(extParams.message().empty(), extParams.message());
|
||||
|
||||
auto typeStrings = extParams.get() | boost::adaptors::transformed([&](Type const* _t) -> string
|
||||
auto typeStrings = extParams.get() | ranges::views::transform([&](Type const* _t) -> string
|
||||
{
|
||||
string typeName = _t->signatureInExternalFunction(inLibrary);
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
#include <libsolutil/Visitor.h>
|
||||
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
@ -1037,7 +1037,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
|
||||
templ("encode", abi.tupleEncoder(nonIndexedArgTypes, nonIndexedParamTypes));
|
||||
templ("nonIndexedArgs", joinHumanReadablePrefixed(nonIndexedArgs));
|
||||
templ("log", "log" + to_string(indexedArgs.size()));
|
||||
templ("indexedArgs", joinHumanReadablePrefixed(indexedArgs | boost::adaptors::transformed([&](auto const& _arg) {
|
||||
templ("indexedArgs", joinHumanReadablePrefixed(indexedArgs | ranges::views::transform([&](auto const& _arg) {
|
||||
return _arg.commaSeparatedList();
|
||||
})));
|
||||
m_code << templ.render();
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <libsolidity/codegen/ir/Common.h>
|
||||
#include <libsolidity/codegen/ir/IRVariable.h>
|
||||
#include <libsolidity/ast/AST.h>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <libsolutil/StringUtils.h>
|
||||
|
||||
using namespace std;
|
||||
|
@ -30,7 +30,8 @@
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
@ -83,7 +84,7 @@ string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) c
|
||||
{
|
||||
string out = "let ";
|
||||
out += boost::algorithm::join(
|
||||
_variableDeclaration.variables | boost::adaptors::transformed(
|
||||
_variableDeclaration.variables | ranges::views::transform(
|
||||
[this](TypedName argument) { return formatTypedName(argument); }
|
||||
),
|
||||
", "
|
||||
@ -101,7 +102,7 @@ string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) con
|
||||
yulAssert(!_functionDefinition.name.empty(), "Invalid function name.");
|
||||
string out = "function " + _functionDefinition.name.str() + "(";
|
||||
out += boost::algorithm::join(
|
||||
_functionDefinition.parameters | boost::adaptors::transformed(
|
||||
_functionDefinition.parameters | ranges::views::transform(
|
||||
[this](TypedName argument) { return formatTypedName(argument); }
|
||||
),
|
||||
", "
|
||||
@ -111,7 +112,7 @@ string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) con
|
||||
{
|
||||
out += " -> ";
|
||||
out += boost::algorithm::join(
|
||||
_functionDefinition.returnVariables | boost::adaptors::transformed(
|
||||
_functionDefinition.returnVariables | ranges::views::transform(
|
||||
[this](TypedName argument) { return formatTypedName(argument); }
|
||||
),
|
||||
", "
|
||||
@ -126,7 +127,7 @@ string AsmPrinter::operator()(FunctionCall const& _functionCall) const
|
||||
return
|
||||
(*this)(_functionCall.functionName) + "(" +
|
||||
boost::algorithm::join(
|
||||
_functionCall.arguments | boost::adaptors::transformed([&](auto&& _node) { return std::visit(*this, _node); }),
|
||||
_functionCall.arguments | ranges::views::transform([&](auto&& _node) { return std::visit(*this, _node); }),
|
||||
", " ) +
|
||||
")";
|
||||
}
|
||||
@ -194,7 +195,7 @@ string AsmPrinter::operator()(Block const& _block) const
|
||||
if (_block.statements.empty())
|
||||
return "{ }";
|
||||
string body = boost::algorithm::join(
|
||||
_block.statements | boost::adaptors::transformed([&](auto&& _node) { return std::visit(*this, _node); }),
|
||||
_block.statements | ranges::views::transform([&](auto&& _node) { return std::visit(*this, _node); }),
|
||||
"\n"
|
||||
);
|
||||
if (body.size() < 30 && body.find('\n') == string::npos)
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <libsolutil/Visitor.h>
|
||||
#include <libsolutil/LEB128.h>
|
||||
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
|
||||
#include <range/v3/view/map.hpp>
|
||||
#include <range/v3/view/reverse.hpp>
|
||||
|
||||
|
@ -31,7 +31,8 @@
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
@ -67,7 +68,7 @@ string TextTransform::run(wasm::Module const& _module)
|
||||
{
|
||||
ret += " (import \"" + imp.module + "\" \"" + imp.externalName + "\" (func $" + imp.internalName;
|
||||
if (!imp.paramTypes.empty())
|
||||
ret += " (param" + joinHumanReadablePrefixed(imp.paramTypes | boost::adaptors::transformed(encodeType), " ", " ") + ")";
|
||||
ret += " (param" + joinHumanReadablePrefixed(imp.paramTypes | ranges::views::transform(encodeType), " ", " ") + ")";
|
||||
if (imp.returnType)
|
||||
ret += " (result " + encodeType(*imp.returnType) + ")";
|
||||
ret += "))\n";
|
||||
|
@ -63,10 +63,11 @@
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
#ifdef _WIN32 // windows
|
||||
#include <io.h>
|
||||
#define isatty _isatty
|
||||
@ -2047,7 +2048,7 @@ size_t CommandLineInterface::countEnabledOptions(vector<string> const& _optionNa
|
||||
string CommandLineInterface::joinOptionNames(vector<string> const& _optionNames, string _separator)
|
||||
{
|
||||
return boost::algorithm::join(
|
||||
_optionNames | boost::adaptors::transformed([](string const& _option){ return "--" + _option; }),
|
||||
_optionNames | ranges::views::transform([](string const& _option){ return "--" + _option; }),
|
||||
_separator
|
||||
);
|
||||
}
|
||||
|
@ -35,9 +35,10 @@
|
||||
#include <libsolutil/Keccak256.h>
|
||||
#include <libsolutil/ErrorCodes.h>
|
||||
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
@ -3143,11 +3144,11 @@ BOOST_AUTO_TEST_CASE(calldata_array_dynamic_three_dimensional)
|
||||
bytes encoding = encodeArray(
|
||||
outerDynamicallySized,
|
||||
middleDynamicallySized || innerDynamicallySized,
|
||||
data | boost::adaptors::transformed([&](auto const& _middleData) {
|
||||
data | ranges::views::transform([&](auto const& _middleData) {
|
||||
return encodeArray(
|
||||
middleDynamicallySized,
|
||||
innerDynamicallySized,
|
||||
_middleData | boost::adaptors::transformed([&](auto const& _values) {
|
||||
_middleData | ranges::views::transform([&](auto const& _values) {
|
||||
return encodeArray(innerDynamicallySized, false, _values);
|
||||
})
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user