1 // Copyright 2021 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 #include <algorithm>
16
17 #include "src/ast/block_statement.h"
18 #include "src/ast/loop_statement.h"
19 #include "src/ast/statement.h"
20 #include "src/sem/block_statement.h"
21 #include "src/sem/statement.h"
22
23 TINT_INSTANTIATE_TYPEINFO(tint::sem::Statement);
24 TINT_INSTANTIATE_TYPEINFO(tint::sem::CompoundStatement);
25
26 namespace tint {
27 namespace sem {
28
Statement(const ast::Statement * declaration,const CompoundStatement * parent,const sem::Function * function)29 Statement::Statement(const ast::Statement* declaration,
30 const CompoundStatement* parent,
31 const sem::Function* function)
32 : declaration_(declaration), parent_(parent), function_(function) {}
33
34 Statement::~Statement() = default;
35
Block() const36 const BlockStatement* Statement::Block() const {
37 return FindFirstParent<BlockStatement>();
38 }
39
CompoundStatement(const ast::Statement * declaration,const CompoundStatement * parent,const sem::Function * function)40 CompoundStatement::CompoundStatement(const ast::Statement* declaration,
41 const CompoundStatement* parent,
42 const sem::Function* function)
43 : Base(declaration, parent, function) {}
44
45 CompoundStatement::~CompoundStatement() = default;
46
47 } // namespace sem
48 } // namespace tint
49