Commit 01cd8afa by Olli Etuaho

Add GLSL output of switch and case

BUG=angle:921 Change-Id: I0d752440ce6ffdfcc005f1a6123694bdfeb1b067 Reviewed-on: https://chromium-review.googlesource.com/251526Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c8716df9
......@@ -512,6 +512,8 @@ class TIntermSwitch : public TIntermNode
TIntermSwitch *getAsSwitchNode() override { return this; }
TIntermAggregate *getStatementList() { return mStatementList; }
protected:
TIntermTyped *mInit;
TIntermAggregate *mStatementList;
......
......@@ -36,6 +36,14 @@ bool isSingleStatement(TIntermNode *node)
{
return false;
}
else if (node->getAsSwitchNode())
{
return false;
}
else if (node->getAsCaseNode())
{
return false;
}
return true;
}
} // namespace
......@@ -638,16 +646,34 @@ bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection *node)
return false;
}
bool TOutputGLSLBase::visitSwitch(Visit, TIntermSwitch *)
bool TOutputGLSLBase::visitSwitch(Visit visit, TIntermSwitch *node)
{
UNIMPLEMENTED();
return false;
if (node->getStatementList())
{
writeTriplet(visit, "switch (", ") ", nullptr);
// The curly braces get written when visiting the statementList aggregate
}
else
{
// No statementList, so it won't output curly braces
writeTriplet(visit, "switch (", ") {", "}\n");
}
return true;
}
bool TOutputGLSLBase::visitCase(Visit, TIntermCase *)
bool TOutputGLSLBase::visitCase(Visit visit, TIntermCase *node)
{
UNIMPLEMENTED();
return false;
if (node->hasCondition())
{
writeTriplet(visit, "case (", nullptr, "):\n");
return true;
}
else
{
TInfoSinkBase &out = objSink();
out << "default:\n";
return false;
}
}
bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
......
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