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,25 +943,38 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
{
TInfoSinkBase &out = context.infoSink.obj;
out << "if(";
if(node->getType().getBasicType() == EbtVoid) // if/else statement
{
out << "if(";
node->getCondition()->traverse(this);
node->getCondition()->traverse(this);
out << ")\n"
"{\n";
out << ")\n"
"{\n";
node->getTrueBlock()->traverse(this);
node->getTrueBlock()->traverse(this);
out << ";}\n";
out << ";}\n";
if (node->getFalseBlock())
{
out << "else\n"
"{\n";
if (node->getFalseBlock())
{
out << "else\n"
"{\n";
node->getFalseBlock()->traverse(this);
node->getFalseBlock()->traverse(this);
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;
......
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