mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9501 from ethereum/calldataToMemoryCopy
[Sol->Yul] Implementing bytes copying from calldata to memory.
This commit is contained in:
@@ -2406,6 +2406,29 @@ string YulUtilFunctions::conversionFunctionSpecial(Type const& _from, Type const
|
||||
.render();
|
||||
}
|
||||
|
||||
if (_from.category() == Type::Category::Array && _to.category() == Type::Category::Array)
|
||||
{
|
||||
auto const& fromArrayType = dynamic_cast<ArrayType const&>(_from);
|
||||
auto const& toArrayType = dynamic_cast<ArrayType const&>(_to);
|
||||
|
||||
solAssert(!fromArrayType.baseType()->isDynamicallyEncoded(), "");
|
||||
solUnimplementedAssert(fromArrayType.isByteArray() && toArrayType.isByteArray(), "");
|
||||
solUnimplementedAssert(toArrayType.location() == DataLocation::Memory, "");
|
||||
solUnimplementedAssert(fromArrayType.location() == DataLocation::CallData, "");
|
||||
solUnimplementedAssert(toArrayType.isDynamicallySized(), "");
|
||||
|
||||
Whiskers templ(R"(
|
||||
function <functionName>(offset, length) -> converted {
|
||||
converted := <allocateMemoryArray>(length)
|
||||
<copyToMemory>(offset, add(converted, 0x20), length)
|
||||
}
|
||||
)");
|
||||
templ("functionName", functionName);
|
||||
templ("allocateMemoryArray", allocateMemoryArrayFunction(toArrayType));
|
||||
templ("copyToMemory", copyToMemoryFunction(fromArrayType.location() == DataLocation::CallData));
|
||||
return templ.render();
|
||||
}
|
||||
|
||||
solUnimplementedAssert(
|
||||
_from.category() == Type::Category::StringLiteral,
|
||||
"Type conversion " + _from.toString() + " -> " + _to.toString() + " not yet implemented."
|
||||
|
||||
Reference in New Issue
Block a user