Replace Variable::(Is|As)* with Castable

Change-Id: I7a49287af079d53cee095fa2243dd21757546b56
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34318
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent 19fe07236e
commit aedca4288c
14 changed files with 75 additions and 93 deletions

View File

@@ -122,11 +122,12 @@ void VertexPullingTransform::FindOrInsertVertexIndexIfUsed() {
// Look for an existing vertex index builtin
for (auto* v : mod_->global_variables()) {
if (!v->IsDecorated() || v->storage_class() != ast::StorageClass::kInput) {
if (!v->Is<ast::DecoratedVariable>() ||
v->storage_class() != ast::StorageClass::kInput) {
continue;
}
for (auto* d : v->AsDecorated()->decorations()) {
for (auto* d : v->As<ast::DecoratedVariable>()->decorations()) {
if (d->Is<ast::BuiltinDecoration>() &&
d->As<ast::BuiltinDecoration>()->value() ==
ast::Builtin::kVertexIdx) {
@@ -165,11 +166,12 @@ void VertexPullingTransform::FindOrInsertInstanceIndexIfUsed() {
// Look for an existing instance index builtin
for (auto* v : mod_->global_variables()) {
if (!v->IsDecorated() || v->storage_class() != ast::StorageClass::kInput) {
if (!v->Is<ast::DecoratedVariable>() ||
v->storage_class() != ast::StorageClass::kInput) {
continue;
}
for (auto* d : v->AsDecorated()->decorations()) {
for (auto* d : v->As<ast::DecoratedVariable>()->decorations()) {
if (d->Is<ast::BuiltinDecoration>() &&
d->As<ast::BuiltinDecoration>()->value() ==
ast::Builtin::kInstanceIdx) {
@@ -195,11 +197,12 @@ void VertexPullingTransform::FindOrInsertInstanceIndexIfUsed() {
void VertexPullingTransform::ConvertVertexInputVariablesToPrivate() {
for (auto*& v : mod_->global_variables()) {
if (!v->IsDecorated() || v->storage_class() != ast::StorageClass::kInput) {
if (!v->Is<ast::DecoratedVariable>() ||
v->storage_class() != ast::StorageClass::kInput) {
continue;
}
for (auto* d : v->AsDecorated()->decorations()) {
for (auto* d : v->As<ast::DecoratedVariable>()->decorations()) {
if (auto* l = d->As<ast::LocationDecoration>()) {
uint32_t location = l->value();
// This is where the replacement happens. Expressions use identifier