blob: c7b2d9a834b162dec4a39cac484b07c1408cb169 [file] [log] [blame]
dan sinclair9e7f9dc2020-09-29 18:07:50 +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#ifndef SRC_AST_CONSTANT_ID_DECORATION_H_
16#define SRC_AST_CONSTANT_ID_DECORATION_H_
17
18#include "src/ast/builtin.h"
19#include "src/ast/variable_decoration.h"
20
21namespace tint {
22namespace ast {
23
24/// A constant id decoration
25class ConstantIdDecoration : public VariableDecoration {
26 public:
27 /// constructor
28 /// @param val the constant_id value
29 explicit ConstantIdDecoration(uint32_t val);
30 ~ConstantIdDecoration() override;
31
32 /// @returns true if this is a constant_id decoration
33 bool IsConstantId() const override;
34
35 /// @returns the constant id value
36 uint32_t value() const { return value_; }
37
38 /// Outputs the decoration to the given stream
39 /// @param out the stream to output too
40 void to_str(std::ostream& out) const override;
41
42 private:
43 uint32_t value_ = 0;
44};
45
46} // namespace ast
47} // namespace tint
48
49#endif // SRC_AST_CONSTANT_ID_DECORATION_H_