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/IntermTraverse.cpp b/src/compiler/translator/IntermTraverse.cpp
index 79cb86d..7adea71 100644
--- a/src/compiler/translator/IntermTraverse.cpp
+++ b/src/compiler/translator/IntermTraverse.cpp
@@ -33,6 +33,11 @@
     it->traverseUnary(this);
 }
 
+void TIntermTernary::traverse(TIntermTraverser *it)
+{
+    it->traverseTernary(this);
+}
+
 void TIntermSelection::traverse(TIntermTraverser *it)
 {
     it->traverseSelection(this);
@@ -567,6 +572,31 @@
 }
 
 //
+// Traverse a ternary node.  Same comments in binary node apply here.
+//
+void TIntermTraverser::traverseTernary(TIntermTernary *node)
+{
+    bool visit = true;
+
+    if (preVisit)
+        visit = visitTernary(PreVisit, node);
+
+    if (visit)
+    {
+        incrementDepth(node);
+        node->getCondition()->traverse(this);
+        if (node->getTrueExpression())
+            node->getTrueExpression()->traverse(this);
+        if (node->getFalseExpression())
+            node->getFalseExpression()->traverse(this);
+        decrementDepth();
+    }
+
+    if (visit && postVisit)
+        visitTernary(PostVisit, node);
+}
+
+//
 // Traverse a selection node.  Same comments in binary node apply here.
 //
 void TIntermTraverser::traverseSelection(TIntermSelection *node)