Add Convert factory function to SkSL IRNodes.

SkSL IRNodes now have two different factory functions:

XxxxxStatement::Convert -- this is the equivalent of
    IRGenerator::convertXxxxx. Type coercion is fully supported. Errors
    are reported via ErrorReporter. Failure is handled gracefully by
    returning null.

XxxxxStatement::Make -- this is treated more like `new XxxxxStatement`
    but with optimizations applied. Types must already be correct.
    If the passed-in arguments don't make sense, errors are reported
    via SkASSERT. `Make` is always expected to return an IRNode--
    either exactly what was passed in, or an equivalent simpler form.

(In some rare exceptions, supporting Make was too difficult and is
not handled in this CL. Constructor was the biggest edge case; it
is extremely complicated [skia:11032], and supporting Make would require
duplicating most of its logic. It was too much copy-and-paste for me.)

Rationale for this change:

Originally, when the Inliner or Rehydrator would create an IRNode, it
would just allocate it via `new` or `make_unique` and take it as-is.
No error-checking, no optimization.

I decided to allow those callers to benefit from simple optimizations.
This meant porting logic from the IRGenerator (e.g. `convertIf`, which
removes empty branches) into widely available factory functions.
However, the Inliner and Rehydrator don't need the type coercion, and
we'd rather have them assert/succeed instead of getting a null and
crashing (in the unexpected case that recreating an IRNode causes an
error to be detected).

Change-Id: I6949328e904258a627106524ed4134b524e012b6
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377843
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 37a06b4..bad4829 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -330,9 +330,11 @@
             return expression.clone();
         case Expression::Kind::kConstructor: {
             const Constructor& constructor = expression.as<Constructor>();
-            return Constructor::Make(*fContext, offset,
-                                     *constructor.type().clone(symbolTableForExpression),
-                                     argList(constructor.arguments()));
+            auto inlinedCtor = Constructor::Convert(
+                    *fContext, offset, *constructor.type().clone(symbolTableForExpression),
+                    argList(constructor.arguments()));
+            SkASSERT(inlinedCtor);
+            return inlinedCtor;
         }
         case Expression::Kind::kExternalFunctionCall: {
             const ExternalFunctionCall& externalCall = expression.as<ExternalFunctionCall>();