[Sol->Yul] Implement .length for storage arrays

This commit is contained in:
Mathias Baumann
2019-06-19 18:09:23 +02:00
parent c5b50039d2
commit 910cb8d329
6 changed files with 225 additions and 1 deletions
@@ -703,7 +703,35 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess)
}
case Type::Category::Array:
{
solUnimplementedAssert(false, "");
auto const& type = dynamic_cast<ArrayType const&>(*_memberAccess.expression().annotation().type);
solAssert(member == "length", "");
if (!type.isDynamicallySized())
defineExpression(_memberAccess) << type.length() << "\n";
else
switch (type.location())
{
case DataLocation::CallData:
solUnimplementedAssert(false, "");
//m_context << Instruction::SWAP1 << Instruction::POP;
break;
case DataLocation::Storage:
setLValue(_memberAccess, make_unique<IRStorageArrayLength>(
m_context,
m_context.variable(_memberAccess.expression()),
*_memberAccess.annotation().type,
type
));
break;
case DataLocation::Memory:
solUnimplementedAssert(false, "");
//m_context << Instruction::MLOAD;
break;
}
break;
}
case Type::Category::FixedBytes:
{