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
|
BoolResult ArraySliceType::isImplicitlyConvertibleTo(Type const& _other) const
|
||||||
{
|
{
|
||||||
if (
|
return
|
||||||
m_arrayType.dataStoredIn(DataLocation::CallData) &&
|
(*this) == _other ||
|
||||||
m_arrayType.isDynamicallySized() &&
|
(
|
||||||
m_arrayType.isImplicitlyConvertibleTo(_other)
|
m_arrayType.dataStoredIn(DataLocation::CallData) &&
|
||||||
)
|
m_arrayType.isDynamicallySized() &&
|
||||||
return true;
|
m_arrayType.isImplicitlyConvertibleTo(_other)
|
||||||
return (*this) == _other;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
string ArraySliceType::richIdentifier() const
|
string ArraySliceType::richIdentifier() const
|
||||||
|
@ -2852,8 +2852,8 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
|||||||
solAssert(_from.dataStoredIn(DataLocation::CallData), "");
|
solAssert(_from.dataStoredIn(DataLocation::CallData), "");
|
||||||
solAssert(_to.category() == Type::Category::Array, "");
|
solAssert(_to.category() == Type::Category::Array, "");
|
||||||
|
|
||||||
ArraySliceType const& fromType = dynamic_cast<ArraySliceType const&>(_from);
|
auto const& fromType = dynamic_cast<ArraySliceType const&>(_from);
|
||||||
ArrayType const& targetType = dynamic_cast<ArrayType const&>(_to);
|
auto const& targetType = dynamic_cast<ArrayType const&>(_to);
|
||||||
|
|
||||||
solAssert(!fromType.arrayType().baseType()->isDynamicallyEncoded(), "");
|
solAssert(!fromType.arrayType().baseType()->isDynamicallyEncoded(), "");
|
||||||
solAssert(
|
solAssert(
|
||||||
@ -2861,6 +2861,9 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
|||||||
"Converting arrays of different type is not possible"
|
"Converting arrays of different type is not possible"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!targetType.dataStoredIn(DataLocation::CallData))
|
||||||
|
return arrayConversionFunction(fromType.arrayType(), targetType);
|
||||||
|
|
||||||
string const functionName =
|
string const functionName =
|
||||||
"convert_" +
|
"convert_" +
|
||||||
_from.identifier() +
|
_from.identifier() +
|
||||||
|
Loading…
Reference in New Issue
Block a user