mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9503 from ethereum/copyStructCalldataMemorySol2Yul
[Sol->Yul] Implementing struct copying from calldata to memory.
This commit is contained in:
commit
e68d16d8e0
@ -1911,8 +1911,23 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
||||
break;
|
||||
}
|
||||
case Type::Category::Struct:
|
||||
solUnimplementedAssert(false, "Struct conversion not implemented.");
|
||||
{
|
||||
solAssert(toCategory == Type::Category::Struct, "");
|
||||
auto const& fromStructType = dynamic_cast<StructType const &>(_from);
|
||||
auto const& toStructType = dynamic_cast<StructType const &>(_to);
|
||||
solAssert(fromStructType.structDefinition() == toStructType.structDefinition(), "");
|
||||
|
||||
solUnimplementedAssert(!fromStructType.isDynamicallyEncoded(), "");
|
||||
solUnimplementedAssert(toStructType.location() == DataLocation::Memory, "");
|
||||
solUnimplementedAssert(fromStructType.location() == DataLocation::CallData, "");
|
||||
|
||||
body = Whiskers(R"(
|
||||
converted := <abiDecode>(value, calldatasize())
|
||||
)")("abiDecode", ABIFunctions(m_evmVersion, m_revertStrings, m_functionCollector).tupleDecoder(
|
||||
{&toStructType}
|
||||
)).render();
|
||||
break;
|
||||
}
|
||||
case Type::Category::FixedBytes:
|
||||
{
|
||||
FixedBytesType const& from = dynamic_cast<FixedBytesType const&>(_from);
|
||||
|
@ -1,6 +1,5 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint256 a;
|
||||
@ -13,5 +12,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256,uint256)): 42, 23 -> 42, 23
|
||||
|
@ -23,5 +23,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256,uint256,(uint256,uint256),uint256)): 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5
|
||||
|
Loading…
Reference in New Issue
Block a user