mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Properly compute source mappings for immutables.
This commit is contained in:
committed by
Mathias Baumann
parent
49d7b78466
commit
b1dd0d0d02
@@ -48,11 +48,11 @@ using namespace solidity::evmasm;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::util;
|
||||
|
||||
AssemblyItem const& Assembly::append(AssemblyItem const& _i)
|
||||
AssemblyItem const& Assembly::append(AssemblyItem _i)
|
||||
{
|
||||
assertThrow(m_deposit >= 0, AssemblyException, "Stack underflow.");
|
||||
m_deposit += static_cast<int>(_i.deposit());
|
||||
m_items.emplace_back(_i);
|
||||
m_items.emplace_back(move(_i));
|
||||
if (!m_items.back().location().isValid() && m_currentSourceLocation.isValid())
|
||||
m_items.back().setLocation(m_currentSourceLocation);
|
||||
m_items.back().m_modifierDepth = m_currentModifierDepth;
|
||||
@@ -68,7 +68,7 @@ unsigned Assembly::codeSize(unsigned subTagSize) const
|
||||
ret += i.second.size();
|
||||
|
||||
for (AssemblyItem const& i: m_items)
|
||||
ret += i.bytesRequired(tagSize);
|
||||
ret += i.bytesRequired(tagSize, Precision::Approximate);
|
||||
if (numberEncodingSize(ret) <= tagSize)
|
||||
return static_cast<unsigned>(ret);
|
||||
}
|
||||
@@ -696,8 +696,11 @@ LinkerObject const& Assembly::assemble() const
|
||||
break;
|
||||
case PushImmutable:
|
||||
ret.bytecode.push_back(static_cast<uint8_t>(Instruction::PUSH32));
|
||||
// Maps keccak back to the "identifier" string of that immutable.
|
||||
ret.immutableReferences[i.data()].first = m_immutables.at(i.data());
|
||||
// Record the bytecode offset of the PUSH32 argument.
|
||||
ret.immutableReferences[i.data()].second.emplace_back(ret.bytecode.size());
|
||||
// Advance bytecode by 32 bytes (default initialized).
|
||||
ret.bytecode.resize(ret.bytecode.size() + 32);
|
||||
break;
|
||||
case VerbatimBytecode:
|
||||
@@ -705,6 +708,7 @@ LinkerObject const& Assembly::assemble() const
|
||||
break;
|
||||
case AssignImmutable:
|
||||
{
|
||||
// Expect 2 elements on stack (source, dest_base)
|
||||
auto const& offsets = immutableReferencesBySub[i.data()].second;
|
||||
for (size_t i = 0; i < offsets.size(); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user