mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Add Symbol to struct type.
This CL adds a Symbol to the struct type along side the name. The name will be removed in a future CL when the symbol is used everywhere. Change-Id: I6c355908651ba0a155a1e0c9ed1192313a405568 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35620 Commit-Queue: dan sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
2abecbba16
commit
24bbbbb25f
@@ -952,8 +952,9 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||
|
||||
namer_.SuggestSanitizedName(type_id, "S");
|
||||
|
||||
auto* result = ast_module_.create<ast::type::Struct>(namer_.GetName(type_id),
|
||||
ast_struct);
|
||||
auto name = namer_.GetName(type_id);
|
||||
auto* result = ast_module_.create<ast::type::Struct>(
|
||||
ast_module_.RegisterSymbol(name), name, ast_struct);
|
||||
id_to_type_[type_id] = result;
|
||||
if (num_non_writable_members == members.size()) {
|
||||
read_only_struct_types_.insert(result);
|
||||
|
||||
@@ -1059,7 +1059,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructInitializer) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||
x_200
|
||||
private
|
||||
@@ -1088,7 +1089,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructNullInitializer) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||
x_200
|
||||
private
|
||||
@@ -1117,7 +1119,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructUndefInitializer) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||
x_200
|
||||
private
|
||||
@@ -1200,7 +1203,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_DescriptorSetDecoration_Valid) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
@@ -1254,7 +1258,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_BindingDecoration_Valid) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
Variable{
|
||||
Decorations{
|
||||
@@ -1309,7 +1314,8 @@ TEST_F(SpvParserTest,
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
S Struct{
|
||||
[[block]]
|
||||
@@ -1340,7 +1346,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_ColMajorDecoration_Dropped) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
S Struct{
|
||||
[[block]]
|
||||
@@ -1369,7 +1376,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixStrideDecoration_Dropped) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
S Struct{
|
||||
[[block]]
|
||||
@@ -1418,7 +1426,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_AllMembers) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
S Struct{
|
||||
[[block]]
|
||||
@@ -1447,7 +1456,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_NotAllMembers) {
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
S Struct{
|
||||
[[block]]
|
||||
@@ -1479,7 +1489,8 @@ TEST_F(
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
const auto module_str =
|
||||
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||
S Struct{
|
||||
[[block]]
|
||||
|
||||
@@ -1192,8 +1192,9 @@ Maybe<std::unique_ptr<ast::type::Struct>> ParserImpl::struct_decl(
|
||||
return Failure::kErrored;
|
||||
|
||||
return std::make_unique<ast::type::Struct>(
|
||||
name.value, create<ast::Struct>(source, std::move(body.value),
|
||||
std::move(struct_decos.value)));
|
||||
module_.RegisterSymbol(name.value), name.value,
|
||||
create<ast::Struct>(source, std::move(body.value),
|
||||
std::move(struct_decos.value)));
|
||||
}
|
||||
|
||||
// struct_body_decl
|
||||
|
||||
@@ -43,9 +43,9 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) {
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||
ast::type::Struct str("B", {});
|
||||
|
||||
auto p = parser("type a = B");
|
||||
|
||||
ast::type::Struct str(p->get_module().RegisterSymbol("B"), "B", {});
|
||||
p->register_constructed("B", &str);
|
||||
|
||||
auto t = p->type_alias();
|
||||
@@ -59,6 +59,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||
ASSERT_TRUE(alias->type()->Is<ast::type::Struct>());
|
||||
|
||||
auto* s = alias->type()->As<ast::type::Struct>();
|
||||
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
|
||||
EXPECT_EQ(s->name(), "B");
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_InvalidType) {
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto p = parser("my_var : [[access(read)]] S");
|
||||
|
||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(&mem);
|
||||
@@ -94,9 +96,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||
decos.push_back(&block_deco);
|
||||
|
||||
ast::Struct str(Source{}, members, decos);
|
||||
ast::type::Struct s("S", &str);
|
||||
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||
|
||||
auto p = parser("my_var : [[access(read)]] S");
|
||||
p->register_constructed("S", &s);
|
||||
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
@@ -111,6 +112,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto p = parser("my_var : [[access(read_write)]] S");
|
||||
|
||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(&mem);
|
||||
@@ -120,9 +123,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||
decos.push_back(&block_deco);
|
||||
|
||||
ast::Struct str(Source{}, members, decos);
|
||||
ast::type::Struct s("S", &str);
|
||||
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||
|
||||
auto p = parser("my_var : [[access(read_write)]] S");
|
||||
p->register_constructed("S", &s);
|
||||
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
@@ -137,6 +139,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto p = parser("my_var : [[access(read), access(read_write)]] S");
|
||||
|
||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(&mem);
|
||||
@@ -146,9 +150,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||
decos.push_back(&block_deco);
|
||||
|
||||
ast::Struct str(Source{}, members, decos);
|
||||
ast::type::Struct s("S", &str);
|
||||
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||
|
||||
auto p = parser("my_var : [[access(read), access(read_write)]] S");
|
||||
p->register_constructed("S", &s);
|
||||
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
@@ -160,6 +163,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
|
||||
|
||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(&mem);
|
||||
@@ -169,9 +174,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
|
||||
decos.push_back(&block_deco);
|
||||
|
||||
ast::Struct str(Source{}, members, decos);
|
||||
ast::type::Struct s("S", &str);
|
||||
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||
|
||||
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
|
||||
p->register_constructed("S", &s);
|
||||
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
@@ -199,6 +203,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_AccessDecoIllegalValue) {
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto p = parser("my_var : [[stride(1)]] S");
|
||||
|
||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(&mem);
|
||||
@@ -208,9 +214,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
|
||||
decos.push_back(&block_deco);
|
||||
|
||||
ast::Struct str(Source{}, members, decos);
|
||||
ast::type::Struct s("S", &str);
|
||||
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||
|
||||
auto p = parser("my_var : [[stride(1)]] S");
|
||||
p->register_constructed("S", &s);
|
||||
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
|
||||
Reference in New Issue
Block a user