blob: 88858218aef73db2faf417903618b21b38da03e8 [file] [log] [blame]
Ethan Nicholasc8d9c8e2020-09-22 15:05:37 -04001/*
2 * Copyright 2020 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 "src/sksl/ir/SkSLIRNode.h"
9
10#include "src/sksl/ir/SkSLExpression.h"
11
12namespace SkSL {
13
Ethan Nicholas59d660c2020-09-28 09:18:15 -040014IRNode::IRNode(int offset, int kind, const BlockData& data,
15 std::vector<std::unique_ptr<Statement>> stmts)
Ethan Nicholas7bd60432020-09-25 14:31:59 -040016: fOffset(offset)
17, fKind(kind)
18, fData(data)
19, fStatementChildren(std::move(stmts)) {}
20
Ethan Nicholas59d660c2020-09-28 09:18:15 -040021IRNode::IRNode(int offset, int kind, const BoolLiteralData& data)
22: fOffset(offset)
23, fKind(kind)
24, fData(data) {}
25
Ethan Nicholasd83ded82020-09-29 17:05:54 -040026IRNode::IRNode(int offset, int kind, const EnumData& data)
27: fOffset(offset)
28, fKind(kind)
29, fData(data) {}
30
Ethan Nicholase96cdd12020-09-28 16:27:18 -040031IRNode::IRNode(int offset, int kind, const IntLiteralData& data)
32: fOffset(offset)
33, fKind(kind)
34, fData(data) {}
Ethan Nicholas59d660c2020-09-28 09:18:15 -040035
Ethan Nicholas135e2372020-09-29 10:21:29 -040036IRNode::IRNode(int offset, int kind, const FloatLiteralData& data)
37: fOffset(offset)
38, fKind(kind)
39, fData(data) {}
40
Ethan Nicholasefb09e22020-09-30 10:17:00 -040041IRNode::IRNode(int offset, int kind, const String& data)
42: fOffset(offset)
43, fKind(kind)
44, fData(data) {}
45
Ethan Nicholasc8d9c8e2020-09-22 15:05:37 -040046IRNode::IRNode(int offset, int kind, const Type* data)
47: fOffset(offset)
48, fKind(kind)
49, fData(data) {}
50
Ethan Nicholas59d660c2020-09-28 09:18:15 -040051IRNode::IRNode(int offset, int kind, const TypeTokenData& data)
Ethan Nicholasc8d9c8e2020-09-22 15:05:37 -040052: fOffset(offset)
53, fKind(kind)
54, fData(data) {}
55
56IRNode::IRNode(const IRNode& other)
57 : fOffset(other.fOffset)
58 , fKind(other.fKind)
59 , fData(other.fData) {
60 // For now, we can't use a default copy constructor because of the std::unique_ptr children.
61 // Since we never copy nodes containing children, it's easiest just to assert we don't have any
62 // than bother with cloning them.
63 SkASSERT(other.fExpressionChildren.empty());
64}
65
66IRNode::~IRNode() {}
67
68} // namespace SkSL