mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Activating bytes to bytesNN for legacy codegen by calling yul util function.
This commit is contained in:
parent
52538558b1
commit
cbb7e53b22
@ -961,8 +961,31 @@ void CompilerUtils::convertType(
|
|||||||
}
|
}
|
||||||
case Type::Category::Array:
|
case Type::Category::Array:
|
||||||
{
|
{
|
||||||
solAssert(targetTypeCategory == stackTypeCategory, "");
|
|
||||||
auto const& typeOnStack = dynamic_cast<ArrayType const&>(_typeOnStack);
|
auto const& typeOnStack = dynamic_cast<ArrayType const&>(_typeOnStack);
|
||||||
|
if (_targetType.category() == Type::Category::FixedBytes)
|
||||||
|
{
|
||||||
|
solAssert(
|
||||||
|
typeOnStack.isByteArray() && !typeOnStack.isString(),
|
||||||
|
"Array types other than bytes not convertible to bytesNN."
|
||||||
|
);
|
||||||
|
solAssert(typeOnStack.isDynamicallySized(), "");
|
||||||
|
|
||||||
|
bool fromCalldata = typeOnStack.dataStoredIn(DataLocation::CallData);
|
||||||
|
solAssert(typeOnStack.sizeOnStack() == (fromCalldata ? 2 : 1), "");
|
||||||
|
if (fromCalldata)
|
||||||
|
m_context << Instruction::SWAP1;
|
||||||
|
|
||||||
|
m_context.callYulFunction(
|
||||||
|
m_context.utilFunctions().bytesToFixedBytesConversionFunction(
|
||||||
|
typeOnStack,
|
||||||
|
dynamic_cast<FixedBytesType const &>(_targetType)
|
||||||
|
),
|
||||||
|
typeOnStack.sizeOnStack(),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
solAssert(targetTypeCategory == stackTypeCategory, "");
|
||||||
auto const& targetType = dynamic_cast<ArrayType const&>(_targetType);
|
auto const& targetType = dynamic_cast<ArrayType const&>(_targetType);
|
||||||
switch (targetType.location())
|
switch (targetType.location())
|
||||||
{
|
{
|
||||||
@ -1066,8 +1089,30 @@ void CompilerUtils::convertType(
|
|||||||
}
|
}
|
||||||
case Type::Category::ArraySlice:
|
case Type::Category::ArraySlice:
|
||||||
{
|
{
|
||||||
solAssert(_targetType.category() == Type::Category::Array, "");
|
|
||||||
auto& typeOnStack = dynamic_cast<ArraySliceType const&>(_typeOnStack);
|
auto& typeOnStack = dynamic_cast<ArraySliceType const&>(_typeOnStack);
|
||||||
|
if (_targetType.category() == Type::Category::FixedBytes)
|
||||||
|
{
|
||||||
|
solAssert(
|
||||||
|
typeOnStack.arrayType().isByteArray() && !typeOnStack.arrayType().isString(),
|
||||||
|
"Array types other than bytes not convertible to bytesNN."
|
||||||
|
);
|
||||||
|
solAssert(typeOnStack.isDynamicallySized(), "");
|
||||||
|
solAssert(typeOnStack.dataStoredIn(DataLocation::CallData), "");
|
||||||
|
solAssert(typeOnStack.sizeOnStack() == 2, "");
|
||||||
|
|
||||||
|
m_context << Instruction::SWAP1;
|
||||||
|
m_context.callYulFunction(
|
||||||
|
m_context.utilFunctions().bytesToFixedBytesConversionFunction(
|
||||||
|
typeOnStack.arrayType(),
|
||||||
|
dynamic_cast<FixedBytesType const &>(_targetType)
|
||||||
|
),
|
||||||
|
2,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
solAssert(_targetType.category() == Type::Category::Array, "");
|
||||||
auto const& targetArrayType = dynamic_cast<ArrayType const&>(_targetType);
|
auto const& targetArrayType = dynamic_cast<ArrayType const&>(_targetType);
|
||||||
solAssert(typeOnStack.arrayType().isImplicitlyConvertibleTo(targetArrayType), "");
|
solAssert(typeOnStack.arrayType().isImplicitlyConvertibleTo(targetArrayType), "");
|
||||||
solAssert(
|
solAssert(
|
||||||
|
Loading…
Reference in New Issue
Block a user