mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 17:35:30 +00:00
resolver: Resolve for-loops
Still nothing creates these, yet. Bug: tint:952 Change-Id: If35f9c68ede6c6e41b6e9510f0b60751fea5bd49 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56762 Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
@@ -105,7 +105,7 @@ class FunctionBlockStatement
|
||||
ast::Function const* const function_;
|
||||
};
|
||||
|
||||
/// Holds semantic information about a loop block
|
||||
/// Holds semantic information about a loop block or a for-loop block
|
||||
class LoopBlockStatement : public Castable<LoopBlockStatement, BlockStatement> {
|
||||
public:
|
||||
/// Constructor
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "src/ast/block_statement.h"
|
||||
#include "src/ast/loop_statement.h"
|
||||
#include "src/ast/statement.h"
|
||||
#include "src/debug.h"
|
||||
#include "src/sem/block_statement.h"
|
||||
#include "src/sem/statement.h"
|
||||
|
||||
@@ -27,32 +26,7 @@ namespace tint {
|
||||
namespace sem {
|
||||
|
||||
Statement::Statement(const ast::Statement* declaration, const Statement* parent)
|
||||
: declaration_(declaration), parent_(parent) {
|
||||
#ifndef NDEBUG
|
||||
if (parent_) {
|
||||
auto* block = Block();
|
||||
if (parent_ == block) {
|
||||
// The parent of this statement is a block. We thus expect the statement
|
||||
// to be an element of the block. There is one exception: a loop's
|
||||
// continuing block has the loop's body as its parent, but the continuing
|
||||
// block is not a statement in the body, so we rule out that case.
|
||||
auto& stmts = block->Declaration()->statements();
|
||||
if (std::find(stmts.begin(), stmts.end(), declaration) == stmts.end()) {
|
||||
bool statement_is_continuing_for_loop = false;
|
||||
if (parent_->parent_ != nullptr) {
|
||||
if (auto* loop =
|
||||
parent_->parent_->Declaration()->As<ast::LoopStatement>()) {
|
||||
if (loop->has_continuing() && Declaration() == loop->continuing()) {
|
||||
statement_is_continuing_for_loop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
TINT_ASSERT(Semantic, statement_is_continuing_for_loop);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // NDEBUG
|
||||
}
|
||||
: declaration_(declaration), parent_(parent) {}
|
||||
|
||||
const BlockStatement* Statement::Block() const {
|
||||
auto* stmt = parent_;
|
||||
|
||||
Reference in New Issue
Block a user