WIP - Expression compiler for array push

This commit is contained in:
Lefteris Karapetsas 2015-10-12 10:11:58 +02:00
parent 763b544822
commit 3287cd464f

View File

@ -784,8 +784,9 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
}
case Type::Category::Array:
{
solAssert(member == "length", "Illegal array member.");
auto const& type = dynamic_cast<ArrayType const&>(*_memberAccess.expression().annotation().type);
if (member == "length")
{
if (!type.isDynamicallySized())
{
utils().popStackElement(type);
@ -804,6 +805,21 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
m_context << eth::Instruction::MLOAD;
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;
}
default: