mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol->Yul] Implementing conversion from calldata slices to memory arrays.
Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
parent
b99a74fb34
commit
8aa4568b10
@ -2074,13 +2074,13 @@ std::unique_ptr<ReferenceType> ArrayType::copyForLocation(DataLocation _location
|
||||
|
||||
BoolResult ArraySliceType::isImplicitlyConvertibleTo(Type const& _other) const
|
||||
{
|
||||
if (
|
||||
m_arrayType.dataStoredIn(DataLocation::CallData) &&
|
||||
m_arrayType.isDynamicallySized() &&
|
||||
m_arrayType.isImplicitlyConvertibleTo(_other)
|
||||
)
|
||||
return true;
|
||||
return (*this) == _other;
|
||||
return
|
||||
(*this) == _other ||
|
||||
(
|
||||
m_arrayType.dataStoredIn(DataLocation::CallData) &&
|
||||
m_arrayType.isDynamicallySized() &&
|
||||
m_arrayType.isImplicitlyConvertibleTo(_other)
|
||||
);
|
||||
}
|
||||
|
||||
string ArraySliceType::richIdentifier() const
|
||||
|
@ -2852,8 +2852,8 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
||||
solAssert(_from.dataStoredIn(DataLocation::CallData), "");
|
||||
solAssert(_to.category() == Type::Category::Array, "");
|
||||
|
||||
ArraySliceType const& fromType = dynamic_cast<ArraySliceType const&>(_from);
|
||||
ArrayType const& targetType = dynamic_cast<ArrayType const&>(_to);
|
||||
auto const& fromType = dynamic_cast<ArraySliceType const&>(_from);
|
||||
auto const& targetType = dynamic_cast<ArrayType const&>(_to);
|
||||
|
||||
solAssert(!fromType.arrayType().baseType()->isDynamicallyEncoded(), "");
|
||||
solAssert(
|
||||
@ -2861,6 +2861,9 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
||||
"Converting arrays of different type is not possible"
|
||||
);
|
||||
|
||||
if (!targetType.dataStoredIn(DataLocation::CallData))
|
||||
return arrayConversionFunction(fromType.arrayType(), targetType);
|
||||
|
||||
string const functionName =
|
||||
"convert_" +
|
||||
_from.identifier() +
|
||||
|
Loading…
Reference in New Issue
Block a user