Rename attribute values.

This CL renames the attributes to store `expr` instead of `value`.
This closer matches what is stored.

Bug: tint:1633
Change-Id: If1db34d1f9186afa111c394f18ed049dd2f56f91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101525
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
dan sinclair
2022-09-08 01:04:34 +00:00
committed by Dawn LUCI CQ
parent 7ca82ac4d0
commit c4e076ffe6
27 changed files with 94 additions and 101 deletions

View File

@@ -25,8 +25,8 @@ namespace tint::ast {
BindingAttribute::BindingAttribute(ProgramID pid,
NodeID nid,
const Source& src,
const ast::Expression* val)
: Base(pid, nid, src), value(val) {}
const ast::Expression* exp)
: Base(pid, nid, src), expr(exp) {}
BindingAttribute::~BindingAttribute() = default;
@@ -37,8 +37,8 @@ std::string BindingAttribute::Name() const {
const BindingAttribute* BindingAttribute::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto src = ctx->Clone(source);
auto* value_ = ctx->Clone(value);
return ctx->dst->create<BindingAttribute>(src, value_);
auto* expr_ = ctx->Clone(expr);
return ctx->dst->create<BindingAttribute>(src, expr_);
}
} // namespace tint::ast

View File

@@ -29,8 +29,8 @@ class BindingAttribute final : public Castable<BindingAttribute, Attribute> {
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param value the binding value expression
BindingAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* value);
/// @param expr the binding expression
BindingAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr);
~BindingAttribute() override;
/// @returns the WGSL name for the attribute
@@ -42,8 +42,8 @@ class BindingAttribute final : public Castable<BindingAttribute, Attribute> {
/// @return the newly cloned node
const BindingAttribute* Clone(CloneContext* ctx) const override;
/// the binding value expression
const ast::Expression* const value;
/// the binding expression
const ast::Expression* const expr;
};
} // namespace tint::ast

View File

@@ -22,7 +22,7 @@ using BindingAttributeTest = TestHelper;
TEST_F(BindingAttributeTest, Creation) {
auto* d = Binding(2_a);
EXPECT_TRUE(d->value->Is<IntLiteralExpression>());
EXPECT_TRUE(d->expr->Is<IntLiteralExpression>());
}
} // namespace

View File

@@ -25,8 +25,8 @@ namespace tint::ast {
GroupAttribute::GroupAttribute(ProgramID pid,
NodeID nid,
const Source& src,
const ast::Expression* val)
: Base(pid, nid, src), value(val) {}
const ast::Expression* exp)
: Base(pid, nid, src), expr(exp) {}
GroupAttribute::~GroupAttribute() = default;
@@ -37,8 +37,8 @@ std::string GroupAttribute::Name() const {
const GroupAttribute* GroupAttribute::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto src = ctx->Clone(source);
auto* value_ = ctx->Clone(value);
return ctx->dst->create<GroupAttribute>(src, value_);
auto* expr_ = ctx->Clone(expr);
return ctx->dst->create<GroupAttribute>(src, expr_);
}
} // namespace tint::ast

View File

@@ -29,8 +29,8 @@ class GroupAttribute final : public Castable<GroupAttribute, Attribute> {
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param value the group value expression
GroupAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* value);
/// @param expr the group expression
GroupAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr);
~GroupAttribute() override;
/// @returns the WGSL name for the attribute
@@ -42,8 +42,8 @@ class GroupAttribute final : public Castable<GroupAttribute, Attribute> {
/// @return the newly cloned node
const GroupAttribute* Clone(CloneContext* ctx) const override;
/// The group value expression
const ast::Expression* const value;
/// The group expression
const ast::Expression* const expr;
};
} // namespace tint::ast

View File

@@ -22,7 +22,7 @@ using GroupAttributeTest = TestHelper;
TEST_F(GroupAttributeTest, Creation) {
auto* d = Group(2_a);
EXPECT_TRUE(d->value->Is<IntLiteralExpression>());
EXPECT_TRUE(d->expr->Is<IntLiteralExpression>());
}
} // namespace

View File

@@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdAttribute);
namespace tint::ast {
IdAttribute::IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* val)
: Base(pid, nid, src), value(val) {}
IdAttribute::IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* exp)
: Base(pid, nid, src), expr(exp) {}
IdAttribute::~IdAttribute() = default;
@@ -34,8 +34,8 @@ std::string IdAttribute::Name() const {
const IdAttribute* IdAttribute::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto src = ctx->Clone(source);
auto* value_ = ctx->Clone(value);
return ctx->dst->create<IdAttribute>(src, value_);
auto* expr_ = ctx->Clone(expr);
return ctx->dst->create<IdAttribute>(src, expr_);
}
} // namespace tint::ast

View File

@@ -29,8 +29,8 @@ class IdAttribute final : public Castable<IdAttribute, Attribute> {
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param val the numeric id value expression
IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* val);
/// @param expr the numeric id expression
IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr);
~IdAttribute() override;
/// @returns the WGSL name for the attribute
@@ -42,8 +42,8 @@ class IdAttribute final : public Castable<IdAttribute, Attribute> {
/// @return the newly cloned node
const IdAttribute* Clone(CloneContext* ctx) const override;
/// The id value expression
const ast::Expression* const value;
/// The id expression
const ast::Expression* const expr;
};
} // namespace tint::ast

View File

@@ -24,7 +24,7 @@ using IdAttributeTest = TestHelper;
TEST_F(IdAttributeTest, Creation) {
auto* d = Id(12_a);
EXPECT_TRUE(d->value->Is<ast::IntLiteralExpression>());
EXPECT_TRUE(d->expr->Is<ast::IntLiteralExpression>());
}
} // namespace

View File

@@ -25,8 +25,8 @@ namespace tint::ast {
LocationAttribute::LocationAttribute(ProgramID pid,
NodeID nid,
const Source& src,
const ast::Expression* val)
: Base(pid, nid, src), value(val) {}
const ast::Expression* exp)
: Base(pid, nid, src), expr(exp) {}
LocationAttribute::~LocationAttribute() = default;
@@ -37,8 +37,8 @@ std::string LocationAttribute::Name() const {
const LocationAttribute* LocationAttribute::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto src = ctx->Clone(source);
auto value_ = ctx->Clone(value);
return ctx->dst->create<LocationAttribute>(src, value_);
auto expr_ = ctx->Clone(expr);
return ctx->dst->create<LocationAttribute>(src, expr_);
}
} // namespace tint::ast

View File

@@ -29,8 +29,8 @@ class LocationAttribute final : public Castable<LocationAttribute, Attribute> {
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param value the location value expression
LocationAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* value);
/// @param expr the location expression
LocationAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr);
~LocationAttribute() override;
/// @returns the WGSL name for the attribute
@@ -42,8 +42,8 @@ class LocationAttribute final : public Castable<LocationAttribute, Attribute> {
/// @return the newly cloned node
const LocationAttribute* Clone(CloneContext* ctx) const override;
/// The location value
const ast::Expression* const value;
/// The location expression
const ast::Expression* const expr;
};
} // namespace tint::ast

View File

@@ -22,7 +22,7 @@ using LocationAttributeTest = TestHelper;
TEST_F(LocationAttributeTest, Creation) {
auto* d = Location(2_a);
EXPECT_TRUE(d->value->Is<IntLiteralExpression>());
EXPECT_TRUE(d->expr->Is<IntLiteralExpression>());
}
} // namespace

View File

@@ -27,7 +27,7 @@ StructMemberAlignAttribute::StructMemberAlignAttribute(ProgramID pid,
NodeID nid,
const Source& src,
const ast::Expression* a)
: Base(pid, nid, src), align(a) {}
: Base(pid, nid, src), expr(a) {}
StructMemberAlignAttribute::~StructMemberAlignAttribute() = default;
@@ -38,8 +38,8 @@ std::string StructMemberAlignAttribute::Name() const {
const StructMemberAlignAttribute* StructMemberAlignAttribute::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto src = ctx->Clone(source);
auto* align_ = ctx->Clone(align);
return ctx->dst->create<StructMemberAlignAttribute>(src, align_);
auto* expr_ = ctx->Clone(expr);
return ctx->dst->create<StructMemberAlignAttribute>(src, expr_);
}
} // namespace tint::ast

View File

@@ -30,7 +30,7 @@ class StructMemberAlignAttribute final : public Castable<StructMemberAlignAttrib
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param align the align value expression
/// @param align the align expression
StructMemberAlignAttribute(ProgramID pid,
NodeID nid,
const Source& src,
@@ -46,8 +46,8 @@ class StructMemberAlignAttribute final : public Castable<StructMemberAlignAttrib
/// @return the newly cloned node
const StructMemberAlignAttribute* Clone(CloneContext* ctx) const override;
/// The align value expression
const ast::Expression* const align;
/// The align expression
const ast::Expression* const expr;
};
} // namespace tint::ast

View File

@@ -24,8 +24,8 @@ using StructMemberAlignAttributeTest = TestHelper;
TEST_F(StructMemberAlignAttributeTest, Creation) {
auto* val = Expr("ident");
auto* d = create<StructMemberAlignAttribute>(val);
EXPECT_EQ(val, d->align);
EXPECT_TRUE(d->align->Is<IdentifierExpression>());
EXPECT_EQ(val, d->expr);
EXPECT_TRUE(d->expr->Is<IdentifierExpression>());
}
} // namespace

View File

@@ -102,8 +102,8 @@ TEST_F(VariableTest, WithAttributes) {
auto* location = ast::GetAttribute<ast::LocationAttribute>(attributes);
ASSERT_NE(nullptr, location);
ASSERT_NE(nullptr, location->value);
EXPECT_TRUE(location->value->Is<ast::IntLiteralExpression>());
ASSERT_NE(nullptr, location->expr);
EXPECT_TRUE(location->expr->Is<ast::IntLiteralExpression>());
}
TEST_F(VariableTest, HasBindingPoint_BothProvided) {