Update ExpressionCompiler.cpp

This commit is contained in:
RJ 2016-01-10 01:12:17 -06:00
parent df9dfa8fef
commit e18eaa4615

View File

@ -186,7 +186,6 @@ bool ExpressionCompiler::visit(Assignment const& _assignment)
_assignment.leftHandSide().annotation().type _assignment.leftHandSide().annotation().type
); );
utils().convertType(*_assignment.rightHandSide().annotation().type, *type); utils().convertType(*_assignment.rightHandSide().annotation().type, *type);
_assignment.leftHandSide().accept(*this); _assignment.leftHandSide().accept(*this);
solAssert(!!m_currentLValue, "LValue not retrieved."); solAssert(!!m_currentLValue, "LValue not retrieved.");
@ -219,25 +218,48 @@ bool ExpressionCompiler::visit(Assignment const& _assignment)
bool ExpressionCompiler::visit(TupleExpression const& _tuple) bool ExpressionCompiler::visit(TupleExpression const& _tuple)
{ {
vector<unique_ptr<LValue>> lvalues; if (_tuple.isInlineArray())
for (auto const& component: _tuple.components()) {
if (component) ArrayType const& arrayType = dynamic_cast<ArrayType const&>(*_tuple.annotation().type);
{ auto components = _tuple.components();
component->accept(*this);
if (_tuple.annotation().lValueRequested) m_context << max(u256(32u), arrayType.memorySize());
{ utils().allocateMemory();
solAssert(!!m_currentLValue, ""); m_context << eth::Instruction::DUP1;
lvalues.push_back(move(m_currentLValue));
} for (unsigned i = 0; i < components.size(); ++i)
} {
else if (_tuple.annotation().lValueRequested) components[i]->accept(*this);
lvalues.push_back(unique_ptr<LValue>()); utils().convertType(*components[i]->annotation().type, *arrayType.baseType(), true);
if (_tuple.annotation().lValueRequested) cout << components[i]->annotation().type->toString(true) << endl;
components[i]->annotation().type = arrayType.baseType(); //force conversion
cout << components[i]->annotation().type->toString(true) << endl;
utils().storeInMemoryDynamic(*components[i]->annotation().type, true);
}
m_context << eth::Instruction::POP;
}
else
{ {
if (_tuple.components().size() == 1) vector<unique_ptr<LValue>> lvalues;
m_currentLValue = move(lvalues[0]); for (auto const& component: _tuple.components())
else if (component)
m_currentLValue.reset(new TupleObject(m_context, move(lvalues))); {
component->accept(*this);
if (_tuple.annotation().lValueRequested)
{
solAssert(!!m_currentLValue, "");
lvalues.push_back(move(m_currentLValue));
}
}
else if (_tuple.annotation().lValueRequested)
lvalues.push_back(unique_ptr<LValue>());
if (_tuple.annotation().lValueRequested)
{
if (_tuple.components().size() == 1)
m_currentLValue = move(lvalues[0]);
else
m_currentLValue.reset(new TupleObject(m_context, move(lvalues)));
}
} }
return false; return false;
} }