• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SECTION
9 #define SKSL_SECTION
10 
11 #include "src/sksl/ir/SkSLProgramElement.h"
12 
13 namespace SkSL {
14 
15 /**
16  * A section declaration (e.g. @body { body code here })..
17  */
18 struct Section : public ProgramElement {
SectionSection19     Section(int offset, String name, String arg, String text)
20     : INHERITED(offset, kSection_Kind)
21     , fName(std::move(name))
22     , fArgument(std::move(arg))
23     , fText(std::move(text)) {}
24 
cloneSection25     std::unique_ptr<ProgramElement> clone() const override {
26         return std::unique_ptr<ProgramElement>(new Section(fOffset, fName, fArgument, fText));
27     }
28 
descriptionSection29     String description() const override {
30         String result = "@" + fName;
31         if (fArgument.size()) {
32             result += "(" + fArgument + ")";
33         }
34         result += " { " + fText + " }";
35         return result;
36     }
37 
38     const String fName;
39     const String fArgument;
40     const String fText;
41 
42     typedef ProgramElement INHERITED;
43 };
44 
45 } // namespace
46 
47 #endif
48