Commit 43613b03 by Olli Etuaho

Make sure that the AST root is always a sequence node

This enables inserting helper functions as an AST transformation. BUG=angleproject:1116 TEST=angle_unittests Change-Id: I169d4d3a726d0e389cb3444fe9dfb4c6c5d80155 Reviewed-on: https://chromium-review.googlesource.com/290513Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent ef1eb273
......@@ -242,7 +242,7 @@ TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[],
}
root = parseContext.getTreeRoot();
success = intermediate.postProcess(root);
root = intermediate.postProcess(root);
// Disallow expressions deemed too complex.
if (success && (compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY))
......
......@@ -426,19 +426,27 @@ TIntermBranch* TIntermediate::addBranch(
// This is to be executed once the final root is put on top by the parsing
// process.
//
bool TIntermediate::postProcess(TIntermNode *root)
TIntermAggregate *TIntermediate::postProcess(TIntermNode *root)
{
if (root == NULL)
return true;
if (root == nullptr)
return nullptr;
//
// First, finish off the top level sequence, if any
// Finish off the top level sequence, if any
//
TIntermAggregate *aggRoot = root->getAsAggregate();
if (aggRoot && aggRoot->getOp() == EOpNull)
if (aggRoot != nullptr && aggRoot->getOp() == EOpNull)
{
aggRoot->setOp(EOpSequence);
}
else if (aggRoot == nullptr || aggRoot->getOp() != EOpSequence)
{
aggRoot = new TIntermAggregate(EOpSequence);
aggRoot->setLine(root->getLine());
aggRoot->getSequence()->push_back(root);
}
return true;
return aggRoot;
}
TIntermTyped *TIntermediate::foldAggregateBuiltIn(TIntermAggregate *aggregate)
......
......@@ -60,7 +60,7 @@ class TIntermediate
TIntermBranch *addBranch(TOperator, const TSourceLoc &);
TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &);
TIntermTyped *addSwizzle(TVectorFields &, const TSourceLoc &);
bool postProcess(TIntermNode *);
TIntermAggregate *postProcess(TIntermNode *root);
static void outputTree(TIntermNode *, TInfoSinkBase &);
......
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