• 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 
29 #ifdef SK_DEBUG
descriptionSection30     String description() const override {
31         String result = "@" + fName;
32         if (fArgument.size()) {
33             result += "(" + fArgument + ")";
34         }
35         result += " { " + fText + " }";
36         return result;
37     }
38 #endif
39 
40     const String fName;
41     const String fArgument;
42     const String fText;
43 
44     typedef ProgramElement INHERITED;
45 };
46 
47 } // namespace
48 
49 #endif
50