feat: change generation of bytecode for pushes with zero-value

This commit is contained in:
hrkrshnn 2023-04-09 16:00:26 +02:00
parent 8757e0aa11
commit 0bfcdaf794

View File

@ -560,11 +560,18 @@ LinkerObject const& Assembly::assemble() const
break; break;
case Push: case Push:
{ {
unsigned b = max<unsigned>(1, numberEncodingSize(i.data())); unsigned b = numberEncodingSize(i.data());
if (b == 0 && !m_evmVersion.hasPush0())
{
b = 1;
}
ret.bytecode.push_back(static_cast<uint8_t>(pushInstruction(b))); ret.bytecode.push_back(static_cast<uint8_t>(pushInstruction(b)));
ret.bytecode.resize(ret.bytecode.size() + b); if (b > 0)
bytesRef byr(&ret.bytecode.back() + 1 - b, b); {
toBigEndian(i.data(), byr); ret.bytecode.resize(ret.bytecode.size() + b);
bytesRef byr(&ret.bytecode.back() + 1 - b, b);
toBigEndian(i.data(), byr);
}
break; break;
} }
case PushTag: case PushTag: