Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLExtension.h
Go to the documentation of this file.
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
14
15#include <memory>
16#include <string>
17#include <string_view>
18
19namespace SkSL {
20
21class Context;
22
23/**
24 * #extension <name> : enable
25 */
26class Extension final : public ProgramElement {
27public:
28 inline static constexpr Kind kIRNodeKind = Kind::kExtension;
29
30 Extension(Position pos, std::string_view name)
32 , fName(name) {}
33
34 std::string_view name() const {
35 return fName;
36 }
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,
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,
48 std::string_view name);
49
50 std::string description() const override {
51 return "#extension " + std::string(this->name()) + " : enable";
52 }
53
54private:
55 std::string_view fName;
56
57 using INHERITED = ProgramElement;
58};
59
60} // namespace SkSL
61
62#endif
SkPoint pos
static constexpr Kind kIRNodeKind
std::string description() const override
static std::unique_ptr< Extension > Convert(const Context &context, Position pos, std::string_view name, std::string_view behaviorText)
std::string_view name() const
static std::unique_ptr< Extension > Make(const Context &context, Position pos, std::string_view name)
Extension(Position pos, std::string_view name)
ProgramElementKind
Definition SkSLIRNode.h:19