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>
This commit is contained in:
dan sinclair 2020-07-27 15:25:00 +00:00 committed by Sarah Mashayekhi
parent cfdc5995ec
commit e8c12f32f9
13 changed files with 0 additions and 141 deletions

View File

@ -38,12 +38,6 @@ CaseStatement::CaseStatement(CaseStatement&&) = default;
CaseStatement::~CaseStatement() = default;
void CaseStatement::set_body(StatementList body) {
for (auto& stmt : body) {
body_->append(std::move(stmt));
}
}
bool CaseStatement::IsCase() const {
return true;
}

View File

@ -65,9 +65,6 @@ class CaseStatement : public Statement {
/// @returns true if this is a default statement
bool IsDefault() const { return selectors_.empty(); }
/// 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) {

View File

@ -23,36 +23,14 @@ ElseStatement::ElseStatement()
ElseStatement::ElseStatement(std::unique_ptr<BlockStatement> body)
: 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)
@ -64,12 +42,6 @@ ElseStatement::ElseStatement(ElseStatement&&) = default;
ElseStatement::~ElseStatement() = default;
void ElseStatement::set_body(StatementList body) {
for (auto& stmt : body) {
body_->append(std::move(stmt));
}
}
bool ElseStatement::IsElse() const {
return true;
}

View File

@ -37,31 +37,16 @@ class ElseStatement : public Statement {
/// 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
/// @param condition the else condition
/// @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);
@ -101,10 +86,6 @@ class ElseStatement : public Statement {
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_;
};

View File

@ -156,12 +156,6 @@ void Function::add_ancestor_entry_point(const std::string& ep) {
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())

View File

@ -122,9 +122,6 @@ class Function : public Node {
/// @returns the function return type.
type::Type* return_type() const { return return_type_; }
/// 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) {

View File

@ -26,15 +26,6 @@ IfStatement::IfStatement(std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body)
: Statement(), condition_(std::move(condition)), body_(std::move(body)) {}
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)
@ -46,12 +37,6 @@ IfStatement::IfStatement(IfStatement&&) = default;
IfStatement::~IfStatement() = default;
void IfStatement::set_body(StatementList body) {
for (auto& stmt : body) {
body_->append(std::move(stmt));
}
}
bool IfStatement::IsIf() const {
return true;
}

View File

@ -40,13 +40,6 @@ class IfStatement : public Statement {
/// @param source the source information
/// @param condition the if condition
/// @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);
@ -62,9 +55,6 @@ class IfStatement : public Statement {
/// @returns the if condition or nullptr if none set
Expression* condition() const { return condition_.get(); }
/// 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) {

View File

@ -26,16 +26,6 @@ LoopStatement::LoopStatement(std::unique_ptr<BlockStatement> body,
std::unique_ptr<BlockStatement> continuing)
: 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)
@ -47,18 +37,6 @@ LoopStatement::LoopStatement(LoopStatement&&) = default;
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;
}

View File

@ -37,13 +37,6 @@ class LoopStatement : public Statement {
/// @param source the loop statement source
/// @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);
@ -56,9 +49,6 @@ class LoopStatement : public Statement {
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 @@ class LoopStatement : public Statement {
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

View File

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

View File

@ -57,15 +57,6 @@ bool ValidatorImpl::ValidateStatements(const ast::BlockStatement& block) {
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;

View File

@ -58,10 +58,6 @@ class ValidatorImpl {
/// @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