mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
Replace StructDecoration::IsBlock with Castable
Change-Id: I4b053aab610b18f99b72156f92317bc8eaf430b4 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34313 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
|
||||
#include "src/ast/struct.h"
|
||||
|
||||
#include "src/ast/struct_block_decoration.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
@@ -52,7 +54,7 @@ StructMember* Struct::get_member(const std::string& name) const {
|
||||
|
||||
bool Struct::IsBlockDecorated() const {
|
||||
for (auto* deco : decorations_) {
|
||||
if (deco->IsBlock()) {
|
||||
if (deco->Is<StructBlockDecoration>()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@ StructBlockDecoration::StructBlockDecoration(const Source& source)
|
||||
|
||||
StructBlockDecoration::~StructBlockDecoration() = default;
|
||||
|
||||
bool StructBlockDecoration::IsBlock() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void StructBlockDecoration::to_str(std::ostream& out, size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "block";
|
||||
|
||||
@@ -33,9 +33,6 @@ class StructBlockDecoration
|
||||
explicit StructBlockDecoration(const Source& source);
|
||||
~StructBlockDecoration() override;
|
||||
|
||||
/// @returns true if this is a block struct
|
||||
bool IsBlock() const override;
|
||||
|
||||
/// Outputs the decoration to the given stream
|
||||
/// @param out the stream to write to
|
||||
/// @param indent number of spaces to indent the node when writing
|
||||
|
||||
@@ -35,9 +35,6 @@ class StructDecoration : public Castable<StructDecoration, Decoration> {
|
||||
/// @return the decoration kind
|
||||
DecorationKind GetKind() const override;
|
||||
|
||||
/// @returns true if this is a block struct
|
||||
virtual bool IsBlock() const = 0;
|
||||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param source the source of this decoration
|
||||
|
||||
@@ -57,7 +57,7 @@ TEST_F(StructTest, Creation_WithDecorations) {
|
||||
Struct s{decos, members};
|
||||
EXPECT_EQ(s.members().size(), 1u);
|
||||
ASSERT_EQ(s.decorations().size(), 1u);
|
||||
EXPECT_TRUE(s.decorations()[0]->IsBlock());
|
||||
EXPECT_TRUE(s.decorations()[0]->Is<StructBlockDecoration>());
|
||||
EXPECT_EQ(s.source().range.begin.line, 0u);
|
||||
EXPECT_EQ(s.source().range.begin.column, 0u);
|
||||
EXPECT_EQ(s.source().range.end.line, 0u);
|
||||
@@ -79,7 +79,7 @@ TEST_F(StructTest, CreationWithSourceAndDecorations) {
|
||||
decos, members};
|
||||
EXPECT_EQ(s.members().size(), 1u);
|
||||
ASSERT_EQ(s.decorations().size(), 1u);
|
||||
EXPECT_TRUE(s.decorations()[0]->IsBlock());
|
||||
EXPECT_TRUE(s.decorations()[0]->Is<StructBlockDecoration>());
|
||||
EXPECT_EQ(s.source().range.begin.line, 27u);
|
||||
EXPECT_EQ(s.source().range.begin.column, 4u);
|
||||
EXPECT_EQ(s.source().range.end.line, 27u);
|
||||
|
||||
Reference in New Issue
Block a user