mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-08 13:09:10 +00:00
This change introduces sem::CompoundStatement, a new base class for statements that can hold other statements. sem::BlockStatements now derives from sem::CompoundStatement, and this change introduces the following new CompoundStatements: * `sem::IfStatement` * `sem::ElseStatement` * `sem::ForLoopStatement` * `sem::LoopStatement` * `sem::SwitchStatement`. These new CompoundStatements are now inserted into the semantic tree as now documented in `docs/compound_statements.md`. The `sem::BlockStatement::FindFirstParent()` methods have been moved down to `sem::Statement`. The `Resolver::BlockScope()` method has been replaced with `Resolver::Scope()` which now maintains the `current_statement_`, `current_compound_statement_ ` and `current_block_`. This simplifies statement nesting. The most significant change in behavior is that statements now always have a parent, so calling Block() on the initializer or continuing of a for-loop statement will now return the BlockStatement that holds the for-loop. Before this would return nullptr. Fixed: tint:979 Change-Id: I90e38fd719da2a281ed9210e975ab96171cb6842 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57707 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com>
32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
// Copyright 2021 The Tint Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "src/sem/for_loop_statement.h"
|
|
|
|
#include "src/program_builder.h"
|
|
|
|
TINT_INSTANTIATE_TYPEINFO(tint::sem::ForLoopStatement);
|
|
|
|
namespace tint {
|
|
namespace sem {
|
|
|
|
ForLoopStatement::ForLoopStatement(const ast::ForLoopStatement* declaration,
|
|
CompoundStatement* parent)
|
|
: Base(declaration, parent) {}
|
|
|
|
ForLoopStatement::~ForLoopStatement() = default;
|
|
|
|
} // namespace sem
|
|
} // namespace tint
|