Coverage Report

Created: 2024-05-20 07:14

/src/skia/src/sksl/ir/SkSLExtension.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2016 Google Inc.
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_EXTENSION
9
#define SKSL_EXTENSION
10
11
#include "src/sksl/SkSLPosition.h"
12
#include "src/sksl/ir/SkSLIRNode.h"
13
#include "src/sksl/ir/SkSLProgramElement.h"
14
15
#include <memory>
16
#include <string>
17
#include <string_view>
18
19
namespace SkSL {
20
21
class Context;
22
23
/**
24
 * #extension <name> : enable
25
 */
26
class Extension final : public ProgramElement {
27
public:
28
    inline static constexpr Kind kIRNodeKind = Kind::kExtension;
29
30
    Extension(Position pos, std::string_view name)
31
            : INHERITED(pos, kIRNodeKind)
32
0
            , fName(name) {}
33
34
0
    std::string_view name() const {
35
0
        return fName;
36
0
    }
37
38
    // Reports errors via ErrorReporter. This may return null even if no error occurred;
39
    // in particular, if the behavior text is `disabled`, no ProgramElement is necessary.
40
    static std::unique_ptr<Extension> Convert(const Context& context,
41
                                              Position pos,
42
                                              std::string_view name,
43
                                              std::string_view behaviorText);
44
45
    // Asserts if an error is detected.
46
    static std::unique_ptr<Extension> Make(const Context& context,
47
                                           Position pos,
48
                                           std::string_view name);
49
50
0
    std::string description() const override {
51
0
        return "#extension " + std::string(this->name()) + " : enable";
52
0
    }
53
54
private:
55
    std::string_view fName;
56
57
    using INHERITED = ProgramElement;
58
};
59
60
}  // namespace SkSL
61
62
#endif