blob: 8da885e8ee9a496aea49bc14b799a3e4d07d2cbd [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 Nicholas6e86ec92020-09-30 14:29:56 -040031IRNode::IRNode(int offset, int kind, const ExternalValueData& data)
32: fOffset(offset)
33, fKind(kind)
34, fData(data) {}
35
Ethan Nicholas556b8be2020-10-02 17:08:55 -040036IRNode::IRNode(int offset, int kind, const FieldData& data)
37: fOffset(offset)
38, fKind(kind)
39, fData(data) {}
40
Ethan Nicholase96cdd12020-09-28 16:27:18 -040041IRNode::IRNode(int offset, int kind, const IntLiteralData& data)
42: fOffset(offset)
43, fKind(kind)
44, fData(data) {}
Ethan Nicholas59d660c2020-09-28 09:18:15 -040045
Ethan Nicholasa3f22f12020-10-01 12:13:17 -040046IRNode::IRNode(int offset, int kind, const FloatLiteralData& data)
47: fOffset(offset)
48, fKind(kind)
49, fData(data) {}
50
Ethan Nicholasefb09e22020-09-30 10:17:00 -040051IRNode::IRNode(int offset, int kind, const String& data)
52: fOffset(offset)
53, fKind(kind)
54, fData(data) {}
55
Ethan Nicholas556b8be2020-10-02 17:08:55 -040056IRNode::IRNode(int offset, int kind, const SymbolData& data)
57: fOffset(offset)
58, fKind(kind)
59, fData(data) {}
60
Ethan Nicholasc8d9c8e2020-09-22 15:05:37 -040061IRNode::IRNode(int offset, int kind, const Type* data)
62: fOffset(offset)
63, fKind(kind)
64, fData(data) {}
65
Ethan Nicholas59d660c2020-09-28 09:18:15 -040066IRNode::IRNode(int offset, int kind, const TypeTokenData& data)
Ethan Nicholasc8d9c8e2020-09-22 15:05:37 -040067: fOffset(offset)
68, fKind(kind)
69, fData(data) {}
70
71IRNode::IRNode(const IRNode& other)
72 : fOffset(other.fOffset)
73 , fKind(other.fKind)
74 , fData(other.fData) {
75 // For now, we can't use a default copy constructor because of the std::unique_ptr children.
76 // Since we never copy nodes containing children, it's easiest just to assert we don't have any
77 // than bother with cloning them.
78 SkASSERT(other.fExpressionChildren.empty());
79}
80
81IRNode::~IRNode() {}
82
83} // namespace SkSL