Access struct member name through sem.
This CL changes the uses of Declaration()->symbol for struct members in the sem to access the `Name` directly. Bug: tint:1718 Change-Id: I3050147b97bea66d6c283e176a7152f36eb2b25f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112444 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
d5d207ba9f
commit
c5b1b5c77a
|
@ -648,9 +648,9 @@ void Inspector::AddEntryPointInOutVariables(std::string name,
|
|||
if (auto* struct_ty = unwrapped_type->As<sem::Struct>()) {
|
||||
// Recurse into members.
|
||||
for (auto* member : struct_ty->Members()) {
|
||||
AddEntryPointInOutVariables(
|
||||
name + "." + program_->Symbols().NameFor(member->Declaration()->symbol),
|
||||
member->Type(), member->Declaration()->attributes, member->Location(), variables);
|
||||
AddEntryPointInOutVariables(name + "." + program_->Symbols().NameFor(member->Name()),
|
||||
member->Type(), member->Declaration()->attributes,
|
||||
member->Location(), variables);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3620,7 +3620,7 @@ bool Resolver::ApplyAddressSpaceUsageToType(ast::AddressSpace address_space,
|
|||
decl->type->source)) {
|
||||
std::stringstream err;
|
||||
err << "while analyzing structure member " << sem_.TypeNameOf(str) << "."
|
||||
<< builder_->Symbols().NameFor(decl->symbol);
|
||||
<< builder_->Symbols().NameFor(member->Name());
|
||||
AddNote(err.str(), decl->source);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -413,7 +413,7 @@ bool Validator::AddressSpaceLayout(const sem::Type* store_ty,
|
|||
};
|
||||
|
||||
auto member_name_of = [this](const sem::StructMember* sm) {
|
||||
return symbols_.NameFor(sm->Declaration()->symbol);
|
||||
return symbols_.NameFor(sm->Name());
|
||||
};
|
||||
|
||||
// Only validate the [type + address space] once
|
||||
|
|
|
@ -80,7 +80,7 @@ bool Struct::Equals(const sem::Type& other) const {
|
|||
|
||||
const StructMember* Struct::FindMember(Symbol name) const {
|
||||
for (auto* member : members_) {
|
||||
if (member->Declaration()->symbol == name) {
|
||||
if (member->Name() == name) {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +102,7 @@ std::string Struct::FriendlyName(const SymbolTable& symbols) const {
|
|||
std::string Struct::Layout(const tint::SymbolTable& symbols) const {
|
||||
std::stringstream ss;
|
||||
|
||||
auto member_name_of = [&](const sem::StructMember* sm) {
|
||||
return symbols.NameFor(sm->Declaration()->symbol);
|
||||
};
|
||||
auto member_name_of = [&](const sem::StructMember* sm) { return symbols.NameFor(sm->Name()); };
|
||||
|
||||
if (Members().empty()) {
|
||||
return {};
|
||||
|
|
|
@ -359,10 +359,10 @@ struct CanonicalizeEntryPointIO::State {
|
|||
continue;
|
||||
}
|
||||
|
||||
auto* member_ast = member->Declaration();
|
||||
auto name = ctx.src->Symbols().NameFor(member_ast->symbol);
|
||||
auto name = ctx.src->Symbols().NameFor(member->Name());
|
||||
|
||||
auto attributes = CloneShaderIOAttributes(member_ast->attributes, do_interpolate);
|
||||
auto attributes =
|
||||
CloneShaderIOAttributes(member->Declaration()->attributes, do_interpolate);
|
||||
auto* input_expr =
|
||||
AddInput(name, member->Type(), member->Location(), std::move(attributes));
|
||||
inner_struct_values.Push(input_expr);
|
||||
|
@ -388,9 +388,9 @@ struct CanonicalizeEntryPointIO::State {
|
|||
continue;
|
||||
}
|
||||
|
||||
auto* member_ast = member->Declaration();
|
||||
auto name = ctx.src->Symbols().NameFor(member_ast->symbol);
|
||||
auto attributes = CloneShaderIOAttributes(member_ast->attributes, do_interpolate);
|
||||
auto name = ctx.src->Symbols().NameFor(member->Name());
|
||||
auto attributes =
|
||||
CloneShaderIOAttributes(member->Declaration()->attributes, do_interpolate);
|
||||
|
||||
// Extract the original structure member.
|
||||
AddOutput(name, member->Type(), member->Location(), std::move(attributes),
|
||||
|
|
|
@ -645,8 +645,8 @@ struct DecomposeMemoryAccess::State {
|
|||
utils::Vector<const ast::Statement*, 8> stmts;
|
||||
for (auto* member : str->Members()) {
|
||||
auto* offset = b.Add("offset", u32(member->Offset()));
|
||||
auto* element = b.MemberAccessor(
|
||||
"value", ctx.Clone(member->Declaration()->symbol));
|
||||
auto* element =
|
||||
b.MemberAccessor("value", ctx.Clone(member->Name()));
|
||||
Symbol store =
|
||||
StoreFunc(buf_ty, member->Type()->UnwrapRef(), var_user);
|
||||
auto* call = b.Call(store, "buffer", offset, element);
|
||||
|
|
|
@ -107,7 +107,7 @@ Transform::ApplyResult NumWorkgroupsFromUniform::Apply(const Program* src,
|
|||
// Capture the symbols that would be used to access this member, which
|
||||
// we will replace later. We currently have no way to get from the
|
||||
// parameter directly to the member accessor expressions that use it.
|
||||
to_replace.insert({param->Declaration()->symbol, member->Declaration()->symbol});
|
||||
to_replace.insert({param->Declaration()->symbol, member->Name()});
|
||||
|
||||
// Remove the struct member.
|
||||
// The CanonicalizeEntryPointIO transform will have generated this
|
||||
|
|
|
@ -57,7 +57,7 @@ struct PackedVec3::State {
|
|||
|
||||
// Apply the PackedVec3::Attribute to the member
|
||||
auto* member_decl = member->Declaration();
|
||||
auto name = ctx.Clone(member_decl->symbol);
|
||||
auto name = ctx.Clone(member->Name());
|
||||
auto* type = ctx.Clone(member_decl->type);
|
||||
utils::Vector<const ast::Attribute*, 4> attrs{
|
||||
b.ASTNodes().Create<Attribute>(b.ID(), b.AllocateNodeID()),
|
||||
|
|
|
@ -131,8 +131,7 @@ Transform::ApplyResult TruncateInterstageVariables::Apply(const Program* src,
|
|||
}
|
||||
|
||||
truncated_members.Push(ctx.Clone(member->Declaration()));
|
||||
initializer_exprs.Push(
|
||||
b.MemberAccessor("io", ctx.Clone(member->Declaration()->symbol)));
|
||||
initializer_exprs.Push(b.MemberAccessor("io", ctx.Clone(member->Name())));
|
||||
}
|
||||
|
||||
// Create the new shader io struct.
|
||||
|
|
Loading…
Reference in New Issue