Spreadsheet/Expressions: Fixed issue #3363.

This commit is contained in:
Eivind Kvedalen
2018-03-24 09:22:52 +01:00
committed by wmayer
parent acbd182e15
commit 53d4757ba7
2 changed files with 31 additions and 2 deletions

View File

@@ -1589,7 +1589,17 @@ Expression *ConditionalExpression::simplify() const
std::string ConditionalExpression::toString() const
{
return condition->toString() + " ? " + trueExpr->toString() + " : " + falseExpr->toString();
std::string cstr = condition->toString();
std::string tstr = trueExpr->toString();
std::string fstr = falseExpr->toString();
if (trueExpr->priority() <= priority())
tstr = "(" + tstr + ")";
if (falseExpr->priority() <= priority())
fstr = "(" + fstr + ")";
return cstr + " ? " + tstr + " : " + fstr;
}
Expression *ConditionalExpression::copy() const
@@ -1599,7 +1609,7 @@ Expression *ConditionalExpression::copy() const
int ConditionalExpression::priority() const
{
return 0;
return 2;
}
void ConditionalExpression::getDeps(std::set<ObjectIdentifier> &props) const