Replace Type::(Is|As)U32 with Castable

Change-Id: I4999d45950fdffe4345cf0abae1b026244abba1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34273
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent 38409c79dc
commit d11ced4765
33 changed files with 124 additions and 118 deletions

View File

@@ -316,7 +316,8 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
}
auto* cond_type = s->condition()->result_type()->UnwrapAll();
if (!(cond_type->Is<ast::type::I32Type>() || cond_type->IsU32())) {
if (!(cond_type->Is<ast::type::I32Type>() ||
cond_type->Is<ast::type::U32Type>())) {
add_error(s->condition()->source(), "v-0025",
"switch statement selector expression must be of a "
"scalar integer type");
@@ -342,12 +343,13 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
return false;
}
auto v = static_cast<int32_t>(selector->type()->IsU32()
auto v = static_cast<int32_t>(selector->type()->Is<ast::type::U32Type>()
? selector->AsUint()->value()
: selector->AsSint()->value());
if (selector_set.count(v)) {
auto v_str = selector->type()->IsU32() ? selector->AsUint()->to_str()
: selector->AsSint()->to_str();
auto v_str = selector->type()->Is<ast::type::U32Type>()
? selector->AsUint()->to_str()
: selector->AsSint()->to_str();
add_error(case_stmt->source(), "v-0027",
"a literal value must not appear more than once in "
"the case selectors for a switch statement: '" +