• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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_ELSE_STATEMENT_H_
16 #define SRC_AST_ELSE_STATEMENT_H_
17 
18 #include <vector>
19 
20 #include "src/ast/block_statement.h"
21 #include "src/ast/expression.h"
22 
23 namespace tint {
24 namespace ast {
25 
26 /// An else statement
27 class ElseStatement : public Castable<ElseStatement, Statement> {
28  public:
29   /// Constructor
30   /// @param pid the identifier of the program that owns this node
31   /// @param src the source of this node
32   /// @param condition the else condition
33   /// @param body the else body
34   ElseStatement(ProgramID pid,
35                 const Source& src,
36                 const Expression* condition,
37                 const BlockStatement* body);
38   /// Move constructor
39   ElseStatement(ElseStatement&&);
40   ~ElseStatement() override;
41 
42   /// Clones this node and all transitive child nodes using the `CloneContext`
43   /// `ctx`.
44   /// @param ctx the clone context
45   /// @return the newly cloned node
46   const ElseStatement* Clone(CloneContext* ctx) const override;
47 
48   /// The else condition or nullptr if none set
49   const Expression* const condition;
50 
51   /// The else body
52   const BlockStatement* const body;
53 };
54 
55 /// A list of else statements
56 using ElseStatementList = std::vector<const ElseStatement*>;
57 
58 }  // namespace ast
59 }  // namespace tint
60 
61 #endif  // SRC_AST_ELSE_STATEMENT_H_
62