support decayed tuple expression as left value

This commit is contained in:
Lu Guanqun 2016-01-04 16:11:04 +08:00
parent 6b711d0527
commit 568da11369
2 changed files with 10 additions and 2 deletions

View File

@ -792,6 +792,9 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
} }
else else
types.push_back(TypePointer()); types.push_back(TypePointer());
if (components.size() == 1)
_tuple.annotation().type = type(*components[0]);
else
_tuple.annotation().type = make_shared<TupleType>(types); _tuple.annotation().type = make_shared<TupleType>(types);
// If some of the components are not LValues, the error is reported above. // If some of the components are not LValues, the error is reported above.
_tuple.annotation().isLValue = true; _tuple.annotation().isLValue = true;

View File

@ -233,7 +233,12 @@ bool ExpressionCompiler::visit(TupleExpression const& _tuple)
else if (_tuple.annotation().lValueRequested) else if (_tuple.annotation().lValueRequested)
lvalues.push_back(unique_ptr<LValue>()); lvalues.push_back(unique_ptr<LValue>());
if (_tuple.annotation().lValueRequested) if (_tuple.annotation().lValueRequested)
{
if (_tuple.components().size() == 1)
m_currentLValue = move(lvalues[0]);
else
m_currentLValue.reset(new TupleObject(m_context, move(lvalues))); m_currentLValue.reset(new TupleObject(m_context, move(lvalues)));
}
return false; return false;
} }