James Price | 4924186 | 2022-03-31 22:30:10 +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 | |
| 15 | #ifndef SRC_TINT_AST_COMPOUND_ASSIGNMENT_STATEMENT_H_ |
| 16 | #define SRC_TINT_AST_COMPOUND_ASSIGNMENT_STATEMENT_H_ |
| 17 | |
| 18 | #include "src/tint/ast/binary_expression.h" |
| 19 | #include "src/tint/ast/expression.h" |
| 20 | #include "src/tint/ast/statement.h" |
| 21 | |
dan sinclair | 34323ac | 2022-04-07 18:39:35 +0000 | [diff] [blame] | 22 | namespace tint::ast { |
James Price | 4924186 | 2022-03-31 22:30:10 +0000 | [diff] [blame] | 23 | |
| 24 | /// A compound assignment statement |
dan sinclair | 12fa303 | 2023-04-19 23:52:33 +0000 | [diff] [blame] | 25 | class CompoundAssignmentStatement final |
| 26 | : public utils::Castable<CompoundAssignmentStatement, Statement> { |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 27 | public: |
| 28 | /// Constructor |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 29 | /// @param pid the identifier of the program that owns this node |
| 30 | /// @param nid the unique node identifier |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 31 | /// @param source the compound assignment statement source |
| 32 | /// @param lhs the left side of the expression |
| 33 | /// @param rhs the right side of the expression |
| 34 | /// @param op the binary operator |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 35 | CompoundAssignmentStatement(ProgramID pid, |
| 36 | NodeID nid, |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 37 | const Source& source, |
| 38 | const Expression* lhs, |
| 39 | const Expression* rhs, |
| 40 | BinaryOp op); |
Ben Clayton | 9a56b25 | 2023-03-15 14:09:40 +0000 | [diff] [blame] | 41 | |
| 42 | /// Destructor |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 43 | ~CompoundAssignmentStatement() override; |
James Price | 4924186 | 2022-03-31 22:30:10 +0000 | [diff] [blame] | 44 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 45 | /// Clones this node and all transitive child nodes using the `CloneContext` |
| 46 | /// `ctx`. |
| 47 | /// @param ctx the clone context |
| 48 | /// @return the newly cloned node |
| 49 | const CompoundAssignmentStatement* Clone(CloneContext* ctx) const override; |
James Price | 4924186 | 2022-03-31 22:30:10 +0000 | [diff] [blame] | 50 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 51 | /// left side expression |
| 52 | const Expression* const lhs; |
James Price | 4924186 | 2022-03-31 22:30:10 +0000 | [diff] [blame] | 53 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 54 | /// right side expression |
| 55 | const Expression* const rhs; |
James Price | 4924186 | 2022-03-31 22:30:10 +0000 | [diff] [blame] | 56 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 57 | /// the binary operator |
| 58 | const BinaryOp op; |
James Price | 4924186 | 2022-03-31 22:30:10 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
dan sinclair | 34323ac | 2022-04-07 18:39:35 +0000 | [diff] [blame] | 61 | } // namespace tint::ast |
James Price | 4924186 | 2022-03-31 22:30:10 +0000 | [diff] [blame] | 62 | |
| 63 | #endif // SRC_TINT_AST_COMPOUND_ASSIGNMENT_STATEMENT_H_ |