Remove StatementList.
This CL removes the StatementList define now that BlockStatement is used
everywhere.
Bug: tint:130
Change-Id: Id51de13cd1ca0cd69023523c762fe719bc2da999
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25725
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
diff --git a/src/ast/case_statement.cc b/src/ast/case_statement.cc
index f56c8ef..ab4cb35 100644
--- a/src/ast/case_statement.cc
+++ b/src/ast/case_statement.cc
@@ -38,12 +38,6 @@
CaseStatement::~CaseStatement() = default;
-void CaseStatement::set_body(StatementList body) {
- for (auto& stmt : body) {
- body_->append(std::move(stmt));
- }
-}
-
bool CaseStatement::IsCase() const {
return true;
}
diff --git a/src/ast/case_statement.h b/src/ast/case_statement.h
index ac1a9c1..571eeb3 100644
--- a/src/ast/case_statement.h
+++ b/src/ast/case_statement.h
@@ -67,9 +67,6 @@
/// Sets the case body
/// @param body the case body
- void set_body(StatementList body);
- /// Sets the case body
- /// @param body the case body
void set_body(std::unique_ptr<BlockStatement> body) {
body_ = std::move(body);
}
diff --git a/src/ast/else_statement.cc b/src/ast/else_statement.cc
index 15891ce..d181caa 100644
--- a/src/ast/else_statement.cc
+++ b/src/ast/else_statement.cc
@@ -24,37 +24,15 @@
: Statement(), body_(std::move(body)) {}
ElseStatement::ElseStatement(std::unique_ptr<Expression> condition,
- StatementList body)
- : Statement(),
- condition_(std::move(condition)),
- body_(std::make_unique<BlockStatement>()) {
- set_body(std::move(body));
-}
-
-ElseStatement::ElseStatement(std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body)
: Statement(), condition_(std::move(condition)), body_(std::move(body)) {}
-ElseStatement::ElseStatement(const Source& source, StatementList body)
- : Statement(source), body_(std::make_unique<BlockStatement>()) {
- set_body(std::move(body));
-}
-
ElseStatement::ElseStatement(const Source& source,
std::unique_ptr<BlockStatement> body)
: Statement(source), body_(std::move(body)) {}
ElseStatement::ElseStatement(const Source& source,
std::unique_ptr<Expression> condition,
- StatementList body)
- : Statement(source),
- condition_(std::move(condition)),
- body_(std::make_unique<BlockStatement>()) {
- set_body(std::move(body));
-}
-
-ElseStatement::ElseStatement(const Source& source,
- std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body)
: Statement(source),
condition_(std::move(condition)),
@@ -64,12 +42,6 @@
ElseStatement::~ElseStatement() = default;
-void ElseStatement::set_body(StatementList body) {
- for (auto& stmt : body) {
- body_->append(std::move(stmt));
- }
-}
-
bool ElseStatement::IsElse() const {
return true;
}
diff --git a/src/ast/else_statement.h b/src/ast/else_statement.h
index d0e0cf7..fda156b 100644
--- a/src/ast/else_statement.h
+++ b/src/ast/else_statement.h
@@ -37,19 +37,11 @@
/// Constructor
/// @param condition the else condition
/// @param body the else body
- ElseStatement(std::unique_ptr<Expression> condition, StatementList body);
- /// Constructor
- /// @param condition the else condition
- /// @param body the else body
ElseStatement(std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body);
/// Constructor
/// @param source the source information
/// @param body the else body
- ElseStatement(const Source& source, StatementList body);
- /// Constructor
- /// @param source the source information
- /// @param body the else body
ElseStatement(const Source& source, std::unique_ptr<BlockStatement> body);
/// Constructor
/// @param source the source information
@@ -57,13 +49,6 @@
/// @param body the else body
ElseStatement(const Source& source,
std::unique_ptr<Expression> condition,
- StatementList body);
- /// Constructor
- /// @param source the source information
- /// @param condition the else condition
- /// @param body the else body
- ElseStatement(const Source& source,
- std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body);
/// Move constructor
ElseStatement(ElseStatement&&);
@@ -101,10 +86,6 @@
private:
ElseStatement(const ElseStatement&) = delete;
- /// Sets the else body
- /// @param body the else body
- void set_body(StatementList body);
-
std::unique_ptr<Expression> condition_;
std::unique_ptr<BlockStatement> body_;
};
diff --git a/src/ast/function.cc b/src/ast/function.cc
index 7f9ae61..adacdad 100644
--- a/src/ast/function.cc
+++ b/src/ast/function.cc
@@ -156,12 +156,6 @@
ancestor_entry_points_.push_back(ep);
}
-void Function::set_body(StatementList body) {
- for (auto& stmt : body) {
- body_->append(std::move(stmt));
- }
-}
-
bool Function::IsValid() const {
for (const auto& param : params_) {
if (param == nullptr || !param->IsValid())
diff --git a/src/ast/function.h b/src/ast/function.h
index a6dbe18..a112e20 100644
--- a/src/ast/function.h
+++ b/src/ast/function.h
@@ -124,9 +124,6 @@
/// Sets the body of the function
/// @param body the function body
- void set_body(StatementList body);
- /// Sets the body of the function
- /// @param body the function body
void set_body(std::unique_ptr<BlockStatement> body) {
body_ = std::move(body);
}
diff --git a/src/ast/if_statement.cc b/src/ast/if_statement.cc
index 342c08f..5008c7d 100644
--- a/src/ast/if_statement.cc
+++ b/src/ast/if_statement.cc
@@ -28,15 +28,6 @@
IfStatement::IfStatement(const Source& source,
std::unique_ptr<Expression> condition,
- StatementList body)
- : Statement(source),
- condition_(std::move(condition)),
- body_(std::make_unique<BlockStatement>()) {
- set_body(std::move(body));
-}
-
-IfStatement::IfStatement(const Source& source,
- std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body)
: Statement(source),
condition_(std::move(condition)),
@@ -46,12 +37,6 @@
IfStatement::~IfStatement() = default;
-void IfStatement::set_body(StatementList body) {
- for (auto& stmt : body) {
- body_->append(std::move(stmt));
- }
-}
-
bool IfStatement::IsIf() const {
return true;
}
diff --git a/src/ast/if_statement.h b/src/ast/if_statement.h
index 8db80e5..8108ebf 100644
--- a/src/ast/if_statement.h
+++ b/src/ast/if_statement.h
@@ -42,13 +42,6 @@
/// @param body the if body
IfStatement(const Source& source,
std::unique_ptr<Expression> condition,
- StatementList body);
- /// Constructor
- /// @param source the source information
- /// @param condition the if condition
- /// @param body the if body
- IfStatement(const Source& source,
- std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body);
/// Move constructor
IfStatement(IfStatement&&);
@@ -64,9 +57,6 @@
/// Sets the if body
/// @param body the if body
- void set_body(StatementList body);
- /// Sets the if body
- /// @param body the if body
void set_body(std::unique_ptr<BlockStatement> body) {
body_ = std::move(body);
}
diff --git a/src/ast/loop_statement.cc b/src/ast/loop_statement.cc
index 33f4ddb..5faafdb 100644
--- a/src/ast/loop_statement.cc
+++ b/src/ast/loop_statement.cc
@@ -27,16 +27,6 @@
: Statement(), body_(std::move(body)), continuing_(std::move(continuing)) {}
LoopStatement::LoopStatement(const Source& source,
- StatementList body,
- StatementList continuing)
- : Statement(source),
- body_(std::make_unique<BlockStatement>()),
- continuing_(std::make_unique<BlockStatement>()) {
- set_body(std::move(body));
- set_continuing(std::move(continuing));
-}
-
-LoopStatement::LoopStatement(const Source& source,
std::unique_ptr<BlockStatement> body,
std::unique_ptr<BlockStatement> continuing)
: Statement(source),
@@ -47,18 +37,6 @@
LoopStatement::~LoopStatement() = default;
-void LoopStatement::set_body(StatementList body) {
- for (auto& stmt : body) {
- body_->append(std::move(stmt));
- }
-}
-
-void LoopStatement::set_continuing(StatementList continuing) {
- for (auto& stmt : continuing) {
- continuing_->append(std::move(stmt));
- }
-}
-
bool LoopStatement::IsLoop() const {
return true;
}
diff --git a/src/ast/loop_statement.h b/src/ast/loop_statement.h
index d46bda2..bf8f8a5 100644
--- a/src/ast/loop_statement.h
+++ b/src/ast/loop_statement.h
@@ -38,13 +38,6 @@
/// @param body the body statements
/// @param continuing the continuing statements
LoopStatement(const Source& source,
- StatementList body,
- StatementList continuing);
- /// Constructor
- /// @param source the loop statement source
- /// @param body the body statements
- /// @param continuing the continuing statements
- LoopStatement(const Source& source,
std::unique_ptr<BlockStatement> body,
std::unique_ptr<BlockStatement> continuing);
/// Move constructor
@@ -56,9 +49,6 @@
void set_body(std::unique_ptr<BlockStatement> body) {
body_ = std::move(body);
}
- /// Sets the body statements
- /// @param body the body statements
- void set_body(StatementList body);
/// @returns the body statements
const BlockStatement* body() const { return body_.get(); }
@@ -67,9 +57,6 @@
void set_continuing(std::unique_ptr<BlockStatement> continuing) {
continuing_ = std::move(continuing);
}
- /// Sets the continuing statements
- /// @param continuing the continuing statements
- void set_continuing(StatementList continuing);
/// @returns the continuing statements
const BlockStatement* continuing() const { return continuing_.get(); }
/// @returns true if there are continuing statements in the loop
diff --git a/src/ast/statement.h b/src/ast/statement.h
index 7df9aea..3bd1452 100644
--- a/src/ast/statement.h
+++ b/src/ast/statement.h
@@ -143,9 +143,6 @@
Statement(const Statement&) = delete;
};
-/// A list of unique statements
-using StatementList = std::vector<std::unique_ptr<Statement>>;
-
} // namespace ast
} // namespace tint
diff --git a/src/validator_impl.cc b/src/validator_impl.cc
index 3645c96..71ff6d4 100644
--- a/src/validator_impl.cc
+++ b/src/validator_impl.cc
@@ -57,15 +57,6 @@
return true;
}
-bool ValidatorImpl::ValidateStatements(const ast::StatementList& stmts) {
- for (const auto& stmt : stmts) {
- if (!ValidateStatement(*(stmt.get()))) {
- return false;
- }
- }
- return true;
-}
-
bool ValidatorImpl::ValidateStatement(const ast::Statement& stmt) {
if (stmt.IsAssign() && !ValidateAssign(*(stmt.AsAssign())))
return false;
diff --git a/src/validator_impl.h b/src/validator_impl.h
index 750fb66..c7eba93 100644
--- a/src/validator_impl.h
+++ b/src/validator_impl.h
@@ -58,10 +58,6 @@
/// @param block the statements to check
/// @returns true if the validation was successful
bool ValidateStatements(const ast::BlockStatement& block);
- /// Validates a set of statements
- /// @param stmts the statements to check
- /// @returns true if the validation was successful
- bool ValidateStatements(const ast::StatementList& stmts);
/// Validates a statement
/// @param stmt the statement to check
/// @returns true if the validation was successful