ast: Remove Struct constructors that don't take a Source

And swap the `decorations` and `members` parameters, as decorations come last for other constructors.

Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: Ie9b814c1de24b6c987f0fbb9e6f92da7c352caa2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35163
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-12-12 12:52:44 +00:00
committed by Commit Bot service account
parent 4543d1a232
commit bcf37549c8
33 changed files with 390 additions and 286 deletions

View File

@@ -947,8 +947,8 @@ ast::type::Type* ParserImpl::ConvertType(
}
// Now make the struct.
auto* ast_struct = create<ast::Struct>(std::move(ast_struct_decorations),
std::move(ast_members));
auto* ast_struct = create<ast::Struct>(Source{}, std::move(ast_members),
std::move(ast_struct_decorations));
namer_.SuggestSanitizedName(type_id, "S");

View File

@@ -1192,8 +1192,8 @@ 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(struct_decos.value),
std::move(body.value)));
name.value, create<ast::Struct>(source, std::move(body.value),
std::move(struct_decos.value)));
}
// struct_body_decl

View File

@@ -93,7 +93,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
ast::StructDecorationList decos;
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read)]] S");
@@ -119,7 +119,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
ast::StructDecorationList decos;
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read_write)]] S");
@@ -145,7 +145,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
ast::StructDecorationList decos;
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read), access(read_write)]] S");
@@ -168,7 +168,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
ast::StructDecorationList decos;
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
@@ -207,7 +207,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
ast::StructDecorationList decos;
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[stride(1)]] S");