diff --git a/src/ast/case_statement.cc b/src/ast/case_statement.cc index f56c8ef41a..ab4cb3536f 100644 --- a/src/ast/case_statement.cc +++ b/src/ast/case_statement.cc @@ -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; } diff --git a/src/ast/case_statement.h b/src/ast/case_statement.h index ac1a9c19c9..571eeb384f 100644 --- a/src/ast/case_statement.h +++ b/src/ast/case_statement.h @@ -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 body) { diff --git a/src/ast/else_statement.cc b/src/ast/else_statement.cc index 15891ceef1..d181caa4b1 100644 --- a/src/ast/else_statement.cc +++ b/src/ast/else_statement.cc @@ -23,36 +23,14 @@ ElseStatement::ElseStatement() ElseStatement::ElseStatement(std::unique_ptr body) : Statement(), body_(std::move(body)) {} -ElseStatement::ElseStatement(std::unique_ptr condition, - StatementList body) - : Statement(), - condition_(std::move(condition)), - body_(std::make_unique()) { - set_body(std::move(body)); -} - ElseStatement::ElseStatement(std::unique_ptr condition, std::unique_ptr body) : Statement(), condition_(std::move(condition)), body_(std::move(body)) {} -ElseStatement::ElseStatement(const Source& source, StatementList body) - : Statement(source), body_(std::make_unique()) { - set_body(std::move(body)); -} - ElseStatement::ElseStatement(const Source& source, std::unique_ptr body) : Statement(source), body_(std::move(body)) {} -ElseStatement::ElseStatement(const Source& source, - std::unique_ptr condition, - StatementList body) - : Statement(source), - condition_(std::move(condition)), - body_(std::make_unique()) { - set_body(std::move(body)); -} - ElseStatement::ElseStatement(const Source& source, std::unique_ptr condition, std::unique_ptr 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; } diff --git a/src/ast/else_statement.h b/src/ast/else_statement.h index d0e0cf7403..fda156b80e 100644 --- a/src/ast/else_statement.h +++ b/src/ast/else_statement.h @@ -37,31 +37,16 @@ class ElseStatement : public Statement { /// Constructor /// @param condition the else condition /// @param body the else body - ElseStatement(std::unique_ptr condition, StatementList body); - /// Constructor - /// @param condition the else condition - /// @param body the else body ElseStatement(std::unique_ptr condition, std::unique_ptr 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 body); /// Constructor /// @param source the source information /// @param condition the else condition /// @param body the else body - ElseStatement(const Source& source, - std::unique_ptr 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 condition, std::unique_ptr 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 condition_; std::unique_ptr body_; }; diff --git a/src/ast/function.cc b/src/ast/function.cc index 7f9ae616d7..adacdad5c9 100644 --- a/src/ast/function.cc +++ b/src/ast/function.cc @@ -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()) diff --git a/src/ast/function.h b/src/ast/function.h index a6dbe1877f..a112e20aa7 100644 --- a/src/ast/function.h +++ b/src/ast/function.h @@ -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 body) { diff --git a/src/ast/if_statement.cc b/src/ast/if_statement.cc index 342c08f01a..5008c7db9e 100644 --- a/src/ast/if_statement.cc +++ b/src/ast/if_statement.cc @@ -26,15 +26,6 @@ IfStatement::IfStatement(std::unique_ptr condition, std::unique_ptr body) : Statement(), condition_(std::move(condition)), body_(std::move(body)) {} -IfStatement::IfStatement(const Source& source, - std::unique_ptr condition, - StatementList body) - : Statement(source), - condition_(std::move(condition)), - body_(std::make_unique()) { - set_body(std::move(body)); -} - IfStatement::IfStatement(const Source& source, std::unique_ptr condition, std::unique_ptr 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; } diff --git a/src/ast/if_statement.h b/src/ast/if_statement.h index 8db80e5da6..8108ebf948 100644 --- a/src/ast/if_statement.h +++ b/src/ast/if_statement.h @@ -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 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 condition, std::unique_ptr 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 body) { diff --git a/src/ast/loop_statement.cc b/src/ast/loop_statement.cc index 33f4ddb03d..5faafdbd47 100644 --- a/src/ast/loop_statement.cc +++ b/src/ast/loop_statement.cc @@ -26,16 +26,6 @@ LoopStatement::LoopStatement(std::unique_ptr body, std::unique_ptr 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()), - continuing_(std::make_unique()) { - set_body(std::move(body)); - set_continuing(std::move(continuing)); -} - LoopStatement::LoopStatement(const Source& source, std::unique_ptr body, std::unique_ptr 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; } diff --git a/src/ast/loop_statement.h b/src/ast/loop_statement.h index d46bda29f8..bf8f8a5131 100644 --- a/src/ast/loop_statement.h +++ b/src/ast/loop_statement.h @@ -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 body, std::unique_ptr continuing); @@ -56,9 +49,6 @@ class LoopStatement : public Statement { void set_body(std::unique_ptr 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 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 7df9aea6cc..3bd14525ae 100644 --- a/src/ast/statement.h +++ b/src/ast/statement.h @@ -143,9 +143,6 @@ class Statement : public Node { Statement(const Statement&) = delete; }; -/// A list of unique statements -using StatementList = std::vector>; - } // namespace ast } // namespace tint diff --git a/src/validator_impl.cc b/src/validator_impl.cc index 3645c96095..71ff6d447d 100644 --- a/src/validator_impl.cc +++ b/src/validator_impl.cc @@ -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; diff --git a/src/validator_impl.h b/src/validator_impl.h index 750fb66b47..c7eba9360c 100644 --- a/src/validator_impl.h +++ b/src/validator_impl.h @@ -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