Fix Yul IR push

This commit is contained in:
Daniel Kirchner
2019-11-28 18:11:38 +01:00
parent f7fc42d8c3
commit 7d1b0c6023
5 changed files with 106 additions and 13 deletions
@@ -659,15 +659,28 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
ArrayType const& arrayType = dynamic_cast<ArrayType const&>(
*dynamic_cast<MemberAccess const&>(_functionCall.expression()).expression().annotation().type
);
defineExpression(_functionCall) <<
m_utils.storageArrayPushFunction(arrayType) <<
"(" <<
m_context.variable(_functionCall.expression()) <<
", " << (
arguments.empty() ?
m_utils.zeroValueFunction(*arrayType.baseType()) + "()" :
expressionAsType(*arguments.front(), *arrayType.baseType())
) << ")\n";
if (arguments.empty())
{
auto slotName = m_context.newYulVariable();
auto offsetName = m_context.newYulVariable();
m_code << "let " << slotName << ", " << offsetName << " := " <<
m_utils.storageArrayPushZeroFunction(arrayType) <<
"(" << m_context.variable(_functionCall.expression()) << ")\n";
setLValue(_functionCall, make_unique<IRStorageItem>(
m_context.utils(),
slotName,
offsetName,
*arrayType.baseType()
));
}
else
m_code <<
m_utils.storageArrayPushFunction(arrayType) <<
"(" <<
m_context.variable(_functionCall.expression()) <<
", " <<
expressionAsType(*arguments.front(), *arrayType.baseType()) <<
")\n";
break;
}
default: