Coverage Report

Created: 2024-05-20 07:14

/src/skia/src/sksl/ir/SkSLConstructorArray.h
Line
Count
Source (jump to first uncovered line)
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/SkSLDefines.h"
12
#include "src/sksl/SkSLPosition.h"
13
#include "src/sksl/ir/SkSLConstructor.h"
14
#include "src/sksl/ir/SkSLExpression.h"
15
#include "src/sksl/ir/SkSLIRNode.h"
16
17
#include <memory>
18
#include <utility>
19
20
namespace SkSL {
21
22
class Context;
23
class Type;
24
25
/**
26
 * Represents the construction of an array type, such as "float[5](x, y, z, w, 1)".
27
 */
28
class ConstructorArray final : public MultiArgumentConstructor {
29
public:
30
    inline static constexpr Kind kIRNodeKind = Kind::kConstructorArray;
31
32
    ConstructorArray(Position pos, const Type& type, ExpressionArray arguments)
33
0
        : INHERITED(pos, kIRNodeKind, &type, std::move(arguments)) {}
34
35
    // ConstructorArray::Convert will typecheck and create array-constructor expressions.
36
    // Reports errors via the ErrorReporter; returns null on error.
37
    static std::unique_ptr<Expression> Convert(const Context& context,
38
                                               Position pos,
39
                                               const Type& type,
40
                                               ExpressionArray args);
41
42
    // ConstructorArray::Make creates array-constructor expressions; errors reported via SkASSERT.
43
    static std::unique_ptr<Expression> Make(const Context& context,
44
                                            Position pos,
45
                                            const Type& type,
46
                                            ExpressionArray args);
47
48
0
    std::unique_ptr<Expression> clone(Position pos) const override {
49
0
        return std::make_unique<ConstructorArray>(pos, this->type(), this->arguments().clone());
50
0
    }
51
52
private:
53
    using INHERITED = MultiArgumentConstructor;
54
};
55
56
}  // namespace SkSL
57
58
#endif