diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 5d624c26d..b1a77cf89 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -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 diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index 2ff69e4ac..b77141445 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -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(*type).isSigned() - ) - { - m_context << u256(type->storageBytes() - 1) << Instruction::SIGNEXTEND; - cleaned = true; - } else if (FunctionType const* fun = dynamic_cast(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(*type).isSigned() + ) + { + m_context << u256(type->storageBytes() - 1) << Instruction::SIGNEXTEND; + cleaned = true; + } + if (!cleaned) { solAssert(type->sizeOnStack() == 1, ""); diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index 7f6f48e26..9da1d5063 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -2923,16 +2923,9 @@ string YulUtilFunctions::cleanupFromStorageFunction(Type const& _type) return templ.render(); } - bool leftAligned = false; - if ( - encodingType->category() != Type::Category::Function || - dynamic_cast(*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) + ")");