Replaced keys, values and reverse with ranges

This commit is contained in:
anurag4u80
2021-03-31 23:33:04 +05:30
parent 851051c64a
commit bbcdddeed9
18 changed files with 56 additions and 53 deletions
+6 -8
View File
@@ -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);
+1 -3
View File
@@ -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, [&]() {