mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix calldata index access.
This commit is contained in:
parent
826ed58b2f
commit
8f570a3184
@ -1998,28 +1998,27 @@ void IRGeneratorForStatements::endVisit(IndexAccess const& _indexAccess)
|
||||
}
|
||||
case DataLocation::CallData:
|
||||
{
|
||||
IRVariable var(m_context.newYulVariable(), *arrayType.baseType());
|
||||
define(var) <<
|
||||
m_utils.calldataArrayIndexAccessFunction(arrayType) <<
|
||||
"(" <<
|
||||
IRVariable(_indexAccess.baseExpression()).commaSeparatedList() <<
|
||||
", " <<
|
||||
expressionAsType(*_indexAccess.indexExpression(), *TypeProvider::uint256()) <<
|
||||
string const indexAccessFunctionCall =
|
||||
m_utils.calldataArrayIndexAccessFunction(arrayType) +
|
||||
"(" +
|
||||
IRVariable(_indexAccess.baseExpression()).commaSeparatedList() +
|
||||
", " +
|
||||
expressionAsType(*_indexAccess.indexExpression(), *TypeProvider::uint256()) +
|
||||
")\n";
|
||||
if (arrayType.isByteArray())
|
||||
define(_indexAccess) <<
|
||||
m_utils.cleanupFunction(*arrayType.baseType()) <<
|
||||
"(calldataload(" <<
|
||||
var.name() <<
|
||||
indexAccessFunctionCall <<
|
||||
"))\n";
|
||||
else if (arrayType.baseType()->isValueType())
|
||||
define(_indexAccess) <<
|
||||
m_utils.readFromCalldata(*arrayType.baseType()) <<
|
||||
"(" <<
|
||||
var.commaSeparatedList() <<
|
||||
indexAccessFunctionCall <<
|
||||
")\n";
|
||||
else
|
||||
define(_indexAccess, var);
|
||||
define(_indexAccess) << indexAccessFunctionCall;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ contract C {
|
||||
return reenc ? this.f_reenc(a) : this.f(a);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g(bool): false -> 23, 37, 71
|
||||
// g(bool): true -> 23, 37, 71
|
||||
|
Loading…
Reference in New Issue
Block a user