aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ast/SkSLASTSection.h
blob: 6c1f8eefa263c57d8723fa202887918794c0b68b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SKSL_ASTSECTION
#define SKSL_ASTSECTION

#include "SkSLASTDeclaration.h"

namespace SkSL {

/**
 * A section declaration (e.g. @body { body code here })..
 */
struct ASTSection : public ASTDeclaration {
    ASTSection(int offset, String name, String arg, String text)
    : INHERITED(offset, kSection_Kind)
    , fName(std::move(name))
    , fArgument(std::move(arg))
    , fText(std::move(text)) {}

    String description() const override {
        String result = "@" + fName;
        if (fArgument.size()) {
            result += "(" + fArgument + ")";
        }
        result += " { " + fText + " }";
        return result;
    }

    const String fName;
    const String fArgument;
    const String fText;

    typedef ASTDeclaration INHERITED;
};

} // namespace

#endif