Ethan Nicholas | c8d9c8e | 2020-09-22 15:05:37 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 12 | namespace SkSL { |
| 13 | |
Ethan Nicholas | 59d660c | 2020-09-28 09:18:15 -0400 | [diff] [blame] | 14 | IRNode::IRNode(int offset, int kind, const BlockData& data, |
| 15 | std::vector<std::unique_ptr<Statement>> stmts) |
Ethan Nicholas | 7bd6043 | 2020-09-25 14:31:59 -0400 | [diff] [blame] | 16 | : fOffset(offset) |
| 17 | , fKind(kind) |
| 18 | , fData(data) |
| 19 | , fStatementChildren(std::move(stmts)) {} |
| 20 | |
Ethan Nicholas | 59d660c | 2020-09-28 09:18:15 -0400 | [diff] [blame] | 21 | IRNode::IRNode(int offset, int kind, const BoolLiteralData& data) |
| 22 | : fOffset(offset) |
| 23 | , fKind(kind) |
| 24 | , fData(data) {} |
| 25 | |
Ethan Nicholas | d83ded8 | 2020-09-29 17:05:54 -0400 | [diff] [blame] | 26 | IRNode::IRNode(int offset, int kind, const EnumData& data) |
| 27 | : fOffset(offset) |
| 28 | , fKind(kind) |
| 29 | , fData(data) {} |
| 30 | |
Ethan Nicholas | 6e86ec9 | 2020-09-30 14:29:56 -0400 | [diff] [blame] | 31 | IRNode::IRNode(int offset, int kind, const ExternalValueData& data) |
| 32 | : fOffset(offset) |
| 33 | , fKind(kind) |
| 34 | , fData(data) {} |
| 35 | |
Ethan Nicholas | 556b8be | 2020-10-02 17:08:55 -0400 | [diff] [blame^] | 36 | IRNode::IRNode(int offset, int kind, const FieldData& data) |
| 37 | : fOffset(offset) |
| 38 | , fKind(kind) |
| 39 | , fData(data) {} |
| 40 | |
Ethan Nicholas | e96cdd1 | 2020-09-28 16:27:18 -0400 | [diff] [blame] | 41 | IRNode::IRNode(int offset, int kind, const IntLiteralData& data) |
| 42 | : fOffset(offset) |
| 43 | , fKind(kind) |
| 44 | , fData(data) {} |
Ethan Nicholas | 59d660c | 2020-09-28 09:18:15 -0400 | [diff] [blame] | 45 | |
Ethan Nicholas | a3f22f1 | 2020-10-01 12:13:17 -0400 | [diff] [blame] | 46 | IRNode::IRNode(int offset, int kind, const FloatLiteralData& data) |
| 47 | : fOffset(offset) |
| 48 | , fKind(kind) |
| 49 | , fData(data) {} |
| 50 | |
Ethan Nicholas | efb09e2 | 2020-09-30 10:17:00 -0400 | [diff] [blame] | 51 | IRNode::IRNode(int offset, int kind, const String& data) |
| 52 | : fOffset(offset) |
| 53 | , fKind(kind) |
| 54 | , fData(data) {} |
| 55 | |
Ethan Nicholas | 556b8be | 2020-10-02 17:08:55 -0400 | [diff] [blame^] | 56 | IRNode::IRNode(int offset, int kind, const SymbolData& data) |
| 57 | : fOffset(offset) |
| 58 | , fKind(kind) |
| 59 | , fData(data) {} |
| 60 | |
Ethan Nicholas | c8d9c8e | 2020-09-22 15:05:37 -0400 | [diff] [blame] | 61 | IRNode::IRNode(int offset, int kind, const Type* data) |
| 62 | : fOffset(offset) |
| 63 | , fKind(kind) |
| 64 | , fData(data) {} |
| 65 | |
Ethan Nicholas | 59d660c | 2020-09-28 09:18:15 -0400 | [diff] [blame] | 66 | IRNode::IRNode(int offset, int kind, const TypeTokenData& data) |
Ethan Nicholas | c8d9c8e | 2020-09-22 15:05:37 -0400 | [diff] [blame] | 67 | : fOffset(offset) |
| 68 | , fKind(kind) |
| 69 | , fData(data) {} |
| 70 | |
| 71 | IRNode::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 | |
| 81 | IRNode::~IRNode() {} |
| 82 | |
| 83 | } // namespace SkSL |