Program: Remove deprecated constructed-type methods
Fixup all usages Bug: tint:390 Change-Id: I739a7625cd385cb889369ab7c766462fbcd7cf12 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38546 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
a86f4effe4
commit
1b3d6e460c
|
@ -118,18 +118,6 @@ class Program {
|
||||||
return types_.Get<T>(std::forward<ARGS>(args)...);
|
return types_.Get<T>(std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a constructed type to the program.
|
|
||||||
/// The type must be an alias or a struct.
|
|
||||||
/// [DEPRECATED]: Use AST().AddConstructedType(type)
|
|
||||||
/// @param type the constructed type to add
|
|
||||||
void AddConstructedType(type::Type* type) { AST().AddConstructedType(type); }
|
|
||||||
|
|
||||||
/// @returns the constructed types in the program
|
|
||||||
/// [DEPRECATED]: Use AST().ConstructedTypes()
|
|
||||||
const std::vector<type::Type*>& constructed_types() const {
|
|
||||||
return AST().ConstructedTypes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @returns the functions declared in the translation unit
|
/// @returns the functions declared in the translation unit
|
||||||
/// [DEPRECATED]: Use AST().Functions()
|
/// [DEPRECATED]: Use AST().Functions()
|
||||||
const ast::FunctionList& Functions() const { return AST().Functions(); }
|
const ast::FunctionList& Functions() const { return AST().Functions(); }
|
||||||
|
|
|
@ -63,26 +63,26 @@ TEST_F(ProgramTest, IsValid_Invalid_GlobalVariable) {
|
||||||
|
|
||||||
TEST_F(ProgramTest, IsValid_Alias) {
|
TEST_F(ProgramTest, IsValid_Alias) {
|
||||||
auto* alias = ty.alias("alias", ty.f32);
|
auto* alias = ty.alias("alias", ty.f32);
|
||||||
mod->AddConstructedType(alias);
|
mod->AST().AddConstructedType(alias);
|
||||||
EXPECT_TRUE(mod->IsValid());
|
EXPECT_TRUE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProgramTest, IsValid_Null_Alias) {
|
TEST_F(ProgramTest, IsValid_Null_Alias) {
|
||||||
mod->AddConstructedType(nullptr);
|
mod->AST().AddConstructedType(nullptr);
|
||||||
EXPECT_FALSE(mod->IsValid());
|
EXPECT_FALSE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProgramTest, IsValid_Struct) {
|
TEST_F(ProgramTest, IsValid_Struct) {
|
||||||
auto* st = ty.struct_("name", {});
|
auto* st = ty.struct_("name", {});
|
||||||
auto* alias = ty.alias("name", st);
|
auto* alias = ty.alias("name", st);
|
||||||
mod->AddConstructedType(alias);
|
mod->AST().AddConstructedType(alias);
|
||||||
EXPECT_TRUE(mod->IsValid());
|
EXPECT_TRUE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProgramTest, IsValid_Struct_EmptyName) {
|
TEST_F(ProgramTest, IsValid_Struct_EmptyName) {
|
||||||
auto* st = ty.struct_("", {});
|
auto* st = ty.struct_("", {});
|
||||||
auto* alias = ty.alias("name", st);
|
auto* alias = ty.alias("name", st);
|
||||||
mod->AddConstructedType(alias);
|
mod->AST().AddConstructedType(alias);
|
||||||
EXPECT_FALSE(mod->IsValid());
|
EXPECT_FALSE(mod->IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -969,7 +969,7 @@ type::Type* ParserImpl::ConvertType(
|
||||||
if (num_non_writable_members == members.size()) {
|
if (num_non_writable_members == members.size()) {
|
||||||
read_only_struct_types_.insert(result);
|
read_only_struct_types_.insert(result);
|
||||||
}
|
}
|
||||||
program_.AddConstructedType(result);
|
program_.AST().AddConstructedType(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1133,7 +1133,7 @@ void ParserImpl::MaybeGenerateAlias(uint32_t type_id,
|
||||||
program_.RegisterSymbol(name), ast_underlying_type);
|
program_.RegisterSymbol(name), ast_underlying_type);
|
||||||
// Record this new alias as the AST type for this SPIR-V ID.
|
// Record this new alias as the AST type for this SPIR-V ID.
|
||||||
id_to_type_[type_id] = ast_alias_type;
|
id_to_type_[type_id] = ast_alias_type;
|
||||||
program_.AddConstructedType(ast_alias_type);
|
program_.AST().AddConstructedType(ast_alias_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::EmitModuleScopeVariables() {
|
bool ParserImpl::EmitModuleScopeVariables() {
|
||||||
|
|
|
@ -347,7 +347,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
||||||
if (!expect("type alias", Token::Type::kSemicolon))
|
if (!expect("type alias", Token::Type::kSemicolon))
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
program_.AddConstructedType(ta.value);
|
program_.AST().AddConstructedType(ta.value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
||||||
auto* type = str.value;
|
auto* type = str.value;
|
||||||
register_constructed(
|
register_constructed(
|
||||||
program_.SymbolToName(type->As<type::Struct>()->symbol()), type);
|
program_.SymbolToName(type->As<type::Struct>()->symbol()), type);
|
||||||
program_.AddConstructedType(type);
|
program_.AST().AddConstructedType(type);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,10 +87,10 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias) {
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
|
|
||||||
auto& m = p->get_program();
|
auto& m = p->get_program();
|
||||||
ASSERT_EQ(m.constructed_types().size(), 1u);
|
ASSERT_EQ(m.AST().ConstructedTypes().size(), 1u);
|
||||||
ASSERT_TRUE(m.constructed_types()[0]->Is<type::Alias>());
|
ASSERT_TRUE(m.AST().ConstructedTypes()[0]->Is<type::Alias>());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(m.SymbolToName(
|
||||||
m.SymbolToName(m.constructed_types()[0]->As<type::Alias>()->symbol()),
|
m.AST().ConstructedTypes()[0]->As<type::Alias>()->symbol()),
|
||||||
"A");
|
"A");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,13 +104,13 @@ type B = A;)");
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
|
|
||||||
auto& m = p->get_program();
|
auto& m = p->get_program();
|
||||||
ASSERT_EQ(m.constructed_types().size(), 2u);
|
ASSERT_EQ(m.AST().ConstructedTypes().size(), 2u);
|
||||||
ASSERT_TRUE(m.constructed_types()[0]->Is<type::Struct>());
|
ASSERT_TRUE(m.AST().ConstructedTypes()[0]->Is<type::Struct>());
|
||||||
auto* str = m.constructed_types()[0]->As<type::Struct>();
|
auto* str = m.AST().ConstructedTypes()[0]->As<type::Struct>();
|
||||||
EXPECT_EQ(str->symbol(), p->get_program().RegisterSymbol("A"));
|
EXPECT_EQ(str->symbol(), p->get_program().RegisterSymbol("A"));
|
||||||
|
|
||||||
ASSERT_TRUE(m.constructed_types()[1]->Is<type::Alias>());
|
ASSERT_TRUE(m.AST().ConstructedTypes()[1]->Is<type::Alias>());
|
||||||
auto* alias = m.constructed_types()[1]->As<type::Alias>();
|
auto* alias = m.AST().ConstructedTypes()[1]->As<type::Alias>();
|
||||||
EXPECT_EQ(alias->symbol(), p->get_program().RegisterSymbol("B"));
|
EXPECT_EQ(alias->symbol(), p->get_program().RegisterSymbol("B"));
|
||||||
EXPECT_EQ(alias->type(), str);
|
EXPECT_EQ(alias->type(), str);
|
||||||
}
|
}
|
||||||
|
@ -162,9 +162,9 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) {
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
|
|
||||||
auto& m = p->get_program();
|
auto& m = p->get_program();
|
||||||
ASSERT_EQ(m.constructed_types().size(), 1u);
|
ASSERT_EQ(m.AST().ConstructedTypes().size(), 1u);
|
||||||
|
|
||||||
auto* t = m.constructed_types()[0];
|
auto* t = m.AST().ConstructedTypes()[0];
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
ASSERT_TRUE(t->Is<type::Struct>());
|
ASSERT_TRUE(t->Is<type::Struct>());
|
||||||
|
|
||||||
|
@ -181,9 +181,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
|
|
||||||
auto& m = p->get_program();
|
auto& m = p->get_program();
|
||||||
ASSERT_EQ(m.constructed_types().size(), 1u);
|
ASSERT_EQ(m.AST().ConstructedTypes().size(), 1u);
|
||||||
|
|
||||||
auto* t = m.constructed_types()[0];
|
auto* t = m.AST().ConstructedTypes()[0];
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
ASSERT_TRUE(t->Is<type::Struct>());
|
ASSERT_TRUE(t->Is<type::Struct>());
|
||||||
|
|
||||||
|
@ -205,9 +205,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
|
|
||||||
auto& m = p->get_program();
|
auto& m = p->get_program();
|
||||||
ASSERT_EQ(m.constructed_types().size(), 1u);
|
ASSERT_EQ(m.AST().ConstructedTypes().size(), 1u);
|
||||||
|
|
||||||
auto* t = m.constructed_types()[0];
|
auto* t = m.AST().ConstructedTypes()[0];
|
||||||
ASSERT_NE(t, nullptr);
|
ASSERT_NE(t, nullptr);
|
||||||
ASSERT_TRUE(t->Is<type::Struct>());
|
ASSERT_TRUE(t->Is<type::Struct>());
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(Program* dst) {
|
||||||
|
|
||||||
dst->AST().AddGlobalVariable(idx_var);
|
dst->AST().AddGlobalVariable(idx_var);
|
||||||
|
|
||||||
dst->AddConstructedType(struct_type);
|
dst->AST().AddConstructedType(struct_type);
|
||||||
|
|
||||||
return idx_var;
|
return idx_var;
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ void VertexPulling::State::AddVertexStorageBuffers() {
|
||||||
});
|
});
|
||||||
out->AST().AddGlobalVariable(var);
|
out->AST().AddGlobalVariable(var);
|
||||||
}
|
}
|
||||||
out->AddConstructedType(struct_type);
|
out->AST().AddConstructedType(struct_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
|
ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
|
||||||
|
|
|
@ -375,7 +375,7 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
||||||
create<ast::VariableDeclStatement>(var),
|
create<ast::VariableDeclStatement>(var),
|
||||||
create<ast::SwitchStatement>(Expr("a"), body),
|
create<ast::SwitchStatement>(Expr("a"), body),
|
||||||
});
|
});
|
||||||
mod->AddConstructedType(my_int);
|
mod->AST().AddConstructedType(my_int);
|
||||||
|
|
||||||
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool ValidatorImpl::Validate() {
|
||||||
if (!ValidateGlobalVariables(program_->AST().GlobalVariables())) {
|
if (!ValidateGlobalVariables(program_->AST().GlobalVariables())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ValidateConstructedTypes(program_->constructed_types())) {
|
if (!ValidateConstructedTypes(program_->AST().ConstructedTypes())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ValidateFunctions(program_->Functions())) {
|
if (!ValidateFunctions(program_->Functions())) {
|
||||||
|
|
|
@ -51,11 +51,11 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) {
|
||||||
|
|
||||||
auto* struct_type = ty.struct_("Foo", st);
|
auto* struct_type = ty.struct_("Foo", st);
|
||||||
|
|
||||||
mod->AddConstructedType(struct_type);
|
mod->AST().AddConstructedType(struct_type);
|
||||||
|
|
||||||
ValidatorImpl& v = Build();
|
ValidatorImpl& v = Build();
|
||||||
|
|
||||||
EXPECT_TRUE(v.ValidateConstructedTypes(mod->constructed_types()));
|
EXPECT_TRUE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
|
TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
|
||||||
|
@ -71,11 +71,11 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
|
||||||
decos);
|
decos);
|
||||||
|
|
||||||
auto* struct_type = ty.struct_("Foo", st);
|
auto* struct_type = ty.struct_("Foo", st);
|
||||||
mod->AddConstructedType(struct_type);
|
mod->AST().AddConstructedType(struct_type);
|
||||||
|
|
||||||
ValidatorImpl& v = Build();
|
ValidatorImpl& v = Build();
|
||||||
|
|
||||||
EXPECT_FALSE(v.ValidateConstructedTypes(mod->constructed_types()));
|
EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
|
||||||
EXPECT_EQ(v.error(),
|
EXPECT_EQ(v.error(),
|
||||||
"v-0031: a struct containing a runtime-sized array must be "
|
"v-0031: a struct containing a runtime-sized array must be "
|
||||||
"in the 'storage' storage class: 'Foo'");
|
"in the 'storage' storage class: 'Foo'");
|
||||||
|
@ -99,11 +99,11 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) {
|
||||||
|
|
||||||
auto* struct_type = ty.struct_("Foo", st);
|
auto* struct_type = ty.struct_("Foo", st);
|
||||||
|
|
||||||
mod->AddConstructedType(struct_type);
|
mod->AST().AddConstructedType(struct_type);
|
||||||
|
|
||||||
ValidatorImpl& v = Build();
|
ValidatorImpl& v = Build();
|
||||||
|
|
||||||
EXPECT_FALSE(v.ValidateConstructedTypes(mod->constructed_types()));
|
EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
|
||||||
EXPECT_EQ(v.error(),
|
EXPECT_EQ(v.error(),
|
||||||
"12:34 v-0015: runtime arrays may only appear as the last member "
|
"12:34 v-0015: runtime arrays may only appear as the last member "
|
||||||
"of a struct");
|
"of a struct");
|
||||||
|
@ -125,11 +125,11 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) {
|
||||||
ast::StructMemberList{Member("b", alias), Member("a", ty.u32)}, decos);
|
ast::StructMemberList{Member("b", alias), Member("a", ty.u32)}, decos);
|
||||||
|
|
||||||
auto* struct_type = ty.struct_("s", st);
|
auto* struct_type = ty.struct_("s", st);
|
||||||
mod->AddConstructedType(struct_type);
|
mod->AST().AddConstructedType(struct_type);
|
||||||
|
|
||||||
ValidatorImpl& v = Build();
|
ValidatorImpl& v = Build();
|
||||||
|
|
||||||
EXPECT_FALSE(v.ValidateConstructedTypes(mod->constructed_types()));
|
EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
|
||||||
EXPECT_EQ(v.error(),
|
EXPECT_EQ(v.error(),
|
||||||
"v-0015: runtime arrays may only appear as the last member "
|
"v-0015: runtime arrays may only appear as the last member "
|
||||||
"of a struct");
|
"of a struct");
|
||||||
|
@ -151,11 +151,11 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) {
|
||||||
ast::StructMemberList{Member("a", ty.u32), Member("b", alias)}, decos);
|
ast::StructMemberList{Member("a", ty.u32), Member("b", alias)}, decos);
|
||||||
|
|
||||||
auto* struct_type = ty.struct_("s", st);
|
auto* struct_type = ty.struct_("s", st);
|
||||||
mod->AddConstructedType(struct_type);
|
mod->AST().AddConstructedType(struct_type);
|
||||||
|
|
||||||
ValidatorImpl& v = Build();
|
ValidatorImpl& v = Build();
|
||||||
|
|
||||||
EXPECT_TRUE(v.ValidateConstructedTypes(mod->constructed_types()));
|
EXPECT_TRUE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
|
TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
|
||||||
|
|
|
@ -140,12 +140,12 @@ bool GeneratorImpl::Generate(std::ostream& out) {
|
||||||
register_global(global);
|
register_global(global);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* const ty : program_->constructed_types()) {
|
for (auto* const ty : program_->AST().ConstructedTypes()) {
|
||||||
if (!EmitConstructedType(out, ty)) {
|
if (!EmitConstructedType(out, ty)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!program_->constructed_types().empty()) {
|
if (!program_->AST().ConstructedTypes().empty()) {
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
||||||
create<ast::GroupDecoration>(1),
|
create<ast::GroupDecoration>(1),
|
||||||
});
|
});
|
||||||
|
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
|
|
||||||
td.RegisterVariableForTesting(coord_var);
|
td.RegisterVariableForTesting(coord_var);
|
||||||
mod->AST().AddGlobalVariable(coord_var);
|
mod->AST().AddGlobalVariable(coord_var);
|
||||||
|
@ -1053,7 +1053,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
||||||
create<ast::GroupDecoration>(0),
|
create<ast::GroupDecoration>(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
td.RegisterVariableForTesting(data_var);
|
td.RegisterVariableForTesting(data_var);
|
||||||
mod->AST().AddGlobalVariable(data_var);
|
mod->AST().AddGlobalVariable(data_var);
|
||||||
|
|
||||||
|
|
|
@ -119,12 +119,12 @@ bool GeneratorImpl::Generate() {
|
||||||
global_variables_.set(global->symbol(), global);
|
global_variables_.set(global->symbol(), global);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* const ty : program_->constructed_types()) {
|
for (auto* const ty : program_->AST().ConstructedTypes()) {
|
||||||
if (!EmitConstructedType(ty)) {
|
if (!EmitConstructedType(ty)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!program_->constructed_types().empty()) {
|
if (!program_->AST().ConstructedTypes().empty()) {
|
||||||
out_ << std::endl;
|
out_ << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -350,7 +350,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
auto* s = ty.struct_("Data", str);
|
auto* s = ty.struct_("Data", str);
|
||||||
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||||
|
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||||
|
@ -405,7 +405,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
|
|
||||||
auto* s = ty.struct_("Data", str);
|
auto* s = ty.struct_("Data", str);
|
||||||
type::AccessControl ac(ast::AccessControl::kReadOnly, s);
|
type::AccessControl ac(ast::AccessControl::kReadOnly, s);
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||||
|
@ -722,7 +722,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
|
|
||||||
auto* s = ty.struct_("Data", str);
|
auto* s = ty.struct_("Data", str);
|
||||||
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||||
|
@ -791,7 +791,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
|
|
||||||
auto* s = ty.struct_("Data", str);
|
auto* s = ty.struct_("Data", str);
|
||||||
type::AccessControl ac(ast::AccessControl::kReadOnly, s);
|
type::AccessControl ac(ast::AccessControl::kReadOnly, s);
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
|
||||||
|
@ -986,7 +986,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
|
||||||
create<ast::GroupDecoration>(0)});
|
create<ast::GroupDecoration>(0)});
|
||||||
|
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
td.RegisterVariableForTesting(data_var);
|
td.RegisterVariableForTesting(data_var);
|
||||||
mod->AST().AddGlobalVariable(data_var);
|
mod->AST().AddGlobalVariable(data_var);
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
||||||
create<ast::GroupDecoration>(0),
|
create<ast::GroupDecoration>(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
|
|
||||||
td.RegisterVariableForTesting(data_var);
|
td.RegisterVariableForTesting(data_var);
|
||||||
mod->AST().AddGlobalVariable(data_var);
|
mod->AST().AddGlobalVariable(data_var);
|
||||||
|
|
|
@ -84,12 +84,12 @@ GeneratorImpl::GeneratorImpl(const Program* program)
|
||||||
GeneratorImpl::~GeneratorImpl() = default;
|
GeneratorImpl::~GeneratorImpl() = default;
|
||||||
|
|
||||||
bool GeneratorImpl::Generate() {
|
bool GeneratorImpl::Generate() {
|
||||||
for (auto* const ty : program_->constructed_types()) {
|
for (auto* const ty : program_->AST().ConstructedTypes()) {
|
||||||
if (!EmitConstructedType(ty)) {
|
if (!EmitConstructedType(ty)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!program_->constructed_types().empty())
|
if (!program_->AST().ConstructedTypes().empty())
|
||||||
out_ << std::endl;
|
out_ << std::endl;
|
||||||
|
|
||||||
for (auto* var : program_->AST().GlobalVariables()) {
|
for (auto* var : program_->AST().GlobalVariables()) {
|
||||||
|
@ -121,12 +121,12 @@ bool GeneratorImpl::GenerateEntryPoint(ast::PipelineStage stage,
|
||||||
|
|
||||||
// TODO(dsinclair): We always emit constructed types even if they aren't
|
// TODO(dsinclair): We always emit constructed types even if they aren't
|
||||||
// strictly needed
|
// strictly needed
|
||||||
for (auto* const ty : program_->constructed_types()) {
|
for (auto* const ty : program_->AST().ConstructedTypes()) {
|
||||||
if (!EmitConstructedType(ty)) {
|
if (!EmitConstructedType(ty)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!program_->constructed_types().empty()) {
|
if (!program_->AST().ConstructedTypes().empty()) {
|
||||||
out_ << std::endl;
|
out_ << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ TEST_F(WgslGeneratorImplTest,
|
||||||
create<ast::GroupDecoration>(0),
|
create<ast::GroupDecoration>(0),
|
||||||
});
|
});
|
||||||
|
|
||||||
mod->AddConstructedType(s);
|
mod->AST().AddConstructedType(s);
|
||||||
|
|
||||||
td.RegisterVariableForTesting(data_var);
|
td.RegisterVariableForTesting(data_var);
|
||||||
mod->AST().AddGlobalVariable(data_var);
|
mod->AST().AddGlobalVariable(data_var);
|
||||||
|
|
Loading…
Reference in New Issue