mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use only a single stack slot for storage references.
This commit is contained in:
@@ -714,7 +714,6 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
|
||||
{
|
||||
case DataLocation::Storage:
|
||||
{
|
||||
m_context << eth::Instruction::POP; // structs always align to new slot
|
||||
pair<u256, unsigned> const& offsets = type.getStorageOffsetsOfMember(member);
|
||||
m_context << offsets.first << eth::Instruction::ADD << u256(offsets.second);
|
||||
setLValueToStorageItem(_memberAccess);
|
||||
@@ -792,8 +791,6 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
|
||||
Type const& baseType = *_indexAccess.getBaseExpression().getType();
|
||||
if (baseType.getCategory() == Type::Category::Mapping)
|
||||
{
|
||||
// storage byte offset is ignored for mappings, it should be zero.
|
||||
m_context << eth::Instruction::POP;
|
||||
// stack: storage_base_ref
|
||||
Type const& keyType = *dynamic_cast<MappingType const&>(baseType).getKeyType();
|
||||
m_context << u256(0); // memory position
|
||||
@@ -812,10 +809,6 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
|
||||
ArrayType const& arrayType = dynamic_cast<ArrayType const&>(baseType);
|
||||
solAssert(_indexAccess.getIndexExpression(), "Index expression expected.");
|
||||
|
||||
// remove storage byte offset
|
||||
if (arrayType.location() == DataLocation::Storage)
|
||||
m_context << eth::Instruction::POP;
|
||||
|
||||
_indexAccess.getIndexExpression()->accept(*this);
|
||||
// stack layout: <base_ref> [<length>] <index>
|
||||
ArrayUtils(m_context).accessIndex(arrayType);
|
||||
|
||||
Reference in New Issue
Block a user