dan sinclair | a322f5d | 2020-03-30 22:46:06 +0000 | [diff] [blame] | 1 | // Copyright 2020 The Tint Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #include "src/ast/scalar_constructor_expression.h" |
| 16 | |
| 17 | namespace tint { |
| 18 | namespace ast { |
| 19 | |
| 20 | ScalarConstructorExpression::ScalarConstructorExpression() |
| 21 | : ConstructorExpression() {} |
| 22 | |
| 23 | ScalarConstructorExpression::ScalarConstructorExpression( |
| 24 | std::unique_ptr<Literal> literal) |
| 25 | : ConstructorExpression(), literal_(std::move(literal)) {} |
| 26 | |
| 27 | ScalarConstructorExpression::ScalarConstructorExpression( |
| 28 | const Source& source, |
| 29 | std::unique_ptr<Literal> litearl) |
| 30 | : ConstructorExpression(source), literal_(std::move(litearl)) {} |
| 31 | |
Ryan Harrison | 4d32be4 | 2020-04-09 18:52:06 +0000 | [diff] [blame] | 32 | ScalarConstructorExpression::ScalarConstructorExpression( |
| 33 | ScalarConstructorExpression&&) = default; |
| 34 | |
dan sinclair | a322f5d | 2020-03-30 22:46:06 +0000 | [diff] [blame] | 35 | ScalarConstructorExpression::~ScalarConstructorExpression() = default; |
| 36 | |
Ryan Harrison | 4d32be4 | 2020-04-09 18:52:06 +0000 | [diff] [blame] | 37 | bool ScalarConstructorExpression::IsScalarConstructor() const { |
| 38 | return true; |
| 39 | } |
| 40 | |
dan sinclair | a322f5d | 2020-03-30 22:46:06 +0000 | [diff] [blame] | 41 | bool ScalarConstructorExpression::IsValid() const { |
| 42 | return literal_ != nullptr; |
| 43 | } |
| 44 | |
| 45 | void ScalarConstructorExpression::to_str(std::ostream& out, |
| 46 | size_t indent) const { |
| 47 | make_indent(out, indent); |
dan sinclair | 80598ed | 2020-11-16 14:46:27 +0000 | [diff] [blame^] | 48 | out << "ScalarConstructor[" << result_type_str() << "]{" << literal_->to_str() |
| 49 | << "}" << std::endl; |
dan sinclair | a322f5d | 2020-03-30 22:46:06 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | } // namespace ast |
| 53 | } // namespace tint |