Simplify loop conditions so that they won't generate statements
Introduce an AST traverser that can move the evaluation of certain
types of loop conditions and loop expressions inside the loop. This
way subsequent AST transformations don't have to worry about cases
where they have to insert new statements to implement a loop condition
or expression.
This includes the revert of "Unfold short-circuiting operators in loop
conditions correctly". The new traverser covers the loop cases that
used to be handled in UnfoldShortCircuitToIf.
BUG=angleproject:1465
TEST=WebGL conformance tests,
dEQP-GLES2.functional.shaders.*select_iteration_count*
Change-Id: I88e50e007e924d5884a217117690ac7fa2f96d38
Reviewed-on: https://chromium-review.googlesource.com/362570
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index fb6bec1..2ce85e0 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -197,6 +197,7 @@
bool TIntermLoop::replaceChildNode(
TIntermNode *original, TIntermNode *replacement)
{
+ ASSERT(original != nullptr); // This risks replacing multiple children.
REPLACE_IF_IS(mInit, TIntermNode, original, replacement);
REPLACE_IF_IS(mCond, TIntermTyped, original, replacement);
REPLACE_IF_IS(mExpr, TIntermTyped, original, replacement);