Remove SymbolTable::NameFor

This CL removes the `NameFor` method from SymbolTable and accesses the
symbols name directly.

Change-Id: Ic4ad6eecfa78efb946d97aeaecf2d784af2e6f16
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127301
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair
2023-04-18 19:38:25 +00:00
committed by Dawn LUCI CQ
parent b353ebe752
commit d026e13f48
183 changed files with 700 additions and 874 deletions

View File

@@ -28,7 +28,7 @@ bool AbstractFloat::Equals(const UniqueNode& other) const {
return other.Is<AbstractFloat>();
}
std::string AbstractFloat::FriendlyName(const SymbolTable&) const {
std::string AbstractFloat::FriendlyName() const {
return "abstract-float";
}

View File

@@ -35,9 +35,8 @@ class AbstractFloat final : public Castable<AbstractFloat, AbstractNumeric> {
/// @returns true if this type is equal to the given type
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type when printed in diagnostics.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -29,7 +29,7 @@ bool AbstractInt::Equals(const UniqueNode& other) const {
return other.Is<AbstractInt>();
}
std::string AbstractInt::FriendlyName(const SymbolTable&) const {
std::string AbstractInt::FriendlyName() const {
return "abstract-int";
}

View File

@@ -35,9 +35,8 @@ class AbstractInt final : public Castable<AbstractInt, AbstractNumeric> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type when printed in diagnostics.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -81,14 +81,14 @@ bool Array::Equals(const UniqueNode& other) const {
return false;
}
std::string Array::FriendlyName(const SymbolTable& symbols) const {
std::string Array::FriendlyName() const {
utils::StringStream out;
if (!IsStrideImplicit()) {
out << "@stride(" << stride_ << ") ";
}
out << "array<" << element_->FriendlyName(symbols);
out << "array<" << element_->FriendlyName();
auto count_str = count_->FriendlyName(symbols);
auto count_str = count_->FriendlyName();
if (!count_str.empty()) {
out << ", " << count_str;
}

View File

@@ -93,10 +93,9 @@ class Array final : public Castable<Array, Type> {
/// natural stride
bool IsStrideImplicit() const { return stride_ == implicit_stride_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -36,7 +36,7 @@ bool ConstantArrayCount::Equals(const UniqueNode& other) const {
return false;
}
std::string ConstantArrayCount::FriendlyName(const SymbolTable&) const {
std::string ConstantArrayCount::FriendlyName() const {
return std::to_string(value);
}
@@ -52,7 +52,7 @@ bool RuntimeArrayCount::Equals(const UniqueNode& other) const {
return other.Is<RuntimeArrayCount>();
}
std::string RuntimeArrayCount::FriendlyName(const SymbolTable&) const {
std::string RuntimeArrayCount::FriendlyName() const {
return "";
}

View File

@@ -29,9 +29,8 @@ class ArrayCount : public Castable<ArrayCount, UniqueNode> {
public:
~ArrayCount() override;
/// @param symbols the symbol table
/// @returns the friendly name for this array count
virtual std::string FriendlyName(const SymbolTable& symbols) const = 0;
virtual std::string FriendlyName() const = 0;
/// @param ctx the clone context
/// @returns a clone of this type
@@ -60,9 +59,8 @@ class ConstantArrayCount final : public Castable<ConstantArrayCount, ArrayCount>
/// @returns true if this array count is equal to other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the symbol table
/// @returns the friendly name for this array count
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type
@@ -87,9 +85,8 @@ class RuntimeArrayCount final : public Castable<RuntimeArrayCount, ArrayCount> {
/// @returns true if this array count is equal to other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the symbol table
/// @returns the friendly name for this array count
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -98,22 +98,22 @@ TEST_F(ArrayTest, Equals) {
TEST_F(ArrayTest, FriendlyNameRuntimeSized) {
auto* arr = create<Array>(create<I32>(), create<RuntimeArrayCount>(), 0u, 4u, 4u, 4u);
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32>");
EXPECT_EQ(arr->FriendlyName(), "array<i32>");
}
TEST_F(ArrayTest, FriendlyNameStaticSized) {
auto* arr = create<Array>(create<I32>(), create<ConstantArrayCount>(5u), 4u, 20u, 4u, 4u);
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32, 5>");
EXPECT_EQ(arr->FriendlyName(), "array<i32, 5>");
}
TEST_F(ArrayTest, FriendlyNameRuntimeSizedNonImplicitStride) {
auto* arr = create<Array>(create<I32>(), create<RuntimeArrayCount>(), 0u, 4u, 8u, 4u);
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32>");
EXPECT_EQ(arr->FriendlyName(), "@stride(8) array<i32>");
}
TEST_F(ArrayTest, FriendlyNameStaticSizedNonImplicitStride) {
auto* arr = create<Array>(create<I32>(), create<ConstantArrayCount>(5u), 4u, 20u, 8u, 4u);
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32, 5>");
EXPECT_EQ(arr->FriendlyName(), "@stride(8) array<i32, 5>");
}
TEST_F(ArrayTest, IsConstructable) {

View File

@@ -42,9 +42,9 @@ bool Atomic::Equals(const type::UniqueNode& other) const {
return false;
}
std::string Atomic::FriendlyName(const SymbolTable& symbols) const {
std::string Atomic::FriendlyName() const {
utils::StringStream out;
out << "atomic<" << subtype_->FriendlyName(symbols) << ">";
out << "atomic<" << subtype_->FriendlyName() << ">";
return out.str();
}

View File

@@ -38,10 +38,9 @@ class Atomic final : public Castable<Atomic, Type> {
/// @returns the atomic type
const type::Type* Type() const { return subtype_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @returns the size in bytes of the type.
uint32_t Size() const override;

View File

@@ -47,7 +47,7 @@ TEST_F(AtomicTest, Equals) {
TEST_F(AtomicTest, FriendlyName) {
auto* a = create<Atomic>(create<I32>());
EXPECT_EQ(a->FriendlyName(Symbols()), "atomic<i32>");
EXPECT_EQ(a->FriendlyName(), "atomic<i32>");
}
TEST_F(AtomicTest, Clone) {

View File

@@ -34,7 +34,7 @@ bool Bool::Equals(const UniqueNode& other) const {
return other.Is<Bool>();
}
std::string Bool::FriendlyName(const SymbolTable&) const {
std::string Bool::FriendlyName() const {
return "bool";
}

View File

@@ -40,10 +40,9 @@ class Bool final : public Castable<Bool, Type> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @returns the size in bytes of the type.
/// @note: booleans are not host-sharable, but still may exist in workgroup

View File

@@ -41,7 +41,7 @@ TEST_F(BoolTest, Equals) {
TEST_F(BoolTest, FriendlyName) {
Bool b;
EXPECT_EQ(b.FriendlyName(Symbols()), "bool");
EXPECT_EQ(b.FriendlyName(), "bool");
}
TEST_F(BoolTest, Clone) {

View File

@@ -46,7 +46,7 @@ bool DepthMultisampledTexture::Equals(const UniqueNode& other) const {
return false;
}
std::string DepthMultisampledTexture::FriendlyName(const SymbolTable&) const {
std::string DepthMultisampledTexture::FriendlyName() const {
utils::StringStream out;
out << "texture_depth_multisampled_" << dim();
return out.str();

View File

@@ -36,10 +36,9 @@ class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture,
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -55,7 +55,7 @@ TEST_F(DepthMultisampledTextureTest, Dim) {
TEST_F(DepthMultisampledTextureTest, FriendlyName) {
DepthMultisampledTexture d(TextureDimension::k2d);
EXPECT_EQ(d.FriendlyName(Symbols()), "texture_depth_multisampled_2d");
EXPECT_EQ(d.FriendlyName(), "texture_depth_multisampled_2d");
}
TEST_F(DepthMultisampledTextureTest, Clone) {

View File

@@ -47,7 +47,7 @@ bool DepthTexture::Equals(const UniqueNode& other) const {
return false;
}
std::string DepthTexture::FriendlyName(const SymbolTable&) const {
std::string DepthTexture::FriendlyName() const {
utils::StringStream out;
out << "texture_depth_" << dim();
return out.str();

View File

@@ -36,10 +36,9 @@ class DepthTexture final : public Castable<DepthTexture, Texture> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -67,7 +67,7 @@ TEST_F(DepthTextureTest, Dim) {
TEST_F(DepthTextureTest, FriendlyName) {
DepthTexture d(TextureDimension::kCube);
EXPECT_EQ(d.FriendlyName(Symbols()), "texture_depth_cube");
EXPECT_EQ(d.FriendlyName(), "texture_depth_cube");
}
TEST_F(DepthTextureTest, Clone) {

View File

@@ -31,7 +31,7 @@ bool ExternalTexture::Equals(const UniqueNode& other) const {
return other.Is<ExternalTexture>();
}
std::string ExternalTexture::FriendlyName(const SymbolTable&) const {
std::string ExternalTexture::FriendlyName() const {
return "texture_external";
}

View File

@@ -34,10 +34,9 @@ class ExternalTexture final : public Castable<ExternalTexture, Texture> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -64,7 +64,7 @@ TEST_F(ExternalTextureTest, Dim) {
TEST_F(ExternalTextureTest, FriendlyName) {
ExternalTexture s;
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_external");
EXPECT_EQ(s.FriendlyName(), "texture_external");
}
TEST_F(ExternalTextureTest, Clone) {

View File

@@ -34,7 +34,7 @@ bool F16::Equals(const UniqueNode& other) const {
return other.Is<F16>();
}
std::string F16::FriendlyName(const SymbolTable&) const {
std::string F16::FriendlyName() const {
return "f16";
}

View File

@@ -34,10 +34,9 @@ class F16 final : public Castable<F16, Type> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @returns the size in bytes of the type.
uint32_t Size() const override;

View File

@@ -41,7 +41,7 @@ TEST_F(F16Test, Equals) {
TEST_F(F16Test, FriendlyName) {
F16 f;
EXPECT_EQ(f.FriendlyName(Symbols()), "f16");
EXPECT_EQ(f.FriendlyName(), "f16");
}
TEST_F(F16Test, Clone) {

View File

@@ -34,7 +34,7 @@ bool F32::Equals(const UniqueNode& other) const {
return other.Is<F32>();
}
std::string F32::FriendlyName(const SymbolTable&) const {
std::string F32::FriendlyName() const {
return "f32";
}

View File

@@ -34,10 +34,9 @@ class F32 final : public Castable<F32, Type> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @returns the size in bytes of the type.
uint32_t Size() const override;

View File

@@ -41,7 +41,7 @@ TEST_F(F32Test, Equals) {
TEST_F(F32Test, FriendlyName) {
F32 f;
EXPECT_EQ(f.FriendlyName(Symbols()), "f32");
EXPECT_EQ(f.FriendlyName(), "f32");
}
TEST_F(F32Test, Clone) {

View File

@@ -34,7 +34,7 @@ bool I32::Equals(const UniqueNode& other) const {
return other.Is<I32>();
}
std::string I32::FriendlyName(const SymbolTable&) const {
std::string I32::FriendlyName() const {
return "i32";
}

View File

@@ -34,10 +34,9 @@ class I32 final : public Castable<I32, Type> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @returns the size in bytes of the type.
uint32_t Size() const override;

View File

@@ -41,7 +41,7 @@ TEST_F(I32Test, Equals) {
TEST_F(I32Test, FriendlyName) {
I32 i;
EXPECT_EQ(i.FriendlyName(Symbols()), "i32");
EXPECT_EQ(i.FriendlyName(), "i32");
}
TEST_F(I32Test, Clone) {

View File

@@ -51,9 +51,9 @@ bool Matrix::Equals(const UniqueNode& other) const {
return false;
}
std::string Matrix::FriendlyName(const SymbolTable& symbols) const {
std::string Matrix::FriendlyName() const {
utils::StringStream out;
out << "mat" << columns_ << "x" << rows_ << "<" << subtype_->FriendlyName(symbols) << ">";
out << "mat" << columns_ << "x" << rows_ << "<" << subtype_->FriendlyName() << ">";
return out.str();
}

View File

@@ -51,10 +51,9 @@ class Matrix final : public Castable<Matrix, Type> {
/// @returns the column-vector type of the matrix
const Vector* ColumnType() const { return column_type_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @returns the size in bytes of the type. This may include tail padding.
uint32_t Size() const override;

View File

@@ -62,7 +62,7 @@ TEST_F(MatrixTest, FriendlyName) {
I32 i32;
Vector c{&i32, 3};
Matrix m{&c, 2};
EXPECT_EQ(m.FriendlyName(Symbols()), "mat2x3<i32>");
EXPECT_EQ(m.FriendlyName(), "mat2x3<i32>");
}
TEST_F(MatrixTest, Clone) {

View File

@@ -40,9 +40,9 @@ bool MultisampledTexture::Equals(const UniqueNode& other) const {
return false;
}
std::string MultisampledTexture::FriendlyName(const SymbolTable& symbols) const {
std::string MultisampledTexture::FriendlyName() const {
utils::StringStream out;
out << "texture_multisampled_" << dim() << "<" << type_->FriendlyName(symbols) << ">";
out << "texture_multisampled_" << dim() << "<" << type_->FriendlyName() << ">";
return out.str();
}

View File

@@ -40,10 +40,9 @@ class MultisampledTexture final : public Castable<MultisampledTexture, Texture>
/// @returns the subtype of the sampled texture
const Type* type() const { return type_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -79,7 +79,7 @@ TEST_F(MultisampledTextureTest, Type) {
TEST_F(MultisampledTextureTest, FriendlyName) {
F32 f32;
MultisampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
EXPECT_EQ(s.FriendlyName(), "texture_multisampled_3d<f32>");
}
TEST_F(MultisampledTextureTest, Clone) {

View File

@@ -43,13 +43,13 @@ bool Pointer::Equals(const UniqueNode& other) const {
return false;
}
std::string Pointer::FriendlyName(const SymbolTable& symbols) const {
std::string Pointer::FriendlyName() const {
utils::StringStream out;
out << "ptr<";
if (address_space_ != builtin::AddressSpace::kUndefined) {
out << address_space_ << ", ";
}
out << subtype_->FriendlyName(symbols) << ", " << access_;
out << subtype_->FriendlyName() << ", " << access_;
out << ">";
return out.str();
}

View File

@@ -48,10 +48,9 @@ class Pointer final : public Castable<Pointer, Type> {
/// @returns the access control of the reference
builtin::Access Access() const { return access_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -74,13 +74,13 @@ TEST_F(PointerTest, Equals) {
TEST_F(PointerTest, FriendlyName) {
auto* r =
create<Pointer>(create<I32>(), builtin::AddressSpace::kUndefined, builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<i32, read>");
EXPECT_EQ(r->FriendlyName(), "ptr<i32, read>");
}
TEST_F(PointerTest, FriendlyNameWithAddressSpace) {
auto* r =
create<Pointer>(create<I32>(), builtin::AddressSpace::kWorkgroup, builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<workgroup, i32, read>");
EXPECT_EQ(r->FriendlyName(), "ptr<workgroup, i32, read>");
}
TEST_F(PointerTest, Clone) {

View File

@@ -44,13 +44,13 @@ bool Reference::Equals(const UniqueNode& other) const {
return false;
}
std::string Reference::FriendlyName(const SymbolTable& symbols) const {
std::string Reference::FriendlyName() const {
utils::StringStream out;
out << "ref<";
if (address_space_ != builtin::AddressSpace::kUndefined) {
out << address_space_ << ", ";
}
out << subtype_->FriendlyName(symbols) << ", " << access_;
out << subtype_->FriendlyName() << ", " << access_;
out << ">";
return out.str();
}

View File

@@ -48,10 +48,9 @@ class Reference final : public Castable<Reference, Type> {
/// @returns the resolved access control of the reference.
builtin::Access Access() const { return access_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -74,13 +74,13 @@ TEST_F(ReferenceTest, Equals) {
TEST_F(ReferenceTest, FriendlyName) {
auto* r =
create<Reference>(create<I32>(), builtin::AddressSpace::kUndefined, builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<i32, read>");
EXPECT_EQ(r->FriendlyName(), "ref<i32, read>");
}
TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) {
auto* r =
create<Reference>(create<I32>(), builtin::AddressSpace::kWorkgroup, builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<workgroup, i32, read>");
EXPECT_EQ(r->FriendlyName(), "ref<workgroup, i32, read>");
}
TEST_F(ReferenceTest, Clone) {

View File

@@ -39,9 +39,9 @@ bool SampledTexture::Equals(const UniqueNode& other) const {
return false;
}
std::string SampledTexture::FriendlyName(const SymbolTable& symbols) const {
std::string SampledTexture::FriendlyName() const {
utils::StringStream out;
out << "texture_" << dim() << "<" << type_->FriendlyName(symbols) << ">";
out << "texture_" << dim() << "<" << type_->FriendlyName() << ">";
return out.str();
}

View File

@@ -40,10 +40,9 @@ class SampledTexture final : public Castable<SampledTexture, Texture> {
/// @returns the subtype of the sampled texture
Type* type() const { return const_cast<Type*>(type_); }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -83,7 +83,7 @@ TEST_F(SampledTextureTest, Type) {
TEST_F(SampledTextureTest, FriendlyName) {
F32 f32;
SampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>");
EXPECT_EQ(s.FriendlyName(), "texture_3d<f32>");
}
TEST_F(SampledTextureTest, Clone) {

View File

@@ -33,7 +33,7 @@ bool Sampler::Equals(const UniqueNode& other) const {
return false;
}
std::string Sampler::FriendlyName(const SymbolTable&) const {
std::string Sampler::FriendlyName() const {
return kind_ == SamplerKind::kSampler ? "sampler" : "sampler_comparison";
}

View File

@@ -42,10 +42,9 @@ class Sampler final : public Castable<Sampler, Type> {
/// @returns true if this is a comparison sampler
bool IsComparison() const { return kind_ == SamplerKind::kComparisonSampler; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type

View File

@@ -55,12 +55,12 @@ TEST_F(SamplerTest, Equals) {
TEST_F(SamplerTest, FriendlyNameSampler) {
Sampler s{SamplerKind::kSampler};
EXPECT_EQ(s.FriendlyName(Symbols()), "sampler");
EXPECT_EQ(s.FriendlyName(), "sampler");
}
TEST_F(SamplerTest, FriendlyNameComparisonSampler) {
Sampler s{SamplerKind::kComparisonSampler};
EXPECT_EQ(s.FriendlyName(Symbols()), "sampler_comparison");
EXPECT_EQ(s.FriendlyName(), "sampler_comparison");
}
TEST_F(SamplerTest, Clone) {

View File

@@ -43,7 +43,7 @@ bool StorageTexture::Equals(const UniqueNode& other) const {
return false;
}
std::string StorageTexture::FriendlyName(const SymbolTable&) const {
std::string StorageTexture::FriendlyName() const {
utils::StringStream out;
out << "texture_storage_" << dim() << "<" << texel_format_ << ", " << access_ << ">";
return out.str();

View File

@@ -58,10 +58,9 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
/// @returns the access control
builtin::Access access() const { return access_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param format the storage texture image format
/// @param type_mgr the Manager used to build the returned type

View File

@@ -96,7 +96,7 @@ TEST_F(StorageTextureTest, Format) {
TEST_F(StorageTextureTest, FriendlyName) {
auto* s = Create(TextureDimension::k2dArray, builtin::TexelFormat::kRgba32Float,
builtin::Access::kReadWrite);
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read_write>");
EXPECT_EQ(s->FriendlyName(), "texture_storage_2d_array<rgba32float, read_write>");
}
TEST_F(StorageTextureTest, F32) {

View File

@@ -92,14 +92,14 @@ uint32_t Struct::Size() const {
return size_;
}
std::string Struct::FriendlyName(const SymbolTable& symbols) const {
return symbols.NameFor(name_);
std::string Struct::FriendlyName() const {
return name_.Name();
}
std::string Struct::Layout(const tint::SymbolTable& symbols) const {
std::string Struct::Layout() const {
utils::StringStream ss;
auto member_name_of = [&](const StructMember* sm) { return symbols.NameFor(sm->Name()); };
auto member_name_of = [&](const StructMember* sm) { return sm->Name().Name(); };
if (Members().IsEmpty()) {
return {};
@@ -128,7 +128,7 @@ std::string Struct::Layout(const tint::SymbolTable& symbols) const {
<< align << ") size(" << std::setw(size_w) << size << ") */ " << s << ";\n";
};
print_struct_begin_line(Align(), Size(), UnwrapRef()->FriendlyName(symbols));
print_struct_begin_line(Align(), Size(), UnwrapRef()->FriendlyName());
for (size_t i = 0; i < Members().Length(); ++i) {
auto* const m = Members()[i];
@@ -147,7 +147,7 @@ std::string Struct::Layout(const tint::SymbolTable& symbols) const {
// Output member
std::string member_name = member_name_of(m);
print_member_line(m->Offset(), m->Align(), m->Size(),
member_name + " : " + m->Type()->UnwrapRef()->FriendlyName(symbols));
member_name + " : " + m->Type()->UnwrapRef()->FriendlyName());
}
// Output struct size padding, if any
@@ -163,7 +163,7 @@ std::string Struct::Layout(const tint::SymbolTable& symbols) const {
}
Struct* Struct::Clone(CloneContext& ctx) const {
auto sym = ctx.dst.st->Register(ctx.src.st->NameFor(name_));
auto sym = ctx.dst.st->Register(name_.Name());
utils::Vector<const StructMember*, 4> members;
for (const auto& mem : members_) {
@@ -192,7 +192,7 @@ StructMember::StructMember(tint::Source source,
StructMember::~StructMember() = default;
StructMember* StructMember::Clone(CloneContext& ctx) const {
auto sym = ctx.dst.st->Register(ctx.src.st->NameFor(name_));
auto sym = ctx.dst.st->Register(name_.Name());
auto* ty = type_->Clone(ctx);
return ctx.dst.mgr->Get<StructMember>(source_, sym, ty, index_, offset_, align_, size_,
location_);

View File

@@ -131,15 +131,13 @@ class Struct : public Castable<Struct, Type> {
return pipeline_stage_uses_;
}
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param symbols the program's symbol table
/// @returns a multiline string that describes the layout of this struct,
/// including size and alignment information.
std::string Layout(const tint::SymbolTable& symbols) const;
std::string Layout() const;
/// @param concrete the conversion-rank ordered concrete versions of this abstract structure.
void SetConcreteTypes(utils::VectorRef<const Struct*> concrete) { concrete_types_ = concrete; }

View File

@@ -46,7 +46,7 @@ TEST_F(TypeStructTest, FriendlyName) {
auto name = Sym("my_struct");
auto* s = create<Struct>(Source{}, name, utils::Empty, 4u /* align */, 4u /* size */,
4u /* size_no_padding */);
EXPECT_EQ(s->FriendlyName(Symbols()), "my_struct");
EXPECT_EQ(s->FriendlyName(), "my_struct");
}
TEST_F(TypeStructTest, Layout) {
@@ -70,7 +70,7 @@ TEST_F(TypeStructTest, Layout) {
auto* sem_inner_st = p.Sem().Get(inner_st);
auto* sem_outer_st = p.Sem().Get(outer_st);
EXPECT_EQ(sem_inner_st->Layout(p.Symbols()),
EXPECT_EQ(sem_inner_st->Layout(),
R"(/* align(16) size(64) */ struct Inner {
/* offset( 0) align( 4) size( 4) */ a : i32;
/* offset( 4) align( 4) size( 4) */ b : u32;
@@ -81,7 +81,7 @@ TEST_F(TypeStructTest, Layout) {
/* offset(32) align( 8) size(32) */ e : mat4x2<f32>;
/* */ };)");
EXPECT_EQ(sem_outer_st->Layout(p.Symbols()),
EXPECT_EQ(sem_outer_st->Layout(),
R"(/* align(16) size(80) */ struct Outer {
/* offset( 0) align(16) size(64) */ inner : Inner;
/* offset(64) align( 4) size( 4) */ a : i32;
@@ -224,7 +224,7 @@ TEST_F(TypeStructTest, Clone) {
auto* st = s->Clone(ctx);
EXPECT_TRUE(new_st.Get("my_struct").IsValid());
EXPECT_EQ(new_st.NameFor(st->Name()), "my_struct");
EXPECT_EQ(st->Name().Name(), "my_struct");
EXPECT_EQ(st->Align(), 4u);
EXPECT_EQ(st->Size(), 8u);
@@ -233,14 +233,14 @@ TEST_F(TypeStructTest, Clone) {
auto members = st->Members();
ASSERT_EQ(members.Length(), 2u);
EXPECT_EQ(new_st.NameFor(members[0]->Name()), "b");
EXPECT_EQ(members[0]->Name().Name(), "b");
EXPECT_TRUE(members[0]->Type()->Is<Vector>());
EXPECT_EQ(members[0]->Index(), 0u);
EXPECT_EQ(members[0]->Offset(), 0u);
EXPECT_EQ(members[0]->Align(), 16u);
EXPECT_EQ(members[0]->Size(), 12u);
EXPECT_EQ(new_st.NameFor(members[1]->Name()), "a");
EXPECT_EQ(members[1]->Name().Name(), "a");
EXPECT_TRUE(members[1]->Type()->Is<I32>());
EXPECT_EQ(members[1]->Index(), 1u);
EXPECT_EQ(members[1]->Offset(), 16u);

View File

@@ -52,10 +52,9 @@ class Type : public Castable<Type, UniqueNode> {
/// Destructor
~Type() override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
virtual std::string FriendlyName(const SymbolTable& symbols) const = 0;
virtual std::string FriendlyName() const = 0;
/// @returns the inner most pointee type if this is a pointer, `this`
/// otherwise

View File

@@ -34,7 +34,7 @@ bool U32::Equals(const UniqueNode& other) const {
return other.Is<U32>();
}
std::string U32::FriendlyName(const SymbolTable&) const {
std::string U32::FriendlyName() const {
return "u32";
}

View File

@@ -34,10 +34,9 @@ class U32 final : public Castable<U32, Type> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @returns the size in bytes of the type.
uint32_t Size() const override;

View File

@@ -41,7 +41,7 @@ TEST_F(U32Test, Equals) {
TEST_F(U32Test, FriendlyName) {
U32 u;
EXPECT_EQ(u.FriendlyName(Symbols()), "u32");
EXPECT_EQ(u.FriendlyName(), "u32");
}
TEST_F(U32Test, Clone) {

View File

@@ -47,12 +47,12 @@ bool Vector::Equals(const UniqueNode& other) const {
return false;
}
std::string Vector::FriendlyName(const SymbolTable& symbols) const {
std::string Vector::FriendlyName() const {
utils::StringStream out;
if (packed_) {
out << "__packed_";
}
out << "vec" << width_ << "<" << subtype_->FriendlyName(symbols) << ">";
out << "vec" << width_ << "<" << subtype_->FriendlyName() << ">";
return out.str();
}

View File

@@ -40,10 +40,9 @@ class Vector : public Castable<Vector, Type> {
/// @returns the type of the vector elements
const Type* type() const { return subtype_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @returns the number of elements in the vector
uint32_t Width() const { return width_; }

View File

@@ -71,13 +71,13 @@ TEST_F(VectorTest, Equals) {
TEST_F(VectorTest, FriendlyName) {
auto* f32 = create<F32>();
auto* v = create<Vector>(f32, 3u);
EXPECT_EQ(v->FriendlyName(Symbols()), "vec3<f32>");
EXPECT_EQ(v->FriendlyName(), "vec3<f32>");
}
TEST_F(VectorTest, FriendlyName_Packed) {
auto* f32 = create<F32>();
auto* v = create<Vector>(f32, 3u, true);
EXPECT_EQ(v->FriendlyName(Symbols()), "__packed_vec3<f32>");
EXPECT_EQ(v->FriendlyName(), "__packed_vec3<f32>");
}
TEST_F(VectorTest, Clone) {

View File

@@ -28,7 +28,7 @@ bool Void::Equals(const UniqueNode& other) const {
return other.Is<Void>();
}
std::string Void::FriendlyName(const SymbolTable&) const {
std::string Void::FriendlyName() const {
return "void";
}

View File

@@ -34,10 +34,9 @@ class Void final : public Castable<Void, Type> {
/// @returns true if the this type is equal to @p other
bool Equals(const UniqueNode& other) const override;
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
/// declared in WGSL.
std::string FriendlyName(const SymbolTable& symbols) const override;
std::string FriendlyName() const override;
/// @param ctx the clone context
/// @returns a clone of this type