Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 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_ASTSECTION |
| 9 | #define SKSL_ASTSECTION |
| 10 | |
| 11 | #include "SkSLASTDeclaration.h" |
| 12 | |
| 13 | namespace SkSL { |
| 14 | |
| 15 | /** |
| 16 | * A section declaration (e.g. @body { body code here }).. |
| 17 | */ |
| 18 | struct ASTSection : public ASTDeclaration { |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 19 | ASTSection(int offset, String name, String arg, String text) |
| 20 | : INHERITED(offset, kSection_Kind) |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 21 | , fName(std::move(name)) |
| 22 | , fArgument(std::move(arg)) |
| 23 | , fText(std::move(text)) {} |
| 24 | |
| 25 | String description() const override { |
| 26 | String result = "@" + fName; |
| 27 | if (fArgument.size()) { |
| 28 | result += "(" + fArgument + ")"; |
| 29 | } |
| 30 | result += " { " + fText + " }"; |
| 31 | return result; |
| 32 | } |
| 33 | |
| 34 | const String fName; |
| 35 | const String fArgument; |
| 36 | const String fText; |
| 37 | |
| 38 | typedef ASTDeclaration INHERITED; |
| 39 | }; |
| 40 | |
| 41 | } // namespace |
| 42 | |
| 43 | #endif |