Convert IRGenerator::convertFor to ForStatement::Make.

Since while statements are implemented in terms of a for loop, also
added ForStatement::MakeWhile() which assumes null for the init-stmt and
the next-expr.

We currently don't have any optimizations for for-statements so the
primary benefit is moving code out of IRGenerator.

Change-Id: I4b3fc3482e28b7d28065e85670a6037b511847ff
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375203
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 59e6966..1ec491b 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -461,9 +461,9 @@
             // need to ensure initializer is evaluated first so that we've already remapped its
             // declarations by the time we evaluate test & next
             std::unique_ptr<Statement> initializer = stmt(f.initializer());
-            return std::make_unique<ForStatement>(offset, std::move(initializer), expr(f.test()),
-                                                  expr(f.next()), stmt(f.statement()),
-                                                  SymbolTable::WrapIfBuiltin(f.symbols()));
+            return ForStatement::Make(*fContext, offset, std::move(initializer), expr(f.test()),
+                                      expr(f.next()), stmt(f.statement()),
+                                      SymbolTable::WrapIfBuiltin(f.symbols()));
         }
         case Statement::Kind::kIf: {
             const IfStatement& i = statement.as<IfStatement>();
@@ -726,12 +726,12 @@
         inlineStatements = &innerBlock->children();
 
         // for (int _1_loop = 0; _1_loop < 1; _1_loop++) {...}
-        inlinedBody.children().push_back(std::make_unique<ForStatement>(/*offset=*/-1,
-                                                                        std::move(loopVar.fVarDecl),
-                                                                        std::move(test),
-                                                                        std::move(increment),
-                                                                        std::move(innerBlock),
-                                                                        symbolTable));
+        inlinedBody.children().push_back(ForStatement::Make(*fContext, /*offset=*/-1,
+                                                            std::move(loopVar.fVarDecl),
+                                                            std::move(test),
+                                                            std::move(increment),
+                                                            std::move(innerBlock),
+                                                            symbolTable));
     } else {
         // No early returns, so we can just dump the code into our existing scopeless block.
         inlineStatements = &inlinedBody.children();