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; CaseStatement::~CaseStatement() = default;
void CaseStatement::set_body(StatementList body) {
for (auto& stmt : body) {
body_->append(std::move(stmt));
}
}
bool CaseStatement::IsCase() const { bool CaseStatement::IsCase() const {
return true; return true;
} }

View File

@ -65,9 +65,6 @@ class CaseStatement : public Statement {
/// @returns true if this is a default statement /// @returns true if this is a default statement
bool IsDefault() const { return selectors_.empty(); } bool IsDefault() const { return selectors_.empty(); }
/// Sets the case body
/// @param body the case body
void set_body(StatementList body);
/// Sets the case body /// Sets the case body
/// @param body the case body /// @param body the case body
void set_body(std::unique_ptr<BlockStatement> body) { void set_body(std::unique_ptr<BlockStatement> body) {

View File

@ -23,36 +23,14 @@ ElseStatement::ElseStatement()
ElseStatement::ElseStatement(std::unique_ptr<BlockStatement> body) ElseStatement::ElseStatement(std::unique_ptr<BlockStatement> body)
: Statement(), body_(std::move(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, ElseStatement::ElseStatement(std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body) std::unique_ptr<BlockStatement> body)
: Statement(), condition_(std::move(condition)), body_(std::move(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, ElseStatement::ElseStatement(const Source& source,
std::unique_ptr<BlockStatement> body) std::unique_ptr<BlockStatement> body)
: Statement(source), body_(std::move(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, ElseStatement::ElseStatement(const Source& source,
std::unique_ptr<Expression> condition, std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body) std::unique_ptr<BlockStatement> body)
@ -64,12 +42,6 @@ ElseStatement::ElseStatement(ElseStatement&&) = default;
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 { bool ElseStatement::IsElse() const {
return true; return true;
} }

View File

@ -37,31 +37,16 @@ class ElseStatement : public Statement {
/// Constructor /// Constructor
/// @param condition the else condition /// @param condition the else condition
/// @param body the else body /// @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, ElseStatement(std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body); std::unique_ptr<BlockStatement> body);
/// Constructor /// Constructor
/// @param source the source information /// @param source the source information
/// @param body the else body /// @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); ElseStatement(const Source& source, std::unique_ptr<BlockStatement> body);
/// Constructor /// Constructor
/// @param source the source information /// @param source the source information
/// @param condition the else condition /// @param condition the else condition
/// @param body the else body /// @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, ElseStatement(const Source& source,
std::unique_ptr<Expression> condition, std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body); std::unique_ptr<BlockStatement> body);
@ -101,10 +86,6 @@ class ElseStatement : public Statement {
private: private:
ElseStatement(const ElseStatement&) = delete; 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<Expression> condition_;
std::unique_ptr<BlockStatement> body_; 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); 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 { bool Function::IsValid() const {
for (const auto& param : params_) { for (const auto& param : params_) {
if (param == nullptr || !param->IsValid()) if (param == nullptr || !param->IsValid())

View File

@ -122,9 +122,6 @@ class Function : public Node {
/// @returns the function return type. /// @returns the function return type.
type::Type* return_type() const { return 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 /// Sets the body of the function
/// @param body the function body /// @param body the function body
void set_body(std::unique_ptr<BlockStatement> 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) std::unique_ptr<BlockStatement> body)
: Statement(), condition_(std::move(condition)), body_(std::move(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, IfStatement::IfStatement(const Source& source,
std::unique_ptr<Expression> condition, std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body) std::unique_ptr<BlockStatement> body)
@ -46,12 +37,6 @@ IfStatement::IfStatement(IfStatement&&) = default;
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 { bool IfStatement::IsIf() const {
return true; return true;
} }

View File

@ -40,13 +40,6 @@ class IfStatement : public Statement {
/// @param source the source information /// @param source the source information
/// @param condition the if condition /// @param condition the if condition
/// @param body the if body /// @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, IfStatement(const Source& source,
std::unique_ptr<Expression> condition, std::unique_ptr<Expression> condition,
std::unique_ptr<BlockStatement> body); std::unique_ptr<BlockStatement> body);
@ -62,9 +55,6 @@ class IfStatement : public Statement {
/// @returns the if condition or nullptr if none set /// @returns the if condition or nullptr if none set
Expression* condition() const { return condition_.get(); } Expression* condition() const { return condition_.get(); }
/// Sets the if body
/// @param body the if body
void set_body(StatementList body);
/// Sets the if body /// Sets the if body
/// @param body the if body /// @param body the if body
void set_body(std::unique_ptr<BlockStatement> 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) std::unique_ptr<BlockStatement> continuing)
: Statement(), body_(std::move(body)), continuing_(std::move(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, LoopStatement::LoopStatement(const Source& source,
std::unique_ptr<BlockStatement> body, std::unique_ptr<BlockStatement> body,
std::unique_ptr<BlockStatement> continuing) std::unique_ptr<BlockStatement> continuing)
@ -47,18 +37,6 @@ LoopStatement::LoopStatement(LoopStatement&&) = default;
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 { bool LoopStatement::IsLoop() const {
return true; return true;
} }

View File

@ -37,13 +37,6 @@ class LoopStatement : public Statement {
/// @param source the loop statement source /// @param source the loop statement source
/// @param body the body statements /// @param body the body statements
/// @param continuing the continuing 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, LoopStatement(const Source& source,
std::unique_ptr<BlockStatement> body, std::unique_ptr<BlockStatement> body,
std::unique_ptr<BlockStatement> continuing); std::unique_ptr<BlockStatement> continuing);
@ -56,9 +49,6 @@ class LoopStatement : public Statement {
void set_body(std::unique_ptr<BlockStatement> body) { void set_body(std::unique_ptr<BlockStatement> body) {
body_ = std::move(body); body_ = std::move(body);
} }
/// Sets the body statements
/// @param body the body statements
void set_body(StatementList body);
/// @returns the body statements /// @returns the body statements
const BlockStatement* body() const { return body_.get(); } const BlockStatement* body() const { return body_.get(); }
@ -67,9 +57,6 @@ class LoopStatement : public Statement {
void set_continuing(std::unique_ptr<BlockStatement> continuing) { void set_continuing(std::unique_ptr<BlockStatement> continuing) {
continuing_ = std::move(continuing); continuing_ = std::move(continuing);
} }
/// Sets the continuing statements
/// @param continuing the continuing statements
void set_continuing(StatementList continuing);
/// @returns the continuing statements /// @returns the continuing statements
const BlockStatement* continuing() const { return continuing_.get(); } const BlockStatement* continuing() const { return continuing_.get(); }
/// @returns true if there are continuing statements in the loop /// @returns true if there are continuing statements in the loop

View File

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

View File

@ -57,15 +57,6 @@ bool ValidatorImpl::ValidateStatements(const ast::BlockStatement& block) {
return true; 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) { bool ValidatorImpl::ValidateStatement(const ast::Statement& stmt) {
if (stmt.IsAssign() && !ValidateAssign(*(stmt.AsAssign()))) if (stmt.IsAssign() && !ValidateAssign(*(stmt.AsAssign())))
return false; return false;

View File

@ -58,10 +58,6 @@ class ValidatorImpl {
/// @param block the statements to check /// @param block the statements to check
/// @returns true if the validation was successful /// @returns true if the validation was successful
bool ValidateStatements(const ast::BlockStatement& block); 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 /// Validates a statement
/// @param stmt the statement to check /// @param stmt the statement to check
/// @returns true if the validation was successful /// @returns true if the validation was successful