mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Consider non-external functions not left-aligned.
This commit is contained in:
parent
cb052611cf
commit
77932edb02
@ -3072,10 +3072,7 @@ u256 FunctionType::storageSize() const
|
||||
|
||||
bool FunctionType::leftAligned() const
|
||||
{
|
||||
if (m_kind == Kind::External)
|
||||
return true;
|
||||
else
|
||||
solAssert(false, "Alignment property of non-exportable function type requested.");
|
||||
return m_kind == Kind::External;
|
||||
}
|
||||
|
||||
unsigned FunctionType::storageBytes() const
|
||||
|
@ -237,19 +237,6 @@ void StorageItem::retrieveValue(SourceLocation const&, bool _remove) const
|
||||
if (type->category() == Type::Category::FixedPoint)
|
||||
// implementation should be very similar to the integer case.
|
||||
solUnimplemented("Not yet implemented - FixedPointType.");
|
||||
if (type->leftAligned())
|
||||
{
|
||||
CompilerUtils(m_context).leftShiftNumberOnStack(256 - 8 * type->storageBytes());
|
||||
cleaned = true;
|
||||
}
|
||||
else if (
|
||||
type->category() == Type::Category::Integer &&
|
||||
dynamic_cast<IntegerType const&>(*type).isSigned()
|
||||
)
|
||||
{
|
||||
m_context << u256(type->storageBytes() - 1) << Instruction::SIGNEXTEND;
|
||||
cleaned = true;
|
||||
}
|
||||
else if (FunctionType const* fun = dynamic_cast<decltype(fun)>(type))
|
||||
{
|
||||
if (fun->kind() == FunctionType::Kind::External)
|
||||
@ -264,6 +251,20 @@ void StorageItem::retrieveValue(SourceLocation const&, bool _remove) const
|
||||
m_context << Instruction::MUL << Instruction::OR;
|
||||
}
|
||||
}
|
||||
else if (type->leftAligned())
|
||||
{
|
||||
CompilerUtils(m_context).leftShiftNumberOnStack(256 - 8 * type->storageBytes());
|
||||
cleaned = true;
|
||||
}
|
||||
else if (
|
||||
type->category() == Type::Category::Integer &&
|
||||
dynamic_cast<IntegerType const&>(*type).isSigned()
|
||||
)
|
||||
{
|
||||
m_context << u256(type->storageBytes() - 1) << Instruction::SIGNEXTEND;
|
||||
cleaned = true;
|
||||
}
|
||||
|
||||
if (!cleaned)
|
||||
{
|
||||
solAssert(type->sizeOnStack() == 1, "");
|
||||
|
@ -2923,16 +2923,9 @@ string YulUtilFunctions::cleanupFromStorageFunction(Type const& _type)
|
||||
return templ.render();
|
||||
}
|
||||
|
||||
bool leftAligned = false;
|
||||
if (
|
||||
encodingType->category() != Type::Category::Function ||
|
||||
dynamic_cast<FunctionType const&>(*encodingType).kind() == FunctionType::Kind::External
|
||||
)
|
||||
leftAligned = encodingType->leftAligned();
|
||||
|
||||
if (storageBytes == 32)
|
||||
templ("cleaned", "value");
|
||||
else if (leftAligned)
|
||||
else if (encodingType->leftAligned())
|
||||
templ("cleaned", shiftLeftFunction(256 - 8 * storageBytes) + "(value)");
|
||||
else
|
||||
templ("cleaned", "and(value, " + toCompactHexWithPrefix((u256(1) << (8 * storageBytes)) - 1) + ")");
|
||||
|
Loading…
Reference in New Issue
Block a user