mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename variables and review suggestion.
This commit is contained in:
parent
24d6e6295e
commit
561e5d9b27
@ -94,14 +94,14 @@ void CompilerContext::callLowLevelFunction(
|
|||||||
*this << retTag.tag();
|
*this << retTag.tag();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerContext::callYulUtilFunction(
|
void CompilerContext::callYulFunction(
|
||||||
string const& _name,
|
string const& _name,
|
||||||
unsigned _inArgs,
|
unsigned _inArgs,
|
||||||
unsigned _outArgs
|
unsigned _outArgs
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
m_externallyUsedFunctions.insert(_name);
|
m_externallyUsedYulFunctions.insert(_name);
|
||||||
auto retTag = pushNewTag();
|
auto const retTag = pushNewTag();
|
||||||
CompilerUtils(*this).moveIntoStack(_inArgs);
|
CompilerUtils(*this).moveIntoStack(_inArgs);
|
||||||
appendJumpTo(namedTag(_name));
|
appendJumpTo(namedTag(_name));
|
||||||
adjustStackOffset(int(_outArgs) - 1 - _inArgs);
|
adjustStackOffset(int(_outArgs) - 1 - _inArgs);
|
||||||
@ -150,8 +150,8 @@ void CompilerContext::appendMissingLowLevelFunctions()
|
|||||||
pair<string, set<string>> CompilerContext::requestedYulFunctions()
|
pair<string, set<string>> CompilerContext::requestedYulFunctions()
|
||||||
{
|
{
|
||||||
set<string> empty;
|
set<string> empty;
|
||||||
swap(empty, m_externallyUsedFunctions);
|
swap(empty, m_externallyUsedYulFunctions);
|
||||||
return make_pair(m_functionCollector->requestedFunctions(), std::move(empty));
|
return make_pair(m_yulFunctionCollector->requestedFunctions(), std::move(empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerContext::addVariable(
|
void CompilerContext::addVariable(
|
||||||
|
@ -65,8 +65,8 @@ public:
|
|||||||
m_evmVersion(_evmVersion),
|
m_evmVersion(_evmVersion),
|
||||||
m_revertStrings(_revertStrings),
|
m_revertStrings(_revertStrings),
|
||||||
m_runtimeContext(_runtimeContext),
|
m_runtimeContext(_runtimeContext),
|
||||||
m_abiFunctions(m_evmVersion, m_revertStrings, m_functionCollector),
|
m_abiFunctions(m_evmVersion, m_revertStrings, m_yulFunctionCollector),
|
||||||
m_yulUtilFunctions(m_evmVersion, m_revertStrings, m_functionCollector)
|
m_yulUtilFunctions(m_evmVersion, m_revertStrings, m_yulFunctionCollector)
|
||||||
{
|
{
|
||||||
if (m_runtimeContext)
|
if (m_runtimeContext)
|
||||||
m_runtimeSub = size_t(m_asm->newSub(m_runtimeContext->m_asm).data());
|
m_runtimeSub = size_t(m_asm->newSub(m_runtimeContext->m_asm).data());
|
||||||
@ -133,8 +133,8 @@ public:
|
|||||||
std::function<void(CompilerContext&)> const& _generator
|
std::function<void(CompilerContext&)> const& _generator
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Appends a call to a yul util function and registers the function as externally used.
|
/// Appends a call to a yul function and registers the function as externally used.
|
||||||
void callYulUtilFunction(
|
void callYulFunction(
|
||||||
std::string const& _name,
|
std::string const& _name,
|
||||||
unsigned _inArgs,
|
unsigned _inArgs,
|
||||||
unsigned _outArgs
|
unsigned _outArgs
|
||||||
@ -370,10 +370,10 @@ private:
|
|||||||
size_t m_runtimeSub = -1;
|
size_t m_runtimeSub = -1;
|
||||||
/// An index of low-level function labels by name.
|
/// An index of low-level function labels by name.
|
||||||
std::map<std::string, evmasm::AssemblyItem> m_lowLevelFunctions;
|
std::map<std::string, evmasm::AssemblyItem> m_lowLevelFunctions;
|
||||||
// Collector for yul functions.
|
/// Collector for yul functions.
|
||||||
std::shared_ptr<MultiUseYulFunctionCollector> m_functionCollector = std::make_shared<MultiUseYulFunctionCollector>();
|
std::shared_ptr<MultiUseYulFunctionCollector> m_yulFunctionCollector = std::make_shared<MultiUseYulFunctionCollector>();
|
||||||
/// Set of externally used yul functions.
|
/// Set of externally used yul functions.
|
||||||
std::set<std::string> m_externallyUsedFunctions;
|
std::set<std::string> m_externallyUsedYulFunctions;
|
||||||
/// Container for ABI functions to be generated.
|
/// Container for ABI functions to be generated.
|
||||||
ABIFunctions m_abiFunctions;
|
ABIFunctions m_abiFunctions;
|
||||||
/// Container for Yul Util functions to be generated.
|
/// Container for Yul Util functions to be generated.
|
||||||
|
@ -599,7 +599,7 @@ void CompilerUtils::abiEncodeV2(
|
|||||||
_padToWordBoundaries ?
|
_padToWordBoundaries ?
|
||||||
m_context.abiFunctions().tupleEncoder(_givenTypes, _targetTypes, _encodeAsLibraryTypes) :
|
m_context.abiFunctions().tupleEncoder(_givenTypes, _targetTypes, _encodeAsLibraryTypes) :
|
||||||
m_context.abiFunctions().tupleEncoderPacked(_givenTypes, _targetTypes);
|
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)
|
void CompilerUtils::abiDecodeV2(TypePointers const& _parameterTypes, bool _fromMemory)
|
||||||
@ -609,7 +609,7 @@ void CompilerUtils::abiDecodeV2(TypePointers const& _parameterTypes, bool _fromM
|
|||||||
m_context << Instruction::SWAP1;
|
m_context << Instruction::SWAP1;
|
||||||
// stack: <end> <start>
|
// stack: <end> <start>
|
||||||
string decoderName = m_context.abiFunctions().tupleDecoder(_parameterTypes, _fromMemory);
|
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)
|
void CompilerUtils::zeroInitialiseMemoryArray(ArrayType const& _type)
|
||||||
|
@ -1267,12 +1267,12 @@ void ContractCompiler::appendMissingFunctions()
|
|||||||
solAssert(m_context.nextFunctionToCompile() != function, "Compiled the wrong function?");
|
solAssert(m_context.nextFunctionToCompile() != function, "Compiled the wrong function?");
|
||||||
}
|
}
|
||||||
m_context.appendMissingLowLevelFunctions();
|
m_context.appendMissingLowLevelFunctions();
|
||||||
auto yulFunctions = m_context.requestedYulFunctions();
|
auto [yulFunctions, externallyUsedYulFunctions] = m_context.requestedYulFunctions();
|
||||||
if (!yulFunctions.first.empty())
|
if (!yulFunctions.empty())
|
||||||
m_context.appendInlineAssembly(
|
m_context.appendInlineAssembly(
|
||||||
"{" + move(yulFunctions.first) + "}",
|
"{" + move(yulFunctions) + "}",
|
||||||
{},
|
{},
|
||||||
yulFunctions.second,
|
externallyUsedYulFunctions,
|
||||||
true,
|
true,
|
||||||
m_optimiserSettings
|
m_optimiserSettings
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user