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/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 1fcf100..5da0996 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -956,7 +956,17 @@
{
TInfoSinkBase &out = context.infoSink.obj;
- if (node->getType().getBasicType() == EbtVoid) // if/else statement
+ if (node->usesTernaryOperator())
+ {
+ out << "(";
+ node->getCondition()->traverse(this);
+ out << ") ? (";
+ node->getTrueBlock()->traverse(this);
+ out << ") : (";
+ node->getFalseBlock()->traverse(this);
+ out << ")\n";
+ }
+ else // if/else statement
{
out << "if(";
@@ -979,16 +989,6 @@
out << ";}\n";
}
}
- else // Ternary operator expression
- {
- out << "(";
- node->getCondition()->traverse(this);
- out << ") ? (";
- node->getTrueBlock()->traverse(this);
- out << ") : (";
- node->getFalseBlock()->traverse(this);
- out << ")\n";
- }
return false;
}