From cf4057be0111e98c2e6e0743ed4480b18b12e7a9 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Mon, 19 Apr 2021 21:13:12 +0000 Subject: [PATCH] Rename type::Array to type::ArrayType This is to avoid name conflicts once we move all classes from namespace `type` to `sem`. Bug: tint:724 Change-Id: Icc3d81ae62eb3b329ce28e78a23ea27f29c9263b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48360 Commit-Queue: Antonio Maiorano Reviewed-by: Ben Clayton --- src/inspector/inspector.cc | 2 +- src/inspector/inspector_test.cc | 12 ++++---- src/intrinsic_table.cc | 4 +-- src/program_builder.h | 15 ++++++---- src/reader/spirv/parser_impl.cc | 8 +++--- .../spirv/parser_impl_convert_type_test.cc | 14 +++++----- src/reader/wgsl/parser_impl.cc | 2 +- .../wgsl/parser_impl_global_decl_test.cc | 4 +-- src/reader/wgsl/parser_impl_type_decl_test.cc | 28 +++++++++---------- src/resolver/decoration_validation_test.cc | 25 +++++++++-------- src/resolver/resolver.cc | 26 ++++++++--------- src/resolver/resolver.h | 2 +- src/sem/array.cc | 5 +++- src/sem/array.h | 8 +++--- src/sem/type_mappings.h | 4 +-- src/transform/bound_array_accessors.cc | 6 ++-- src/transform/decompose_storage_access.cc | 6 ++-- src/transform/hlsl.cc | 2 +- src/type/access_control_type_test.cc | 2 +- src/type/alias_type_test.cc | 2 +- src/type/array_type.cc | 18 ++++++------ src/type/array_type.h | 12 ++++---- src/type/array_type_test.cc | 27 +++++++++--------- src/type/bool_type_test.cc | 2 +- src/type/depth_texture_type_test.cc | 2 +- src/type/external_texture_type_test.cc | 2 +- src/type/f32_type_test.cc | 2 +- src/type/i32_type_test.cc | 2 +- src/type/matrix_type_test.cc | 2 +- src/type/multisampled_texture_type_test.cc | 2 +- src/type/pointer_type_test.cc | 2 +- src/type/sampled_texture_type_test.cc | 2 +- src/type/sampler_type_test.cc | 2 +- src/type/storage_texture_type_test.cc | 2 +- src/type/struct_type_test.cc | 2 +- src/type/u32_type_test.cc | 2 +- src/type/vector_type_test.cc | 2 +- src/writer/hlsl/generator_impl.cc | 19 +++++++------ src/writer/msl/generator_impl.cc | 20 ++++++------- ...rator_impl_variable_decl_statement_test.cc | 2 +- src/writer/spirv/builder.cc | 18 ++++++------ src/writer/spirv/builder.h | 2 +- src/writer/wgsl/generator_impl.cc | 2 +- src/writer/wgsl/generator_impl_type_test.cc | 20 ++++++------- 44 files changed, 179 insertions(+), 166 deletions(-) diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index a11a4467af..f532847b95 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -82,7 +82,7 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(type::Type* base_type) { return ResourceBinding::SampledKind::kUnknown; } - if (auto* at = base_type->As()) { + if (auto* at = base_type->As()) { base_type = at->type(); } else if (auto* mt = base_type->As()) { base_type = mt->type(); diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index 826c3b6263..62616b7e58 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -645,13 +645,13 @@ class InspectorHelper : public ProgramBuilder { return *inspector_; } - type::Array* u32_array_type(uint32_t count) { + type::ArrayType* u32_array_type(uint32_t count) { if (array_type_memo_.find(count) == array_type_memo_.end()) { array_type_memo_[count] = - create(ty.u32(), count, - ast::DecorationList{ - create(4), - }); + create(ty.u32(), count, + ast::DecorationList{ + create(4), + }); } return array_type_memo_[count]; } @@ -671,7 +671,7 @@ class InspectorHelper : public ProgramBuilder { std::unique_ptr inspector_; type::Sampler sampler_type_; type::Sampler comparison_sampler_type_; - std::map array_type_memo_; + std::map array_type_memo_; std::map, type::Vector*> vector_type_memo_; }; diff --git a/src/intrinsic_table.cc b/src/intrinsic_table.cc index 39df6a54a4..4bcd8c7183 100644 --- a/src/intrinsic_table.cc +++ b/src/intrinsic_table.cc @@ -404,7 +404,7 @@ class ArrayBuilder : public Builder { : element_builder_(element_builder) {} bool MatchUnwrapped(MatchState& state, type::Type* ty) const override { - if (auto* arr = ty->As()) { + if (auto* arr = ty->As()) { if (arr->size() == 0) { return element_builder_->Match(state, arr->type()); } @@ -414,7 +414,7 @@ class ArrayBuilder : public Builder { type::Type* Build(BuildState& state) const override { auto* el = element_builder_->Build(state); - return state.ty_mgr.Get(el, 0, ast::DecorationList{}); + return state.ty_mgr.Get(el, 0, ast::DecorationList{}); } std::string str() const override { diff --git a/src/program_builder.h b/src/program_builder.h index 8e3802c81e..a930fd52bd 100644 --- a/src/program_builder.h +++ b/src/program_builder.h @@ -490,16 +490,19 @@ class ProgramBuilder { /// @param subtype the array element type /// @param n the array size. 0 represents a runtime-array. /// @return the tint AST type for a array of size `n` of type `T` - type::Array* array(type::Type* subtype, uint32_t n = 0) const { - return builder->create(subtype, n, ast::DecorationList{}); + type::ArrayType* array(type::Type* subtype, uint32_t n = 0) const { + return builder->create(subtype, n, + ast::DecorationList{}); } /// @param subtype the array element type /// @param n the array size. 0 represents a runtime-array. /// @param stride the array stride. /// @return the tint AST type for a array of size `n` of type `T` - type::Array* array(type::Type* subtype, uint32_t n, uint32_t stride) const { - return builder->create( + type::ArrayType* array(type::Type* subtype, + uint32_t n, + uint32_t stride) const { + return builder->create( subtype, n, ast::DecorationList{ builder->create(stride), @@ -508,14 +511,14 @@ class ProgramBuilder { /// @return the tint AST type for an array of size `N` of type `T` template - type::Array* array() const { + type::ArrayType* array() const { return array(Of(), N); } /// @param stride the array stride /// @return the tint AST type for an array of size `N` of type `T` template - type::Array* array(uint32_t stride) const { + type::ArrayType* array(uint32_t stride) const { return array(Of(), N, stride); } diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index fd3ada40ff..7fc36ee842 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -762,7 +762,7 @@ type::Type* ParserImpl::ConvertType( if (!ParseArrayDecorations(rtarr_ty, &decorations)) { return nullptr; } - return create(ast_elem_ty, 0, std::move(decorations)); + return create(ast_elem_ty, 0, std::move(decorations)); } type::Type* ParserImpl::ConvertType( @@ -807,8 +807,8 @@ type::Type* ParserImpl::ConvertType( if (remap_buffer_block_type_.count(elem_type_id)) { remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty)); } - return create(ast_elem_ty, static_cast(num_elem), - std::move(decorations)); + return create(ast_elem_ty, static_cast(num_elem), + std::move(decorations)); } bool ParserImpl::ParseArrayDecorations( @@ -1493,7 +1493,7 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) { return create(Source{}, type, std::move(ast_components)); } - if (auto* arr_ty = type->As()) { + if (auto* arr_ty = type->As()) { ast::ExpressionList ast_components; for (size_t i = 0; i < arr_ty->size(); ++i) { ast_components.emplace_back(MakeNullValue(arr_ty->type())); diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc index ab21b4db01..b1ccd149cf 100644 --- a/src/reader/spirv/parser_impl_convert_type_test.cc +++ b/src/reader/spirv/parser_impl_convert_type_test.cc @@ -326,8 +326,8 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); EXPECT_TRUE(arr_type->IsRuntimeArray()); ASSERT_NE(arr_type, nullptr); EXPECT_EQ(arr_type->size(), 0u); @@ -361,7 +361,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - auto* arr_type = type->As(); + auto* arr_type = type->As(); EXPECT_TRUE(arr_type->IsRuntimeArray()); ASSERT_NE(arr_type, nullptr); ASSERT_EQ(arr_type->decorations().size(), 1u); @@ -409,8 +409,8 @@ TEST_F(SpvParserTest, ConvertType_Array) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); EXPECT_FALSE(arr_type->IsRuntimeArray()); ASSERT_NE(arr_type, nullptr); EXPECT_EQ(arr_type->size(), 42u); @@ -496,8 +496,8 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); ASSERT_NE(arr_type, nullptr); ASSERT_EQ(arr_type->decorations().size(), 1u); diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 794cad8615..f7ee20fb59 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -1052,7 +1052,7 @@ Expect ParserImpl::expect_type_decl_array( size = val.value; } - return create(subtype.value, size, std::move(decos)); + return create(subtype.value, size, std::move(decos)); }); } diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc index afef34e7ba..1bbb9bd151 100644 --- a/src/reader/wgsl/parser_impl_global_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_decl_test.cc @@ -191,8 +191,8 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) { EXPECT_FALSE(str->IsBlockDecorated()); const auto* ty = str->impl()->members()[0]->type(); - ASSERT_TRUE(ty->Is()); - const auto* arr = ty->As(); + ASSERT_TRUE(ty->Is()); + const auto* arr = ty->As(); ASSERT_EQ(arr->decorations().size(), 1u); auto* stride = arr->decorations()[0]; diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc index 995c41160b..66fc791dfc 100644 --- a/src/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/reader/wgsl/parser_impl_type_decl_test.cc @@ -338,9 +338,9 @@ TEST_F(ParserImplTest, TypeDecl_Array) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_FALSE(a->IsRuntimeArray()); ASSERT_EQ(a->size(), 5u); ASSERT_TRUE(a->type()->Is()); @@ -354,9 +354,9 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_FALSE(a->IsRuntimeArray()); ASSERT_EQ(a->size(), 5u); ASSERT_TRUE(a->type()->Is()); @@ -374,9 +374,9 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); ASSERT_TRUE(a->type()->Is()); @@ -393,9 +393,9 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); ASSERT_TRUE(a->type()->Is()); @@ -414,9 +414,9 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); ASSERT_TRUE(a->type()->Is()); @@ -517,9 +517,9 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); ASSERT_TRUE(a->type()->Is()); } @@ -531,9 +531,9 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Vec) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); ASSERT_TRUE(a->type()->is_unsigned_integer_vector()); } diff --git a/src/resolver/decoration_validation_test.cc b/src/resolver/decoration_validation_test.cc index ea372e540f..cb3455edad 100644 --- a/src/resolver/decoration_validation_test.cc +++ b/src/resolver/decoration_validation_test.cc @@ -127,9 +127,10 @@ TEST_P(ArrayDecorationTest, IsValid) { auto& params = GetParam(); ast::StructMemberList members{Member( - "a", create(ty.f32(), 0, - ast::DecorationList{createDecoration( - Source{{12, 34}}, *this, params.kind)}))}; + "a", + create(ty.f32(), 0, + ast::DecorationList{createDecoration( + Source{{12, 34}}, *this, params.kind)}))}; auto* s = create( members, ast::DecorationList{create()}); auto* s_ty = ty.struct_("mystruct", s); @@ -333,10 +334,10 @@ TEST_P(ArrayStrideTest, All) { SCOPED_TRACE(ss.str()); auto* arr = - create(el_ty, 4, - ast::DecorationList{ - create(params.stride), - }); + create(el_ty, 4, + ast::DecorationList{ + create(params.stride), + }); Global(Source{{12, 34}}, "myarray", arr, ast::StorageClass::kInput); @@ -421,11 +422,11 @@ INSTANTIATE_TEST_SUITE_P( Params{ty_mat4x4, (default_mat4x4.align - 1) * 7, false})); TEST_F(ArrayStrideTest, MultipleDecorations) { - auto* arr = create(ty.i32(), 4, - ast::DecorationList{ - create(4), - create(4), - }); + auto* arr = create(ty.i32(), 4, + ast::DecorationList{ + create(4), + create(4), + }); Global(Source{{12, 34}}, "myarray", arr, ast::StorageClass::kInput); diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index 31f9dcce09..ed826d7c04 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -123,7 +123,7 @@ bool Resolver::IsStorable(type::Type* type) { type->Is()) { return true; } - if (type::Array* arr = type->As()) { + if (type::ArrayType* arr = type->As()) { return IsStorable(arr->type()); } if (type::Struct* str = type->As()) { @@ -149,7 +149,7 @@ bool Resolver::IsHostShareable(type::Type* type) { if (auto* mat = type->As()) { return IsHostShareable(mat->type()); } - if (auto* arr = type->As()) { + if (auto* arr = type->As()) { return IsHostShareable(arr->type()); } if (auto* str = type->As()) { @@ -228,7 +228,7 @@ bool Resolver::Type(type::Type* ty) { if (!Structure(str)) { return false; } - } else if (auto* arr = ty->As()) { + } else if (auto* arr = ty->As()) { if (!Array(arr, Source{})) { return false; } @@ -248,7 +248,7 @@ Resolver::VariableInfo* Resolver::Variable(ast::Variable* var, variable_to_info_.emplace(var, info); // Resolve variable's type - if (auto* arr = info->type->As()) { + if (auto* arr = info->type->As()) { if (!Array(arr, var->source())) { return nullptr; } @@ -358,7 +358,7 @@ bool Resolver::ValidateGlobalVariable(const VariableInfo* info) { bool Resolver::ValidateVariable(const ast::Variable* var) { auto* type = variable_to_info_[var]->type; - if (auto* r = type->UnwrapAll()->As()) { + if (auto* r = type->UnwrapAll()->As()) { if (r->IsRuntimeArray()) { diagnostics_.add_error( "v-0015", @@ -568,7 +568,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { builder_->Symbols().NameFor(func->symbol()), func->source()); return false; - } else if (auto* arr = member_ty->As()) { + } else if (auto* arr = member_ty->As()) { if (arr->IsRuntimeArray()) { diagnostics_.add_error( "entry point IO types cannot contain runtime sized arrays", @@ -946,7 +946,7 @@ bool Resolver::ArrayAccessor(ast::ArrayAccessorExpression* expr) { auto* res = TypeOf(expr->array()); auto* parent_type = res->UnwrapAll(); type::Type* ret = nullptr; - if (auto* arr = parent_type->As()) { + if (auto* arr = parent_type->As()) { ret = arr->type(); } else if (auto* vec = parent_type->As()) { ret = vec->type(); @@ -962,7 +962,7 @@ bool Resolver::ArrayAccessor(ast::ArrayAccessorExpression* expr) { // If we're extracting from a pointer, we return a pointer. if (auto* ptr = res->As()) { ret = builder_->create(ret, ptr->storage_class()); - } else if (auto* arr = parent_type->As()) { + } else if (auto* arr = parent_type->As()) { if (!arr->type()->is_scalar()) { // If we extract a non-scalar from an array then we also get a pointer. We // will generate a Function storage class variable to store this into. @@ -1916,9 +1916,9 @@ bool Resolver::DefaultAlignAndSize(type::Type* ty, return true; } return false; - } else if (cty->Is()) { + } else if (cty->Is()) { if (auto* sem = - Array(ty->UnwrapAliasIfNeeded()->As(), source)) { + Array(ty->UnwrapAliasIfNeeded()->As(), source)) { align = sem->Align(); size = sem->Size(); return true; @@ -1929,7 +1929,7 @@ bool Resolver::DefaultAlignAndSize(type::Type* ty, return false; } -const sem::Array* Resolver::Array(type::Array* arr, const Source& source) { +const sem::Array* Resolver::Array(type::ArrayType* arr, const Source& source) { if (auto* sem = builder_->Sem().Get(arr)) { // Semantic info already constructed for this array type return sem; @@ -2000,7 +2000,7 @@ const sem::Array* Resolver::Array(type::Array* arr, const Source& source) { bool Resolver::ValidateStructure(const type::Struct* st) { for (auto* member : st->impl()->members()) { - if (auto* r = member->type()->UnwrapAll()->As()) { + if (auto* r = member->type()->UnwrapAll()->As()) { if (r->IsRuntimeArray()) { if (member != st->impl()->members().back()) { diagnostics_.add_error( @@ -2391,7 +2391,7 @@ bool Resolver::ApplyStorageClassUsageToType(ast::StorageClass sc, return true; } - if (auto* arr = ty->As()) { + if (auto* arr = ty->As()) { return ApplyStorageClassUsageToType(sc, arr->type(), usage); } diff --git a/src/resolver/resolver.h b/src/resolver/resolver.h index 321d0aaa16..067941e9c3 100644 --- a/src/resolver/resolver.h +++ b/src/resolver/resolver.h @@ -256,7 +256,7 @@ class Resolver { /// returned. /// @param arr the Array to get semantic information for /// @param source the Source of the ast node with this array as its type - const sem::Array* Array(type::Array* arr, const Source& source); + const sem::Array* Array(type::ArrayType* arr, const Source& source); /// @returns the StructInfo for the structure `str`, building it if it hasn't /// been constructed already. If an error is raised, nullptr is returned. diff --git a/src/sem/array.cc b/src/sem/array.cc index 7dc6aa903f..2126a53349 100644 --- a/src/sem/array.cc +++ b/src/sem/array.cc @@ -19,7 +19,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::Array); namespace tint { namespace sem { -Array::Array(type::Array* type, uint32_t align, uint32_t size, uint32_t stride) +Array::Array(type::ArrayType* type, + uint32_t align, + uint32_t size, + uint32_t stride) : type_(type), align_(align), size_(size), stride_(stride) {} } // namespace sem diff --git a/src/sem/array.h b/src/sem/array.h index e2c98d683a..c9861c68c4 100644 --- a/src/sem/array.h +++ b/src/sem/array.h @@ -23,7 +23,7 @@ namespace tint { // Forward declarations namespace type { -class Array; +class ArrayType; } // namespace type namespace sem { @@ -37,10 +37,10 @@ class Array : public Castable { /// @param size the byte size of the structure /// @param stride the number of bytes from the start of one element of the /// array to the start of the next element - Array(type::Array* type, uint32_t align, uint32_t size, uint32_t stride); + Array(type::ArrayType* type, uint32_t align, uint32_t size, uint32_t stride); /// @return the resolved type of the Array - type::Array* Type() const { return type_; } + type::ArrayType* Type() const { return type_; } /// @returns the byte alignment of the array /// @note this may differ from the alignment of a structure member of this @@ -57,7 +57,7 @@ class Array : public Castable { uint32_t Stride() const { return stride_; } private: - type::Array* const type_; + type::ArrayType* const type_; uint32_t const align_; uint32_t const size_; uint32_t const stride_; diff --git a/src/sem/type_mappings.h b/src/sem/type_mappings.h index 2787bbe66f..b92bc4c018 100644 --- a/src/sem/type_mappings.h +++ b/src/sem/type_mappings.h @@ -30,7 +30,7 @@ class StructMember; class Variable; } // namespace ast namespace type { -class Array; +class ArrayType; class Struct; } // namespace type @@ -53,7 +53,7 @@ class Variable; /// rules will be used to infer the return type based on the argument type. struct TypeMappings { //! @cond Doxygen_Suppress - Array* operator()(type::Array*); + Array* operator()(type::ArrayType*); Call* operator()(ast::CallExpression*); Expression* operator()(ast::Expression*); Function* operator()(ast::Function*); diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc index 55485a413b..c08495e551 100644 --- a/src/transform/bound_array_accessors.cc +++ b/src/transform/bound_array_accessors.cc @@ -42,7 +42,7 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( auto& diags = ctx->dst->Diagnostics(); auto* ret_type = ctx->src->Sem().Get(expr->array())->Type()->UnwrapAll(); - if (!ret_type->Is() && !ret_type->Is() && + if (!ret_type->Is() && !ret_type->Is() && !ret_type->Is()) { return nullptr; } @@ -52,10 +52,10 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( uint32_t size = 0; bool is_vec = ret_type->Is(); - bool is_arr = ret_type->Is(); + bool is_arr = ret_type->Is(); if (is_vec || is_arr) { size = is_vec ? ret_type->As()->size() - : ret_type->As()->size(); + : ret_type->As()->size(); } else { // The row accessor would have been an embedded array accessor and already // handled, so we just need to do columns here. diff --git a/src/transform/decompose_storage_access.cc b/src/transform/decompose_storage_access.cc index fb77b550d4..002d32f41e 100644 --- a/src/transform/decompose_storage_access.cc +++ b/src/transform/decompose_storage_access.cc @@ -447,7 +447,7 @@ struct State { member->Declaration()->type()->UnwrapAll()); values.emplace_back(ctx.dst->Call(load, "buffer", offset)); } - } else if (auto* arr_ty = el_ty->As()) { + } else if (auto* arr_ty = el_ty->As()) { auto& sem = ctx.src->Sem(); auto* arr = sem.Get(arr_ty); for (uint32_t i = 0; i < arr_ty->size(); i++) { @@ -518,7 +518,7 @@ struct State { auto* call = ctx.dst->Call(store, "buffer", offset, access); body.emplace_back(ctx.dst->create(call)); } - } else if (auto* arr_ty = el_ty->As()) { + } else if (auto* arr_ty = el_ty->As()) { auto& sem = ctx.src->Sem(); auto* arr = sem.Get(arr_ty); for (uint32_t i = 0; i < arr_ty->size(); i++) { @@ -678,7 +678,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) { if (auto* accessor = node->As()) { if (auto access = state.TakeAccess(accessor->array())) { // X[Y] - if (auto* arr_ty = access.type->As()) { + if (auto* arr_ty = access.type->As()) { auto stride = sem.Get(arr_ty)->Stride(); auto offset = Mul(stride, accessor->idx_expr()); state.AddAccesss(accessor, diff --git a/src/transform/hlsl.cc b/src/transform/hlsl.cc index 83d309ec88..6fa55dc443 100644 --- a/src/transform/hlsl.cc +++ b/src/transform/hlsl.cc @@ -96,7 +96,7 @@ void Hlsl::PromoteInitializersToConstVar(CloneContext& ctx) const { } auto* src_ty = src_sem_expr->Type(); - if (src_ty->IsAnyOf()) { + if (src_ty->IsAnyOf()) { // Create a new symbol for the constant auto dst_symbol = ctx.dst->Symbols().New(); // Clone the type diff --git a/src/type/access_control_type_test.cc b/src/type/access_control_type_test.cc index e390400103..2ce685628e 100644 --- a/src/type/access_control_type_test.cc +++ b/src/type/access_control_type_test.cc @@ -37,7 +37,7 @@ TEST_F(AccessControlTest, Is) { Type* ty = &at; EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/alias_type_test.cc b/src/type/alias_type_test.cc index cb7e51ee3a..b9f5c2b7cb 100644 --- a/src/type/alias_type_test.cc +++ b/src/type/alias_type_test.cc @@ -33,7 +33,7 @@ TEST_F(AliasTest, Is) { type::Type* ty = at; EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/array_type.cc b/src/type/array_type.cc index d84c36b49f..f7f7208a8b 100644 --- a/src/type/array_type.cc +++ b/src/type/array_type.cc @@ -18,19 +18,21 @@ #include "src/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::type::Array); +TINT_INSTANTIATE_TYPEINFO(tint::type::ArrayType); namespace tint { namespace type { -Array::Array(Type* subtype, uint32_t size, ast::DecorationList decorations) +ArrayType::ArrayType(Type* subtype, + uint32_t size, + ast::DecorationList decorations) : subtype_(subtype), size_(size), decos_(decorations) {} -Array::Array(Array&&) = default; +ArrayType::ArrayType(ArrayType&&) = default; -Array::~Array() = default; +ArrayType::~ArrayType() = default; -std::string Array::type_name() const { +std::string ArrayType::type_name() const { TINT_ASSERT(subtype_); std::string type_name = "__array" + subtype_->type_name(); @@ -46,7 +48,7 @@ std::string Array::type_name() const { return type_name; } -std::string Array::FriendlyName(const SymbolTable& symbols) const { +std::string ArrayType::FriendlyName(const SymbolTable& symbols) const { std::ostringstream out; for (auto* deco : decos_) { if (auto* stride = deco->As()) { @@ -61,11 +63,11 @@ std::string Array::FriendlyName(const SymbolTable& symbols) const { return out.str(); } -Array* Array::Clone(CloneContext* ctx) const { +ArrayType* ArrayType::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto* ty = ctx->Clone(type()); auto decos = ctx->Clone(decorations()); - return ctx->dst->create(ty, size_, decos); + return ctx->dst->create(ty, size_, decos); } } // namespace type diff --git a/src/type/array_type.h b/src/type/array_type.h index 73456bc4fa..2dc8228010 100644 --- a/src/type/array_type.h +++ b/src/type/array_type.h @@ -24,17 +24,19 @@ namespace tint { namespace type { /// An array type. If size is zero then it is a runtime array. -class Array : public Castable { +// TODO(amaiorano): https://crbug.com/tint/724 Fold into sem::Array once parsers +// don't create this anymore. +class ArrayType : public Castable { public: /// Constructor /// @param subtype the type of the array elements /// @param size the number of elements in the array. `0` represents a /// runtime-sized array. /// @param decorations the array decorations - Array(Type* subtype, uint32_t size, ast::DecorationList decorations); + ArrayType(Type* subtype, uint32_t size, ast::DecorationList decorations); /// Move constructor - Array(Array&&); - ~Array() override; + ArrayType(ArrayType&&); + ~ArrayType() override; /// @returns true if this is a runtime array. /// i.e. the size is determined at runtime @@ -59,7 +61,7 @@ class Array : public Castable { /// Clones this type and all transitive types using the `CloneContext` `ctx`. /// @param ctx the clone context /// @return the newly cloned type - Array* Clone(CloneContext* ctx) const override; + ArrayType* Clone(CloneContext* ctx) const override; private: Type* const subtype_; diff --git a/src/type/array_type_test.cc b/src/type/array_type_test.cc index 062adddc1d..8986d104ee 100644 --- a/src/type/array_type_test.cc +++ b/src/type/array_type_test.cc @@ -24,30 +24,30 @@ using ArrayTest = TestHelper; TEST_F(ArrayTest, CreateSizedArray) { U32 u32; - Array arr{&u32, 3, ast::DecorationList{}}; + ArrayType arr{&u32, 3, ast::DecorationList{}}; EXPECT_EQ(arr.type(), &u32); EXPECT_EQ(arr.size(), 3u); - EXPECT_TRUE(arr.Is()); + EXPECT_TRUE(arr.Is()); EXPECT_FALSE(arr.IsRuntimeArray()); } TEST_F(ArrayTest, CreateRuntimeArray) { U32 u32; - Array arr{&u32, 0, ast::DecorationList{}}; + ArrayType arr{&u32, 0, ast::DecorationList{}}; EXPECT_EQ(arr.type(), &u32); EXPECT_EQ(arr.size(), 0u); - EXPECT_TRUE(arr.Is()); + EXPECT_TRUE(arr.Is()); EXPECT_TRUE(arr.IsRuntimeArray()); } TEST_F(ArrayTest, Is) { I32 i32; - Array arr{&i32, 3, ast::DecorationList{}}; + ArrayType arr{&i32, 3, ast::DecorationList{}}; Type* ty = &arr; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); + EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); @@ -62,35 +62,36 @@ TEST_F(ArrayTest, Is) { TEST_F(ArrayTest, TypeName) { I32 i32; - Array arr{&i32, 0, ast::DecorationList{}}; + ArrayType arr{&i32, 0, ast::DecorationList{}}; EXPECT_EQ(arr.type_name(), "__array__i32"); } TEST_F(ArrayTest, FriendlyNameRuntimeSized) { - Array arr{ty.i32(), 0, ast::DecorationList{}}; + ArrayType arr{ty.i32(), 0, ast::DecorationList{}}; EXPECT_EQ(arr.FriendlyName(Symbols()), "array"); } TEST_F(ArrayTest, FriendlyNameStaticSized) { - Array arr{ty.i32(), 5, ast::DecorationList{}}; + ArrayType arr{ty.i32(), 5, ast::DecorationList{}}; EXPECT_EQ(arr.FriendlyName(Symbols()), "array"); } TEST_F(ArrayTest, FriendlyNameWithStride) { - Array arr{ty.i32(), 5, - ast::DecorationList{create(32)}}; + ArrayType arr{ty.i32(), 5, + ast::DecorationList{create(32)}}; EXPECT_EQ(arr.FriendlyName(Symbols()), "[[stride(32)]] array"); } TEST_F(ArrayTest, TypeName_RuntimeArray) { I32 i32; - Array arr{&i32, 3, ast::DecorationList{}}; + ArrayType arr{&i32, 3, ast::DecorationList{}}; EXPECT_EQ(arr.type_name(), "__array__i32_3"); } TEST_F(ArrayTest, TypeName_WithStride) { I32 i32; - Array arr{&i32, 3, ast::DecorationList{create(16)}}; + ArrayType arr{&i32, 3, + ast::DecorationList{create(16)}}; EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16"); } diff --git a/src/type/bool_type_test.cc b/src/type/bool_type_test.cc index 7751c53de4..bd96693a8f 100644 --- a/src/type/bool_type_test.cc +++ b/src/type/bool_type_test.cc @@ -27,7 +27,7 @@ TEST_F(BoolTest, Is) { Type* ty = &b; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/depth_texture_type_test.cc b/src/type/depth_texture_type_test.cc index 8406febe9b..10364c0623 100644 --- a/src/type/depth_texture_type_test.cc +++ b/src/type/depth_texture_type_test.cc @@ -32,7 +32,7 @@ TEST_F(DepthTextureTest, Is) { Type* ty = &d; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/external_texture_type_test.cc b/src/type/external_texture_type_test.cc index c1811595d0..1129c9262d 100644 --- a/src/type/external_texture_type_test.cc +++ b/src/type/external_texture_type_test.cc @@ -33,7 +33,7 @@ TEST_F(ExternalTextureTest, Is) { Type* ty = &s; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/f32_type_test.cc b/src/type/f32_type_test.cc index 2985597599..23686a4807 100644 --- a/src/type/f32_type_test.cc +++ b/src/type/f32_type_test.cc @@ -27,7 +27,7 @@ TEST_F(F32Test, Is) { Type* ty = &f; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/i32_type_test.cc b/src/type/i32_type_test.cc index 38aca922d9..9170155f9e 100644 --- a/src/type/i32_type_test.cc +++ b/src/type/i32_type_test.cc @@ -27,7 +27,7 @@ TEST_F(I32Test, Is) { Type* ty = &i; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); diff --git a/src/type/matrix_type_test.cc b/src/type/matrix_type_test.cc index 09dc8f01ca..40c7d5c1f1 100644 --- a/src/type/matrix_type_test.cc +++ b/src/type/matrix_type_test.cc @@ -36,7 +36,7 @@ TEST_F(MatrixTest, Is) { Type* ty = &m; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/multisampled_texture_type_test.cc b/src/type/multisampled_texture_type_test.cc index 2e15846ac2..bcafafc712 100644 --- a/src/type/multisampled_texture_type_test.cc +++ b/src/type/multisampled_texture_type_test.cc @@ -33,7 +33,7 @@ TEST_F(MultisampledTextureTest, Is) { Type* ty = &s; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/pointer_type_test.cc b/src/type/pointer_type_test.cc index f79211c245..65c517853a 100644 --- a/src/type/pointer_type_test.cc +++ b/src/type/pointer_type_test.cc @@ -35,7 +35,7 @@ TEST_F(PointerTest, Is) { Type* ty = &p; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/sampled_texture_type_test.cc b/src/type/sampled_texture_type_test.cc index 3dc6c38b5b..bfbaff8821 100644 --- a/src/type/sampled_texture_type_test.cc +++ b/src/type/sampled_texture_type_test.cc @@ -32,7 +32,7 @@ TEST_F(SampledTextureTest, Is) { Type* ty = &s; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/sampler_type_test.cc b/src/type/sampler_type_test.cc index a3ea06d39e..fb6ccdf3dc 100644 --- a/src/type/sampler_type_test.cc +++ b/src/type/sampler_type_test.cc @@ -38,7 +38,7 @@ TEST_F(SamplerTest, Is) { Type* ty = &s; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/storage_texture_type_test.cc b/src/type/storage_texture_type_test.cc index ff8efc7876..4dee89c960 100644 --- a/src/type/storage_texture_type_test.cc +++ b/src/type/storage_texture_type_test.cc @@ -34,7 +34,7 @@ TEST_F(StorageTextureTest, Is) { Type* ty = s; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/struct_type_test.cc b/src/type/struct_type_test.cc index 6ea9bb227b..c90bf4803a 100644 --- a/src/type/struct_type_test.cc +++ b/src/type/struct_type_test.cc @@ -37,7 +37,7 @@ TEST_F(StructTypeTest, Is) { type::Type* ty = s; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/u32_type_test.cc b/src/type/u32_type_test.cc index c320cb55af..af3752d3a9 100644 --- a/src/type/u32_type_test.cc +++ b/src/type/u32_type_test.cc @@ -27,7 +27,7 @@ TEST_F(U32Test, Is) { Type* ty = &u; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/vector_type_test.cc b/src/type/vector_type_test.cc index 8c4a793055..ab0cf3c67e 100644 --- a/src/type/vector_type_test.cc +++ b/src/type/vector_type_test.cc @@ -35,7 +35,7 @@ TEST_F(VectorTest, Is) { Type* ty = &v; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index fed3572e07..f4741ce17d 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -1315,8 +1315,9 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& pre, return EmitZeroValue(out, expr->type()); } - bool brackets = - expr->type()->UnwrapAliasIfNeeded()->IsAnyOf(); + bool brackets = expr->type() + ->UnwrapAliasIfNeeded() + ->IsAnyOf(); if (brackets) { out << "{"; @@ -1643,7 +1644,7 @@ bool GeneratorImpl::EmitFunctionInternal(std::ostream& out, return false; } // Array name is output as part of the type - if (!type->Is()) { + if (!type->Is()) { out << " " << builder_.Symbols().NameFor(v->symbol()); } } @@ -1909,7 +1910,7 @@ bool GeneratorImpl::EmitEntryPointData( if (!EmitType(out, var->DeclaredType(), var->StorageClass(), name)) { return false; } - if (!var->DeclaredType()->UnwrapAliasIfNeeded()->Is()) { + if (!var->DeclaredType()->UnwrapAliasIfNeeded()->Is()) { out << " " << name; } @@ -2397,10 +2398,10 @@ bool GeneratorImpl::EmitType(std::ostream& out, if (auto* alias = type->As()) { out << builder_.Symbols().NameFor(alias->symbol()); - } else if (auto* ary = type->As()) { + } else if (auto* ary = type->As()) { type::Type* base_type = ary; std::vector sizes; - while (auto* arr = base_type->As()) { + while (auto* arr = base_type->As()) { if (arr->IsRuntimeArray()) { TINT_ICE(diagnostics_) << "Runtime arrays may only exist in storage buffers, which should " @@ -2564,7 +2565,7 @@ bool GeneratorImpl::EmitStructType(std::ostream& out, return false; } // Array member name will be output with the type - if (!mem->type()->Is()) { + if (!mem->type()->Is()) { out << " " << builder_.Symbols().NameFor(mem->symbol()); } @@ -2663,7 +2664,7 @@ bool GeneratorImpl::EmitVariable(std::ostream& out, builder_.Symbols().NameFor(var->symbol()))) { return false; } - if (!type->Is()) { + if (!type->Is()) { out << " " << builder_.Symbols().NameFor(var->symbol()); } out << constructor_out.str() << ";" << std::endl; @@ -2725,7 +2726,7 @@ bool GeneratorImpl::EmitProgramConstVariable(std::ostream& out, builder_.Symbols().NameFor(var->symbol()))) { return false; } - if (!type->Is()) { + if (!type->Is()) { out << " " << builder_.Symbols().NameFor(var->symbol()); } diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index b50c263c87..30016a5edf 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -886,7 +886,7 @@ bool GeneratorImpl::EmitContinue(ast::ContinueStatement*) { } bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { - if (expr->type()->IsAnyOf()) { + if (expr->type()->IsAnyOf()) { out_ << "{"; } else { if (!EmitType(expr->type(), "")) { @@ -915,7 +915,7 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { } } - if (expr->type()->IsAnyOf()) { + if (expr->type()->IsAnyOf()) { out_ << "}"; } else { out_ << ")"; @@ -936,7 +936,7 @@ bool GeneratorImpl::EmitZeroValue(type::Type* type) { return EmitZeroValue(vec->type()); } else if (auto* mat = type->As()) { return EmitZeroValue(mat->type()); - } else if (auto* arr = type->As()) { + } else if (auto* arr = type->As()) { out_ << "{"; if (!EmitZeroValue(arr->type())) { return false; @@ -1325,7 +1325,7 @@ bool GeneratorImpl::EmitFunctionInternal(ast::Function* func, return false; } // Array name is output as part of the type - if (!type->Is()) { + if (!type->Is()) { out_ << " " << program_->Symbols().NameFor(v->symbol()); } } @@ -1908,10 +1908,10 @@ bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) { if (auto* alias = type->As()) { out_ << program_->Symbols().NameFor(alias->symbol()); - } else if (auto* ary = type->As()) { + } else if (auto* ary = type->As()) { type::Type* base_type = ary; std::vector sizes; - while (auto* arr = base_type->As()) { + while (auto* arr = base_type->As()) { if (arr->IsRuntimeArray()) { sizes.push_back(1); } else { @@ -2120,7 +2120,7 @@ bool GeneratorImpl::EmitStructType(const type::Struct* str) { auto* ty = mem->type()->UnwrapAliasIfNeeded(); // Array member name will be output with the type - if (!ty->Is()) { + if (!ty->Is()) { out_ << " " << program_->Symbols().NameFor(mem->symbol()); } @@ -2222,7 +2222,7 @@ bool GeneratorImpl::EmitVariable(const sem::Variable* var, if (!EmitType(var->Type(), program_->Symbols().NameFor(decl->symbol()))) { return false; } - if (!var->Type()->Is()) { + if (!var->Type()->Is()) { out_ << " " << program_->Symbols().NameFor(decl->symbol()); } @@ -2265,7 +2265,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) { if (!EmitType(type, program_->Symbols().NameFor(var->symbol()))) { return false; } - if (!type->Is()) { + if (!type->Is()) { out_ << " " << program_->Symbols().NameFor(var->symbol()); } @@ -2326,7 +2326,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign( } } - if (auto* arr = ty->As()) { + if (auto* arr = ty->As()) { auto* sem = program_->Sem().Get(arr); if (!sem) { TINT_ICE(diagnostics_) << "Array missing semantic info"; diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc index 9b6e19e93d..72d6ade695 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -52,7 +52,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) { - type::Array ary(ty.f32(), 5, ast::DecorationList{}); + type::ArrayType ary(ty.f32(), 5, ast::DecorationList{}); auto* var = Var("a", &ary, ast::StorageClass::kNone); auto* stmt = create(var); diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 4482b7db49..3d955f85be 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -112,7 +112,7 @@ uint32_t IndexFromName(char name) { /// @param type the given type, which must not be null /// @returns the nested matrix type, or nullptr if none type::Matrix* GetNestedMatrixType(type::Type* type) { - while (auto* arr = type->As()) { + while (auto* arr = type->As()) { type = arr->type(); } return type->As(); @@ -827,8 +827,8 @@ bool Builder::GenerateArrayAccessor(ast::ArrayAccessorExpression* expr, // If the source is a pointer we access chain into it. We also access chain // into an array of non-scalar types. if (info->source_type->Is() || - (info->source_type->Is() && - !info->source_type->As()->type()->is_scalar())) { + (info->source_type->Is() && + !info->source_type->As()->type()->is_scalar())) { info->access_chain_indices.push_back(idx_id); info->source_type = TypeOf(expr); return true; @@ -1045,8 +1045,8 @@ uint32_t Builder::GenerateAccessorExpression(ast::Expression* expr) { auto* ary_res_type = TypeOf(array->array()); if (!ary_res_type->Is() && - (ary_res_type->Is() && - !ary_res_type->As()->type()->is_scalar())) { + (ary_res_type->Is() && + !ary_res_type->As()->type()->is_scalar())) { type::Pointer ptr(ary_res_type, ast::StorageClass::kFunction); auto result_type_id = GenerateTypeIfNeeded(&ptr); if (result_type_id == 0) { @@ -1250,7 +1250,7 @@ bool Builder::is_constructor_const(ast::Expression* expr, bool is_global_init) { subtype = vec->type()->UnwrapAll(); } else if (auto* mat = subtype->As()) { subtype = mat->type()->UnwrapAll(); - } else if (auto* arr = subtype->As()) { + } else if (auto* arr = subtype->As()) { subtype = arr->type()->UnwrapAll(); } else if (auto* str = subtype->As()) { subtype = str->impl()->members()[i]->type()->UnwrapAll(); @@ -1329,7 +1329,7 @@ uint32_t Builder::GenerateTypeConstructorExpression( // If the result is not a vector then we should have validated that the // value type is a correctly sized vector so we can just use it directly. if (result_type == value_type || result_type->Is() || - result_type->Is() || result_type->Is()) { + result_type->Is() || result_type->Is()) { out << "_" << id; ops.push_back(Operand::Int(id)); @@ -2953,7 +2953,7 @@ uint32_t Builder::GenerateTypeIfNeeded(type::Type* type) { result)) { return 0; } - } else if (auto* arr = type->As()) { + } else if (auto* arr = type->As()) { if (!GenerateArrayType(arr, result)) { return 0; } @@ -3084,7 +3084,7 @@ bool Builder::GenerateTextureType(type::Texture* texture, return true; } -bool Builder::GenerateArrayType(type::Array* ary, const Operand& result) { +bool Builder::GenerateArrayType(type::ArrayType* ary, const Operand& result) { auto elem_type = GenerateTypeIfNeeded(ary->type()); if (elem_type == 0) { return false; diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h index d66c4e2f6c..d70280b295 100644 --- a/src/writer/spirv/builder.h +++ b/src/writer/spirv/builder.h @@ -433,7 +433,7 @@ class Builder { /// @param ary the array to generate /// @param result the result operand /// @returns true if the array was successfully generated - bool GenerateArrayType(type::Array* ary, const Operand& result); + bool GenerateArrayType(type::ArrayType* ary, const Operand& result); /// Generates a matrix type declaration /// @param mat the matrix to generate /// @param result the result operand diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index a93a5bf234..eeb9fc62c4 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -390,7 +390,7 @@ bool GeneratorImpl::EmitType(type::Type* type) { return true; } else if (auto* alias = type->As()) { out_ << program_->Symbols().NameFor(alias->symbol()); - } else if (auto* ary = type->As()) { + } else if (auto* ary = type->As()) { for (auto* deco : ary->decorations()) { if (auto* stride = deco->As()) { out_ << "[[stride(" << stride->stride() << ")]] "; diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc index 85c6cdc719..87f9df1f76 100644 --- a/src/writer/wgsl/generator_impl_type_test.cc +++ b/src/writer/wgsl/generator_impl_type_test.cc @@ -73,10 +73,10 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) { } TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) { - auto* a = create(ty.bool_(), 4, - ast::DecorationList{ - create(16u), - }); + auto* a = create(ty.bool_(), 4, + ast::DecorationList{ + create(16u), + }); AST().AddConstructedType(ty.alias("make_type_reachable", a)); GeneratorImpl& gen = Build(); @@ -86,11 +86,11 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) { } TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) { - auto* a = create(ty.bool_(), 4, - ast::DecorationList{ - create(16u), - create(32u), - }); + auto* a = create(ty.bool_(), 4, + ast::DecorationList{ + create(16u), + create(32u), + }); AST().AddConstructedType(ty.alias("make_type_reachable", a)); GeneratorImpl& gen = Build(); @@ -100,7 +100,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) { } TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) { - auto* a = create(ty.bool_(), 0, ast::DecorationList{}); + auto* a = create(ty.bool_(), 0, ast::DecorationList{}); AST().AddConstructedType(ty.alias("make_type_reachable", a)); GeneratorImpl& gen = Build();