• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SKSL_CONSTRUCTOR_ARRAY
9 #define SKSL_CONSTRUCTOR_ARRAY
10 
11 #include "src/sksl/ir/SkSLConstructor.h"
12 
13 namespace SkSL {
14 
15 /**
16  * Represents the construction of an array type, such as "float[5](x, y, z, w, 1)".
17  */
18 class ConstructorArray final : public MultiArgumentConstructor {
19 public:
20     inline static constexpr Kind kExpressionKind = Kind::kConstructorArray;
21 
ConstructorArray(int line,const Type & type,ExpressionArray arguments)22     ConstructorArray(int line, const Type& type, ExpressionArray arguments)
23         : INHERITED(line, kExpressionKind, &type, std::move(arguments)) {}
24 
25     // ConstructorArray::Convert will typecheck and create array-constructor expressions.
26     // Reports errors via the ErrorReporter; returns null on error.
27     static std::unique_ptr<Expression> Convert(const Context& context,
28                                                int line,
29                                                const Type& type,
30                                                ExpressionArray args);
31 
32     // ConstructorArray::Make creates array-constructor expressions; errors reported via SkASSERT.
33     static std::unique_ptr<Expression> Make(const Context& context,
34                                             int line,
35                                             const Type& type,
36                                             ExpressionArray args);
37 
clone()38     std::unique_ptr<Expression> clone() const override {
39         return std::make_unique<ConstructorArray>(fLine, this->type(), this->cloneArguments());
40     }
41 
42 private:
43     using INHERITED = MultiArgumentConstructor;
44 };
45 
46 }  // namespace SkSL
47 
48 #endif
49