summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/RewriteDoWhile.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
commit4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 (patch)
treef000dd831240707a03b8c806db292c2a15cde3ce /gfx/angle/src/compiler/translator/RewriteDoWhile.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
downloadUXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.gz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.lz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.xz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.zip
Roll back to ANGLE/2845
Diffstat (limited to 'gfx/angle/src/compiler/translator/RewriteDoWhile.cpp')
-rwxr-xr-xgfx/angle/src/compiler/translator/RewriteDoWhile.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/gfx/angle/src/compiler/translator/RewriteDoWhile.cpp b/gfx/angle/src/compiler/translator/RewriteDoWhile.cpp
index 7999cbf49..834744754 100755
--- a/gfx/angle/src/compiler/translator/RewriteDoWhile.cpp
+++ b/gfx/angle/src/compiler/translator/RewriteDoWhile.cpp
@@ -11,9 +11,6 @@
#include "compiler/translator/IntermNode.h"
-namespace sh
-{
-
namespace
{
@@ -46,11 +43,15 @@ class DoWhileRewriter : public TIntermTraverser
public:
DoWhileRewriter() : TIntermTraverser(true, false, false) {}
- bool visitBlock(Visit, TIntermBlock *node) override
+ bool visitAggregate(Visit, TIntermAggregate *node) override
{
- // A well-formed AST can only have do-while inside TIntermBlock. By doing a prefix traversal
- // we are able to replace the do-while in the sequence directly as the content of the
- // do-while will be traversed later.
+ // A well-formed AST can only have do-while in EOpSequence which represent lists of
+ // statements. By doing a prefix traversal we are able to replace the do-while in the
+ // sequence directly as the content of the do-while will be traversed later.
+ if (node->getOp() != EOpSequence)
+ {
+ return true;
+ }
TIntermSequence *statements = node->getSequence();
@@ -70,7 +71,7 @@ class DoWhileRewriter : public TIntermTraverser
TType boolType = TType(EbtBool);
// bool temp = false;
- TIntermDeclaration *tempDeclaration = nullptr;
+ TIntermAggregate *tempDeclaration = nullptr;
{
TConstantUnion *falseConstant = new TConstantUnion();
falseConstant->setBConst(false);
@@ -94,22 +95,23 @@ class DoWhileRewriter : public TIntermTraverser
// break;
// }
// }
- TIntermIfElse *breakIf = nullptr;
+ TIntermSelection *breakIf = nullptr;
{
TIntermBranch *breakStatement = new TIntermBranch(EOpBreak, nullptr);
- TIntermBlock *breakBlock = new TIntermBlock();
+ TIntermAggregate *breakBlock = new TIntermAggregate(EOpSequence);
breakBlock->getSequence()->push_back(breakStatement);
- TIntermUnary *negatedCondition =
- new TIntermUnary(EOpLogicalNot, loop->getCondition());
+ TIntermUnary *negatedCondition = new TIntermUnary(EOpLogicalNot);
+ negatedCondition->setOperand(loop->getCondition());
- TIntermIfElse *innerIf = new TIntermIfElse(negatedCondition, breakBlock, nullptr);
+ TIntermSelection *innerIf =
+ new TIntermSelection(negatedCondition, breakBlock, nullptr);
- TIntermBlock *innerIfBlock = new TIntermBlock();
+ TIntermAggregate *innerIfBlock = new TIntermAggregate(EOpSequence);
innerIfBlock->getSequence()->push_back(innerIf);
- breakIf = new TIntermIfElse(createTempSymbol(boolType), innerIfBlock, nullptr);
+ breakIf = new TIntermSelection(createTempSymbol(boolType), innerIfBlock, nullptr);
}
// Assemble the replacement loops, reusing the do-while loop's body and inserting our
@@ -120,10 +122,14 @@ class DoWhileRewriter : public TIntermTraverser
trueConstant->setBConst(true);
TIntermTyped *trueValue = new TIntermConstantUnion(trueConstant, boolType);
- TIntermBlock *body = loop->getBody();
- if (body == nullptr)
+ TIntermAggregate *body = nullptr;
+ if (loop->getBody() != nullptr)
{
- body = new TIntermBlock();
+ body = loop->getBody()->getAsAggregate();
+ }
+ else
+ {
+ body = new TIntermAggregate(EOpSequence);
}
auto sequence = body->getSequence();
sequence->insert(sequence->begin(), assignTrue);
@@ -155,5 +161,3 @@ void RewriteDoWhile(TIntermNode *root, unsigned int *temporaryIndex)
root->traverse(&rewriter);
}
-
-} // namespace sh