tint: Add FriendlyName() to Program
Use this instead of ProgramBuilder::FriendlyName() in the Std140 transform. If this were called, we'd ICE that the program ids wouldn't match the type, as the type belongs to the source program, not the target program builder. Change-Id: I29066b18789493c231a89f7ee1dbc24d7e66d33f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101180 Auto-Submit: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
8a25fd2002
commit
d7d71889d8
|
@ -130,6 +130,19 @@ const sem::Type* Program::TypeOf(const ast::TypeDecl* type_decl) const {
|
|||
return Sem().Get(type_decl);
|
||||
}
|
||||
|
||||
std::string Program::FriendlyName(const ast::Type* type) const {
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL(Program, type, ID());
|
||||
return type ? type->FriendlyName(Symbols()) : "<null>";
|
||||
}
|
||||
|
||||
std::string Program::FriendlyName(const sem::Type* type) const {
|
||||
return type ? type->FriendlyName(Symbols()) : "<null>";
|
||||
}
|
||||
|
||||
std::string Program::FriendlyName(std::nullptr_t) const {
|
||||
return "<null>";
|
||||
}
|
||||
|
||||
void Program::AssertNotMoved() const {
|
||||
TINT_ASSERT(Program, !moved_);
|
||||
}
|
||||
|
|
|
@ -151,6 +151,21 @@ class Program {
|
|||
/// the type declaration has no resolved type.
|
||||
const sem::Type* TypeOf(const ast::TypeDecl* type_decl) const;
|
||||
|
||||
/// @param type a type
|
||||
/// @returns the name for `type` that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
std::string FriendlyName(const ast::Type* type) const;
|
||||
|
||||
/// @param type a type
|
||||
/// @returns the name for `type` that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
std::string FriendlyName(const sem::Type* type) const;
|
||||
|
||||
/// Overload of FriendlyName, which removes an ambiguity when passing nullptr.
|
||||
/// Simplifies test code.
|
||||
/// @returns "<null>"
|
||||
std::string FriendlyName(std::nullptr_t) const;
|
||||
|
||||
/// A function that can be used to print a program
|
||||
using Printer = std::string (*)(const Program*);
|
||||
|
||||
|
|
|
@ -113,6 +113,19 @@ const sem::Type* ProgramBuilder::TypeOf(const ast::TypeDecl* type_decl) const {
|
|||
return Sem().Get(type_decl);
|
||||
}
|
||||
|
||||
std::string ProgramBuilder::FriendlyName(const ast::Type* type) const {
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL(ProgramBuilder, type, ID());
|
||||
return type ? type->FriendlyName(Symbols()) : "<null>";
|
||||
}
|
||||
|
||||
std::string ProgramBuilder::FriendlyName(const sem::Type* type) const {
|
||||
return type ? type->FriendlyName(Symbols()) : "<null>";
|
||||
}
|
||||
|
||||
std::string ProgramBuilder::FriendlyName(std::nullptr_t) const {
|
||||
return "<null>";
|
||||
}
|
||||
|
||||
const ast::TypeName* ProgramBuilder::TypesBuilder::Of(const ast::TypeDecl* decl) const {
|
||||
return type_name(decl->name);
|
||||
}
|
||||
|
|
|
@ -3110,21 +3110,17 @@ class ProgramBuilder {
|
|||
/// @param type a type
|
||||
/// @returns the name for `type` that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
std::string FriendlyName(const ast::Type* type) {
|
||||
return type ? type->FriendlyName(Symbols()) : "<null>";
|
||||
}
|
||||
std::string FriendlyName(const ast::Type* type) const;
|
||||
|
||||
/// @param type a type
|
||||
/// @returns the name for `type` that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
std::string FriendlyName(const sem::Type* type) {
|
||||
return type ? type->FriendlyName(Symbols()) : "<null>";
|
||||
}
|
||||
std::string FriendlyName(const sem::Type* type) const;
|
||||
|
||||
/// Overload of FriendlyName, which removes an ambiguity when passing nullptr.
|
||||
/// Simplifies test code.
|
||||
/// @returns "<null>"
|
||||
std::string FriendlyName(std::nullptr_t) { return "<null>"; }
|
||||
std::string FriendlyName(std::nullptr_t) const;
|
||||
|
||||
/// Wraps the ast::Expression in a statement. This is used by tests that
|
||||
/// construct a partial AST and require the Resolver to reach these
|
||||
|
|
|
@ -518,7 +518,7 @@ struct Std140::State {
|
|||
},
|
||||
[&](Default) {
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "unhandled type for conversion name: " << b.FriendlyName(ty);
|
||||
<< "unhandled type for conversion name: " << ctx.src->FriendlyName(ty);
|
||||
return "";
|
||||
});
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ struct Std140::State {
|
|||
},
|
||||
[&](Default) {
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "unhandled type for conversion: " << b.FriendlyName(ty);
|
||||
<< "unhandled type for conversion: " << ctx.src->FriendlyName(ty);
|
||||
});
|
||||
|
||||
// Generate the function
|
||||
|
@ -879,7 +879,7 @@ struct Std140::State {
|
|||
}, //
|
||||
[&](Default) -> ExprTypeName {
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "unhandled type for access chain: " << b.FriendlyName(ty);
|
||||
<< "unhandled type for access chain: " << ctx.src->FriendlyName(ty);
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ struct Std140::State {
|
|||
}, //
|
||||
[&](Default) -> ExprTypeName {
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "unhandled type for access chain: " << b.FriendlyName(ty);
|
||||
<< "unhandled type for access chain: " << ctx.src->FriendlyName(ty);
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
@ -929,7 +929,7 @@ struct Std140::State {
|
|||
}, //
|
||||
[&](Default) -> ExprTypeName {
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "unhandled type for access chain: " << b.FriendlyName(ty);
|
||||
<< "unhandled type for access chain: " << ctx.src->FriendlyName(ty);
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue