diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index ee12b9b3e..1d1eb92b9 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -94,14 +94,14 @@ void CompilerContext::callLowLevelFunction( *this << retTag.tag(); } -void CompilerContext::callYulUtilFunction( +void CompilerContext::callYulFunction( string const& _name, unsigned _inArgs, unsigned _outArgs ) { - m_externallyUsedFunctions.insert(_name); - auto retTag = pushNewTag(); + m_externallyUsedYulFunctions.insert(_name); + auto const retTag = pushNewTag(); CompilerUtils(*this).moveIntoStack(_inArgs); appendJumpTo(namedTag(_name)); adjustStackOffset(int(_outArgs) - 1 - _inArgs); @@ -150,8 +150,8 @@ void CompilerContext::appendMissingLowLevelFunctions() pair> CompilerContext::requestedYulFunctions() { set empty; - swap(empty, m_externallyUsedFunctions); - return make_pair(m_functionCollector->requestedFunctions(), std::move(empty)); + swap(empty, m_externallyUsedYulFunctions); + return make_pair(m_yulFunctionCollector->requestedFunctions(), std::move(empty)); } void CompilerContext::addVariable( diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index 6d554da82..76c72770d 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -65,8 +65,8 @@ public: m_evmVersion(_evmVersion), m_revertStrings(_revertStrings), m_runtimeContext(_runtimeContext), - m_abiFunctions(m_evmVersion, m_revertStrings, m_functionCollector), - m_yulUtilFunctions(m_evmVersion, m_revertStrings, m_functionCollector) + m_abiFunctions(m_evmVersion, m_revertStrings, m_yulFunctionCollector), + m_yulUtilFunctions(m_evmVersion, m_revertStrings, m_yulFunctionCollector) { if (m_runtimeContext) m_runtimeSub = size_t(m_asm->newSub(m_runtimeContext->m_asm).data()); @@ -133,8 +133,8 @@ public: std::function const& _generator ); - /// Appends a call to a yul util function and registers the function as externally used. - void callYulUtilFunction( + /// Appends a call to a yul function and registers the function as externally used. + void callYulFunction( std::string const& _name, unsigned _inArgs, unsigned _outArgs @@ -370,10 +370,10 @@ private: size_t m_runtimeSub = -1; /// An index of low-level function labels by name. std::map m_lowLevelFunctions; - // Collector for yul functions. - std::shared_ptr m_functionCollector = std::make_shared(); + /// Collector for yul functions. + std::shared_ptr m_yulFunctionCollector = std::make_shared(); /// Set of externally used yul functions. - std::set m_externallyUsedFunctions; + std::set m_externallyUsedYulFunctions; /// Container for ABI functions to be generated. ABIFunctions m_abiFunctions; /// Container for Yul Util functions to be generated. diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index a0d38eae5..b39633377 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -599,7 +599,7 @@ void CompilerUtils::abiEncodeV2( _padToWordBoundaries ? m_context.abiFunctions().tupleEncoder(_givenTypes, _targetTypes, _encodeAsLibraryTypes) : m_context.abiFunctions().tupleEncoderPacked(_givenTypes, _targetTypes); - m_context.callYulUtilFunction(encoderName, sizeOnStack(_givenTypes) + 1, 1); + m_context.callYulFunction(encoderName, sizeOnStack(_givenTypes) + 1, 1); } void CompilerUtils::abiDecodeV2(TypePointers const& _parameterTypes, bool _fromMemory) @@ -609,7 +609,7 @@ void CompilerUtils::abiDecodeV2(TypePointers const& _parameterTypes, bool _fromM m_context << Instruction::SWAP1; // stack: string decoderName = m_context.abiFunctions().tupleDecoder(_parameterTypes, _fromMemory); - m_context.callYulUtilFunction(decoderName, 2, sizeOnStack(_parameterTypes)); + m_context.callYulFunction(decoderName, 2, sizeOnStack(_parameterTypes)); } void CompilerUtils::zeroInitialiseMemoryArray(ArrayType const& _type) diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 47187b1c8..8b9061af3 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -1267,12 +1267,12 @@ void ContractCompiler::appendMissingFunctions() solAssert(m_context.nextFunctionToCompile() != function, "Compiled the wrong function?"); } m_context.appendMissingLowLevelFunctions(); - auto yulFunctions = m_context.requestedYulFunctions(); - if (!yulFunctions.first.empty()) + auto [yulFunctions, externallyUsedYulFunctions] = m_context.requestedYulFunctions(); + if (!yulFunctions.empty()) m_context.appendInlineAssembly( - "{" + move(yulFunctions.first) + "}", + "{" + move(yulFunctions) + "}", {}, - yulFunctions.second, + externallyUsedYulFunctions, true, m_optimiserSettings );