Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [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 | #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 | |
| 21 | namespace tint { |
| 22 | namespace ast { |
| 23 | |
| 24 | /// A builtin decoration |
Ben Clayton | e319d7f | 2020-11-30 23:30:58 +0000 | [diff] [blame] | 25 | class BuiltinDecoration |
| 26 | : public Castable<BuiltinDecoration, VariableDecoration> { |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 27 | public: |
| 28 | /// constructor |
Ben Clayton | 34a2eb1 | 2020-11-03 21:48:20 +0000 | [diff] [blame] | 29 | /// @param source the source of this decoration |
Ben Clayton | 5aad70a | 2020-12-14 21:10:07 +0000 | [diff] [blame] | 30 | /// @param builtin the builtin value |
| 31 | BuiltinDecoration(const Source& source, Builtin builtin); |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 32 | ~BuiltinDecoration() override; |
| 33 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 34 | /// @returns the builtin value |
| 35 | Builtin value() const { return builtin_; } |
| 36 | |
| 37 | /// Outputs the decoration to the given stream |
Ben Clayton | 6f58546 | 2020-11-13 21:43:58 +0000 | [diff] [blame] | 38 | /// @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 Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 41 | |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 42 | /// 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 Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 50 | private: |
Ben Clayton | be96376 | 2020-12-15 14:52:38 +0000 | [diff] [blame] | 51 | Builtin const builtin_; |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | } // namespace ast |
| 55 | } // namespace tint |
| 56 | |
| 57 | #endif // SRC_AST_BUILTIN_DECORATION_H_ |