ast: Remove the now unused Decoration::IsKind() method
And replace the use of`ast::As(Decoration* deco)` with `Castable::As<T>()`. These were used for dynamic casting, but is now replaced with Castable. Change-Id: Ie5fe19ad4db4bc4d19f5386d2cfddaaf84b215d0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34302 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
e319d7f0e9
commit
370d20a4c6
|
@ -28,10 +28,6 @@ DecorationKind AccessDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AccessDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AccessDecoration::IsAccess() const {
|
bool AccessDecoration::IsAccess() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,6 @@ class AccessDecoration : public Castable<AccessDecoration, TypeDecoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is an access decoration
|
/// @returns true if this is an access decoration
|
||||||
bool IsAccess() const override;
|
bool IsAccess() const override;
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,6 @@ DecorationKind ArrayDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArrayDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArrayDecoration::IsStride() const {
|
bool ArrayDecoration::IsStride() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,6 @@ class ArrayDecoration : public Castable<ArrayDecoration, Decoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a stride decoration
|
/// @returns true if this is a stride decoration
|
||||||
virtual bool IsStride() const;
|
virtual bool IsStride() const;
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,6 @@ DecorationKind BindingDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BindingDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BindingDecoration::IsBinding() const {
|
bool BindingDecoration::IsBinding() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,6 @@ class BindingDecoration
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a binding decoration
|
/// @returns true if this is a binding decoration
|
||||||
bool IsBinding() const override;
|
bool IsBinding() const override;
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,6 @@ DecorationKind BuiltinDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuiltinDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BuiltinDecoration::IsBuiltin() const {
|
bool BuiltinDecoration::IsBuiltin() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,6 @@ class BuiltinDecoration
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a builtin decoration
|
/// @returns true if this is a builtin decoration
|
||||||
bool IsBuiltin() const override;
|
bool IsBuiltin() const override;
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,6 @@ DecorationKind ConstantIdDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConstantIdDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ConstantIdDecoration::IsConstantId() const {
|
bool ConstantIdDecoration::IsConstantId() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,6 @@ class ConstantIdDecoration
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a constant_id decoration
|
/// @returns true if this is a constant_id decoration
|
||||||
bool IsConstantId() const override;
|
bool IsConstantId() const override;
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,6 @@ class Decoration : public Castable<Decoration, Node> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
virtual DecorationKind GetKind() const = 0;
|
virtual DecorationKind GetKind() const = 0;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
virtual bool IsKind(DecorationKind kind) const = 0;
|
|
||||||
|
|
||||||
/// @returns true if the node is valid
|
/// @returns true if the node is valid
|
||||||
bool IsValid() const override;
|
bool IsValid() const override;
|
||||||
|
|
||||||
|
@ -68,19 +63,6 @@ class Decoration : public Castable<Decoration, Node> {
|
||||||
explicit Decoration(const Source& source) : Base(source) {}
|
explicit Decoration(const Source& source) : Base(source) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// As dynamically casts |deco| to the target type |TO|.
|
|
||||||
/// @return the cast decoration, or nullptr if |deco| is not of the type |TO|.
|
|
||||||
template <typename TO>
|
|
||||||
TO* As(Decoration* deco) {
|
|
||||||
if (deco == nullptr) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
if (deco->Is<TO>()) {
|
|
||||||
return static_cast<TO*>(deco);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A list of decorations
|
/// A list of decorations
|
||||||
using DecorationList = std::vector<Decoration*>;
|
using DecorationList = std::vector<Decoration*>;
|
||||||
|
|
||||||
|
|
|
@ -81,112 +81,6 @@ TEST_F(DecorationTest, Kinds) {
|
||||||
EXPECT_EQ(LocationDecoration::Kind, DecorationKind::kLocation);
|
EXPECT_EQ(LocationDecoration::Kind, DecorationKind::kLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DecorationTest, IsKind) {
|
|
||||||
std::vector<DecorationKind> all_kinds{
|
|
||||||
DecorationKind::kArray, DecorationKind::kStride,
|
|
||||||
DecorationKind::kFunction, DecorationKind::kStage,
|
|
||||||
DecorationKind::kWorkgroup, DecorationKind::kStruct,
|
|
||||||
DecorationKind::kStructMember, DecorationKind::kStructMemberOffset,
|
|
||||||
DecorationKind::kType, DecorationKind::kAccess,
|
|
||||||
DecorationKind::kVariable, DecorationKind::kBinding,
|
|
||||||
DecorationKind::kBuiltin, DecorationKind::kConstantId,
|
|
||||||
DecorationKind::kLocation,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExpectedKinds {
|
|
||||||
DecorationKind kind;
|
|
||||||
std::unordered_set<DecorationKind> expect_true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// kArray
|
|
||||||
// | kStride
|
|
||||||
// kFunction
|
|
||||||
// | kStage
|
|
||||||
// | kWorkgroup
|
|
||||||
// kStruct
|
|
||||||
// kStructMember
|
|
||||||
// | kStructMemberOffset
|
|
||||||
// kType
|
|
||||||
// | kAccess
|
|
||||||
// kVariable
|
|
||||||
// | kBinding
|
|
||||||
// | kBuiltin
|
|
||||||
// | kConstantId
|
|
||||||
// | kLocation
|
|
||||||
std::unordered_map<DecorationKind, std::unordered_set<DecorationKind>>
|
|
||||||
kind_is{
|
|
||||||
{
|
|
||||||
DecorationKind::kStride,
|
|
||||||
{DecorationKind::kArray, DecorationKind::kStride},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kStage,
|
|
||||||
{DecorationKind::kFunction, DecorationKind::kStage},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kWorkgroup,
|
|
||||||
{DecorationKind::kFunction, DecorationKind::kWorkgroup},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kStruct,
|
|
||||||
{DecorationKind::kStruct},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kStructMemberOffset,
|
|
||||||
{DecorationKind::kStructMember,
|
|
||||||
DecorationKind::kStructMemberOffset},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kAccess,
|
|
||||||
{DecorationKind::kType, DecorationKind::kAccess},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kBinding,
|
|
||||||
{DecorationKind::kVariable, DecorationKind::kBinding},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kBuiltin,
|
|
||||||
{DecorationKind::kVariable, DecorationKind::kBuiltin},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kConstantId,
|
|
||||||
{DecorationKind::kVariable, DecorationKind::kConstantId},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
DecorationKind::kLocation,
|
|
||||||
{DecorationKind::kVariable, DecorationKind::kLocation},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
auto check = [&](Decoration* d) {
|
|
||||||
auto& is_set = kind_is[d->GetKind()];
|
|
||||||
for (auto test : all_kinds) {
|
|
||||||
bool is_kind = is_set.find(test) != is_set.end();
|
|
||||||
EXPECT_EQ(d->IsKind(test), is_kind)
|
|
||||||
<< "decoration: " << d->GetKind() << " IsKind(" << test << ")";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
StrideDecoration stride(0, {});
|
|
||||||
StageDecoration stage(PipelineStage::kNone, {});
|
|
||||||
WorkgroupDecoration workgroup(0, {});
|
|
||||||
StructMemberOffsetDecoration struct_member_offset(0, {});
|
|
||||||
AccessDecoration access(AccessControl::kReadOnly, {});
|
|
||||||
BindingDecoration binding(0, {});
|
|
||||||
BuiltinDecoration builtin(Builtin::kNone, {});
|
|
||||||
ConstantIdDecoration constant_id(0, {});
|
|
||||||
LocationDecoration location(0, {});
|
|
||||||
|
|
||||||
check(&stride);
|
|
||||||
check(&stage);
|
|
||||||
check(&workgroup);
|
|
||||||
check(&struct_member_offset);
|
|
||||||
check(&access);
|
|
||||||
check(&binding);
|
|
||||||
check(&builtin);
|
|
||||||
check(&constant_id);
|
|
||||||
check(&location);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
|
@ -32,10 +32,6 @@ DecorationKind FunctionDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FunctionDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FunctionDecoration::IsStage() const {
|
bool FunctionDecoration::IsStage() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,6 @@ class FunctionDecoration : public Castable<FunctionDecoration, Decoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a stage decoration
|
/// @returns true if this is a stage decoration
|
||||||
virtual bool IsStage() const;
|
virtual bool IsStage() const;
|
||||||
/// @returns true if this is a workgroup decoration
|
/// @returns true if this is a workgroup decoration
|
||||||
|
|
|
@ -28,10 +28,6 @@ DecorationKind LocationDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocationDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LocationDecoration::IsLocation() const {
|
bool LocationDecoration::IsLocation() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,6 @@ class LocationDecoration
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a location decoration
|
/// @returns true if this is a location decoration
|
||||||
bool IsLocation() const override;
|
bool IsLocation() const override;
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,6 @@ DecorationKind StageDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StageDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StageDecoration::IsStage() const {
|
bool StageDecoration::IsStage() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,6 @@ class StageDecoration : public Castable<StageDecoration, FunctionDecoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a stage decoration
|
/// @returns true if this is a stage decoration
|
||||||
bool IsStage() const override;
|
bool IsStage() const override;
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,6 @@ DecorationKind StrideDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StrideDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StrideDecoration::IsStride() const {
|
bool StrideDecoration::IsStride() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,6 @@ class StrideDecoration : public Castable<StrideDecoration, ArrayDecoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a stride decoration
|
/// @returns true if this is a stride decoration
|
||||||
bool IsStride() const override;
|
bool IsStride() const override;
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,5 @@ DecorationKind StructDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StructDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
|
@ -35,11 +35,6 @@ class StructDecoration : public Castable<StructDecoration, Decoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a block struct
|
/// @returns true if this is a block struct
|
||||||
virtual bool IsBlock() const = 0;
|
virtual bool IsBlock() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,6 @@ DecorationKind StructMemberDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StructMemberDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StructMemberDecoration::IsOffset() const {
|
bool StructMemberDecoration::IsOffset() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,6 @@ class StructMemberDecoration
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is an offset decoration
|
/// @returns true if this is an offset decoration
|
||||||
virtual bool IsOffset() const;
|
virtual bool IsOffset() const;
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,6 @@ DecorationKind StructMemberOffsetDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StructMemberOffsetDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StructMemberOffsetDecoration::IsOffset() const {
|
bool StructMemberOffsetDecoration::IsOffset() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,11 +41,6 @@ class StructMemberOffsetDecoration
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is an offset decoration
|
/// @returns true if this is an offset decoration
|
||||||
bool IsOffset() const override;
|
bool IsOffset() const override;
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,6 @@ DecorationKind TypeDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TypeDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TypeDecoration::IsAccess() const {
|
bool TypeDecoration::IsAccess() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,6 @@ class TypeDecoration : public Castable<TypeDecoration, Decoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is an access decoration
|
/// @returns true if this is an access decoration
|
||||||
virtual bool IsAccess() const;
|
virtual bool IsAccess() const;
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,6 @@ DecorationKind VariableDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VariableDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VariableDecoration::IsBinding() const {
|
bool VariableDecoration::IsBinding() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,6 @@ class VariableDecoration : public Castable<VariableDecoration, Decoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a binding decoration
|
/// @returns true if this is a binding decoration
|
||||||
virtual bool IsBinding() const;
|
virtual bool IsBinding() const;
|
||||||
/// @returns true if this is a builtin decoration
|
/// @returns true if this is a builtin decoration
|
||||||
|
|
|
@ -39,10 +39,6 @@ DecorationKind WorkgroupDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorkgroupDecoration::IsKind(DecorationKind kind) const {
|
|
||||||
return kind == Kind || Base::IsKind(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WorkgroupDecoration::IsWorkgroup() const {
|
bool WorkgroupDecoration::IsWorkgroup() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,6 @@ class WorkgroupDecoration
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
DecorationKind GetKind() const override;
|
||||||
|
|
||||||
/// @param kind the decoration kind
|
|
||||||
/// @return true if this Decoration is of the (or derives from) the given
|
|
||||||
/// kind.
|
|
||||||
bool IsKind(DecorationKind kind) const override;
|
|
||||||
|
|
||||||
/// @returns true if this is a workgroup decoration
|
/// @returns true if this is a workgroup decoration
|
||||||
bool IsWorkgroup() const override;
|
bool IsWorkgroup() const override;
|
||||||
|
|
||||||
|
|
|
@ -2895,7 +2895,7 @@ std::vector<T*> ParserImpl::take_decorations(ast::DecorationList& in) {
|
||||||
out.reserve(in.size());
|
out.reserve(in.size());
|
||||||
for (auto* deco : in) {
|
for (auto* deco : in) {
|
||||||
if (deco->Is<T>()) {
|
if (deco->Is<T>()) {
|
||||||
out.emplace_back(ast::As<T>(deco));
|
out.emplace_back(deco->As<T>());
|
||||||
} else {
|
} else {
|
||||||
remaining.emplace_back(deco);
|
remaining.emplace_back(deco);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ TEST_F(ParserImplTest, FunctionDecorationList_Parses) {
|
||||||
EXPECT_TRUE(decos.matched);
|
EXPECT_TRUE(decos.matched);
|
||||||
ASSERT_EQ(decos.value.size(), 2u);
|
ASSERT_EQ(decos.value.size(), 2u);
|
||||||
|
|
||||||
auto* deco_0 = ast::As<ast::FunctionDecoration>(decos.value[0]);
|
auto* deco_0 = decos.value[0]->As<ast::FunctionDecoration>();
|
||||||
auto* deco_1 = ast::As<ast::FunctionDecoration>(decos.value[1]);
|
auto* deco_1 = decos.value[1]->As<ast::FunctionDecoration>();
|
||||||
ASSERT_NE(deco_0, nullptr);
|
ASSERT_NE(deco_0, nullptr);
|
||||||
ASSERT_NE(deco_1, nullptr);
|
ASSERT_NE(deco_1, nullptr);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup) {
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr) << p->error();
|
ASSERT_NE(deco.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
auto* func_deco = ast::As<ast::FunctionDecoration>(deco.value);
|
auto* func_deco = deco.value->As<ast::FunctionDecoration>();
|
||||||
ASSERT_NE(func_deco, nullptr);
|
ASSERT_NE(func_deco, nullptr);
|
||||||
ASSERT_TRUE(func_deco->IsWorkgroup());
|
ASSERT_TRUE(func_deco->IsWorkgroup());
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_2Param) {
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr) << p->error();
|
ASSERT_NE(deco.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
auto* func_deco = ast::As<ast::FunctionDecoration>(deco.value);
|
auto* func_deco = deco.value->As<ast::FunctionDecoration>();
|
||||||
ASSERT_NE(func_deco, nullptr) << p->error();
|
ASSERT_NE(func_deco, nullptr) << p->error();
|
||||||
ASSERT_TRUE(func_deco->IsWorkgroup());
|
ASSERT_TRUE(func_deco->IsWorkgroup());
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_3Param) {
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr) << p->error();
|
ASSERT_NE(deco.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
auto* func_deco = ast::As<ast::FunctionDecoration>(deco.value);
|
auto* func_deco = deco.value->As<ast::FunctionDecoration>();
|
||||||
ASSERT_NE(func_deco, nullptr);
|
ASSERT_NE(func_deco, nullptr);
|
||||||
ASSERT_TRUE(func_deco->IsWorkgroup());
|
ASSERT_TRUE(func_deco->IsWorkgroup());
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Stage) {
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr) << p->error();
|
ASSERT_NE(deco.value, nullptr) << p->error();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
auto* func_deco = ast::As<ast::FunctionDecoration>(deco.value);
|
auto* func_deco = deco.value->As<ast::FunctionDecoration>();
|
||||||
ASSERT_NE(func_deco, nullptr);
|
ASSERT_NE(func_deco, nullptr);
|
||||||
ASSERT_TRUE(func_deco->IsStage());
|
ASSERT_TRUE(func_deco->IsStage());
|
||||||
EXPECT_EQ(func_deco->AsStage()->value(), ast::PipelineStage::kCompute);
|
EXPECT_EQ(func_deco->AsStage()->value(), ast::PipelineStage::kCompute);
|
||||||
|
|
|
@ -28,7 +28,7 @@ TEST_F(ParserImplTest, StructDecorationDecl_Parses) {
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
EXPECT_TRUE(decos.matched);
|
EXPECT_TRUE(decos.matched);
|
||||||
ASSERT_EQ(decos.value.size(), 1u);
|
ASSERT_EQ(decos.value.size(), 1u);
|
||||||
auto* struct_deco = ast::As<ast::StructDecoration>(decos.value[0]);
|
auto* struct_deco = decos.value[0]->As<ast::StructDecoration>();
|
||||||
EXPECT_TRUE(struct_deco->IsBlock());
|
EXPECT_TRUE(struct_deco->IsBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ TEST_P(StructDecorationTest, Parses) {
|
||||||
EXPECT_TRUE(deco.matched);
|
EXPECT_TRUE(deco.matched);
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr);
|
ASSERT_NE(deco.value, nullptr);
|
||||||
auto* struct_deco = ast::As<ast::StructDecoration>(deco.value);
|
auto* struct_deco = deco.value->As<ast::StructDecoration>();
|
||||||
ASSERT_NE(struct_deco, nullptr);
|
ASSERT_NE(struct_deco, nullptr);
|
||||||
EXPECT_EQ(struct_deco->IsBlock(), params.is_block);
|
EXPECT_EQ(struct_deco->IsBlock(), params.is_block);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_Single) {
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
EXPECT_TRUE(decos.matched);
|
EXPECT_TRUE(decos.matched);
|
||||||
ASSERT_EQ(decos.value.size(), 1u);
|
ASSERT_EQ(decos.value.size(), 1u);
|
||||||
auto* deco = ast::As<ast::StructMemberDecoration>(decos.value[0]);
|
auto* deco = decos.value[0]->As<ast::StructMemberDecoration>();
|
||||||
ASSERT_NE(deco, nullptr);
|
ASSERT_NE(deco, nullptr);
|
||||||
EXPECT_TRUE(deco->IsOffset());
|
EXPECT_TRUE(deco->IsOffset());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset) {
|
||||||
ASSERT_NE(deco.value, nullptr);
|
ASSERT_NE(deco.value, nullptr);
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
|
|
||||||
auto* member_deco = ast::As<ast::StructMemberDecoration>(deco.value);
|
auto* member_deco = deco.value->As<ast::StructMemberDecoration>();
|
||||||
ASSERT_NE(member_deco, nullptr);
|
ASSERT_NE(member_deco, nullptr);
|
||||||
ASSERT_TRUE(member_deco->IsOffset());
|
ASSERT_TRUE(member_deco->IsOffset());
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ TEST_F(ParserImplTest, VariableDecorationList_Parses) {
|
||||||
ASSERT_TRUE(decos.matched);
|
ASSERT_TRUE(decos.matched);
|
||||||
ASSERT_EQ(decos.value.size(), 2u);
|
ASSERT_EQ(decos.value.size(), 2u);
|
||||||
|
|
||||||
auto* deco_0 = ast::As<ast::VariableDecoration>(decos.value[0]);
|
auto* deco_0 = decos.value[0]->As<ast::VariableDecoration>();
|
||||||
auto* deco_1 = ast::As<ast::VariableDecoration>(decos.value[1]);
|
auto* deco_1 = decos.value[1]->As<ast::VariableDecoration>();
|
||||||
ASSERT_NE(deco_0, nullptr);
|
ASSERT_NE(deco_0, nullptr);
|
||||||
ASSERT_NE(deco_1, nullptr);
|
ASSERT_NE(deco_1, nullptr);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location) {
|
||||||
EXPECT_TRUE(deco.matched);
|
EXPECT_TRUE(deco.matched);
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr);
|
ASSERT_NE(deco.value, nullptr);
|
||||||
auto* var_deco = ast::As<ast::VariableDecoration>(deco.value);
|
auto* var_deco = deco.value->As<ast::VariableDecoration>();
|
||||||
ASSERT_NE(var_deco, nullptr);
|
ASSERT_NE(var_deco, nullptr);
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(var_deco->IsLocation());
|
ASSERT_TRUE(var_deco->IsLocation());
|
||||||
|
@ -101,7 +101,7 @@ TEST_P(BuiltinTest, VariableDecoration_Builtin) {
|
||||||
EXPECT_TRUE(deco.matched);
|
EXPECT_TRUE(deco.matched);
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr);
|
ASSERT_NE(deco.value, nullptr);
|
||||||
auto* var_deco = ast::As<ast::VariableDecoration>(deco.value);
|
auto* var_deco = deco.value->As<ast::VariableDecoration>();
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
ASSERT_NE(var_deco, nullptr);
|
ASSERT_NE(var_deco, nullptr);
|
||||||
ASSERT_TRUE(var_deco->IsBuiltin());
|
ASSERT_TRUE(var_deco->IsBuiltin());
|
||||||
|
@ -180,7 +180,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding) {
|
||||||
EXPECT_TRUE(deco.matched);
|
EXPECT_TRUE(deco.matched);
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr);
|
ASSERT_NE(deco.value, nullptr);
|
||||||
auto* var_deco = ast::As<ast::VariableDecoration>(deco.value);
|
auto* var_deco = deco.value->As<ast::VariableDecoration>();
|
||||||
ASSERT_NE(var_deco, nullptr);
|
ASSERT_NE(var_deco, nullptr);
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_TRUE(var_deco->IsBinding());
|
ASSERT_TRUE(var_deco->IsBinding());
|
||||||
|
@ -237,7 +237,7 @@ TEST_F(ParserImplTest, VariableDecoration_set) {
|
||||||
EXPECT_TRUE(deco.matched);
|
EXPECT_TRUE(deco.matched);
|
||||||
EXPECT_FALSE(deco.errored);
|
EXPECT_FALSE(deco.errored);
|
||||||
ASSERT_NE(deco.value, nullptr);
|
ASSERT_NE(deco.value, nullptr);
|
||||||
auto* var_deco = ast::As<ast::VariableDecoration>(deco.value);
|
auto* var_deco = deco.value->As<ast::VariableDecoration>();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
ASSERT_NE(var_deco, nullptr);
|
ASSERT_NE(var_deco, nullptr);
|
||||||
ASSERT_TRUE(var_deco->IsSet());
|
ASSERT_TRUE(var_deco->IsSet());
|
||||||
|
|
Loading…
Reference in New Issue