diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-08-05 11:35:53 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-08-05 11:35:53 +0200 |
commit | 6bd66b1728eeddb058066edda740aaeb2ceaec23 (patch) | |
tree | 985faf01c526763515731569fa01a99f4dbef36e /gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp | |
parent | e0a8dcfed131ffa58a5e2cb1d30fe48c745c2fdc (diff) | |
parent | 559824514dc95e02fbe81f1786e6ac13ee8e9d55 (diff) | |
download | UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.tar UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.tar.gz UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.tar.lz UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.tar.xz UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.zip |
Merge branch 'master' into js-modules
Diffstat (limited to 'gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp')
-rwxr-xr-x | gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp b/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp index 98e010a56..de9050cd8 100755 --- a/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp +++ b/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp @@ -20,9 +20,6 @@ #include "compiler/translator/IntermNode.h" #include "compiler/translator/OutputHLSL.h" -namespace sh -{ - namespace { @@ -32,7 +29,7 @@ class SeparateArrayInitTraverser : private TIntermTraverser static void apply(TIntermNode *root); private: SeparateArrayInitTraverser(); - bool visitDeclaration(Visit, TIntermDeclaration *node) override; + bool visitAggregate(Visit, TIntermAggregate *node) override; }; void SeparateArrayInitTraverser::apply(TIntermNode *root) @@ -47,38 +44,44 @@ SeparateArrayInitTraverser::SeparateArrayInitTraverser() { } -bool SeparateArrayInitTraverser::visitDeclaration(Visit, TIntermDeclaration *node) +bool SeparateArrayInitTraverser::visitAggregate(Visit, TIntermAggregate *node) { - TIntermSequence *sequence = node->getSequence(); - TIntermBinary *initNode = sequence->back()->getAsBinaryNode(); - if (initNode != nullptr && initNode->getOp() == EOpInitialize) + if (node->getOp() == EOpDeclaration) { - TIntermTyped *initializer = initNode->getRight(); - if (initializer->isArray() && !sh::OutputHLSL::canWriteAsHLSLLiteral(initializer)) + TIntermSequence *sequence = node->getSequence(); + TIntermBinary *initNode = sequence->back()->getAsBinaryNode(); + if (initNode != nullptr && initNode->getOp() == EOpInitialize) { - // We rely on that array declarations have been isolated to single declarations. - ASSERT(sequence->size() == 1); - TIntermTyped *symbol = initNode->getLeft(); - TIntermBlock *parentBlock = getParentNode()->getAsBlock(); - ASSERT(parentBlock != nullptr); + TIntermTyped *initializer = initNode->getRight(); + if (initializer->isArray() && !sh::OutputHLSL::canWriteAsHLSLLiteral(initializer)) + { + // We rely on that array declarations have been isolated to single declarations. + ASSERT(sequence->size() == 1); + TIntermTyped *symbol = initNode->getLeft(); + TIntermAggregate *parentAgg = getParentNode()->getAsAggregate(); + ASSERT(parentAgg != nullptr); - TIntermSequence replacements; + TIntermSequence replacements; - TIntermDeclaration *replacementDeclaration = new TIntermDeclaration(); - replacementDeclaration->appendDeclarator(symbol); - replacementDeclaration->setLine(symbol->getLine()); - replacements.push_back(replacementDeclaration); + TIntermAggregate *replacementDeclaration = new TIntermAggregate; + replacementDeclaration->setOp(EOpDeclaration); + replacementDeclaration->getSequence()->push_back(symbol); + replacementDeclaration->setLine(symbol->getLine()); + replacements.push_back(replacementDeclaration); - TIntermBinary *replacementAssignment = - new TIntermBinary(EOpAssign, symbol, initializer); - replacementAssignment->setLine(symbol->getLine()); - replacements.push_back(replacementAssignment); + TIntermBinary *replacementAssignment = new TIntermBinary(EOpAssign); + replacementAssignment->setLeft(symbol); + replacementAssignment->setRight(initializer); + replacementAssignment->setType(initializer->getType()); + replacementAssignment->setLine(symbol->getLine()); + replacements.push_back(replacementAssignment); - mMultiReplacements.push_back( - NodeReplaceWithMultipleEntry(parentBlock, node, replacements)); + mMultiReplacements.push_back(NodeReplaceWithMultipleEntry(parentAgg, node, replacements)); + } } + return false; } - return false; + return true; } } // namespace @@ -87,5 +90,3 @@ void SeparateArrayInitialization(TIntermNode *root) { SeparateArrayInitTraverser::apply(root); } - -} // namespace sh |