Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLSwitchCase.cpp
Go to the documentation of this file.
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
9
10namespace SkSL {
11
12std::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
19std::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
25std::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
SkPoint pos
int64_t SKSL_INT
Definition SkSLDefines.h:16
static std::unique_ptr< SwitchCase > MakeDefault(Position pos, std::unique_ptr< Statement > statement)
SKSL_INT value() const
std::string description() const override
static std::unique_ptr< SwitchCase > Make(Position pos, SKSL_INT value, std::unique_ptr< Statement > statement)
std::unique_ptr< Statement > & statement()