mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Note function entry points.
This commit is contained in:
@@ -148,7 +148,7 @@ void CompilerContext::callYulFunction(
|
||||
m_externallyUsedYulFunctions.insert(_name);
|
||||
auto const retTag = pushNewTag();
|
||||
CompilerUtils(*this).moveIntoStack(_inArgs);
|
||||
appendJumpTo(namedTag(_name), evmasm::AssemblyItem::JumpType::IntoFunction);
|
||||
appendJumpTo(namedTag(_name, _inArgs, _outArgs, {}), evmasm::AssemblyItem::JumpType::IntoFunction);
|
||||
adjustStackOffset(static_cast<int>(_outArgs) - 1 - static_cast<int>(_inArgs));
|
||||
*this << retTag.tag();
|
||||
}
|
||||
@@ -596,7 +596,23 @@ evmasm::AssemblyItem CompilerContext::FunctionCompilationQueue::entryLabel(
|
||||
auto res = m_entryLabels.find(&_declaration);
|
||||
if (res == m_entryLabels.end())
|
||||
{
|
||||
evmasm::AssemblyItem tag(_context.newTag());
|
||||
size_t params = 0;
|
||||
size_t returns = 0;
|
||||
if (auto const* function = dynamic_cast<FunctionDefinition const*>(&_declaration))
|
||||
{
|
||||
FunctionType functionType(*function, FunctionType::Kind::Internal);
|
||||
params = CompilerUtils::sizeOnStack(functionType.parameterTypes());
|
||||
returns = CompilerUtils::sizeOnStack(functionType.returnParameterTypes());
|
||||
}
|
||||
|
||||
// some name that cannot clash with yul function names.
|
||||
string labelName = "@" + _declaration.name() + "_" + to_string(_declaration.id());
|
||||
evmasm::AssemblyItem tag = _context.namedTag(
|
||||
labelName,
|
||||
params,
|
||||
returns,
|
||||
_declaration.id()
|
||||
);
|
||||
m_entryLabels.insert(make_pair(&_declaration, tag));
|
||||
m_functionsToCompile.push(&_declaration);
|
||||
return tag.tag();
|
||||
|
||||
@@ -216,7 +216,10 @@ public:
|
||||
/// @returns a new tag without pushing any opcodes or data
|
||||
evmasm::AssemblyItem newTag() { return m_asm->newTag(); }
|
||||
/// @returns a new tag identified by name.
|
||||
evmasm::AssemblyItem namedTag(std::string const& _name) { return m_asm->namedTag(_name); }
|
||||
evmasm::AssemblyItem namedTag(std::string const& _name, size_t _params, size_t _returns, std::optional<uint64_t> _sourceID)
|
||||
{
|
||||
return m_asm->namedTag(_name, _params, _returns, _sourceID);
|
||||
}
|
||||
/// Adds a subroutine to the code (in the data section) and pushes its size (via a tag)
|
||||
/// on the stack. @returns the pushsub assembly item.
|
||||
evmasm::AssemblyItem addSubroutine(evmasm::AssemblyPointer const& _assembly) { return m_asm->appendSubroutine(_assembly); }
|
||||
|
||||
Reference in New Issue
Block a user