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:
|
case DataLocation::CallData:
|
||||||
{
|
{
|
||||||
IRVariable var(m_context.newYulVariable(), *arrayType.baseType());
|
string const indexAccessFunctionCall =
|
||||||
define(var) <<
|
m_utils.calldataArrayIndexAccessFunction(arrayType) +
|
||||||
m_utils.calldataArrayIndexAccessFunction(arrayType) <<
|
"(" +
|
||||||
"(" <<
|
IRVariable(_indexAccess.baseExpression()).commaSeparatedList() +
|
||||||
IRVariable(_indexAccess.baseExpression()).commaSeparatedList() <<
|
", " +
|
||||||
", " <<
|
expressionAsType(*_indexAccess.indexExpression(), *TypeProvider::uint256()) +
|
||||||
expressionAsType(*_indexAccess.indexExpression(), *TypeProvider::uint256()) <<
|
|
||||||
")\n";
|
")\n";
|
||||||
if (arrayType.isByteArray())
|
if (arrayType.isByteArray())
|
||||||
define(_indexAccess) <<
|
define(_indexAccess) <<
|
||||||
m_utils.cleanupFunction(*arrayType.baseType()) <<
|
m_utils.cleanupFunction(*arrayType.baseType()) <<
|
||||||
"(calldataload(" <<
|
"(calldataload(" <<
|
||||||
var.name() <<
|
indexAccessFunctionCall <<
|
||||||
"))\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()) <<
|
||||||
"(" <<
|
"(" <<
|
||||||
var.commaSeparatedList() <<
|
indexAccessFunctionCall <<
|
||||||
")\n";
|
")\n";
|
||||||
else
|
else
|
||||||
define(_indexAccess, var);
|
define(_indexAccess) << indexAccessFunctionCall;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ contract C {
|
|||||||
return reenc ? this.f_reenc(a) : this.f(a);
|
return reenc ? this.f_reenc(a) : this.f(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
// ----
|
// ----
|
||||||
// g(bool): false -> 23, 37, 71
|
// g(bool): false -> 23, 37, 71
|
||||||
// g(bool): true -> 23, 37, 71
|
// g(bool): true -> 23, 37, 71
|
||||||
|
Loading…
Reference in New Issue
Block a user