reader/spirv: Remove use of BlockStatement::append()

Introduce `StatementBuilder`s , which may hold mutable state, before being converted into the immutable AST node on completion of the `BlockStatement`.

Bug: tint:396
Bug: tint:390
Change-Id: I0381c4ae7948be0de02bc13e54e0037a72baaf0c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35506
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2020-12-14 19:48:47 +00:00
committed by Commit Bot service account
parent 2353bd0d3d
commit b833f1572b
7 changed files with 315 additions and 142 deletions

View File

@@ -24,6 +24,10 @@ namespace ast {
BlockStatement::BlockStatement(const Source& source) : Base(source) {}
BlockStatement::BlockStatement(const Source& source,
const StatementList& statements)
: Base(source), statements_(std::move(statements)) {}
BlockStatement::BlockStatement(BlockStatement&&) = default;
BlockStatement::~BlockStatement() = default;

View File

@@ -30,6 +30,10 @@ class BlockStatement : public Castable<BlockStatement, Statement> {
/// Constructor
/// @param source the block statement source
explicit BlockStatement(const Source& source);
/// Constructor
/// @param source the block statement source
/// @param statements the block statements
BlockStatement(const Source& source, const StatementList& statements);
/// Move constructor
BlockStatement(BlockStatement&&);
~BlockStatement() override;

View File

@@ -42,6 +42,9 @@ class Statement : public Castable<Statement, Node> {
Statement(const Statement&) = delete;
};
/// A list of statements
using StatementList = std::vector<Statement*>;
} // namespace ast
} // namespace tint