/* * 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 names, std::vector> values) : INHERITED(offset, kEnum_Kind) , fTypeName(typeName) , fNames(std::move(names)) , fValues(std::move(values)) { ASSERT(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 fNames; const std::vector> fValues; typedef ASTDeclaration INHERITED; }; } // namespace #endif