Replace VariableDecoration::(Is|As)Set with Castable

Change-Id: I9808e31f3842b70b3df9ed0398583e09e4f2ca42
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34310
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent 2c1d7d5be7
commit c24ac2720d
13 changed files with 13 additions and 39 deletions

View File

@@ -35,7 +35,7 @@ TEST_F(BindingDecorationTest, Is) {
EXPECT_FALSE(d->Is<BuiltinDecoration>());
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
EXPECT_FALSE(d->Is<LocationDecoration>());
EXPECT_FALSE(bd.IsSet());
EXPECT_FALSE(d->Is<SetDecoration>());
}
TEST_F(BindingDecorationTest, ToStr) {

View File

@@ -35,7 +35,7 @@ TEST_F(BuiltinDecorationTest, Is) {
EXPECT_TRUE(d->Is<BuiltinDecoration>());
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
EXPECT_FALSE(d->Is<LocationDecoration>());
EXPECT_FALSE(bd.IsSet());
EXPECT_FALSE(d->Is<SetDecoration>());
}
TEST_F(BuiltinDecorationTest, ToStr) {

View File

@@ -34,7 +34,7 @@ TEST_F(ConstantIdDecorationTest, Is) {
EXPECT_FALSE(d->Is<BuiltinDecoration>());
EXPECT_TRUE(d->Is<ConstantIdDecoration>());
EXPECT_FALSE(d->Is<LocationDecoration>());
EXPECT_FALSE(cd.IsSet());
EXPECT_FALSE(d->Is<SetDecoration>());
}
TEST_F(ConstantIdDecorationTest, ToStr) {

View File

@@ -37,7 +37,7 @@ TEST_F(LocationDecorationTest, Is) {
EXPECT_FALSE(d->Is<BuiltinDecoration>());
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
EXPECT_TRUE(d->Is<LocationDecoration>());
EXPECT_FALSE(ld.IsSet());
EXPECT_FALSE(d->Is<SetDecoration>());
}
TEST_F(LocationDecorationTest, ToStr) {

View File

@@ -22,10 +22,6 @@ SetDecoration::SetDecoration(uint32_t val, const Source& source)
SetDecoration::~SetDecoration() = default;
bool SetDecoration::IsSet() const {
return true;
}
void SetDecoration::to_str(std::ostream& out, size_t indent) const {
make_indent(out, indent);
out << "SetDecoration{" << value_ << "}" << std::endl;

View File

@@ -31,9 +31,6 @@ class SetDecoration : public Castable<SetDecoration, VariableDecoration> {
SetDecoration(uint32_t value, const Source& source);
~SetDecoration() override;
/// @returns true if this is a set decoration
bool IsSet() const override;
/// @returns the set value
uint32_t value() const { return value_; }

View File

@@ -35,7 +35,7 @@ TEST_F(SetDecorationTest, Is) {
EXPECT_FALSE(d->Is<BuiltinDecoration>());
EXPECT_FALSE(d->Is<ConstantIdDecoration>());
EXPECT_FALSE(d->Is<LocationDecoration>());
EXPECT_TRUE(sd.IsSet());
EXPECT_TRUE(d->Is<SetDecoration>());
}
TEST_F(SetDecorationTest, ToStr) {

View File

@@ -16,8 +16,6 @@
#include <assert.h>
#include "src/ast/set_decoration.h"
namespace tint {
namespace ast {
@@ -31,14 +29,5 @@ DecorationKind VariableDecoration::GetKind() const {
return Kind;
}
bool VariableDecoration::IsSet() const {
return false;
}
SetDecoration* VariableDecoration::AsSet() {
assert(IsSet());
return static_cast<SetDecoration*>(this);
}
} // namespace ast
} // namespace tint

View File

@@ -25,8 +25,6 @@
namespace tint {
namespace ast {
class SetDecoration;
/// A decoration attached to a variable
class VariableDecoration : public Castable<VariableDecoration, Decoration> {
public:
@@ -38,12 +36,6 @@ class VariableDecoration : public Castable<VariableDecoration, Decoration> {
/// @return the decoration kind
DecorationKind GetKind() const override;
/// @returns true if this is a set decoration
virtual bool IsSet() const;
/// @returns the decoration as a set decoration
SetDecoration* AsSet();
protected:
/// Constructor
/// @param source the source of this decoration