Flutter Engine
The Flutter Engine
SkSLExtension.cpp
Go to the documentation of this file.
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
9
14
15namespace SkSL {
16
17std::unique_ptr<Extension> Extension::Convert(const Context& context,
19 std::string_view name,
20 std::string_view behaviorText) {
22 // Runtime Effects do not allow any #extensions.
23 context.fErrors->error(pos, "unsupported directive '#extension'");
24 return nullptr;
25 }
26 if (behaviorText == "disable") {
27 // We allow `#extension <name> : disable`, but it is a no-op.
28 return nullptr;
29 }
30 if (behaviorText != "require" && behaviorText != "enable" && behaviorText != "warn") {
31 context.fErrors->error(pos, "expected 'require', 'enable', 'warn', or 'disable'");
32 return nullptr;
33 }
34 // We don't currently do anything different between `require`, `enable`, and `warn`.
35 return Extension::Make(context, pos, name);
36}
37
38std::unique_ptr<Extension> Extension::Make(const Context& context,
40 std::string_view name) {
42 return std::make_unique<SkSL::Extension>(pos, name);
43}
44
45} // namespace SkSL
SkPoint pos
#define SkASSERT(cond)
Definition: SkAssert.h:116
ErrorReporter * fErrors
Definition: SkSLContext.h:36
ProgramConfig * fConfig
Definition: SkSLContext.h:33
void error(Position position, std::string_view msg)
static std::unique_ptr< Extension > Convert(const Context &context, Position pos, std::string_view name, std::string_view behaviorText)
std::string_view name() const
Definition: SkSLExtension.h:34
static std::unique_ptr< Extension > Make(const Context &context, Position pos, std::string_view name)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
static bool IsRuntimeEffect(ProgramKind kind)