James Price | ebe9741 | 2022-04-07 13:42:45 +0000 | [diff] [blame] | 1 | // 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 sinclair | 99181d8 | 2023-07-20 01:14:15 +0000 | [diff] [blame] | 15 | #ifndef SRC_TINT_LANG_WGSL_AST_INCREMENT_DECREMENT_STATEMENT_H_ |
| 16 | #define SRC_TINT_LANG_WGSL_AST_INCREMENT_DECREMENT_STATEMENT_H_ |
James Price | ebe9741 | 2022-04-07 13:42:45 +0000 | [diff] [blame] | 17 | |
dan sinclair | 99181d8 | 2023-07-20 01:14:15 +0000 | [diff] [blame] | 18 | #include "src/tint/lang/wgsl/ast/expression.h" |
| 19 | #include "src/tint/lang/wgsl/ast/statement.h" |
James Price | ebe9741 | 2022-04-07 13:42:45 +0000 | [diff] [blame] | 20 | |
| 21 | namespace tint::ast { |
| 22 | |
| 23 | /// An increment or decrement statement |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 24 | class IncrementDecrementStatement final : public Castable<IncrementDecrementStatement, Statement> { |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 25 | public: |
| 26 | /// Constructor |
| 27 | /// @param pid the identifier of the program that owns this node |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 28 | /// @param nid the unique node identifier |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 29 | /// @param src the source of this node |
| 30 | /// @param lhs the LHS expression |
| 31 | /// @param inc `true` for increment, `false` for decrement |
dan sinclair | 637a2fe | 2023-07-24 21:11:41 +0000 | [diff] [blame] | 32 | IncrementDecrementStatement(GenerationID pid, |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 33 | NodeID nid, |
| 34 | const Source& src, |
| 35 | const Expression* lhs, |
| 36 | bool inc); |
Ben Clayton | 9a56b25 | 2023-03-15 14:09:40 +0000 | [diff] [blame] | 37 | |
| 38 | /// Destructor |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 39 | ~IncrementDecrementStatement() override; |
James Price | ebe9741 | 2022-04-07 13:42:45 +0000 | [diff] [blame] | 40 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 41 | /// 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 Clayton | ae18c41 | 2023-07-29 13:00:40 +0000 | [diff] [blame] | 45 | const IncrementDecrementStatement* Clone(CloneContext& ctx) const override; |
James Price | ebe9741 | 2022-04-07 13:42:45 +0000 | [diff] [blame] | 46 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 47 | /// The LHS expression. |
| 48 | const Expression* const lhs; |
James Price | ebe9741 | 2022-04-07 13:42:45 +0000 | [diff] [blame] | 49 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 50 | /// `true` for increment, `false` for decrement. |
| 51 | bool increment; |
James Price | ebe9741 | 2022-04-07 13:42:45 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | } // namespace tint::ast |
| 55 | |
dan sinclair | 99181d8 | 2023-07-20 01:14:15 +0000 | [diff] [blame] | 56 | #endif // SRC_TINT_LANG_WGSL_AST_INCREMENT_DECREMENT_STATEMENT_H_ |