Revert "[ast] Remove unused constructors and setters."

This reverts commit 4d28b27935.

Reason for revert: Seeing weird build breakage ...

Original change's description:
> [ast] Remove unused constructors and setters.
>
> This CL removes unused default constructors and various set methods
> from the AST classes where they are not longer required.
>
> Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,bclayton@google.com

Change-Id: I9d5bf6fd6d47131650c964cad4e17a1cbe86b040
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34682
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair
2020-12-02 15:18:59 +00:00
committed by Commit Bot service account
parent 4d28b27935
commit 5792783e72
71 changed files with 376 additions and 189 deletions

View File

@@ -2137,13 +2137,12 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
assert(construct->begin_id == block_info.id);
const auto* branch = block_info.basic_block->terminator();
auto* const switch_stmt =
AddStatement(create<ast::SwitchStatement>())->As<ast::SwitchStatement>();
const auto selector_id = branch->GetSingleWordInOperand(0);
// Generate the code for the selector.
auto selector = MakeExpression(selector_id);
ast::CaseStatementList list;
auto* swch = create<ast::SwitchStatement>(selector.expr, list);
auto* const switch_stmt = AddStatement(swch)->As<ast::SwitchStatement>();
switch_stmt->set_condition(selector.expr);
// First, push the statement block for the entire switch. All the actual
// work is done by completion actions of the case/default clauses.
@@ -2195,6 +2194,12 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
// Push them on in reverse order.
const auto last_clause_index = clause_heads.size() - 1;
for (size_t i = last_clause_index;; --i) {
// Create the case clause. Temporarily put it in the wrong order
// on the case statement list.
cases->emplace_back(
create<ast::CaseStatement>(create<ast::BlockStatement>()));
auto* clause = cases->back();
// Create a list of integer literals for the selector values leading to
// this case clause.
ast::CaseSelectorList selectors;
@@ -2215,20 +2220,14 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
create<ast::SintLiteral>(selector.type, value32));
}
}
clause->set_selectors(selectors);
}
// Where does this clause end?
const auto end_id = (i + 1 < clause_heads.size()) ? clause_heads[i + 1]->id
: construct->end_id;
// Create the case clause. Temporarily put it in the wrong order
// on the case statement list.
cases->emplace_back(create<ast::CaseStatement>(selectors, nullptr));
auto* clause = cases->back();
PushNewStatementBlock(construct, end_id, [clause](StatementBlock* s) {
// The `set_body` method of CaseStatement can be removed if this set
// is removed.
clause->set_body(s->statements_);
});

View File

@@ -1745,13 +1745,14 @@ Maybe<ast::CaseStatement*> ParserImpl::switch_body() {
auto source = t.source();
next(); // Consume the peek
ast::CaseSelectorList selector_list;
auto* stmt = create<ast::CaseStatement>(create<ast::BlockStatement>());
stmt->set_source(source);
if (t.IsCase()) {
auto selectors = expect_case_selectors();
if (selectors.errored)
return Failure::kErrored;
selector_list = std::move(selectors.value);
stmt->set_selectors(std::move(selectors.value));
}
const char* use = "case statement";
@@ -1766,7 +1767,9 @@ Maybe<ast::CaseStatement*> ParserImpl::switch_body() {
if (!body.matched)
return add_error(body.source, "expected case body");
return create<ast::CaseStatement>(source, selector_list, body.value);
stmt->set_body(body.value);
return stmt;
}
// case_selectors