Represent array constructors with a dedicated ConstructorArray class.
Change-Id: Ia8c8a3476202257ecc100f9cb31e6d0095135aa1
Bug: skia:11032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391919
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 7915776..422013b 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -17,6 +17,7 @@
#include "src/sksl/ir/SkSLBoolLiteral.h"
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLConstructor.h"
+#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLContinueStatement.h"
#include "src/sksl/ir/SkSLDiscardStatement.h"
@@ -313,6 +314,12 @@
SkASSERT(inlinedCtor);
return inlinedCtor;
}
+ case Expression::Kind::kConstructorArray: {
+ const ConstructorArray& ctor = expression.as<ConstructorArray>();
+ return ConstructorArray::Make(*fContext, offset,
+ *ctor.type().clone(symbolTableForExpression),
+ argList(ctor.arguments()));
+ }
case Expression::Kind::kConstructorDiagonalMatrix: {
const ConstructorDiagonalMatrix& ctor = expression.as<ConstructorDiagonalMatrix>();
return ConstructorDiagonalMatrix::Make(*fContext, offset,
@@ -913,18 +920,15 @@
}
break;
}
- case Expression::Kind::kConstructor: {
- Constructor& constructorExpr = (*expr)->as<Constructor>();
- for (std::unique_ptr<Expression>& arg : constructorExpr.arguments()) {
+ case Expression::Kind::kConstructor:
+ case Expression::Kind::kConstructorArray:
+ case Expression::Kind::kConstructorDiagonalMatrix: {
+ AnyConstructor& constructorExpr = (*expr)->asAnyConstructor();
+ for (std::unique_ptr<Expression>& arg : constructorExpr.argumentSpan()) {
this->visitExpression(&arg);
}
break;
}
- case Expression::Kind::kConstructorDiagonalMatrix: {
- ConstructorDiagonalMatrix& ctorExpr = (*expr)->as<ConstructorDiagonalMatrix>();
- this->visitExpression(&ctorExpr.argument());
- break;
- }
case Expression::Kind::kExternalFunctionCall: {
ExternalFunctionCall& funcCallExpr = (*expr)->as<ExternalFunctionCall>();
for (std::unique_ptr<Expression>& arg : funcCallExpr.arguments()) {