mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
WIP - Expression compiler for array push
This commit is contained in:
parent
763b544822
commit
3287cd464f
@ -784,8 +784,9 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
|
|||||||
}
|
}
|
||||||
case Type::Category::Array:
|
case Type::Category::Array:
|
||||||
{
|
{
|
||||||
solAssert(member == "length", "Illegal array member.");
|
|
||||||
auto const& type = dynamic_cast<ArrayType const&>(*_memberAccess.expression().annotation().type);
|
auto const& type = dynamic_cast<ArrayType const&>(*_memberAccess.expression().annotation().type);
|
||||||
|
if (member == "length")
|
||||||
|
{
|
||||||
if (!type.isDynamicallySized())
|
if (!type.isDynamicallySized())
|
||||||
{
|
{
|
||||||
utils().popStackElement(type);
|
utils().popStackElement(type);
|
||||||
@ -804,6 +805,21 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
|
|||||||
m_context << eth::Instruction::MLOAD;
|
m_context << eth::Instruction::MLOAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (member == "push" && type.isDynamicallySized() && type.location() == DataLocation::Storage)
|
||||||
|
{
|
||||||
|
if (type.isByteArray())
|
||||||
|
{
|
||||||
|
solAssert(!type.isString(), "Index access to string is not allowed.");
|
||||||
|
setLValue<StorageByteArrayElement>(_indexAccess);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setLValueToStorageItem(_indexAccess);
|
||||||
|
setLValue<StorageArrayLength>(_memberAccess, type);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
solAssert(false, "Illegal array member.");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user