Split ternary node class from TIntermSelection

Ternary operator nodes are typed parts of expressions, they always
have two children and the children are also guaranteed to be
TIntermTyped. "If" selection nodes can't be a part of an expression,
they can have either one or two children and the children are code
blocks. Due to all of these differences it makes sense to store these
using two different AST node classes.

BUG=angleproject:1490
TEST=angle_unittests

Change-Id: I913ab1d806e3cdb5c21106f078cc9c0b6c72ac54
Reviewed-on: https://chromium-review.googlesource.com/384512
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/intermOut.cpp b/src/compiler/translator/intermOut.cpp
index 6dca547..942eadc 100644
--- a/src/compiler/translator/intermOut.cpp
+++ b/src/compiler/translator/intermOut.cpp
@@ -44,10 +44,12 @@
     void visitConstantUnion(TIntermConstantUnion *) override;
     bool visitBinary(Visit visit, TIntermBinary *) override;
     bool visitUnary(Visit visit, TIntermUnary *) override;
+    bool visitTernary(Visit visit, TIntermTernary *node) override;
     bool visitSelection(Visit visit, TIntermSelection *) override;
     bool visitAggregate(Visit visit, TIntermAggregate *) override;
     bool visitLoop(Visit visit, TIntermLoop *) override;
     bool visitBranch(Visit visit, TIntermBranch *) override;
+    // TODO: Add missing visit functions
 };
 
 //
@@ -457,14 +459,46 @@
     return true;
 }
 
+bool TOutputTraverser::visitTernary(Visit visit, TIntermTernary *node)
+{
+    TInfoSinkBase &out = sink;
+
+    OutputTreeText(out, node, mDepth);
+
+    out << "Ternary selection";
+    out << " (" << node->getCompleteString() << ")\n";
+
+    ++mDepth;
+
+    OutputTreeText(sink, node, mDepth);
+    out << "Condition\n";
+    node->getCondition()->traverse(this);
+
+    OutputTreeText(sink, node, mDepth);
+    if (node->getTrueExpression())
+    {
+        out << "true case\n";
+        node->getTrueExpression()->traverse(this);
+    }
+    if (node->getFalseExpression())
+    {
+        OutputTreeText(sink, node, mDepth);
+        out << "false case\n";
+        node->getFalseExpression()->traverse(this);
+    }
+
+    --mDepth;
+
+    return false;
+}
+
 bool TOutputTraverser::visitSelection(Visit visit, TIntermSelection *node)
 {
     TInfoSinkBase &out = sink;
 
     OutputTreeText(out, node, mDepth);
 
-    out << "Test condition and select";
-    out << " (" << node->getCompleteString() << ")\n";
+    out << "If test\n";
 
     ++mDepth;