Mapping access with multi-slot keys.

This commit is contained in:
chriseth
2021-02-24 13:44:23 +01:00
parent 2d48052ae5
commit 5e9637bc39
3 changed files with 25 additions and 4 deletions
+1 -3
View File
@@ -2353,8 +2353,6 @@ string YulUtilFunctions::copyArrayFromStorageToMemoryFunction(ArrayType const& _
string YulUtilFunctions::mappingIndexAccessFunction(MappingType const& _mappingType, Type const& _keyType)
{
solAssert(_keyType.sizeOnStack() <= 1, "");
string functionName = "mapping_index_access_" + _mappingType.identifier() + "_of_" + _keyType.identifier();
return m_functionCollector.createFunction(functionName, [&]() {
if (_mappingType.keyType()->isDynamicallySized())
@@ -2364,7 +2362,7 @@ string YulUtilFunctions::mappingIndexAccessFunction(MappingType const& _mappingT
}
)")
("functionName", functionName)
("key", _keyType.sizeOnStack() > 0 ? "key" : "")
("key", suffixedVariableNameList("key_", 0, _keyType.sizeOnStack()))
("hash", packedHashFunction(
{&_keyType, TypeProvider::uint256()},
{_mappingType.keyType(), TypeProvider::uint256()}
@@ -2062,7 +2062,6 @@ void IRGeneratorForStatements::endVisit(IndexAccess const& _indexAccess)
MappingType const& mappingType = dynamic_cast<MappingType const&>(baseType);
Type const& keyType = *_indexAccess.indexExpression()->annotation().type;
solAssert(keyType.sizeOnStack() <= 1, "");
string slot = m_context.newYulVariable();
Whiskers templ("let <slot> := <indexAccess>(<base><?+key>,<key></+key>)\n");