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) {

View File

@ -1110,8 +1110,7 @@ void FunctionEmitter::IncrementLocation(AttributeList* attributes) {
// The old one doesn't leak because it's kept in the builder's AST node
// list.
attr = builder_.Location(
loc_attr->source,
AInt(loc_attr->value->As<ast::IntLiteralExpression>()->value + 1));
loc_attr->source, AInt(loc_attr->expr->As<ast::IntLiteralExpression>()->value + 1));
}
}
}

View File

@ -256,9 +256,9 @@ TEST_F(ParserImplTest, FunctionDecl_ReturnTypeAttributeList) {
ASSERT_EQ(ret_type_attributes.Length(), 1u);
auto* loc = ret_type_attributes[0]->As<ast::LocationAttribute>();
ASSERT_TRUE(loc != nullptr);
EXPECT_TRUE(loc->value->Is<ast::IntLiteralExpression>());
EXPECT_TRUE(loc->expr->Is<ast::IntLiteralExpression>());
auto* exp = loc->value->As<ast::IntLiteralExpression>();
auto* exp = loc->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(1u, exp->value);
auto* body = f->body;

View File

@ -57,8 +57,8 @@ TEST_F(ParserImplTest, FunctionHeader_AttributeReturnType) {
auto* loc = f->return_type_attributes[0]->As<ast::LocationAttribute>();
ASSERT_TRUE(loc != nullptr);
ASSERT_TRUE(loc->value->Is<ast::IntLiteralExpression>());
auto* exp = loc->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(loc->expr->Is<ast::IntLiteralExpression>());
auto* exp = loc->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(exp->value, 1u);
}

View File

@ -201,7 +201,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId) {
auto* override_attr = ast::GetAttribute<ast::IdAttribute>(override->attributes);
ASSERT_NE(override_attr, nullptr);
EXPECT_TRUE(override_attr->value->Is<ast::IntLiteralExpression>());
EXPECT_TRUE(override_attr->expr->Is<ast::IntLiteralExpression>());
}
TEST_F(ParserImplTest, GlobalOverrideDecl_WithId_TrailingComma) {
@ -231,7 +231,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId_TrailingComma) {
auto* override_attr = ast::GetAttribute<ast::IdAttribute>(override->attributes);
ASSERT_NE(override_attr, nullptr);
EXPECT_TRUE(override_attr->value->Is<ast::IntLiteralExpression>());
EXPECT_TRUE(override_attr->expr->Is<ast::IntLiteralExpression>());
}
TEST_F(ParserImplTest, GlobalOverrideDecl_WithoutId) {

View File

@ -120,8 +120,8 @@ TEST_F(ParserImplTest, ParamList_Attributes) {
ASSERT_TRUE(attrs_1[0]->Is<ast::LocationAttribute>());
auto* attr = attrs_1[0]->As<ast::LocationAttribute>();
ASSERT_TRUE(attr->value->Is<ast::IntLiteralExpression>());
auto* loc = attr->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(attr->expr->Is<ast::IntLiteralExpression>());
auto* loc = attr->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(loc->value, 1u);
EXPECT_EQ(e.value[1]->source.range.begin.line, 1u);

View File

@ -102,9 +102,9 @@ TEST_F(ParserImplTest, Attribute_Align) {
ASSERT_TRUE(member_attr->Is<ast::StructMemberAlignAttribute>());
auto* o = member_attr->As<ast::StructMemberAlignAttribute>();
ASSERT_TRUE(o->align->Is<ast::IntLiteralExpression>());
EXPECT_EQ(o->align->As<ast::IntLiteralExpression>()->value, 4);
EXPECT_EQ(o->align->As<ast::IntLiteralExpression>()->suffix,
ASSERT_TRUE(o->expr->Is<ast::IntLiteralExpression>());
EXPECT_EQ(o->expr->As<ast::IntLiteralExpression>()->value, 4);
EXPECT_EQ(o->expr->As<ast::IntLiteralExpression>()->suffix,
ast::IntLiteralExpression::Suffix::kNone);
}
@ -121,9 +121,9 @@ TEST_F(ParserImplTest, Attribute_Align_TrailingComma) {
ASSERT_TRUE(member_attr->Is<ast::StructMemberAlignAttribute>());
auto* o = member_attr->As<ast::StructMemberAlignAttribute>();
ASSERT_TRUE(o->align->Is<ast::IntLiteralExpression>());
ASSERT_TRUE(o->expr->Is<ast::IntLiteralExpression>());
auto* expr = o->align->As<ast::IntLiteralExpression>();
auto* expr = o->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(expr->value, 4);
EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone);
}

View File

@ -51,9 +51,8 @@ TEST_F(ParserImplTest, StructMember_ParsesWithAlignAttribute) {
EXPECT_TRUE(m->attributes[0]->Is<ast::StructMemberAlignAttribute>());
auto* attr = m->attributes[0]->As<ast::StructMemberAlignAttribute>();
ASSERT_TRUE(attr->align->Is<ast::IntLiteralExpression>());
auto* expr = attr->align->As<ast::IntLiteralExpression>();
ASSERT_TRUE(attr->expr->Is<ast::IntLiteralExpression>());
auto* expr = attr->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(expr->value, 2);
EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone);
@ -101,8 +100,8 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleattributes) {
ASSERT_TRUE(m->attributes[1]->Is<ast::StructMemberAlignAttribute>());
auto* attr = m->attributes[1]->As<ast::StructMemberAlignAttribute>();
ASSERT_TRUE(attr->align->Is<ast::IntLiteralExpression>());
auto* expr = attr->align->As<ast::IntLiteralExpression>();
ASSERT_TRUE(attr->expr->Is<ast::IntLiteralExpression>());
auto* expr = attr->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(expr->value, 4);
EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone);

View File

@ -33,9 +33,8 @@ TEST_F(ParserImplTest, AttributeList_Parses) {
ASSERT_TRUE(attr_0->Is<ast::LocationAttribute>());
auto* loc = attr_0->As<ast::LocationAttribute>();
ASSERT_TRUE(loc->value->Is<ast::IntLiteralExpression>());
auto* exp = loc->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(loc->expr->Is<ast::IntLiteralExpression>());
auto* exp = loc->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(exp->value, 4u);
ASSERT_TRUE(attr_1->Is<ast::BuiltinAttribute>());

View File

@ -29,8 +29,8 @@ TEST_F(ParserImplTest, Attribute_Location) {
ASSERT_TRUE(var_attr->Is<ast::LocationAttribute>());
auto* loc = var_attr->As<ast::LocationAttribute>();
ASSERT_TRUE(loc->value->Is<ast::IntLiteralExpression>());
auto* exp = loc->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(loc->expr->Is<ast::IntLiteralExpression>());
auto* exp = loc->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(exp->value, 4u);
}
@ -46,8 +46,8 @@ TEST_F(ParserImplTest, Attribute_Location_TrailingComma) {
ASSERT_TRUE(var_attr->Is<ast::LocationAttribute>());
auto* loc = var_attr->As<ast::LocationAttribute>();
ASSERT_TRUE(loc->value->Is<ast::IntLiteralExpression>());
auto* exp = loc->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(loc->expr->Is<ast::IntLiteralExpression>());
auto* exp = loc->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(exp->value, 4u);
}
@ -368,9 +368,8 @@ TEST_F(ParserImplTest, Attribute_Binding) {
ASSERT_TRUE(var_attr->Is<ast::BindingAttribute>());
auto* binding = var_attr->As<ast::BindingAttribute>();
ASSERT_TRUE(binding->value->Is<ast::IntLiteralExpression>());
auto* expr = binding->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(binding->expr->Is<ast::IntLiteralExpression>());
auto* expr = binding->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(expr->value, 4);
EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone);
}
@ -387,9 +386,8 @@ TEST_F(ParserImplTest, Attribute_Binding_TrailingComma) {
ASSERT_TRUE(var_attr->Is<ast::BindingAttribute>());
auto* binding = var_attr->As<ast::BindingAttribute>();
ASSERT_TRUE(binding->value->Is<ast::IntLiteralExpression>());
auto* expr = binding->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(binding->expr->Is<ast::IntLiteralExpression>());
auto* expr = binding->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(expr->value, 4);
EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone);
}
@ -446,9 +444,8 @@ TEST_F(ParserImplTest, Attribute_group) {
ASSERT_TRUE(var_attr->Is<ast::GroupAttribute>());
auto* group = var_attr->As<ast::GroupAttribute>();
ASSERT_TRUE(group->value->Is<ast::IntLiteralExpression>());
auto* expr = group->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(group->expr->Is<ast::IntLiteralExpression>());
auto* expr = group->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(expr->value, 4);
EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone);
}
@ -465,9 +462,8 @@ TEST_F(ParserImplTest, Attribute_group_TrailingComma) {
ASSERT_TRUE(var_attr->Is<ast::GroupAttribute>());
auto* group = var_attr->As<ast::GroupAttribute>();
ASSERT_TRUE(group->value->Is<ast::IntLiteralExpression>());
auto* expr = group->value->As<ast::IntLiteralExpression>();
ASSERT_TRUE(group->expr->Is<ast::IntLiteralExpression>());
auto* expr = group->expr->As<ast::IntLiteralExpression>();
EXPECT_EQ(expr->value, 4);
EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone);
}

View File

@ -442,7 +442,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) {
sem->SetConstructor(rhs);
if (auto* id_attr = ast::GetAttribute<ast::IdAttribute>(v->attributes)) {
auto* materialize = Materialize(Expression(id_attr->value));
auto* materialize = Materialize(Expression(id_attr->expr));
if (!materialize) {
return nullptr;
}
@ -607,7 +607,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
uint32_t binding = 0;
{
auto* attr = ast::GetAttribute<ast::BindingAttribute>(var->attributes);
auto* materialize = Materialize(Expression(attr->value));
auto* materialize = Materialize(Expression(attr->expr));
if (!materialize) {
return nullptr;
}
@ -623,7 +623,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
uint32_t group = 0;
{
auto* attr = ast::GetAttribute<ast::GroupAttribute>(var->attributes);
auto* materialize = Materialize(Expression(attr->value));
auto* materialize = Materialize(Expression(attr->expr));
if (!materialize) {
return nullptr;
}
@ -640,7 +640,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
std::optional<uint32_t> location;
if (auto* attr = ast::GetAttribute<ast::LocationAttribute>(var->attributes)) {
auto* materialize = Materialize(Expression(attr->value));
auto* materialize = Materialize(Expression(attr->expr));
if (!materialize) {
return nullptr;
}
@ -705,7 +705,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index)
if (param->HasBindingPoint()) {
{
auto* attr = ast::GetAttribute<ast::BindingAttribute>(param->attributes);
auto* materialize = Materialize(Expression(attr->value));
auto* materialize = Materialize(Expression(attr->expr));
if (!materialize) {
return nullptr;
}
@ -719,7 +719,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index)
}
{
auto* attr = ast::GetAttribute<ast::GroupAttribute>(param->attributes);
auto* materialize = Materialize(Expression(attr->value));
auto* materialize = Materialize(Expression(attr->expr));
if (!materialize) {
return nullptr;
}
@ -735,7 +735,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index)
std::optional<uint32_t> location;
if (auto* l = ast::GetAttribute<ast::LocationAttribute>(param->attributes)) {
auto* materialize = Materialize(Expression(l->value));
auto* materialize = Materialize(Expression(l->expr));
if (!materialize) {
return nullptr;
}
@ -944,7 +944,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) {
Mark(attr);
if (auto* a = attr->As<ast::LocationAttribute>()) {
auto* materialize = Materialize(Expression(a->value));
auto* materialize = Materialize(Expression(a->expr));
if (!materialize) {
return nullptr;
}
@ -2811,13 +2811,13 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) {
align = 1;
has_offset_attr = true;
} else if (auto* a = attr->As<ast::StructMemberAlignAttribute>()) {
auto* materialized = Materialize(Expression(a->align));
auto* materialized = Materialize(Expression(a->expr));
if (!materialized) {
return nullptr;
}
auto const_value = materialized->ConstantValue();
if (!const_value) {
AddError("'align' must be constant expression", a->align->source);
AddError("'align' must be constant expression", a->expr->source);
return nullptr;
}
auto value = const_value->As<AInt>();
@ -2838,7 +2838,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) {
size = s->size;
has_size_attr = true;
} else if (auto* l = attr->As<ast::LocationAttribute>()) {
auto* materialize = Materialize(Expression(l->value));
auto* materialize = Materialize(Expression(l->expr));
if (!materialize) {
return nullptr;
}

View File

@ -741,7 +741,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out,
},
[&](const ast::BindingAttribute* binding) {
out << "binding(";
if (!EmitExpression(out, binding->value)) {
if (!EmitExpression(out, binding->expr)) {
return false;
}
out << ")";
@ -749,7 +749,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out,
},
[&](const ast::GroupAttribute* group) {
out << "group(";
if (!EmitExpression(out, group->value)) {
if (!EmitExpression(out, group->expr)) {
return false;
}
out << ")";
@ -757,7 +757,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out,
},
[&](const ast::LocationAttribute* location) {
out << "location(";
if (!EmitExpression(out, location->value)) {
if (!EmitExpression(out, location->expr)) {
return false;
}
out << ")";
@ -781,7 +781,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out,
},
[&](const ast::IdAttribute* override_deco) {
out << "id(";
if (!EmitExpression(out, override_deco->value)) {
if (!EmitExpression(out, override_deco->expr)) {
return false;
}
out << ")";
@ -793,7 +793,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out,
},
[&](const ast::StructMemberAlignAttribute* align) {
out << "align(";
if (!EmitExpression(out, align->align)) {
if (!EmitExpression(out, align->expr)) {
return false;
}
out << ")";