Replace vector<SwitchCase> in Switch with a StatementArray.

This is conceptually the same thing, but we have various places in the
code which expect a unique_ptr<Statement>, and they don't allow a
unique_ptr<SwitchCase> to be passed in, since the types don't match.

This change is particularly relevant to the ProgramWriter, which will be
updated in a followup CL to pass the unique_ptr to visit methods.

Change-Id: I012669fa429a13658ac2be31342c92750fe84b92
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/382723
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLMetalCodeGenerator.cpp b/src/sksl/SkSLMetalCodeGenerator.cpp
index 93a75b7..35f0235 100644
--- a/src/sksl/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/SkSLMetalCodeGenerator.cpp
@@ -1849,17 +1849,18 @@
     this->writeExpression(*s.value(), Precedence::kTopLevel);
     this->writeLine(") {");
     fIndentation++;
-    for (const std::unique_ptr<SwitchCase>& c : s.cases()) {
-        if (c->value()) {
+    for (const std::unique_ptr<Statement>& stmt : s.cases()) {
+        const SwitchCase& c = stmt->as<SwitchCase>();
+        if (c.value()) {
             this->write("case ");
-            this->writeExpression(*c->value(), Precedence::kTopLevel);
+            this->writeExpression(*c.value(), Precedence::kTopLevel);
             this->writeLine(":");
         } else {
             this->writeLine("default:");
         }
-        if (!c->statement()->isEmpty()) {
+        if (!c.statement()->isEmpty()) {
             fIndentation++;
-            this->writeStatement(*c->statement());
+            this->writeStatement(*c.statement());
             fIndentation--;
         }
     }
@@ -2320,8 +2321,8 @@
         case Statement::Kind::kSwitch: {
             const SwitchStatement& sw = s->as<SwitchStatement>();
             Requirements result = this->requirements(sw.value().get());
-            for (const std::unique_ptr<SwitchCase>& sc : sw.cases()) {
-                result |= this->requirements(sc->statement().get());
+            for (const std::unique_ptr<Statement>& sc : sw.cases()) {
+                result |= this->requirements(sc->as<SwitchCase>().statement().get());
             }
             return result;
         }