blob: 52b3ed2245acc80e8bc876421784b9e1fbd23e19 [file] [log] [blame]
dan sinclaira322f5d2020-03-30 22:46:06 +00001// 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
17namespace tint {
18namespace ast {
19
20ScalarConstructorExpression::ScalarConstructorExpression()
21 : ConstructorExpression() {}
22
23ScalarConstructorExpression::ScalarConstructorExpression(
24 std::unique_ptr<Literal> literal)
25 : ConstructorExpression(), literal_(std::move(literal)) {}
26
27ScalarConstructorExpression::ScalarConstructorExpression(
28 const Source& source,
29 std::unique_ptr<Literal> litearl)
30 : ConstructorExpression(source), literal_(std::move(litearl)) {}
31
Ryan Harrison4d32be42020-04-09 18:52:06 +000032ScalarConstructorExpression::ScalarConstructorExpression(
33 ScalarConstructorExpression&&) = default;
34
dan sinclaira322f5d2020-03-30 22:46:06 +000035ScalarConstructorExpression::~ScalarConstructorExpression() = default;
36
Ryan Harrison4d32be42020-04-09 18:52:06 +000037bool ScalarConstructorExpression::IsScalarConstructor() const {
38 return true;
39}
40
dan sinclaira322f5d2020-03-30 22:46:06 +000041bool ScalarConstructorExpression::IsValid() const {
42 return literal_ != nullptr;
43}
44
45void ScalarConstructorExpression::to_str(std::ostream& out,
46 size_t indent) const {
47 make_indent(out, indent);
dan sinclair80598ed2020-11-16 14:46:27 +000048 out << "ScalarConstructor[" << result_type_str() << "]{" << literal_->to_str()
49 << "}" << std::endl;
dan sinclaira322f5d2020-03-30 22:46:06 +000050}
51
52} // namespace ast
53} // namespace tint