From 3958f81fd718498c2ba2e5ffcba91aceec434aa8 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 30 Nov 2020 23:30:58 +0000 Subject: [PATCH] Replace TypeDecoration::(Is|As)Access with Castable Change-Id: I06a2f663cf56f8bb9a9b05557aef428b2d69e84c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34304 Reviewed-by: dan sinclair --- src/ast/access_decoration.cc | 4 ---- src/ast/access_decoration.h | 3 --- src/ast/type_decoration.cc | 9 --------- src/ast/type_decoration.h | 6 ------ src/reader/wgsl/parser_impl.cc | 4 ++-- 5 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/ast/access_decoration.cc b/src/ast/access_decoration.cc index f192b068a8..f77d78c8f3 100644 --- a/src/ast/access_decoration.cc +++ b/src/ast/access_decoration.cc @@ -22,10 +22,6 @@ AccessDecoration::AccessDecoration(AccessControl val, const Source& source) AccessDecoration::~AccessDecoration() = default; -bool AccessDecoration::IsAccess() const { - return true; -} - void AccessDecoration::to_str(std::ostream& out, size_t indent) const { make_indent(out, indent); out << "AccessDecoration{" << value_ << "}" << std::endl; diff --git a/src/ast/access_decoration.h b/src/ast/access_decoration.h index 15f7e122f2..37a400eb06 100644 --- a/src/ast/access_decoration.h +++ b/src/ast/access_decoration.h @@ -32,9 +32,6 @@ class AccessDecoration : public Castable { explicit AccessDecoration(AccessControl value, const Source& source); ~AccessDecoration() override; - /// @returns true if this is an access decoration - bool IsAccess() const override; - /// @returns the access control value AccessControl value() const { return value_; } diff --git a/src/ast/type_decoration.cc b/src/ast/type_decoration.cc index 84f9e5f3ba..e1d872dbd8 100644 --- a/src/ast/type_decoration.cc +++ b/src/ast/type_decoration.cc @@ -31,14 +31,5 @@ DecorationKind TypeDecoration::GetKind() const { return Kind; } -bool TypeDecoration::IsAccess() const { - return false; -} - -AccessDecoration* TypeDecoration::AsAccess() { - assert(IsAccess()); - return static_cast(this); -} - } // namespace ast } // namespace tint diff --git a/src/ast/type_decoration.h b/src/ast/type_decoration.h index 987cc9c2c1..0916a9ac45 100644 --- a/src/ast/type_decoration.h +++ b/src/ast/type_decoration.h @@ -38,12 +38,6 @@ class TypeDecoration : public Castable { /// @return the decoration kind DecorationKind GetKind() const override; - /// @returns true if this is an access decoration - virtual bool IsAccess() const; - - /// @returns the decoration as an access decoration - AccessDecoration* AsAccess(); - protected: /// Constructor /// @param source the source of this decoration diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 675c2fecba..86eeeb8f57 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -840,8 +840,8 @@ Expect ParserImpl::expect_variable_ident_decl( for (auto* deco : access_decos) { // If we have an access control decoration then we take it and wrap our // type up with that decoration - ty = module_.create(deco->AsAccess()->value(), - ty); + ty = module_.create( + deco->As()->value(), ty); } return TypedIdentifier{ty, ident.value, ident.source};