blob: 1c317b9391e3e551085377d8b418c0eecba72c4b [file] [log] [blame]
James Priceebe97412022-04-07 13:42:45 +00001// Copyright 2022 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
dan sinclair99181d82023-07-20 01:14:15 +000015#ifndef SRC_TINT_LANG_WGSL_AST_INCREMENT_DECREMENT_STATEMENT_H_
16#define SRC_TINT_LANG_WGSL_AST_INCREMENT_DECREMENT_STATEMENT_H_
James Priceebe97412022-04-07 13:42:45 +000017
dan sinclair99181d82023-07-20 01:14:15 +000018#include "src/tint/lang/wgsl/ast/expression.h"
19#include "src/tint/lang/wgsl/ast/statement.h"
James Priceebe97412022-04-07 13:42:45 +000020
21namespace tint::ast {
22
23/// An increment or decrement statement
dan sinclairbae54e72023-07-28 15:01:54 +000024class IncrementDecrementStatement final : public Castable<IncrementDecrementStatement, Statement> {
dan sinclair41e4d9a2022-05-01 14:40:55 +000025 public:
26 /// Constructor
27 /// @param pid the identifier of the program that owns this node
Ben Clayton4a92a3c2022-07-18 20:50:02 +000028 /// @param nid the unique node identifier
dan sinclair41e4d9a2022-05-01 14:40:55 +000029 /// @param src the source of this node
30 /// @param lhs the LHS expression
31 /// @param inc `true` for increment, `false` for decrement
dan sinclair637a2fe2023-07-24 21:11:41 +000032 IncrementDecrementStatement(GenerationID pid,
Ben Clayton4a92a3c2022-07-18 20:50:02 +000033 NodeID nid,
34 const Source& src,
35 const Expression* lhs,
36 bool inc);
Ben Clayton9a56b252023-03-15 14:09:40 +000037
38 /// Destructor
dan sinclair41e4d9a2022-05-01 14:40:55 +000039 ~IncrementDecrementStatement() override;
James Priceebe97412022-04-07 13:42:45 +000040
dan sinclair41e4d9a2022-05-01 14:40:55 +000041 /// Clones this node and all transitive child nodes using the `CloneContext`
42 /// `ctx`.
43 /// @param ctx the clone context
44 /// @return the newly cloned node
Ben Claytonae18c412023-07-29 13:00:40 +000045 const IncrementDecrementStatement* Clone(CloneContext& ctx) const override;
James Priceebe97412022-04-07 13:42:45 +000046
dan sinclair41e4d9a2022-05-01 14:40:55 +000047 /// The LHS expression.
48 const Expression* const lhs;
James Priceebe97412022-04-07 13:42:45 +000049
dan sinclair41e4d9a2022-05-01 14:40:55 +000050 /// `true` for increment, `false` for decrement.
51 bool increment;
James Priceebe97412022-04-07 13:42:45 +000052};
53
54} // namespace tint::ast
55
dan sinclair99181d82023-07-20 01:14:15 +000056#endif // SRC_TINT_LANG_WGSL_AST_INCREMENT_DECREMENT_STATEMENT_H_