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
12 namespace SkSL {
13
14 namespace dsl {
15
DSLCase(DSLExpression value,SkSL::StatementArray statements,PositionInfo pos)16 DSLCase::DSLCase(DSLExpression value, SkSL::StatementArray statements, PositionInfo pos)
17 : fValue(std::move(value))
18 , fStatements(std::move(statements))
19 , fPosition(pos) {}
20
DSLCase(DSLExpression value,SkTArray<DSLStatement> statements,PositionInfo pos)21 DSLCase::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
DSLCase(DSLCase && other)30 DSLCase::DSLCase(DSLCase&& other)
31 : fValue(std::move(other.fValue))
32 , fStatements(std::move(other.fStatements)) {}
33
~DSLCase()34 DSLCase::~DSLCase() {}
35
operator =(DSLCase && other)36 DSLCase& DSLCase::operator=(DSLCase&& other) {
37 fValue = std::move(other.fValue);
38 fStatements = std::move(other.fStatements);
39 return *this;
40 }
41
append(DSLStatement stmt)42 void DSLCase::append(DSLStatement stmt) {
43 fStatements.push_back(stmt.release());
44 }
45
46 } // namespace dsl
47
48 } // namespace SkSL
49