blob: 59f7bed14b967f33d96243019d136dc7e545dd0e [file] [log] [blame]
dan sinclair2e404912020-07-21 13:42:05 +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_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
24namespace tint {
25namespace ast {
26
27/// A call expression
Ben Claytone319d7f2020-11-30 23:30:58 +000028class CallStatement : public Castable<CallStatement, Statement> {
dan sinclair2e404912020-07-21 13:42:05 +000029 public:
30 /// Constructor
Ben Claytonbbefff62020-12-12 11:58:44 +000031 /// @param source the input source for the statement
dan sinclair2e404912020-07-21 13:42:05 +000032 /// @param call the function
Ben Claytonbbefff62020-12-12 11:58:44 +000033 CallStatement(const Source& source, CallExpression* call);
dan sinclair2e404912020-07-21 13:42:05 +000034 /// Move constructor
35 CallStatement(CallStatement&&);
36 ~CallStatement() override;
37
dan sinclair2e404912020-07-21 13:42:05 +000038 /// @returns the call expression
Ben Claytonb053acf2020-11-16 16:31:07 +000039 CallExpression* expr() const { return call_; }
dan sinclair2e404912020-07-21 13:42:05 +000040
Ben Claytoned2b9782020-12-01 18:04:17 +000041 /// 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 sinclair2e404912020-07-21 13:42:05 +000049 /// @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 Claytonb053acf2020-11-16 16:31:07 +000060 CallExpression* call_ = nullptr;
dan sinclair2e404912020-07-21 13:42:05 +000061};
62
63} // namespace ast
64} // namespace tint
65
66#endif // SRC_AST_CALL_STATEMENT_H_