blob: 04e99d989179607f1b0817505e6e3566e1353890 [file] [log] [blame]
dan sinclairb4374c22020-07-25 03:34:33 +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_DISCARD_STATEMENT_H_
16#define SRC_AST_DISCARD_STATEMENT_H_
17
18#include "src/ast/statement.h"
19
20namespace tint {
21namespace ast {
22
23/// A discard statement
Ben Claytone319d7f2020-11-30 23:30:58 +000024class DiscardStatement : public Castable<DiscardStatement, Statement> {
dan sinclairb4374c22020-07-25 03:34:33 +000025 public:
26 /// Constructor
Ben Claytone6995de2021-04-13 23:27:27 +000027 /// @param program_id the identifier of the program that owns this node
dan sinclairb4374c22020-07-25 03:34:33 +000028 /// @param source the discard statement source
Ben Claytone6995de2021-04-13 23:27:27 +000029 DiscardStatement(ProgramID program_id, const Source& source);
dan sinclairb4374c22020-07-25 03:34:33 +000030 /// Move constructor
Ben Claytone319d7f2020-11-30 23:30:58 +000031 DiscardStatement(DiscardStatement&&);
dan sinclairb4374c22020-07-25 03:34:33 +000032 ~DiscardStatement() override;
33
Ben Claytoned2b9782020-12-01 18:04:17 +000034 /// Clones this node and all transitive child nodes using the `CloneContext`
35 /// `ctx`.
Ben Claytoned2b9782020-12-01 18:04:17 +000036 /// @param ctx the clone context
37 /// @return the newly cloned node
38 DiscardStatement* Clone(CloneContext* ctx) const override;
39
dan sinclairb4374c22020-07-25 03:34:33 +000040 /// Writes a representation of the node to the output stream
Ben Claytondd1b6fc2021-01-29 10:55:40 +000041 /// @param sem the semantic info for the program
dan sinclairb4374c22020-07-25 03:34:33 +000042 /// @param out the stream to write to
43 /// @param indent number of spaces to indent the node when writing
Antonio Maiorano5cd71b82021-04-16 19:07:51 +000044 void to_str(const sem::Info& sem,
Ben Claytondd1b6fc2021-01-29 10:55:40 +000045 std::ostream& out,
46 size_t indent) const override;
dan sinclairb4374c22020-07-25 03:34:33 +000047
48 private:
49 DiscardStatement(const DiscardStatement&) = delete;
50};
51
52} // namespace ast
53} // namespace tint
54
55#endif // SRC_AST_DISCARD_STATEMENT_H_