blob: 6c44a676783d10deb505319f209780281fdd72f9 (
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
|
/*
* 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_ENUM
#define SKSL_ENUM
#include "SkSLProgramElement.h"
namespace SkSL {
struct Enum : public ProgramElement {
Enum(int offset, StringFragment typeName, std::shared_ptr<SymbolTable> symbols)
: INHERITED(offset, kEnum_Kind)
, fTypeName(typeName)
, fSymbols(std::move(symbols)) {}
String description() const override {
String result = "enum class " + fTypeName + " {\n";
String separator;
for (auto iter = fSymbols->begin(); iter != fSymbols->end(); ++iter) {
result += separator + " " + iter->first + " = " +
((Variable&) *iter->second).fInitialValue->description();
separator = ",\n";
}
result += "\n};";
return result;
}
bool fBuiltin = false;
const StringFragment fTypeName;
const std::shared_ptr<SymbolTable> fSymbols;
typedef ProgramElement INHERITED;
};
} // namespace
#endif
|