Coverage Report

Created: 2024-05-20 07:14

/src/skia/src/sksl/ir/SkSLExtension.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2023 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
#include "src/sksl/ir/SkSLExtension.h"
9
10
#include "include/private/base/SkAssert.h"
11
#include "src/sksl/SkSLContext.h"
12
#include "src/sksl/SkSLErrorReporter.h"
13
#include "src/sksl/SkSLProgramSettings.h"
14
15
namespace SkSL {
16
17
std::unique_ptr<Extension> Extension::Convert(const Context& context,
18
                                              Position pos,
19
                                              std::string_view name,
20
5
                                              std::string_view behaviorText) {
21
5
    if (ProgramConfig::IsRuntimeEffect(context.fConfig->fKind)) {
22
        // Runtime Effects do not allow any #extensions.
23
5
        context.fErrors->error(pos, "unsupported directive '#extension'");
24
5
        return nullptr;
25
5
    }
26
0
    if (behaviorText == "disable") {
27
        // We allow `#extension <name> : disable`, but it is a no-op.
28
0
        return nullptr;
29
0
    }
30
0
    if (behaviorText != "require" && behaviorText != "enable" && behaviorText != "warn") {
31
0
        context.fErrors->error(pos, "expected 'require', 'enable', 'warn', or 'disable'");
32
0
        return nullptr;
33
0
    }
34
    // We don't currently do anything different between `require`, `enable`, and `warn`.
35
0
    return Extension::Make(context, pos, name);
36
0
}
37
38
std::unique_ptr<Extension> Extension::Make(const Context& context,
39
                                           Position pos,
40
0
                                           std::string_view name) {
41
0
    SkASSERT(!ProgramConfig::IsRuntimeEffect(context.fConfig->fKind));
42
0
    return std::make_unique<SkSL::Extension>(pos, name);
43
0
}
Unexecuted instantiation: SkSL::Extension::Make(SkSL::Context const&, SkSL::Position, std::__1::basic_string_view<char, std::__1::char_traits<char> >)
Unexecuted instantiation: SkSL::Extension::Make(SkSL::Context const&, SkSL::Position, std::__1::basic_string_view<char, std::__1::char_traits<char> >)
44
45
}  // namespace SkSL