mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Some more compression.
This commit is contained in:
parent
d3d205b6eb
commit
b3e51bcae1
@ -573,7 +573,7 @@ string YulUtilFunctions::cleanupFromStorageFunction(Type const& _type, bool _spl
|
|||||||
return m_functionCollector->createFunction(functionName, [&] {
|
return m_functionCollector->createFunction(functionName, [&] {
|
||||||
Whiskers templ(R"(
|
Whiskers templ(R"(
|
||||||
function <functionName>(value) -> cleaned {
|
function <functionName>(value) -> cleaned {
|
||||||
<body>
|
cleaned := <cleaned>
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
templ("functionName", functionName);
|
templ("functionName", functionName);
|
||||||
@ -582,16 +582,16 @@ string YulUtilFunctions::cleanupFromStorageFunction(Type const& _type, bool _spl
|
|||||||
if (IntegerType const* type = dynamic_cast<IntegerType const*>(&_type))
|
if (IntegerType const* type = dynamic_cast<IntegerType const*>(&_type))
|
||||||
if (type->isSigned() && storageBytes != 32)
|
if (type->isSigned() && storageBytes != 32)
|
||||||
{
|
{
|
||||||
templ("body", "cleaned := signextend(" + to_string(storageBytes - 1) + ", value)");
|
templ("cleaned", "signextend(" + to_string(storageBytes - 1) + ", value)");
|
||||||
return templ.render();
|
return templ.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storageBytes == 32)
|
if (storageBytes == 32)
|
||||||
templ("body", "cleaned := value");
|
templ("cleaned", "value");
|
||||||
else if (_type.leftAligned())
|
else if (_type.leftAligned())
|
||||||
templ("body", "cleaned := " + shiftLeftFunction(256 - 8 * storageBytes) + "(value)");
|
templ("cleaned", shiftLeftFunction(256 - 8 * storageBytes) + "(value)");
|
||||||
else
|
else
|
||||||
templ("body", "cleaned := and(value, " + toCompactHexWithPrefix((u256(1) << (8 * storageBytes)) - 1) + ")");
|
templ("cleaned", "and(value, " + toCompactHexWithPrefix((u256(1) << (8 * storageBytes)) - 1) + ")");
|
||||||
|
|
||||||
return templ.render();
|
return templ.render();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user