summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-18 08:24:24 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-18 08:24:24 +0200
commitfc61780b35af913801d72086456f493f63197da6 (patch)
treef85891288a7bd988da9f0f15ae64e5c63f00d493 /gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp
parent69f7f9e5f1475891ce11cc4f431692f965b0cd30 (diff)
parent50d3e596bbe89c95615f96eb71f6bc5be737a1db (diff)
downloadUXP-2018.07.18.tar
UXP-2018.07.18.tar.gz
UXP-2018.07.18.tar.lz
UXP-2018.07.18.tar.xz
UXP-2018.07.18.zip
Merge commit '50d3e596bbe89c95615f96eb71f6bc5be737a1db' into Basilisk-releasev2018.07.18
# Conflicts: # browser/app/profile/firefox.js # browser/components/preferences/jar.mn
Diffstat (limited to 'gfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp')
-rwxr-xr-xgfx/angle/src/compiler/translator/SeparateArrayInitialization.cpp59
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