mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Implement datasize, dataoffset and datacopy for yul interpreter.
This commit is contained in:
committed by
Bhargava Shastry
parent
e99efec085
commit
f113f8e4a0
@@ -444,6 +444,29 @@ u256 EVMInstructionInterpreter::eval(
|
||||
return 0;
|
||||
}
|
||||
|
||||
u256 EVMInstructionInterpreter::evalBuiltin(YulString _name, const std::vector<u256>& _arguments)
|
||||
{
|
||||
if (_name == "datasize"_yulstring)
|
||||
return u256(keccak256(h256(_arguments.at(0)))) & 0xfff;
|
||||
else if (_name == "dataoffset"_yulstring)
|
||||
return u256(keccak256(h256(_arguments.at(0) + 2))) & 0xfff;
|
||||
else if (_name == "datacopy"_yulstring)
|
||||
{
|
||||
// This is identical to codecopy.
|
||||
if (logMemoryWrite(_arguments.at(0), _arguments.at(2)))
|
||||
copyZeroExtended(
|
||||
m_state.memory,
|
||||
m_state.code,
|
||||
size_t(_arguments.at(0)),
|
||||
size_t(_arguments.at(1) & size_t(-1)),
|
||||
size_t(_arguments.at(2))
|
||||
);
|
||||
}
|
||||
else
|
||||
yulAssert(false, "Unknown builtin: " + _name.str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool EVMInstructionInterpreter::logMemoryRead(u256 const& _offset, u256 const& _size)
|
||||
{
|
||||
return logMemory(false, _offset, _size);
|
||||
|
||||
Reference in New Issue
Block a user