Replace TypeDecoration::(Is|As)Access with Castable
Change-Id: I06a2f663cf56f8bb9a9b05557aef428b2d69e84c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34304 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
26e944bc4e
commit
3958f81fd7
|
@ -22,10 +22,6 @@ AccessDecoration::AccessDecoration(AccessControl val, const Source& source)
|
||||||
|
|
||||||
AccessDecoration::~AccessDecoration() = default;
|
AccessDecoration::~AccessDecoration() = default;
|
||||||
|
|
||||||
bool AccessDecoration::IsAccess() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccessDecoration::to_str(std::ostream& out, size_t indent) const {
|
void AccessDecoration::to_str(std::ostream& out, size_t indent) const {
|
||||||
make_indent(out, indent);
|
make_indent(out, indent);
|
||||||
out << "AccessDecoration{" << value_ << "}" << std::endl;
|
out << "AccessDecoration{" << value_ << "}" << std::endl;
|
||||||
|
|
|
@ -32,9 +32,6 @@ class AccessDecoration : public Castable<AccessDecoration, TypeDecoration> {
|
||||||
explicit AccessDecoration(AccessControl value, const Source& source);
|
explicit AccessDecoration(AccessControl value, const Source& source);
|
||||||
~AccessDecoration() override;
|
~AccessDecoration() override;
|
||||||
|
|
||||||
/// @returns true if this is an access decoration
|
|
||||||
bool IsAccess() const override;
|
|
||||||
|
|
||||||
/// @returns the access control value
|
/// @returns the access control value
|
||||||
AccessControl value() const { return value_; }
|
AccessControl value() const { return value_; }
|
||||||
|
|
||||||
|
|
|
@ -31,14 +31,5 @@ DecorationKind TypeDecoration::GetKind() const {
|
||||||
return Kind;
|
return Kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TypeDecoration::IsAccess() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessDecoration* TypeDecoration::AsAccess() {
|
|
||||||
assert(IsAccess());
|
|
||||||
return static_cast<AccessDecoration*>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
|
@ -38,12 +38,6 @@ class TypeDecoration : public Castable<TypeDecoration, Decoration> {
|
||||||
/// @return the decoration kind
|
/// @return the decoration kind
|
||||||
DecorationKind GetKind() const override;
|
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:
|
protected:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param source the source of this decoration
|
/// @param source the source of this decoration
|
||||||
|
|
|
@ -840,8 +840,8 @@ Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_variable_ident_decl(
|
||||||
for (auto* deco : access_decos) {
|
for (auto* deco : access_decos) {
|
||||||
// If we have an access control decoration then we take it and wrap our
|
// If we have an access control decoration then we take it and wrap our
|
||||||
// type up with that decoration
|
// type up with that decoration
|
||||||
ty = module_.create<ast::type::AccessControlType>(deco->AsAccess()->value(),
|
ty = module_.create<ast::type::AccessControlType>(
|
||||||
ty);
|
deco->As<ast::AccessDecoration>()->value(), ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TypedIdentifier{ty, ident.value, ident.source};
|
return TypedIdentifier{ty, ident.value, ident.source};
|
||||||
|
|
Loading…
Reference in New Issue