mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Replaced keys, values and reverse with ranges
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
#include <libsolidity/analysis/TypeChecker.h>
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
|
||||
#include <range/v3/view/reverse.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
@@ -238,7 +239,7 @@ void ContractLevelChecker::checkAbstractDefinitions(ContractDefinition const& _c
|
||||
|
||||
// Search from base to derived, collect all functions and modifiers and
|
||||
// update proxies.
|
||||
for (ContractDefinition const* contract: boost::adaptors::reverse(_contract.annotation().linearizedBaseContracts))
|
||||
for (ContractDefinition const* contract: _contract.annotation().linearizedBaseContracts | ranges::views::reverse)
|
||||
{
|
||||
for (VariableDeclaration const* v: contract->stateVariables())
|
||||
if (v->isPartOfExternalInterface())
|
||||
@@ -511,7 +512,7 @@ void ContractLevelChecker::checkPayableFallbackWithoutReceive(ContractDefinition
|
||||
void ContractLevelChecker::checkStorageSize(ContractDefinition const& _contract)
|
||||
{
|
||||
bigint size = 0;
|
||||
for (ContractDefinition const* contract: boost::adaptors::reverse(_contract.annotation().linearizedBaseContracts))
|
||||
for (ContractDefinition const* contract: _contract.annotation().linearizedBaseContracts | ranges::views::reverse)
|
||||
for (VariableDeclaration const* variable: contract->stateVariables())
|
||||
if (!(variable->isConstant() || variable->immutable()))
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <libsolutil/CommonData.h>
|
||||
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
#include <range/v3/view/reverse.hpp>
|
||||
|
||||
using namespace solidity::frontend;
|
||||
using namespace solidity::langutil;
|
||||
@@ -29,7 +29,7 @@ void ImmutableValidator::analyze()
|
||||
{
|
||||
m_inConstructionContext = true;
|
||||
|
||||
auto linearizedContracts = m_currentContract.annotation().linearizedBaseContracts | boost::adaptors::reversed;
|
||||
auto linearizedContracts = m_currentContract.annotation().linearizedBaseContracts | ranges::views::reverse;
|
||||
|
||||
for (ContractDefinition const* contract: linearizedContracts)
|
||||
for (VariableDeclaration const* stateVar: contract->stateVariables())
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/range/adaptor/reversed.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 <limits>
|
||||
#include <unordered_set>
|
||||
@@ -2014,7 +2014,7 @@ FunctionType const* ContractType::newExpressionType() const
|
||||
vector<tuple<VariableDeclaration const*, u256, unsigned>> ContractType::stateVariables() const
|
||||
{
|
||||
vector<VariableDeclaration const*> variables;
|
||||
for (ContractDefinition const* contract: boost::adaptors::reverse(m_contract.annotation().linearizedBaseContracts))
|
||||
for (ContractDefinition const* contract: m_contract.annotation().linearizedBaseContracts | ranges::views::reverse)
|
||||
for (VariableDeclaration const* variable: contract->stateVariables())
|
||||
if (!(variable->isConstant() || variable->immutable()))
|
||||
variables.push_back(variable);
|
||||
@@ -2034,7 +2034,7 @@ vector<tuple<VariableDeclaration const*, u256, unsigned>> ContractType::stateVar
|
||||
vector<VariableDeclaration const*> ContractType::immutableVariables() const
|
||||
{
|
||||
vector<VariableDeclaration const*> variables;
|
||||
for (ContractDefinition const* contract: boost::adaptors::reverse(m_contract.annotation().linearizedBaseContracts))
|
||||
for (ContractDefinition const* contract: m_contract.annotation().linearizedBaseContracts | ranges::views::reverse)
|
||||
for (VariableDeclaration const* variable: contract->stateVariables())
|
||||
if (variable->immutable())
|
||||
variables.push_back(variable);
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include <libsolutil/Whiskers.h>
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
#include <range/v3/view/reverse.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -152,9 +152,7 @@ void ContractCompiler::appendInitAndConstructorCode(ContractDefinition const& _c
|
||||
m_baseArguments = &_contract.annotation().baseConstructorArguments;
|
||||
|
||||
// Initialization of state variables in base-to-derived order.
|
||||
for (ContractDefinition const* contract: boost::adaptors::reverse(
|
||||
_contract.annotation().linearizedBaseContracts
|
||||
))
|
||||
for (ContractDefinition const* contract: _contract.annotation().linearizedBaseContracts | ranges::views::reverse)
|
||||
initializeStateVariables(*contract);
|
||||
|
||||
if (FunctionDefinition const* constructor = _contract.constructor())
|
||||
@@ -200,10 +198,10 @@ size_t ContractCompiler::packIntoContractCreator(ContractDefinition const& _cont
|
||||
m_context.pushSubroutineOffset(m_context.runtimeSub());
|
||||
m_context << u256(0) << Instruction::CODECOPY;
|
||||
// Assign immutable values from stack in reversed order.
|
||||
for (auto const& immutable: immutables | boost::adaptors::reversed)
|
||||
for (auto const& immutable: immutables | ranges::views::reverse)
|
||||
{
|
||||
auto slotNames = m_context.immutableVariableSlotNames(*immutable);
|
||||
for (auto&& slotName: slotNames | boost::adaptors::reversed)
|
||||
for (auto&& slotName: slotNames | ranges::views::reverse)
|
||||
{
|
||||
m_context << u256(0);
|
||||
m_context.appendImmutableAssignment(slotName);
|
||||
@@ -1096,7 +1094,7 @@ bool ContractCompiler::visit(TryCatchClause const& _clause)
|
||||
unsigned varSize = 0;
|
||||
|
||||
if (_clause.parameters())
|
||||
for (ASTPointer<VariableDeclaration> const& varDecl: _clause.parameters()->parameters() | boost::adaptors::reversed)
|
||||
for (ASTPointer<VariableDeclaration> const& varDecl: _clause.parameters()->parameters() | ranges::views::reverse)
|
||||
{
|
||||
solAssert(varDecl, "");
|
||||
varSize += varDecl->annotation().type->sizeOnStack();
|
||||
@@ -1258,7 +1256,7 @@ bool ContractCompiler::visit(Return const& _return)
|
||||
expectedType = types.front();
|
||||
compileExpression(*expression, expectedType);
|
||||
|
||||
for (auto const& retVariable: boost::adaptors::reverse(returnParameters))
|
||||
for (auto const& retVariable: returnParameters | ranges::views::reverse)
|
||||
CompilerUtils(m_context).moveToStackVariable(*retVariable);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <libsolutil/Whiskers.h>
|
||||
#include <libsolutil/StringUtils.h>
|
||||
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <range/v3/view/map.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
@@ -133,7 +133,7 @@ void IRGenerationContext::initializeInternalDispatch(InternalDispatchMap _intern
|
||||
{
|
||||
solAssert(internalDispatchClean(), "");
|
||||
|
||||
for (DispatchSet const& functions: _internalDispatch | boost::adaptors::map_values)
|
||||
for (DispatchSet const& functions: _internalDispatch | ranges::views::values)
|
||||
for (auto function: functions)
|
||||
enqueueFunctionForCodeGeneration(*function);
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
|
||||
#include <range/v3/view/map.hpp>
|
||||
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <variant>
|
||||
|
||||
@@ -255,7 +253,7 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions()
|
||||
);
|
||||
|
||||
InternalDispatchMap internalDispatchMap = m_context.consumeInternalDispatchMap();
|
||||
for (YulArity const& arity: internalDispatchMap | boost::adaptors::map_keys)
|
||||
for (YulArity const& arity: internalDispatchMap | ranges::views::keys)
|
||||
{
|
||||
string funName = IRNames::internalDispatch(arity);
|
||||
m_context.functionCollector().createFunction(funName, [&]() {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include <range/v3/algorithm/for_each.hpp>
|
||||
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
#include <range/v3/view/reverse.hpp>
|
||||
|
||||
#ifdef HAVE_Z3_DLOPEN
|
||||
#include <z3_version.h>
|
||||
@@ -190,7 +190,7 @@ void CHC::endVisit(ContractDefinition const& _contract)
|
||||
}
|
||||
m_errorDest = nullptr;
|
||||
// Then call initializer_Base from base -> derived
|
||||
for (auto base: _contract.annotation().linearizedBaseContracts | boost::adaptors::reversed)
|
||||
for (auto base: _contract.annotation().linearizedBaseContracts | ranges::views::reverse)
|
||||
{
|
||||
errorFlag().increaseIndex();
|
||||
m_context.addAssertion(smt::constructorCall(*m_contractInitializers.at(&_contract).at(base), m_context));
|
||||
@@ -1737,7 +1737,7 @@ optional<string> CHC::generateCounterexample(CHCSolverInterface::CexGraph const&
|
||||
path.emplace_back(boost::algorithm::join(calls, "\n"));
|
||||
}
|
||||
|
||||
return localState + "\nTransaction trace:\n" + boost::algorithm::join(boost::adaptors::reverse(path), "\n");
|
||||
return localState + "\nTransaction trace:\n" + boost::algorithm::join(path | ranges::views::reverse, "\n");
|
||||
}
|
||||
|
||||
map<unsigned, vector<unsigned>> CHC::summaryCalls(CHCSolverInterface::CexGraph const& _graph, unsigned _root)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <range/v3/view.hpp>
|
||||
|
||||
#include <boost/range/adaptors.hpp>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
|
||||
|
||||
#include <deque>
|
||||
|
||||
@@ -2499,7 +2499,7 @@ SecondarySourceLocation SMTEncoder::callStackMessage(vector<CallStackEntry> cons
|
||||
SecondarySourceLocation callStackLocation;
|
||||
solAssert(!_callStack.empty(), "");
|
||||
callStackLocation.append("Callstack:", SourceLocation());
|
||||
for (auto const& call: _callStack | boost::adaptors::reversed)
|
||||
for (auto const& call: _callStack | ranges::views::reverse)
|
||||
if (call.second)
|
||||
callStackLocation.append("", call.second->location());
|
||||
return callStackLocation;
|
||||
|
||||
Reference in New Issue
Block a user