blob: 7c437d50e4f939ec742388e356e70e29753cb1f1 [file] [log] [blame]
Dan Sinclair6e581892020-03-02 15:47:43 -05001// 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#ifndef SRC_AST_BUILTIN_DECORATION_H_
16#define SRC_AST_BUILTIN_DECORATION_H_
17
18#include "src/ast/builtin.h"
19#include "src/ast/variable_decoration.h"
20
21namespace tint {
22namespace ast {
23
24/// A builtin decoration
Ben Claytone319d7f2020-11-30 23:30:58 +000025class BuiltinDecoration
26 : public Castable<BuiltinDecoration, VariableDecoration> {
Dan Sinclair6e581892020-03-02 15:47:43 -050027 public:
28 /// constructor
Ben Clayton34a2eb12020-11-03 21:48:20 +000029 /// @param source the source of this decoration
Ben Clayton5aad70a2020-12-14 21:10:07 +000030 /// @param builtin the builtin value
31 BuiltinDecoration(const Source& source, Builtin builtin);
Dan Sinclair6e581892020-03-02 15:47:43 -050032 ~BuiltinDecoration() override;
33
Dan Sinclair6e581892020-03-02 15:47:43 -050034 /// @returns the builtin value
35 Builtin value() const { return builtin_; }
36
37 /// Outputs the decoration to the given stream
Ben Clayton6f585462020-11-13 21:43:58 +000038 /// @param out the stream to write to
39 /// @param indent number of spaces to indent the node when writing
40 void to_str(std::ostream& out, size_t indent) const override;
Dan Sinclair6e581892020-03-02 15:47:43 -050041
Ben Claytoned2b9782020-12-01 18:04:17 +000042 /// Clones this node and all transitive child nodes using the `CloneContext`
43 /// `ctx`.
44 /// @note Semantic information such as resolved expression type and intrinsic
45 /// information is not cloned.
46 /// @param ctx the clone context
47 /// @return the newly cloned node
48 BuiltinDecoration* Clone(CloneContext* ctx) const override;
49
Dan Sinclair6e581892020-03-02 15:47:43 -050050 private:
Ben Claytonbe963762020-12-15 14:52:38 +000051 Builtin const builtin_;
Dan Sinclair6e581892020-03-02 15:47:43 -050052};
53
54} // namespace ast
55} // namespace tint
56
57#endif // SRC_AST_BUILTIN_DECORATION_H_