Rename VariableStatement to VariableDeclStatement.
This CL renames VariableStatement to VariableDeclStatement to make it
clearer what it was modeling.
Bug: tint:25
Change-Id: Idd0d27fad7cc402f286e1abad74092c9d1961d91
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18341
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index ad795bb..61aeeab 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -63,7 +63,7 @@
#include "src/ast/unary_method_expression.h"
#include "src/ast/unary_op.h"
#include "src/ast/unary_op_expression.h"
-#include "src/ast/variable_statement.h"
+#include "src/ast/variable_decl_statement.h"
#include "src/reader/wgsl/lexer.h"
#include "src/type_manager.h"
@@ -1667,7 +1667,7 @@
// : variable_decl
// | variable_decl EQUAL logical_or_expression
// | CONST variable_ident_decl EQUAL logical_or_expression
-std::unique_ptr<ast::VariableStatement> ParserImpl::variable_stmt() {
+std::unique_ptr<ast::VariableDeclStatement> ParserImpl::variable_stmt() {
auto t = peek();
auto source = t.source();
if (t.IsConst()) {
@@ -1702,7 +1702,7 @@
var->set_is_const(true);
var->set_constructor(std::move(constructor));
- return std::make_unique<ast::VariableStatement>(source, std::move(var));
+ return std::make_unique<ast::VariableDeclStatement>(source, std::move(var));
}
auto var = variable_decl();
@@ -1724,7 +1724,7 @@
var->set_constructor(std::move(constructor));
}
- return std::make_unique<ast::VariableStatement>(source, std::move(var));
+ return std::make_unique<ast::VariableDeclStatement>(source, std::move(var));
}
// if_stmt
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index 22bfb7e..ad39e3d 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -201,7 +201,7 @@
std::unique_ptr<ast::ContinueStatement> continue_stmt();
/// Parses a `variable_stmt` grammar element
/// @returns the parsed variable or nullptr
- std::unique_ptr<ast::VariableStatement> variable_stmt();
+ std::unique_ptr<ast::VariableDeclStatement> variable_stmt();
/// Parses a `if_stmt` grammar element
/// @returns the parsed statement or nullptr
std::unique_ptr<ast::IfStatement> if_stmt();
diff --git a/src/reader/wgsl/parser_impl_case_body_test.cc b/src/reader/wgsl/parser_impl_case_body_test.cc
index 98a9a91..d02a599 100644
--- a/src/reader/wgsl/parser_impl_case_body_test.cc
+++ b/src/reader/wgsl/parser_impl_case_body_test.cc
@@ -36,7 +36,7 @@
auto e = p->case_body();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_EQ(e.size(), 2);
- EXPECT_TRUE(e[0]->IsVariable());
+ EXPECT_TRUE(e[0]->IsVariableDecl());
EXPECT_TRUE(e[1]->IsAssign());
}
diff --git a/src/reader/wgsl/parser_impl_statement_test.cc b/src/reader/wgsl/parser_impl_statement_test.cc
index 51082cc..bc047f3 100644
--- a/src/reader/wgsl/parser_impl_statement_test.cc
+++ b/src/reader/wgsl/parser_impl_statement_test.cc
@@ -130,7 +130,7 @@
auto e = p->statement();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e, nullptr);
- ASSERT_TRUE(e->IsVariable());
+ ASSERT_TRUE(e->IsVariableDecl());
}
TEST_F(ParserImplTest, Statement_Variable_Invalid) {
diff --git a/src/reader/wgsl/parser_impl_variable_stmt_test.cc b/src/reader/wgsl/parser_impl_variable_stmt_test.cc
index 8777380..78b7685 100644
--- a/src/reader/wgsl/parser_impl_variable_stmt_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_stmt_test.cc
@@ -14,7 +14,7 @@
#include "gtest/gtest.h"
#include "src/ast/statement.h"
-#include "src/ast/variable_statement.h"
+#include "src/ast/variable_decl_statement.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@@ -28,7 +28,7 @@
auto e = p->variable_stmt();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e, nullptr);
- ASSERT_TRUE(e->IsVariable());
+ ASSERT_TRUE(e->IsVariableDecl());
ASSERT_NE(e->variable(), nullptr);
EXPECT_EQ(e->variable()->name(), "a");
@@ -40,7 +40,7 @@
auto e = p->variable_stmt();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e, nullptr);
- ASSERT_TRUE(e->IsVariable());
+ ASSERT_TRUE(e->IsVariableDecl());
ASSERT_NE(e->variable(), nullptr);
EXPECT_EQ(e->variable()->name(), "a");
@@ -69,7 +69,7 @@
auto e = p->variable_stmt();
ASSERT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e, nullptr);
- ASSERT_TRUE(e->IsVariable());
+ ASSERT_TRUE(e->IsVariableDecl());
}
TEST_F(ParserImplTest, VariableStmt_Const_InvalidVarIdent) {