Added TIntermSelection::usesTernaryOperator() to distinguish between selection nodes using ternary operator and if-else. Used in both OutputGLSL and OutputHLSL.
Review URL: http://codereview.appspot.com/830042

git-svn-id: https://angleproject.googlecode.com/svn/trunk@82 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputGLSL.cpp b/src/compiler/OutputGLSL.cpp
index de29b54..ee1f49d 100644
--- a/src/compiler/OutputGLSL.cpp
+++ b/src/compiler/OutputGLSL.cpp
@@ -285,23 +285,35 @@
 {
     TInfoSinkBase& out = objSink();
 
-    out << "if (";
-    node->getCondition()->traverse(this);
-    out << ") {\n";
-
-    incrementDepth();
-    node->getTrueBlock()->traverse(this);
-    out << getIndentationString(depth - 2) << "}";
-
-    if (node->getFalseBlock())
+    if (node->usesTernaryOperator())
     {
-        out << " else {\n";
+        out << "(";
+        node->getCondition()->traverse(this);
+        out << ") ? (";
+        node->getTrueBlock()->traverse(this);
+        out << ") : (";
         node->getFalseBlock()->traverse(this);
-        out << getIndentationString(depth - 2) << "}";
+        out << ")";
     }
-    decrementDepth();
+    else
+    {
+        out << "if (";
+        node->getCondition()->traverse(this);
+        out << ") {\n";
 
-    out << "\n";
+        incrementDepth();
+        node->getTrueBlock()->traverse(this);
+        out << getIndentationString(depth - 2) << "}";
+
+        if (node->getFalseBlock())
+        {
+            out << " else {\n";
+            node->getFalseBlock()->traverse(this);
+            out << getIndentationString(depth - 2) << "}";
+        }
+        decrementDepth();
+        out << "\n";
+    }
     return false;
 }