mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol->Yul] Implement .length for storage arrays
This commit is contained in:
@@ -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:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user