ANGLE | Compiler - implement the ternary operator

TRAC #11421 Doesn't take short-circuiting behavior into account yet. Author: Nicolas Capens Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/trunk@51 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent adb5087a
...@@ -943,6 +943,8 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) ...@@ -943,6 +943,8 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
{ {
TInfoSinkBase &out = context.infoSink.obj; TInfoSinkBase &out = context.infoSink.obj;
if(node->getType().getBasicType() == EbtVoid) // if/else statement
{
out << "if("; out << "if(";
node->getCondition()->traverse(this); node->getCondition()->traverse(this);
...@@ -963,6 +965,17 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) ...@@ -963,6 +965,17 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
out << ";}\n"; 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; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment