mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol->Yul] Implementing struct copying from calldata to memory.
Co-authored-by: Daniel Kirchner <daniel@ekpyron.org>
This commit is contained in:
parent
05901f5bc9
commit
d685bee2ec
@ -1911,8 +1911,23 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type::Category::Struct:
|
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;
|
break;
|
||||||
|
}
|
||||||
case Type::Category::FixedBytes:
|
case Type::Category::FixedBytes:
|
||||||
{
|
{
|
||||||
FixedBytesType const& from = dynamic_cast<FixedBytesType const&>(_from);
|
FixedBytesType const& from = dynamic_cast<FixedBytesType const&>(_from);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
struct S {
|
struct S {
|
||||||
uint256 a;
|
uint256 a;
|
||||||
@ -13,5 +12,7 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
// ----
|
// ----
|
||||||
// f((uint256,uint256)): 42, 23 -> 42, 23
|
// 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
|
// f((uint256,uint256,(uint256,uint256),uint256)): 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5
|
||||||
|
Loading…
Reference in New Issue
Block a user