SkSLASTType.h revision 50afc1765511a8d4850fe97aacf8714b609bfd5a
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_ASTTYPE
9#define SKSL_ASTTYPE
10
11#include "SkSLASTPositionNode.h"
12
13namespace SkSL {
14
15/**
16 * A type, such as 'int' or 'struct foo'.
17 */
18struct ASTType : public ASTPositionNode {
19    enum Kind {
20        kIdentifier_Kind,
21        kStruct_Kind
22    };
23
24    ASTType(Position position, SkString name, Kind kind, std::vector<int> sizes)
25    : INHERITED(position)
26    , fName(std::move(name))
27    , fKind(kind)
28    , fSizes(std::move(sizes)) {}
29
30    SkString description() const override {
31        return fName;
32    }
33
34    const SkString fName;
35
36    const Kind fKind;
37
38    // array sizes, -1 meaning unspecified
39    const std::vector<int> fSizes;
40
41    typedef ASTPositionNode INHERITED;
42};
43
44} // namespace
45
46#endif
47