Change comma nodes to TIntermBinary
Comma nodes always have just two parameters. If there's an expression
with several commas in the middle, it's parsed as a tree of comma
operations. It makes more sense to represent it as a binary node
rather than an aggregate node.
After this patch, TIntermAggregate is still used for function
prototypes, function parameter lists, function calls, and variable and
invariant declarations.
BUG=angleproject:1490
TEST=angle_unittests, angle_end2end_tests
Change-Id: I66be10624bf27bcf25987b4d93958d4a07600771
Reviewed-on: https://chromium-review.googlesource.com/397320
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/Intermediate.cpp b/src/compiler/translator/Intermediate.cpp
index bb75d9a..8e6519d 100644
--- a/src/compiler/translator/Intermediate.cpp
+++ b/src/compiler/translator/Intermediate.cpp
@@ -198,19 +198,11 @@
return node;
}
-TIntermTyped *TIntermediate::addComma(TIntermTyped *left,
+TIntermTyped *TIntermediate::AddComma(TIntermTyped *left,
TIntermTyped *right,
const TSourceLoc &line,
int shaderVersion)
{
- TQualifier resultQualifier = EvqConst;
- // ESSL3.00 section 12.43: The result of a sequence operator is not a constant-expression.
- if (shaderVersion >= 300 || left->getQualifier() != EvqConst ||
- right->getQualifier() != EvqConst)
- {
- resultQualifier = EvqTemporary;
- }
-
TIntermTyped *commaNode = nullptr;
if (!left->hasSideEffects())
{
@@ -218,10 +210,10 @@
}
else
{
- commaNode = growAggregate(left, right, line);
- commaNode->getAsAggregate()->setOp(EOpComma);
- commaNode->setType(right->getType());
+ commaNode = new TIntermBinary(EOpComma, left, right);
+ commaNode->setLine(line);
}
+ TQualifier resultQualifier = TIntermBinary::GetCommaQualifier(shaderVersion, left, right);
commaNode->getTypePointer()->setQualifier(resultQualifier);
return commaNode;
}