blob: adbeb27e85c21fc0bdc1bfba67f24c990d7fff6e [file] [log] [blame]
Ben Claytondcdf66e2022-06-17 12:48:51 +00001// Copyright 2022 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/tint/ast/parameter.h"
16
Ben Clayton783b1692022-08-02 17:03:35 +000017#include <utility>
18
Ben Claytondcdf66e2022-06-17 12:48:51 +000019#include "src/tint/program_builder.h"
20
21TINT_INSTANTIATE_TYPEINFO(tint::ast::Parameter);
22
23namespace tint::ast {
24
25Parameter::Parameter(ProgramID pid,
Ben Clayton4a92a3c2022-07-18 20:50:02 +000026 NodeID nid,
Ben Claytondcdf66e2022-06-17 12:48:51 +000027 const Source& src,
Ben Clayton651d9e22023-02-09 10:34:14 +000028 const Identifier* n,
Ben Claytondcdf66e2022-06-17 12:48:51 +000029 const ast::Type* ty,
Ben Clayton783b1692022-08-02 17:03:35 +000030 utils::VectorRef<const Attribute*> attrs)
Ben Clayton651d9e22023-02-09 10:34:14 +000031 : Base(pid, nid, src, n, ty, nullptr, std::move(attrs)) {}
Ben Claytondcdf66e2022-06-17 12:48:51 +000032
33Parameter::Parameter(Parameter&&) = default;
34
35Parameter::~Parameter() = default;
36
Ben Claytone48ef8e2022-06-26 10:52:50 +000037const char* Parameter::Kind() const {
38 return "parameter";
39}
40
Ben Claytondcdf66e2022-06-17 12:48:51 +000041const Parameter* Parameter::Clone(CloneContext* ctx) const {
42 auto src = ctx->Clone(source);
Ben Clayton651d9e22023-02-09 10:34:14 +000043 auto* n = ctx->Clone(name);
Ben Claytondcdf66e2022-06-17 12:48:51 +000044 auto* ty = ctx->Clone(type);
45 auto attrs = ctx->Clone(attributes);
Ben Clayton651d9e22023-02-09 10:34:14 +000046 return ctx->dst->create<Parameter>(src, n, ty, std::move(attrs));
Ben Claytondcdf66e2022-06-17 12:48:51 +000047}
48
49} // namespace tint::ast