summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.cpp')
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.cpp b/src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.cpp
index d33747f85b..9a066075c0 100644
--- a/src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.cpp
@@ -5,8 +5,8 @@
//
// The SeparateDeclarations function processes declarations, so that in the end each declaration
// contains only one declarator.
-// This is useful as an intermediate step when initialization needs to be separated from declaration,
-// or when things need to be unfolded out of the initializer.
+// This is useful as an intermediate step when initialization needs to be separated from
+// declaration, or when things need to be unfolded out of the initializer.
// Example:
// int a[1] = int[1](1), b[1] = int[1](2);
// gets transformed when run through this class into the AST equivalent of:
@@ -15,7 +15,10 @@
#include "compiler/translator/SeparateDeclarations.h"
-#include "compiler/translator/IntermNode.h"
+#include "compiler/translator/IntermTraverse.h"
+
+namespace sh
+{
namespace
{
@@ -24,9 +27,10 @@ class SeparateDeclarationsTraverser : private TIntermTraverser
{
public:
static void apply(TIntermNode *root);
+
private:
SeparateDeclarationsTraverser();
- bool visitAggregate(Visit, TIntermAggregate *node) override;
+ bool visitDeclaration(Visit, TIntermDeclaration *node) override;
};
void SeparateDeclarationsTraverser::apply(TIntermNode *root)
@@ -41,37 +45,35 @@ SeparateDeclarationsTraverser::SeparateDeclarationsTraverser()
{
}
-bool SeparateDeclarationsTraverser::visitAggregate(Visit, TIntermAggregate *node)
+bool SeparateDeclarationsTraverser::visitDeclaration(Visit, TIntermDeclaration *node)
{
- if (node->getOp() == EOpDeclaration)
+ TIntermSequence *sequence = node->getSequence();
+ if (sequence->size() > 1)
{
- TIntermSequence *sequence = node->getSequence();
- if (sequence->size() > 1)
- {
- TIntermAggregate *parentAgg = getParentNode()->getAsAggregate();
- ASSERT(parentAgg != nullptr);
+ TIntermBlock *parentBlock = getParentNode()->getAsBlock();
+ ASSERT(parentBlock != nullptr);
- TIntermSequence replacementDeclarations;
- for (size_t ii = 0; ii < sequence->size(); ++ii)
- {
- TIntermAggregate *replacementDeclaration = new TIntermAggregate;
-
- replacementDeclaration->setOp(EOpDeclaration);
- replacementDeclaration->getSequence()->push_back(sequence->at(ii));
- replacementDeclaration->setLine(sequence->at(ii)->getLine());
- replacementDeclarations.push_back(replacementDeclaration);
- }
+ TIntermSequence replacementDeclarations;
+ for (size_t ii = 0; ii < sequence->size(); ++ii)
+ {
+ TIntermDeclaration *replacementDeclaration = new TIntermDeclaration();
- mMultiReplacements.push_back(NodeReplaceWithMultipleEntry(parentAgg, node, replacementDeclarations));
+ replacementDeclaration->appendDeclarator(sequence->at(ii)->getAsTyped());
+ replacementDeclaration->setLine(sequence->at(ii)->getLine());
+ replacementDeclarations.push_back(replacementDeclaration);
}
- return false;
+
+ mMultiReplacements.push_back(
+ NodeReplaceWithMultipleEntry(parentBlock, node, replacementDeclarations));
}
- return true;
+ return false;
}
-} // namespace
+} // namespace
void SeparateDeclarations(TIntermNode *root)
{
SeparateDeclarationsTraverser::apply(root);
}
+
+} // namespace sh