summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/RewriteDoWhile.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/RewriteDoWhile.cpp
parent69f7f9e5f1475891ce11cc4f431692f965b0cd30 (diff)
parent50d3e596bbe89c95615f96eb71f6bc5be737a1db (diff)
downloadUXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.tar
UXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.tar.gz
UXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.tar.lz
UXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.tar.xz
UXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.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/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