[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
+19
View File
@@ -34,6 +34,7 @@ namespace solidity
class VariableDeclaration;
class IRGenerationContext;
class Type;
class ArrayType;
/**
* Abstract class used to retrieve, delete and store data in LValues.
@@ -107,6 +108,24 @@ private:
boost::variant<std::string, unsigned> const m_offset;
};
/**
* Reference to the "length" member of a dynamically-sized storage array. This is an LValue with special
* semantics since assignments to it might reduce its length and thus the array's members have to be
* deleted.
*/
class IRStorageArrayLength: public IRLValue
{
public:
IRStorageArrayLength(IRGenerationContext& _context, std::string _slot, Type const& _type, ArrayType const& _arrayType);
std::string retrieveValue() const override;
std::string storeValue(std::string const& _value, Type const& _type) const override;
std::string setToZero() const override;
private:
ArrayType const& m_arrayType;
std::string const m_slot;
};
}
}