xref: /third_party/skia/src/sksl/dsl/DSLCase.cpp (revision cb93a386)
1/*
2 * Copyright 2021 Google LLC.
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 "include/sksl/DSLCase.h"
9
10#include "include/private/SkSLStatement.h"
11
12namespace SkSL {
13
14namespace dsl {
15
16DSLCase::DSLCase(DSLExpression value, SkSL::StatementArray statements, PositionInfo pos)
17    : fValue(std::move(value))
18    , fStatements(std::move(statements))
19    , fPosition(pos) {}
20
21DSLCase::DSLCase(DSLExpression value, SkTArray<DSLStatement> statements, PositionInfo pos)
22    : fValue(std::move(value))
23    , fPosition(pos) {
24    fStatements.reserve_back(statements.count());
25    for (DSLStatement& stmt : statements) {
26        fStatements.push_back(stmt.release());
27    }
28}
29
30DSLCase::DSLCase(DSLCase&& other)
31    : fValue(std::move(other.fValue))
32    , fStatements(std::move(other.fStatements)) {}
33
34DSLCase::~DSLCase() {}
35
36DSLCase& DSLCase::operator=(DSLCase&& other) {
37    fValue = std::move(other.fValue);
38    fStatements = std::move(other.fStatements);
39    return *this;
40}
41
42void DSLCase::append(DSLStatement stmt) {
43    fStatements.push_back(stmt.release());
44}
45
46} // namespace dsl
47
48} // namespace SkSL
49