huangcm
2025-08-25 f350412dc55c15118d0a7925d1071877498e5e24
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
44
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
 
#ifndef SKSL_ASTENUM
#define SKSL_ASTENUM
 
#include "SkSLASTDeclaration.h"
namespace SkSL {
 
struct ASTEnum : public ASTDeclaration {
    ASTEnum(int offset, StringFragment typeName, std::vector<StringFragment> names,
            std::vector<std::unique_ptr<ASTExpression>> values)
    : INHERITED(offset, kEnum_Kind)
    , fTypeName(typeName)
    , fNames(std::move(names))
    , fValues(std::move(values)) {
        SkASSERT(fNames.size() == fValues.size());
    }
 
    String description() const override {
        String result = "enum class " + fTypeName + " {\n";
        String separator;
        for (StringFragment name : fNames) {
            result += separator + "    " + name;
            separator = ",\n";
        }
        result += "};";
        return result;
    }
 
    const StringFragment fTypeName;
    const std::vector<StringFragment> fNames;
    const std::vector<std::unique_ptr<ASTExpression>> fValues;
 
    typedef ASTDeclaration INHERITED;
};
 
} // namespace
 
#endif