1 /*
2 * Copyright 2023 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 #include "src/sksl/ir/SkSLSwitchCase.h"
9
10 namespace SkSL {
11
Make(Position pos,SKSL_INT value,std::unique_ptr<Statement> statement)12 std::unique_ptr<SwitchCase> SwitchCase::Make(Position pos,
13 SKSL_INT value,
14 std::unique_ptr<Statement> statement) {
15 return std::unique_ptr<SwitchCase>(new SwitchCase(pos, /*isDefault=*/false, value,
16 std::move(statement)));
17 }
18
MakeDefault(Position pos,std::unique_ptr<Statement> statement)19 std::unique_ptr<SwitchCase> SwitchCase::MakeDefault(Position pos,
20 std::unique_ptr<Statement> statement) {
21 return std::unique_ptr<SwitchCase>(new SwitchCase(pos, /*isDefault=*/true, /*value=*/-1,
22 std::move(statement)));
23 }
24
description() const25 std::string SwitchCase::description() const {
26 return fDefault ? "default: \n" + fStatement->description()
27 : "case " + std::to_string(fValue) + ": \n" + fStatement->description();
28 }
29
30 } // namespace SkSL
31