aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp56
1 files changed, 39 insertions, 17 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index b0e92b59..c7e2a997 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -186,7 +186,6 @@ bool ExpressionCompiler::visit(Assignment const& _assignment)
_assignment.leftHandSide().annotation().type
);
utils().convertType(*_assignment.rightHandSide().annotation().type, *type);
-
_assignment.leftHandSide().accept(*this);
solAssert(!!m_currentLValue, "LValue not retrieved.");
@@ -219,25 +218,48 @@ bool ExpressionCompiler::visit(Assignment const& _assignment)
bool ExpressionCompiler::visit(TupleExpression const& _tuple)
{
- vector<unique_ptr<LValue>> lvalues;
- for (auto const& component: _tuple.components())
- if (component)
- {
- component->accept(*this);
- if (_tuple.annotation().lValueRequested)
+ if (_tuple.isInlineArray())
+ {
+ ArrayType const& arrayType = dynamic_cast<ArrayType const&>(*_tuple.annotation().type);
+ auto components = _tuple.components();
+
+ m_context << max(u256(32u), arrayType.memorySize());
+ utils().allocateMemory();
+ m_context << eth::Instruction::DUP1;
+
+ for (unsigned i = 0; i < components.size(); ++i)
+ {
+ components[i]->accept(*this);
+ utils().convertType(*components[i]->annotation().type, *arrayType.baseType(), true);
+ 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
+ {
+ vector<unique_ptr<LValue>> lvalues;
+ for (auto const& component: _tuple.components())
+ if (component)
{
- solAssert(!!m_currentLValue, "");
- lvalues.push_back(move(m_currentLValue));
+ 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)));
}
- 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;
}