mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol->Yul] Fixing nested bytes array push.
This commit is contained in:
@@ -2576,7 +2576,30 @@ string YulUtilFunctions::updateStorageValueFunction(
|
||||
|
||||
auto const* toReferenceType = dynamic_cast<ReferenceType const*>(&_toType);
|
||||
auto const* fromReferenceType = dynamic_cast<ReferenceType const*>(&_fromType);
|
||||
solAssert(fromReferenceType && toReferenceType, "");
|
||||
solAssert(toReferenceType, "");
|
||||
|
||||
if (!fromReferenceType)
|
||||
{
|
||||
solAssert(_fromType.category() == Type::Category::StringLiteral, "");
|
||||
solAssert(toReferenceType->category() == Type::Category::Array, "");
|
||||
auto const& toArrayType = dynamic_cast<ArrayType const&>(*toReferenceType);
|
||||
solAssert(toArrayType.isByteArray(), "");
|
||||
|
||||
return Whiskers(R"(
|
||||
function <functionName>(slot<?dynamicOffset>, offset</dynamicOffset>) {
|
||||
<?dynamicOffset>if offset { <panic>() }</dynamicOffset>
|
||||
let value := <copyLiteralToMemory>()
|
||||
<copyToStorage>(slot, value)
|
||||
}
|
||||
)")
|
||||
("functionName", functionName)
|
||||
("dynamicOffset", !_offset.has_value())
|
||||
("panic", panicFunction(PanicCode::Generic))
|
||||
("copyLiteralToMemory", copyLiteralToMemoryFunction(dynamic_cast<StringLiteralType const&>(_fromType).value()))
|
||||
("copyToStorage", copyArrayToStorageFunction(*TypeProvider::bytesMemory(), toArrayType))
|
||||
.render();
|
||||
}
|
||||
|
||||
solAssert(*toReferenceType->copyForLocation(
|
||||
fromReferenceType->location(),
|
||||
fromReferenceType->isPointer()
|
||||
|
||||
@@ -1325,8 +1325,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
|
||||
m_utils.storageArrayPushFunction(arrayType, &argument.type()) <<
|
||||
"(" <<
|
||||
IRVariable(_functionCall.expression()).commaSeparatedList() <<
|
||||
", " <<
|
||||
argument.commaSeparatedList() <<
|
||||
(argument.stackSlots().empty() ? "" : (", " + argument.commaSeparatedList())) <<
|
||||
")\n";
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user