| dan sinclair | 2e40491 | 2020-07-21 13:42:05 +0000 | [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_CALL_STATEMENT_H_ |
| 16 | #define SRC_AST_CALL_STATEMENT_H_ |
| 17 | |
| 18 | #include <memory> |
| 19 | #include <utility> |
| 20 | |
| 21 | #include "src/ast/call_expression.h" |
| 22 | #include "src/ast/statement.h" |
| 23 | |
| 24 | namespace tint { |
| 25 | namespace ast { |
| 26 | |
| 27 | /// A call expression |
| Ben Clayton | e319d7f | 2020-11-30 23:30:58 +0000 | [diff] [blame] | 28 | class CallStatement : public Castable<CallStatement, Statement> { |
| dan sinclair | 2e40491 | 2020-07-21 13:42:05 +0000 | [diff] [blame] | 29 | public: |
| 30 | /// Constructor |
| Ben Clayton | bbefff6 | 2020-12-12 11:58:44 +0000 | [diff] [blame] | 31 | /// @param source the input source for the statement |
| dan sinclair | 2e40491 | 2020-07-21 13:42:05 +0000 | [diff] [blame] | 32 | /// @param call the function |
| Ben Clayton | bbefff6 | 2020-12-12 11:58:44 +0000 | [diff] [blame] | 33 | CallStatement(const Source& source, CallExpression* call); |
| dan sinclair | 2e40491 | 2020-07-21 13:42:05 +0000 | [diff] [blame] | 34 | /// Move constructor |
| 35 | CallStatement(CallStatement&&); |
| 36 | ~CallStatement() override; |
| 37 | |
| dan sinclair | 2e40491 | 2020-07-21 13:42:05 +0000 | [diff] [blame] | 38 | /// @returns the call expression |
| Ben Clayton | b053acf | 2020-11-16 16:31:07 +0000 | [diff] [blame] | 39 | CallExpression* expr() const { return call_; } |
| dan sinclair | 2e40491 | 2020-07-21 13:42:05 +0000 | [diff] [blame] | 40 | |
| Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 41 | /// Clones this node and all transitive child nodes using the `CloneContext` |
| 42 | /// `ctx`. |
| 43 | /// @note Semantic information such as resolved expression type and intrinsic |
| 44 | /// information is not cloned. |
| 45 | /// @param ctx the clone context |
| 46 | /// @return the newly cloned node |
| 47 | CallStatement* Clone(CloneContext* ctx) const override; |
| 48 | |
| dan sinclair | 2e40491 | 2020-07-21 13:42:05 +0000 | [diff] [blame] | 49 | /// @returns true if the node is valid |
| 50 | bool IsValid() const override; |
| 51 | |
| 52 | /// Writes a representation of the node to the output stream |
| 53 | /// @param out the stream to write to |
| 54 | /// @param indent number of spaces to indent the node when writing |
| 55 | void to_str(std::ostream& out, size_t indent) const override; |
| 56 | |
| 57 | private: |
| 58 | CallStatement(const CallStatement&) = delete; |
| 59 | |
| Ben Clayton | b053acf | 2020-11-16 16:31:07 +0000 | [diff] [blame] | 60 | CallExpression* call_ = nullptr; |
| dan sinclair | 2e40491 | 2020-07-21 13:42:05 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | } // namespace ast |
| 64 | } // namespace tint |
| 65 | |
| 66 | #endif // SRC_AST_CALL_STATEMENT_H_ |