Implement parsing switch statements
Put in some groundwork for parsing switch statements and case labels in
the parser, including definitions for IntermNode classes. Intermediate
functions for adding the statements are stubbed to only generate errors
for now.
Tested by manually disabling shading language version checks for switch
in a Chromium build and checking that the expected errors are generated.
BUG=angle:921
Change-Id: I064b3e0c4c1b724a083cf5bc78eebfdd3794eb1b
Reviewed-on: https://chromium-review.googlesource.com/250380
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/IntermTraverse.cpp b/src/compiler/translator/IntermTraverse.cpp
index 72b2033..7a7efb7 100644
--- a/src/compiler/translator/IntermTraverse.cpp
+++ b/src/compiler/translator/IntermTraverse.cpp
@@ -194,6 +194,60 @@
}
//
+// Traverse a switch node. Same comments in binary node apply here.
+//
+void TIntermSwitch::traverse(TIntermTraverser *it)
+{
+ bool visit = true;
+
+ if (it->preVisit)
+ visit = it->visitSwitch(PreVisit, this);
+
+ if (visit)
+ {
+ it->incrementDepth(this);
+ if (it->rightToLeft)
+ {
+ if (mStatementList)
+ mStatementList->traverse(it);
+ if (it->inVisit)
+ visit = it->visitSwitch(InVisit, this);
+ if (visit)
+ mInit->traverse(it);
+ }
+ else
+ {
+ mInit->traverse(it);
+ if (it->inVisit)
+ visit = it->visitSwitch(InVisit, this);
+ if (visit && mStatementList)
+ mStatementList->traverse(it);
+ }
+ it->decrementDepth();
+ }
+
+ if (visit && it->postVisit)
+ it->visitSwitch(PostVisit, this);
+}
+
+//
+// Traverse a switch node. Same comments in binary node apply here.
+//
+void TIntermCase::traverse(TIntermTraverser *it)
+{
+ bool visit = true;
+
+ if (it->preVisit)
+ visit = it->visitCase(PreVisit, this);
+
+ if (visit && mCondition)
+ mCondition->traverse(it);
+
+ if (visit && it->postVisit)
+ it->visitCase(PostVisit, this);
+}
+
+//
// Traverse a loop node. Same comments in binary node apply here.
//
void TIntermLoop::traverse(TIntermTraverser *it)