Debian Codegraph @

src/sksl/ir/SkSLModifiersDeclaration.h

raw
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_MODIFIERDECLARATION
9 #define SKSL_MODIFIERDECLARATION
10
11 #include "src/sksl/SkSLPosition.h"
12 #include "src/sksl/ir/SkSLIRNode.h"
13 #include "src/sksl/ir/SkSLLayout.h"
14 #include "src/sksl/ir/SkSLModifierFlags.h"
15 #include "src/sksl/ir/SkSLProgramElement.h"
16
17 #include <memory>
18 #include <string>
19
20 namespace SkSL {
21
22 class Context;
23 struct Modifiers;
24
25 /**
26 * A declaration that consists only of modifiers, e.g.:
27 *
28 * layout(blend_support_all_equations) out;
29 */
30 class ModifiersDeclaration final : public ProgramElement {
31 public:
32 inline static constexpr Kind kIRNodeKind = Kind::kModifiers;
33
34 ModifiersDeclaration(Position pos, const Layout& layout, ModifierFlags flags)
35 : INHERITED(pos, kIRNodeKind)
36 , fLayout(layout)
37 , fFlags(flags) {}
38
39 static std::unique_ptr<ModifiersDeclaration> Convert(const Context& context,
40 const Modifiers& modifiers);
41
42 static std::unique_ptr<ModifiersDeclaration> Make(const Context& context,
43 const Modifiers& modifiers);
44
45 const Layout& layout() const {
46 return fLayout;
47 }
48
49 ModifierFlags modifierFlags() const {
50 return fFlags;
51 }
52
53 std::string description() const override {
54 return fLayout.paddedDescription() + fFlags.description() + ';';
55 }
56
57 private:
58 Layout fLayout;
59 ModifierFlags fFlags;
60
61 using INHERITED = ProgramElement;
62 };
63
64 } // namespace SkSL
65
66 #endif