mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
IRGeneratorForStatements: Small refactor in endVisit(IndexAccess) for readability
This commit is contained in:
parent
16220db759
commit
5b70830a64
@ -2295,14 +2295,13 @@ void IRGeneratorForStatements::endVisit(IndexAccess const& _indexAccess)
|
|||||||
}
|
}
|
||||||
case DataLocation::Memory:
|
case DataLocation::Memory:
|
||||||
{
|
{
|
||||||
string indexAccessFunction = m_utils.memoryArrayIndexAccessFunction(arrayType);
|
string const indexAccessFunction = m_utils.memoryArrayIndexAccessFunction(arrayType);
|
||||||
string const memAddress =
|
string const baseRef = IRVariable(_indexAccess.baseExpression()).part("mpos").name();
|
||||||
indexAccessFunction +
|
string const indexExpression = expressionAsType(
|
||||||
"(" +
|
*_indexAccess.indexExpression(),
|
||||||
IRVariable(_indexAccess.baseExpression()).part("mpos").name() +
|
*TypeProvider::uint256()
|
||||||
", " +
|
);
|
||||||
expressionAsType(*_indexAccess.indexExpression(), *TypeProvider::uint256()) +
|
string const memAddress = indexAccessFunction + "(" + baseRef + ", " + indexExpression + ")";
|
||||||
")";
|
|
||||||
|
|
||||||
setLValue(_indexAccess, IRLValue{
|
setLValue(_indexAccess, IRLValue{
|
||||||
*arrayType.baseType(),
|
*arrayType.baseType(),
|
||||||
@ -2312,28 +2311,28 @@ void IRGeneratorForStatements::endVisit(IndexAccess const& _indexAccess)
|
|||||||
}
|
}
|
||||||
case DataLocation::CallData:
|
case DataLocation::CallData:
|
||||||
{
|
{
|
||||||
string indexAccessFunction = m_utils.calldataArrayIndexAccessFunction(arrayType);
|
string const indexAccessFunction = m_utils.calldataArrayIndexAccessFunction(arrayType);
|
||||||
string const indexAccessFunctionCall =
|
string const baseRef = IRVariable(_indexAccess.baseExpression()).commaSeparatedList();
|
||||||
indexAccessFunction +
|
string const indexExpression = expressionAsType(
|
||||||
"(" +
|
*_indexAccess.indexExpression(),
|
||||||
IRVariable(_indexAccess.baseExpression()).commaSeparatedList() +
|
*TypeProvider::uint256()
|
||||||
", " +
|
);
|
||||||
expressionAsType(*_indexAccess.indexExpression(), *TypeProvider::uint256()) +
|
string const calldataAddress = indexAccessFunction + "(" + baseRef + ", " + indexExpression + ")";
|
||||||
")";
|
|
||||||
if (arrayType.isByteArrayOrString())
|
if (arrayType.isByteArrayOrString())
|
||||||
define(_indexAccess) <<
|
define(_indexAccess) <<
|
||||||
m_utils.cleanupFunction(*arrayType.baseType()) <<
|
m_utils.cleanupFunction(*arrayType.baseType()) <<
|
||||||
"(calldataload(" <<
|
"(calldataload(" <<
|
||||||
indexAccessFunctionCall <<
|
calldataAddress <<
|
||||||
"))\n";
|
"))\n";
|
||||||
else if (arrayType.baseType()->isValueType())
|
else if (arrayType.baseType()->isValueType())
|
||||||
define(_indexAccess) <<
|
define(_indexAccess) <<
|
||||||
m_utils.readFromCalldata(*arrayType.baseType()) <<
|
m_utils.readFromCalldata(*arrayType.baseType()) <<
|
||||||
"(" <<
|
"(" <<
|
||||||
indexAccessFunctionCall <<
|
calldataAddress <<
|
||||||
")\n";
|
")\n";
|
||||||
else
|
else
|
||||||
define(_indexAccess) << indexAccessFunctionCall << "\n";
|
define(_indexAccess) << calldataAddress << "\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user