blob: f23af153f86ee3d98dd3d53a98881c2ad4ad0be0 [file] [log] [blame]
James Price49241862022-03-31 22:30:10 +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
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 sinclair34323ac2022-04-07 18:39:35 +000022namespace tint::ast {
James Price49241862022-03-31 22:30:10 +000023
24/// A compound assignment statement
dan sinclair12fa3032023-04-19 23:52:33 +000025class CompoundAssignmentStatement final
26 : public utils::Castable<CompoundAssignmentStatement, Statement> {
dan sinclair41e4d9a2022-05-01 14:40:55 +000027 public:
28 /// Constructor
Ben Clayton4a92a3c2022-07-18 20:50:02 +000029 /// @param pid the identifier of the program that owns this node
30 /// @param nid the unique node identifier
dan sinclair41e4d9a2022-05-01 14:40:55 +000031 /// @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 Clayton4a92a3c2022-07-18 20:50:02 +000035 CompoundAssignmentStatement(ProgramID pid,
36 NodeID nid,
dan sinclair41e4d9a2022-05-01 14:40:55 +000037 const Source& source,
38 const Expression* lhs,
39 const Expression* rhs,
40 BinaryOp op);
Ben Clayton9a56b252023-03-15 14:09:40 +000041
42 /// Destructor
dan sinclair41e4d9a2022-05-01 14:40:55 +000043 ~CompoundAssignmentStatement() override;
James Price49241862022-03-31 22:30:10 +000044
dan sinclair41e4d9a2022-05-01 14:40:55 +000045 /// 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 Price49241862022-03-31 22:30:10 +000050
dan sinclair41e4d9a2022-05-01 14:40:55 +000051 /// left side expression
52 const Expression* const lhs;
James Price49241862022-03-31 22:30:10 +000053
dan sinclair41e4d9a2022-05-01 14:40:55 +000054 /// right side expression
55 const Expression* const rhs;
James Price49241862022-03-31 22:30:10 +000056
dan sinclair41e4d9a2022-05-01 14:40:55 +000057 /// the binary operator
58 const BinaryOp op;
James Price49241862022-03-31 22:30:10 +000059};
60
dan sinclair34323ac2022-04-07 18:39:35 +000061} // namespace tint::ast
James Price49241862022-03-31 22:30:10 +000062
63#endif // SRC_TINT_AST_COMPOUND_ASSIGNMENT_STATEMENT_H_