blob: 6c1f8eefa263c57d8723fa202887918794c0b68b [file] [log] [blame]
Ethan Nicholas762466e2017-06-29 10:03:38 -04001/*
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
13namespace SkSL {
14
15/**
16 * A section declaration (e.g. @body { body code here })..
17 */
18struct ASTSection : public ASTDeclaration {
Ethan Nicholas5b5f0962017-09-11 13:50:14 -070019 ASTSection(int offset, String name, String arg, String text)
20 : INHERITED(offset, kSection_Kind)
Ethan Nicholas762466e2017-06-29 10:03:38 -040021 , 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