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_IDENTIFIER_EXPRESSION_H_ |
| 16 | #define SRC_AST_IDENTIFIER_EXPRESSION_H_ |
| 17 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 18 | #include "src/ast/expression.h" |
| 19 | |
| 20 | namespace tint { |
| 21 | namespace ast { |
| 22 | |
| 23 | /// An identifier expression |
Ben Clayton | e319d7f | 2020-11-30 23:30:58 +0000 | [diff] [blame] | 24 | class IdentifierExpression : public Castable<IdentifierExpression, Expression> { |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 25 | public: |
| 26 | /// Constructor |
Ben Clayton | e6995de | 2021-04-13 23:27:27 +0000 | [diff] [blame] | 27 | /// @param program_id the identifier of the program that owns this node |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 28 | /// @param source the source |
dan sinclair | 6b59bf4 | 2020-12-11 19:16:13 +0000 | [diff] [blame] | 29 | /// @param sym the symbol for the identifier |
Ben Clayton | e6995de | 2021-04-13 23:27:27 +0000 | [diff] [blame] | 30 | IdentifierExpression(ProgramID program_id, const Source& source, Symbol sym); |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 31 | /// Move constructor |
Ryan Harrison | 4d32be4 | 2020-04-09 18:52:06 +0000 | [diff] [blame] | 32 | IdentifierExpression(IdentifierExpression&&); |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 33 | ~IdentifierExpression() override; |
| 34 | |
dan sinclair | 6b59bf4 | 2020-12-11 19:16:13 +0000 | [diff] [blame] | 35 | /// @returns the symbol for the identifier |
| 36 | Symbol symbol() const { return sym_; } |
dan sinclair | b4fee2f | 2020-09-22 19:42:13 +0000 | [diff] [blame] | 37 | |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 38 | /// Clones this node and all transitive child nodes using the `CloneContext` |
| 39 | /// `ctx`. |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 40 | /// @param ctx the clone context |
| 41 | /// @return the newly cloned node |
| 42 | IdentifierExpression* Clone(CloneContext* ctx) const override; |
| 43 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 44 | /// Writes a representation of the node to the output stream |
Ben Clayton | dd1b6fc | 2021-01-29 10:55:40 +0000 | [diff] [blame] | 45 | /// @param sem the semantic info for the program |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 46 | /// @param out the stream to write to |
| 47 | /// @param indent number of spaces to indent the node when writing |
Antonio Maiorano | 5cd71b8 | 2021-04-16 19:07:51 +0000 | [diff] [blame] | 48 | void to_str(const sem::Info& sem, |
Ben Clayton | dd1b6fc | 2021-01-29 10:55:40 +0000 | [diff] [blame] | 49 | std::ostream& out, |
| 50 | size_t indent) const override; |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 51 | |
| 52 | private: |
| 53 | IdentifierExpression(const IdentifierExpression&) = delete; |
| 54 | |
Ben Clayton | be96376 | 2020-12-15 14:52:38 +0000 | [diff] [blame] | 55 | Symbol const sym_; |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | } // namespace ast |
| 59 | } // namespace tint |
| 60 | |
| 61 | #endif // SRC_AST_IDENTIFIER_EXPRESSION_H_ |