From 12fa30389926a804e6f25414ea987817e2c364e0 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Wed, 19 Apr 2023 23:52:33 +0000 Subject: [PATCH] Move castable into utils. The Castable class is used by utils/. This Cl moves the implementation into the utils/ folder. The `Is` and `As` methods are added into the `tint` namespace to make usage shorter. Change-Id: I0decedb92ebed01b6aa12d2e3efa7190742e9a33 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127402 Commit-Queue: Dan Sinclair Kokoro: Kokoro Reviewed-by: Ben Clayton --- docs/tint/style_guide.md | 2 +- src/tint/BUILD.gn | 6 +- src/tint/CMakeLists.txt | 6 +- src/tint/ast/accessor_expression.h | 2 +- src/tint/ast/alias.h | 2 +- src/tint/ast/assignment_statement.h | 2 +- src/tint/ast/attribute.h | 2 +- src/tint/ast/binary_expression.h | 2 +- src/tint/ast/binding_attribute.h | 2 +- src/tint/ast/bitcast_expression.h | 2 +- src/tint/ast/block_statement.h | 2 +- src/tint/ast/bool_literal_expression.h | 3 +- src/tint/ast/break_if_statement.h | 2 +- src/tint/ast/break_statement.h | 2 +- src/tint/ast/builtin_attribute.h | 2 +- src/tint/ast/call_expression.h | 2 +- src/tint/ast/call_statement.h | 2 +- src/tint/ast/case_selector.h | 2 +- src/tint/ast/case_statement.h | 2 +- src/tint/ast/compound_assignment_statement.h | 3 +- src/tint/ast/const.h | 2 +- src/tint/ast/const_assert.h | 2 +- src/tint/ast/continue_statement.h | 2 +- src/tint/ast/diagnostic_attribute.h | 2 +- src/tint/ast/diagnostic_directive.h | 2 +- src/tint/ast/disable_validation_attribute.h | 2 +- src/tint/ast/discard_statement.h | 2 +- src/tint/ast/enable.h | 2 +- src/tint/ast/expression.h | 2 +- src/tint/ast/extension.h | 2 +- src/tint/ast/float_literal_expression.h | 3 +- src/tint/ast/for_loop_statement.h | 2 +- src/tint/ast/function.h | 2 +- src/tint/ast/group_attribute.h | 2 +- src/tint/ast/id_attribute.h | 2 +- src/tint/ast/identifier.h | 2 +- src/tint/ast/identifier_expression.h | 2 +- src/tint/ast/if_statement.h | 2 +- src/tint/ast/increment_decrement_statement.h | 3 +- src/tint/ast/index_accessor_expression.h | 3 +- src/tint/ast/int_literal_expression.h | 2 +- src/tint/ast/internal_attribute.h | 2 +- src/tint/ast/interpolate_attribute.h | 2 +- src/tint/ast/invariant_attribute.h | 2 +- src/tint/ast/let.h | 2 +- src/tint/ast/literal_expression.h | 2 +- src/tint/ast/location_attribute.h | 2 +- src/tint/ast/loop_statement.h | 2 +- src/tint/ast/member_accessor_expression.h | 2 +- src/tint/ast/module.h | 2 +- src/tint/ast/must_use_attribute.h | 2 +- src/tint/ast/node.h | 2 +- src/tint/ast/override.h | 2 +- src/tint/ast/parameter.h | 2 +- src/tint/ast/phony_expression.h | 2 +- src/tint/ast/return_statement.h | 2 +- src/tint/ast/stage_attribute.h | 2 +- src/tint/ast/statement.h | 2 +- src/tint/ast/stride_attribute.h | 2 +- src/tint/ast/struct.h | 2 +- src/tint/ast/struct_member.h | 2 +- src/tint/ast/struct_member_align_attribute.h | 3 +- src/tint/ast/struct_member_offset_attribute.h | 3 +- src/tint/ast/struct_member_size_attribute.h | 3 +- src/tint/ast/switch_statement.h | 2 +- src/tint/ast/templated_identifier.h | 2 +- src/tint/ast/type_decl.h | 2 +- src/tint/ast/unary_op_expression.h | 2 +- src/tint/ast/var.h | 2 +- src/tint/ast/variable.h | 2 +- src/tint/ast/variable_decl_statement.h | 2 +- src/tint/ast/while_statement.h | 2 +- src/tint/ast/workgroup_attribute.h | 2 +- src/tint/clone_context.cc | 2 +- src/tint/clone_context.h | 26 +++--- src/tint/clone_context_test.cc | 20 ++--- src/tint/constant/composite.h | 4 +- src/tint/constant/node.h | 4 +- src/tint/constant/scalar.h | 4 +- src/tint/constant/splat.h | 4 +- src/tint/constant/value.h | 4 +- src/tint/fuzzers/tint_ast_fuzzer/util.h | 2 +- src/tint/inspector/inspector.cc | 9 ++- src/tint/inspector/inspector.h | 2 +- src/tint/ir/binary.h | 4 +- src/tint/ir/bitcast.h | 4 +- src/tint/ir/block.h | 2 +- src/tint/ir/builtin.h | 4 +- src/tint/ir/call.h | 4 +- src/tint/ir/constant.h | 2 +- src/tint/ir/construct.h | 4 +- src/tint/ir/convert.h | 4 +- src/tint/ir/flow_node.h | 4 +- src/tint/ir/function.h | 2 +- src/tint/ir/if.h | 2 +- src/tint/ir/instruction.h | 4 +- src/tint/ir/loop.h | 2 +- src/tint/ir/switch.h | 2 +- src/tint/ir/temp.h | 2 +- src/tint/ir/terminator.h | 2 +- src/tint/ir/user_call.h | 4 +- src/tint/ir/value.h | 4 +- src/tint/reader/spirv/function.cc | 7 +- src/tint/reader/spirv/function.h | 2 +- src/tint/reader/spirv/parser_type.h | 44 +++++----- .../resolver/attribute_validation_test.cc | 2 +- src/tint/resolver/intrinsic_table.cc | 2 +- src/tint/resolver/resolver.cc | 5 +- src/tint/resolver/validation_test.cc | 4 +- src/tint/resolver/validator.cc | 2 +- src/tint/sem/array_count.cc | 5 +- src/tint/sem/array_count.h | 5 +- src/tint/sem/block_statement.h | 7 +- src/tint/sem/break_if_statement.h | 2 +- src/tint/sem/builtin.h | 2 +- src/tint/sem/builtin_enum_expression.h | 4 +- src/tint/sem/call.h | 2 +- src/tint/sem/call_target.h | 2 +- src/tint/sem/expression.h | 2 +- src/tint/sem/for_loop_statement.h | 2 +- src/tint/sem/function.cc | 2 +- src/tint/sem/function.h | 6 +- src/tint/sem/function_expression.h | 2 +- src/tint/sem/if_statement.h | 2 +- src/tint/sem/index_accessor_expression.h | 3 +- src/tint/sem/info.h | 12 +-- src/tint/sem/load.h | 2 +- src/tint/sem/loop_statement.h | 4 +- src/tint/sem/materialize.h | 2 +- src/tint/sem/member_accessor_expression.h | 7 +- src/tint/sem/module.h | 2 +- src/tint/sem/node.h | 4 +- src/tint/sem/statement.h | 4 +- src/tint/sem/struct.h | 4 +- src/tint/sem/switch_statement.h | 6 +- src/tint/sem/type_expression.h | 2 +- src/tint/sem/type_mappings.h | 6 +- src/tint/sem/value_constructor.h | 2 +- src/tint/sem/value_conversion.h | 2 +- src/tint/sem/value_expression.h | 2 +- src/tint/sem/variable.h | 22 ++--- src/tint/sem/while_statement.h | 2 +- src/tint/switch.h | 20 ++--- src/tint/switch_bench.cc | 80 +++++++++---------- src/tint/switch_test.cc | 30 +++---- src/tint/transform/add_block_attribute.h | 4 +- src/tint/transform/add_empty_entry_point.h | 2 +- .../transform/array_length_from_uniform.cc | 7 +- .../transform/array_length_from_uniform.h | 6 +- src/tint/transform/binding_remapper.h | 4 +- src/tint/transform/builtin_polyfill.cc | 3 +- src/tint/transform/builtin_polyfill.h | 4 +- src/tint/transform/calculate_array_length.h | 5 +- .../transform/canonicalize_entry_point_io.h | 4 +- src/tint/transform/clamp_frag_depth.h | 2 +- src/tint/transform/combine_samplers.cc | 2 +- src/tint/transform/combine_samplers.h | 4 +- src/tint/transform/decompose_memory_access.cc | 4 +- src/tint/transform/decompose_memory_access.h | 4 +- src/tint/transform/decompose_strided_array.h | 2 +- src/tint/transform/decompose_strided_matrix.h | 2 +- src/tint/transform/demote_to_helper.h | 2 +- src/tint/transform/direct_variable_access.h | 4 +- .../transform/disable_uniformity_analysis.h | 3 +- .../transform/expand_compound_assignment.h | 2 +- src/tint/transform/first_index_offset.h | 6 +- src/tint/transform/for_loop_to_loop.h | 2 +- .../localize_struct_array_assignment.h | 2 +- src/tint/transform/manager.h | 2 +- src/tint/transform/merge_return.h | 2 +- .../module_scope_var_to_entry_point_param.h | 2 +- .../transform/multiplanar_external_texture.h | 5 +- .../transform/num_workgroups_from_uniform.h | 4 +- src/tint/transform/packed_vec3.h | 2 +- src/tint/transform/pad_structs.h | 2 +- src/tint/transform/preserve_padding.h | 2 +- .../transform/promote_initializers_to_let.h | 2 +- .../transform/promote_side_effects_to_decl.cc | 4 +- .../transform/promote_side_effects_to_decl.h | 2 +- .../transform/remove_continue_in_switch.h | 2 +- src/tint/transform/remove_phonies.h | 2 +- .../transform/remove_unreachable_statements.h | 3 +- src/tint/transform/renamer.h | 6 +- src/tint/transform/robustness.h | 4 +- src/tint/transform/simplify_pointers.h | 2 +- src/tint/transform/single_entry_point.h | 4 +- src/tint/transform/spirv_atomic.h | 4 +- src/tint/transform/std140.h | 2 +- src/tint/transform/substitute_override.h | 4 +- src/tint/transform/texture_1d_to_2d.h | 2 +- src/tint/transform/transform.h | 12 +-- .../truncate_interstage_variables.cc | 2 +- .../transform/truncate_interstage_variables.h | 5 +- src/tint/transform/unshadow.h | 2 +- .../transform/vectorize_matrix_conversions.h | 3 +- .../vectorize_scalar_matrix_initializers.h | 2 +- src/tint/transform/vertex_pulling.h | 4 +- src/tint/transform/while_to_loop.h | 2 +- .../transform/zero_init_workgroup_memory.h | 2 +- src/tint/type/abstract_float.cc | 4 +- src/tint/type/abstract_float.h | 2 +- src/tint/type/abstract_int.cc | 2 +- src/tint/type/abstract_int.h | 2 +- src/tint/type/abstract_numeric.h | 2 +- src/tint/type/array.cc | 2 +- src/tint/type/array.h | 2 +- src/tint/type/array_count.cc | 5 +- src/tint/type/array_count.h | 6 +- src/tint/type/atomic.cc | 2 +- src/tint/type/atomic.h | 2 +- src/tint/type/bool.cc | 2 +- src/tint/type/bool.h | 2 +- src/tint/type/depth_multisampled_texture.cc | 2 +- src/tint/type/depth_multisampled_texture.h | 2 +- src/tint/type/depth_texture.cc | 2 +- src/tint/type/depth_texture.h | 2 +- src/tint/type/external_texture.cc | 2 +- src/tint/type/external_texture.h | 2 +- src/tint/type/f16.cc | 2 +- src/tint/type/f16.h | 2 +- src/tint/type/f32.cc | 2 +- src/tint/type/f32.h | 2 +- src/tint/type/i32.cc | 2 +- src/tint/type/i32.h | 2 +- src/tint/type/matrix.cc | 2 +- src/tint/type/matrix.h | 2 +- src/tint/type/multisampled_texture.cc | 2 +- src/tint/type/multisampled_texture.h | 2 +- src/tint/type/node.h | 4 +- src/tint/type/pointer.cc | 5 +- src/tint/type/pointer.h | 2 +- src/tint/type/reference.cc | 5 +- src/tint/type/reference.h | 2 +- src/tint/type/sampled_texture.cc | 3 +- src/tint/type/sampled_texture.h | 2 +- src/tint/type/sampler.cc | 3 +- src/tint/type/sampler.h | 2 +- src/tint/type/storage_texture.cc | 3 +- src/tint/type/storage_texture.h | 2 +- src/tint/type/struct.cc | 2 +- src/tint/type/struct.h | 4 +- src/tint/type/texture.h | 2 +- src/tint/type/type.h | 2 +- src/tint/type/u32.cc | 2 +- src/tint/type/u32.h | 2 +- src/tint/type/unique_node.h | 2 +- src/tint/type/vector.cc | 2 +- src/tint/type/vector.h | 2 +- src/tint/type/void.cc | 3 +- src/tint/type/void.h | 2 +- src/tint/{ => utils}/castable.cc | 10 +-- src/tint/{ => utils}/castable.h | 70 +++++++++------- src/tint/{ => utils}/castable_test.cc | 24 +++--- src/tint/utils/slice.h | 2 +- src/tint/writer/glsl/generator_impl.cc | 2 +- src/tint/writer/hlsl/generator_impl.cc | 4 +- src/tint/writer/msl/generator_impl.cc | 2 +- 257 files changed, 547 insertions(+), 500 deletions(-) rename src/tint/{ => utils}/castable.cc (81%) rename src/tint/{ => utils}/castable.h (92%) rename src/tint/{ => utils}/castable_test.cc (94%) diff --git a/docs/tint/style_guide.md b/docs/tint/style_guide.md index 25e91467c8..e5f8fa384a 100644 --- a/docs/tint/style_guide.md +++ b/docs/tint/style_guide.md @@ -14,7 +14,7 @@ * Do not use C++ exceptions * Do not use C++ RTTI. - Instead, use `tint::Castable::As()` from + Instead, use `tint::utils::Castable::As()` from [src/castable.h](../src/castable.h) * Generally, avoid `assert`. Instead, issue a [diagnostic](../src/diagnostic.h) diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index f20948d61a..c0a72ac37b 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -195,8 +195,6 @@ template("libtint_source_set") { libtint_source_set("libtint_base_src") { sources = [ - "castable.cc", - "castable.h", "debug.cc", "debug.h", "diagnostic/diagnostic.cc", @@ -222,6 +220,8 @@ libtint_source_set("libtint_base_src") { "utils/bitset.h", "utils/block_allocator.h", "utils/bump_allocator.h", + "utils/castable.cc", + "utils/castable.h", "utils/compiler_macros.h", "utils/concat.h", "utils/crc32.h", @@ -1590,6 +1590,7 @@ if (tint_build_unittests) { "utils/bitset_test.cc", "utils/block_allocator_test.cc", "utils/bump_allocator_test.cc", + "utils/castable_test.cc", "utils/crc32_test.cc", "utils/defer_test.cc", "utils/enum_set_test.cc", @@ -1982,7 +1983,6 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_base_src") { sources = [ - "castable_test.cc", "debug_test.cc", "number_test.cc", "reflection_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 820366a7f0..628dcb35e9 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -230,8 +230,6 @@ list(APPEND TINT_LIB_SRCS ast/while_statement.h ast/workgroup_attribute.cc ast/workgroup_attribute.h - castable.cc - castable.h clone_context.cc clone_context.h constant/clone_context.h @@ -517,6 +515,8 @@ list(APPEND TINT_LIB_SRCS utils/bitset.h utils/block_allocator.h utils/bump_allocator.h + utils/castable.cc + utils/castable.h utils/compiler_macros.h utils/concat.h utils/crc32.h @@ -882,7 +882,6 @@ if(TINT_BUILD_TESTS) ast/variable_test.cc ast/while_statement_test.cc ast/workgroup_attribute_test.cc - castable_test.cc clone_context_test.cc constant/composite_test.cc constant/scalar_test.cc @@ -996,6 +995,7 @@ if(TINT_BUILD_TESTS) utils/bitset_test.cc utils/block_allocator_test.cc utils/bump_allocator_test.cc + utils/castable_test.cc utils/crc32_test.cc utils/defer_test.cc utils/enum_set_test.cc diff --git a/src/tint/ast/accessor_expression.h b/src/tint/ast/accessor_expression.h index d668f1f2a5..808ac2fb75 100644 --- a/src/tint/ast/accessor_expression.h +++ b/src/tint/ast/accessor_expression.h @@ -20,7 +20,7 @@ namespace tint::ast { /// Base class for IndexAccessorExpression and MemberAccessorExpression -class AccessorExpression : public Castable { +class AccessorExpression : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/alias.h b/src/tint/ast/alias.h index c30d38747b..519a878cf5 100644 --- a/src/tint/ast/alias.h +++ b/src/tint/ast/alias.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A type alias type. Holds a name and pointer to another type. -class Alias final : public Castable { +class Alias final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/assignment_statement.h b/src/tint/ast/assignment_statement.h index 01a1a752c8..482ec4ec69 100644 --- a/src/tint/ast/assignment_statement.h +++ b/src/tint/ast/assignment_statement.h @@ -21,7 +21,7 @@ namespace tint::ast { /// An assignment statement -class AssignmentStatement final : public Castable { +class AssignmentStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/attribute.h b/src/tint/ast/attribute.h index 180978258f..66c309d16e 100644 --- a/src/tint/ast/attribute.h +++ b/src/tint/ast/attribute.h @@ -23,7 +23,7 @@ namespace tint::ast { /// The base class for all attributes -class Attribute : public Castable { +class Attribute : public utils::Castable { public: ~Attribute() override; diff --git a/src/tint/ast/binary_expression.h b/src/tint/ast/binary_expression.h index b314250d23..0382a9b55f 100644 --- a/src/tint/ast/binary_expression.h +++ b/src/tint/ast/binary_expression.h @@ -43,7 +43,7 @@ enum class BinaryOp { }; /// An binary expression -class BinaryExpression final : public Castable { +class BinaryExpression final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/binding_attribute.h b/src/tint/ast/binding_attribute.h index 3ff7c97d35..37c8224367 100644 --- a/src/tint/ast/binding_attribute.h +++ b/src/tint/ast/binding_attribute.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A binding attribute -class BindingAttribute final : public Castable { +class BindingAttribute final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/bitcast_expression.h b/src/tint/ast/bitcast_expression.h index 7737721ab1..d004ddfce9 100644 --- a/src/tint/ast/bitcast_expression.h +++ b/src/tint/ast/bitcast_expression.h @@ -21,7 +21,7 @@ namespace tint::ast { /// A bitcast expression -class BitcastExpression final : public Castable { +class BitcastExpression final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/block_statement.h b/src/tint/ast/block_statement.h index 2044b5b16d..8582ed321a 100644 --- a/src/tint/ast/block_statement.h +++ b/src/tint/ast/block_statement.h @@ -27,7 +27,7 @@ class Attribute; namespace tint::ast { /// A block statement -class BlockStatement final : public Castable { +class BlockStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/bool_literal_expression.h b/src/tint/ast/bool_literal_expression.h index bebd924a7f..fe509df086 100644 --- a/src/tint/ast/bool_literal_expression.h +++ b/src/tint/ast/bool_literal_expression.h @@ -22,7 +22,8 @@ namespace tint::ast { /// A boolean literal -class BoolLiteralExpression final : public Castable { +class BoolLiteralExpression final + : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/break_if_statement.h b/src/tint/ast/break_if_statement.h index a366240368..56cbabca8e 100644 --- a/src/tint/ast/break_if_statement.h +++ b/src/tint/ast/break_if_statement.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A break-if statement -class BreakIfStatement final : public Castable { +class BreakIfStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/break_statement.h b/src/tint/ast/break_statement.h index d9676bbd4d..a22bf03ffd 100644 --- a/src/tint/ast/break_statement.h +++ b/src/tint/ast/break_statement.h @@ -20,7 +20,7 @@ namespace tint::ast { /// An break statement -class BreakStatement final : public Castable { +class BreakStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/builtin_attribute.h b/src/tint/ast/builtin_attribute.h index 2ed6a2d577..88447571d0 100644 --- a/src/tint/ast/builtin_attribute.h +++ b/src/tint/ast/builtin_attribute.h @@ -27,7 +27,7 @@ class Expression; namespace tint::ast { /// A builtin attribute -class BuiltinAttribute final : public Castable { +class BuiltinAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/call_expression.h b/src/tint/ast/call_expression.h index 66604945f9..8ad4cf1322 100644 --- a/src/tint/ast/call_expression.h +++ b/src/tint/ast/call_expression.h @@ -29,7 +29,7 @@ namespace tint::ast { /// * sem::Builtin /// * sem::ValueConstructor /// * sem::ValueConversion -class CallExpression final : public Castable { +class CallExpression final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/call_statement.h b/src/tint/ast/call_statement.h index 9af47a183b..ec561a1ba6 100644 --- a/src/tint/ast/call_statement.h +++ b/src/tint/ast/call_statement.h @@ -21,7 +21,7 @@ namespace tint::ast { /// A call expression -class CallStatement final : public Castable { +class CallStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/case_selector.h b/src/tint/ast/case_selector.h index f2bc1b341c..e381557664 100644 --- a/src/tint/ast/case_selector.h +++ b/src/tint/ast/case_selector.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A case selector -class CaseSelector final : public Castable { +class CaseSelector final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/case_statement.h b/src/tint/ast/case_statement.h index a06c720a7f..fd0d18db06 100644 --- a/src/tint/ast/case_statement.h +++ b/src/tint/ast/case_statement.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A case statement -class CaseStatement final : public Castable { +class CaseStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/compound_assignment_statement.h b/src/tint/ast/compound_assignment_statement.h index bb1f34f88c..f23af153f8 100644 --- a/src/tint/ast/compound_assignment_statement.h +++ b/src/tint/ast/compound_assignment_statement.h @@ -22,7 +22,8 @@ namespace tint::ast { /// A compound assignment statement -class CompoundAssignmentStatement final : public Castable { +class CompoundAssignmentStatement final + : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/const.h b/src/tint/ast/const.h index 95727ce0f0..b008015e7c 100644 --- a/src/tint/ast/const.h +++ b/src/tint/ast/const.h @@ -30,7 +30,7 @@ namespace tint::ast { /// const max_f32 : f32 = 0x1.fffffep+127; // f32 typed constant /// ``` /// @see https://www.w3.org/TR/WGSL/#creation-time-consts -class Const final : public Castable { +class Const final : public utils::Castable { public: /// Create a 'const' creation-time value variable. /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/const_assert.h b/src/tint/ast/const_assert.h index 6774f5e7d5..8de59e3879 100644 --- a/src/tint/ast/const_assert.h +++ b/src/tint/ast/const_assert.h @@ -21,7 +21,7 @@ namespace tint::ast { /// A `const_assert` statement -class ConstAssert final : public Castable { +class ConstAssert final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/continue_statement.h b/src/tint/ast/continue_statement.h index 10af08b353..338a26edf5 100644 --- a/src/tint/ast/continue_statement.h +++ b/src/tint/ast/continue_statement.h @@ -20,7 +20,7 @@ namespace tint::ast { /// An continue statement -class ContinueStatement final : public Castable { +class ContinueStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/diagnostic_attribute.h b/src/tint/ast/diagnostic_attribute.h index ef1fa02fd6..fa63f83825 100644 --- a/src/tint/ast/diagnostic_attribute.h +++ b/src/tint/ast/diagnostic_attribute.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A diagnostic attribute -class DiagnosticAttribute final : public Castable { +class DiagnosticAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/diagnostic_directive.h b/src/tint/ast/diagnostic_directive.h index 979f32c7fb..b944384d8a 100644 --- a/src/tint/ast/diagnostic_directive.h +++ b/src/tint/ast/diagnostic_directive.h @@ -29,7 +29,7 @@ namespace tint::ast { /// // Turn off diagnostics for derivative uniformity violations. /// diagnostic(off, derivative_uniformity); /// ``` -class DiagnosticDirective final : public Castable { +class DiagnosticDirective final : public utils::Castable { public: /// Create a extension /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/disable_validation_attribute.h b/src/tint/ast/disable_validation_attribute.h index 9614bc14b2..4cc0c081a1 100644 --- a/src/tint/ast/disable_validation_attribute.h +++ b/src/tint/ast/disable_validation_attribute.h @@ -53,7 +53,7 @@ enum class DisabledValidation { /// violations. Typically generated by transforms that need to produce ASTs that /// would otherwise cause validation errors. class DisableValidationAttribute final - : public Castable { + : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/discard_statement.h b/src/tint/ast/discard_statement.h index a7646835f9..99d8ee7fce 100644 --- a/src/tint/ast/discard_statement.h +++ b/src/tint/ast/discard_statement.h @@ -20,7 +20,7 @@ namespace tint::ast { /// A discard statement -class DiscardStatement final : public Castable { +class DiscardStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/enable.h b/src/tint/ast/enable.h index 53f0218347..ac7181abba 100644 --- a/src/tint/ast/enable.h +++ b/src/tint/ast/enable.h @@ -28,7 +28,7 @@ namespace tint::ast { /// // Enable an extension named "f16" /// enable f16; /// ``` -class Enable final : public Castable { +class Enable final : public utils::Castable { public: /// Create a extension /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/expression.h b/src/tint/ast/expression.h index e4a94cb58f..e9fce0b2b6 100644 --- a/src/tint/ast/expression.h +++ b/src/tint/ast/expression.h @@ -23,7 +23,7 @@ namespace tint::ast { /// Base expression class -class Expression : public Castable { +class Expression : public utils::Castable { public: ~Expression() override; diff --git a/src/tint/ast/extension.h b/src/tint/ast/extension.h index 4988edbd4d..900d49167e 100644 --- a/src/tint/ast/extension.h +++ b/src/tint/ast/extension.h @@ -24,7 +24,7 @@ namespace tint::ast { /// ``` /// enable f16; /// ``` -class Extension final : public Castable { +class Extension final : public utils::Castable { public: /// Create a extension /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/float_literal_expression.h b/src/tint/ast/float_literal_expression.h index 7920c78f0a..40e7e7c17d 100644 --- a/src/tint/ast/float_literal_expression.h +++ b/src/tint/ast/float_literal_expression.h @@ -22,7 +22,8 @@ namespace tint::ast { /// A float literal -class FloatLiteralExpression final : public Castable { +class FloatLiteralExpression final + : public utils::Castable { public: /// Literal suffix enum class Suffix { diff --git a/src/tint/ast/for_loop_statement.h b/src/tint/ast/for_loop_statement.h index 00fcf1d19d..fa47a29b86 100644 --- a/src/tint/ast/for_loop_statement.h +++ b/src/tint/ast/for_loop_statement.h @@ -22,7 +22,7 @@ namespace tint::ast { class Expression; /// A for loop statement -class ForLoopStatement final : public Castable { +class ForLoopStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/function.h b/src/tint/ast/function.h index 8fa009f2b0..b47d74f578 100644 --- a/src/tint/ast/function.h +++ b/src/tint/ast/function.h @@ -38,7 +38,7 @@ class IdentifierExpression; namespace tint::ast { /// A Function statement. -class Function final : public Castable { +class Function final : public utils::Castable { public: /// Create a function /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/group_attribute.h b/src/tint/ast/group_attribute.h index af57eb5539..47cef56837 100644 --- a/src/tint/ast/group_attribute.h +++ b/src/tint/ast/group_attribute.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A group attribute -class GroupAttribute final : public Castable { +class GroupAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/id_attribute.h b/src/tint/ast/id_attribute.h index 5557a062b8..3e51ce44d5 100644 --- a/src/tint/ast/id_attribute.h +++ b/src/tint/ast/id_attribute.h @@ -23,7 +23,7 @@ namespace tint::ast { /// An id attribute for pipeline-overridable constants -class IdAttribute final : public Castable { +class IdAttribute final : public utils::Castable { public: /// Create an id attribute. /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/identifier.h b/src/tint/ast/identifier.h index df138e9dbd..3fc81df0a5 100644 --- a/src/tint/ast/identifier.h +++ b/src/tint/ast/identifier.h @@ -20,7 +20,7 @@ namespace tint::ast { /// An identifier -class Identifier : public Castable { +class Identifier : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/identifier_expression.h b/src/tint/ast/identifier_expression.h index c2200bd1ae..839445b98c 100644 --- a/src/tint/ast/identifier_expression.h +++ b/src/tint/ast/identifier_expression.h @@ -25,7 +25,7 @@ class Identifier; namespace tint::ast { /// An identifier expression -class IdentifierExpression final : public Castable { +class IdentifierExpression final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/if_statement.h b/src/tint/ast/if_statement.h index 255ce2fa75..3333084023 100644 --- a/src/tint/ast/if_statement.h +++ b/src/tint/ast/if_statement.h @@ -23,7 +23,7 @@ namespace tint::ast { /// An if statement -class IfStatement final : public Castable { +class IfStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/increment_decrement_statement.h b/src/tint/ast/increment_decrement_statement.h index 9046e46f9d..5fa6b937ed 100644 --- a/src/tint/ast/increment_decrement_statement.h +++ b/src/tint/ast/increment_decrement_statement.h @@ -21,7 +21,8 @@ namespace tint::ast { /// An increment or decrement statement -class IncrementDecrementStatement final : public Castable { +class IncrementDecrementStatement final + : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/index_accessor_expression.h b/src/tint/ast/index_accessor_expression.h index 09dc9754a2..6dc6f96f74 100644 --- a/src/tint/ast/index_accessor_expression.h +++ b/src/tint/ast/index_accessor_expression.h @@ -20,7 +20,8 @@ namespace tint::ast { /// An index accessor expression -class IndexAccessorExpression final : public Castable { +class IndexAccessorExpression final + : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/int_literal_expression.h b/src/tint/ast/int_literal_expression.h index 0f50ad306e..bf13f8ee93 100644 --- a/src/tint/ast/int_literal_expression.h +++ b/src/tint/ast/int_literal_expression.h @@ -20,7 +20,7 @@ namespace tint::ast { /// An integer literal. The literal may have an 'i', 'u' or no suffix. -class IntLiteralExpression final : public Castable { +class IntLiteralExpression final : public utils::Castable { public: /// Literal suffix enum class Suffix { diff --git a/src/tint/ast/internal_attribute.h b/src/tint/ast/internal_attribute.h index 36f2a986da..a06a9662f9 100644 --- a/src/tint/ast/internal_attribute.h +++ b/src/tint/ast/internal_attribute.h @@ -30,7 +30,7 @@ namespace tint::ast { /// An attribute used to indicate that a function is tint-internal. /// These attributes are not produced by generators, but instead are usually /// created by transforms for consumption by a particular backend. -class InternalAttribute : public Castable { +class InternalAttribute : public utils::Castable { public: /// Constructor /// @param program_id the identifier of the program that owns this node diff --git a/src/tint/ast/interpolate_attribute.h b/src/tint/ast/interpolate_attribute.h index b3177ed91a..65cf5855a3 100644 --- a/src/tint/ast/interpolate_attribute.h +++ b/src/tint/ast/interpolate_attribute.h @@ -27,7 +27,7 @@ class Expression; namespace tint::ast { /// An interpolate attribute -class InterpolateAttribute final : public Castable { +class InterpolateAttribute final : public utils::Castable { public: /// Create an interpolate attribute. /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/invariant_attribute.h b/src/tint/ast/invariant_attribute.h index 9abb6a4c60..b4da288355 100644 --- a/src/tint/ast/invariant_attribute.h +++ b/src/tint/ast/invariant_attribute.h @@ -22,7 +22,7 @@ namespace tint::ast { /// The invariant attribute -class InvariantAttribute final : public Castable { +class InvariantAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/let.h b/src/tint/ast/let.h index 127c3d442f..1e529c9fd9 100644 --- a/src/tint/ast/let.h +++ b/src/tint/ast/let.h @@ -27,7 +27,7 @@ namespace tint::ast { /// let twice_depth : i32 = width + width; // Must have initializer /// ``` /// @see https://www.w3.org/TR/WGSL/#let-decls -class Let final : public Castable { +class Let final : public utils::Castable { public: /// Create a 'let' variable /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/literal_expression.h b/src/tint/ast/literal_expression.h index b4b2b097a1..5cf5c07c8a 100644 --- a/src/tint/ast/literal_expression.h +++ b/src/tint/ast/literal_expression.h @@ -22,7 +22,7 @@ namespace tint::ast { /// Base class for a literal value expressions -class LiteralExpression : public Castable { +class LiteralExpression : public utils::Castable { public: ~LiteralExpression() override; diff --git a/src/tint/ast/location_attribute.h b/src/tint/ast/location_attribute.h index a41e943c3a..eb10307da6 100644 --- a/src/tint/ast/location_attribute.h +++ b/src/tint/ast/location_attribute.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A location attribute -class LocationAttribute final : public Castable { +class LocationAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/loop_statement.h b/src/tint/ast/loop_statement.h index fc764e23ff..8539345686 100644 --- a/src/tint/ast/loop_statement.h +++ b/src/tint/ast/loop_statement.h @@ -20,7 +20,7 @@ namespace tint::ast { /// A loop statement -class LoopStatement final : public Castable { +class LoopStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/member_accessor_expression.h b/src/tint/ast/member_accessor_expression.h index 95fbbd265a..5ae36b172d 100644 --- a/src/tint/ast/member_accessor_expression.h +++ b/src/tint/ast/member_accessor_expression.h @@ -22,7 +22,7 @@ namespace tint::ast { /// A member accessor expression class MemberAccessorExpression final - : public Castable { + : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/module.h b/src/tint/ast/module.h index 0125fb3fae..130939e98d 100644 --- a/src/tint/ast/module.h +++ b/src/tint/ast/module.h @@ -29,7 +29,7 @@ class TypeDecl; /// Module holds the top-level AST types, functions and global variables used by /// a Program. -class Module final : public Castable { +class Module final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/must_use_attribute.h b/src/tint/ast/must_use_attribute.h index 6befa54026..a135176cb5 100644 --- a/src/tint/ast/must_use_attribute.h +++ b/src/tint/ast/must_use_attribute.h @@ -22,7 +22,7 @@ namespace tint::ast { /// The must_use attribute -class MustUseAttribute final : public Castable { +class MustUseAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/node.h b/src/tint/ast/node.h index afea2e8b1d..3ad56f3e29 100644 --- a/src/tint/ast/node.h +++ b/src/tint/ast/node.h @@ -23,7 +23,7 @@ namespace tint::ast { /// AST base class node -class Node : public Castable { +class Node : public utils::Castable { public: ~Node() override; diff --git a/src/tint/ast/override.h b/src/tint/ast/override.h index b824ed3834..56fc2117dc 100644 --- a/src/tint/ast/override.h +++ b/src/tint/ast/override.h @@ -30,7 +30,7 @@ namespace tint::ast { /// override scale : f32; // No default - must be overridden. /// ``` /// @see https://www.w3.org/TR/WGSL/#override-decls -class Override final : public Castable { +class Override final : public utils::Castable { public: /// Create an 'override' pipeline-overridable constant. /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/parameter.h b/src/tint/ast/parameter.h index b056afa44c..b363d339c8 100644 --- a/src/tint/ast/parameter.h +++ b/src/tint/ast/parameter.h @@ -31,7 +31,7 @@ namespace tint::ast { /// ``` /// /// @see https://www.w3.org/TR/WGSL/#creation-time-consts -class Parameter final : public Castable { +class Parameter final : public utils::Castable { public: /// Create a 'parameter' creation-time value variable. /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/phony_expression.h b/src/tint/ast/phony_expression.h index 7f59c378e9..764bf23501 100644 --- a/src/tint/ast/phony_expression.h +++ b/src/tint/ast/phony_expression.h @@ -21,7 +21,7 @@ namespace tint::ast { /// Represents the `_` of a phony assignment `_ = ` /// @see https://www.w3.org/TR/WGSL/#phony-assignment-section -class PhonyExpression final : public Castable { +class PhonyExpression final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/return_statement.h b/src/tint/ast/return_statement.h index 7eae780916..6beb2154d7 100644 --- a/src/tint/ast/return_statement.h +++ b/src/tint/ast/return_statement.h @@ -21,7 +21,7 @@ namespace tint::ast { /// A return statement -class ReturnStatement final : public Castable { +class ReturnStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/stage_attribute.h b/src/tint/ast/stage_attribute.h index 0bf9d9e932..9b325792fe 100644 --- a/src/tint/ast/stage_attribute.h +++ b/src/tint/ast/stage_attribute.h @@ -23,7 +23,7 @@ namespace tint::ast { /// A workgroup attribute -class StageAttribute final : public Castable { +class StageAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/statement.h b/src/tint/ast/statement.h index fa434cc548..3aeff6ab52 100644 --- a/src/tint/ast/statement.h +++ b/src/tint/ast/statement.h @@ -22,7 +22,7 @@ namespace tint::ast { /// Base statement class -class Statement : public Castable { +class Statement : public utils::Castable { public: ~Statement() override; diff --git a/src/tint/ast/stride_attribute.h b/src/tint/ast/stride_attribute.h index 90146774d1..0d6ba18be3 100644 --- a/src/tint/ast/stride_attribute.h +++ b/src/tint/ast/stride_attribute.h @@ -24,7 +24,7 @@ namespace tint::ast { /// A stride attribute used by the SPIR-V reader for strided arrays and /// matrices. -class StrideAttribute final : public Castable { +class StrideAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/struct.h b/src/tint/ast/struct.h index d7c2281f96..067688dda9 100644 --- a/src/tint/ast/struct.h +++ b/src/tint/ast/struct.h @@ -26,7 +26,7 @@ namespace tint::ast { /// A struct statement. -class Struct final : public Castable { +class Struct final : public utils::Castable { public: /// Create a new struct statement /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/struct_member.h b/src/tint/ast/struct_member.h index 27e5b0ca2a..a44c23d84b 100644 --- a/src/tint/ast/struct_member.h +++ b/src/tint/ast/struct_member.h @@ -28,7 +28,7 @@ class Identifier; namespace tint::ast { /// A struct member statement. -class StructMember final : public Castable { +class StructMember final : public utils::Castable { public: /// Create a new struct member statement /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/struct_member_align_attribute.h b/src/tint/ast/struct_member_align_attribute.h index 1649ae6786..b368b79884 100644 --- a/src/tint/ast/struct_member_align_attribute.h +++ b/src/tint/ast/struct_member_align_attribute.h @@ -24,7 +24,8 @@ namespace tint::ast { /// A struct member align attribute -class StructMemberAlignAttribute final : public Castable { +class StructMemberAlignAttribute final + : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/struct_member_offset_attribute.h b/src/tint/ast/struct_member_offset_attribute.h index ed74397b0f..edfbb13717 100644 --- a/src/tint/ast/struct_member_offset_attribute.h +++ b/src/tint/ast/struct_member_offset_attribute.h @@ -32,7 +32,8 @@ namespace tint::ast { /// trivial for the Resolver to handle `@offset(n)` or `@size(n)` / /// `@align(n)` attributes, so this is what we do, keeping all the layout /// logic in one place. -class StructMemberOffsetAttribute final : public Castable { +class StructMemberOffsetAttribute final + : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/struct_member_size_attribute.h b/src/tint/ast/struct_member_size_attribute.h index 2a0c71fb70..5b2bb4e710 100644 --- a/src/tint/ast/struct_member_size_attribute.h +++ b/src/tint/ast/struct_member_size_attribute.h @@ -24,7 +24,8 @@ namespace tint::ast { /// A struct member size attribute -class StructMemberSizeAttribute final : public Castable { +class StructMemberSizeAttribute final + : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/switch_statement.h b/src/tint/ast/switch_statement.h index f2b820181e..f376f8228b 100644 --- a/src/tint/ast/switch_statement.h +++ b/src/tint/ast/switch_statement.h @@ -21,7 +21,7 @@ namespace tint::ast { /// A switch statement -class SwitchStatement final : public Castable { +class SwitchStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/templated_identifier.h b/src/tint/ast/templated_identifier.h index 74ddb43667..92b834535a 100644 --- a/src/tint/ast/templated_identifier.h +++ b/src/tint/ast/templated_identifier.h @@ -26,7 +26,7 @@ class Expression; namespace tint::ast { /// A templated identifier expression -class TemplatedIdentifier final : public Castable { +class TemplatedIdentifier final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/type_decl.h b/src/tint/ast/type_decl.h index 8ec0fe49f4..aa0bc14b9f 100644 --- a/src/tint/ast/type_decl.h +++ b/src/tint/ast/type_decl.h @@ -25,7 +25,7 @@ class Identifier; namespace tint::ast { /// The base class for type declarations. -class TypeDecl : public Castable { +class TypeDecl : public utils::Castable { public: /// Create a new struct statement /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/unary_op_expression.h b/src/tint/ast/unary_op_expression.h index 3639447307..6004975251 100644 --- a/src/tint/ast/unary_op_expression.h +++ b/src/tint/ast/unary_op_expression.h @@ -21,7 +21,7 @@ namespace tint::ast { /// A unary op expression -class UnaryOpExpression final : public Castable { +class UnaryOpExpression final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/var.h b/src/tint/ast/var.h index 6f08a6f0fe..e3cfde0984 100644 --- a/src/tint/ast/var.h +++ b/src/tint/ast/var.h @@ -39,7 +39,7 @@ namespace tint::ast { /// ``` /// /// @see https://www.w3.org/TR/WGSL/#var-decls -class Var final : public Castable { +class Var final : public utils::Castable { public: /// Create a 'var' variable /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/variable.h b/src/tint/ast/variable.h index 2230ac3684..0a1ccb217d 100644 --- a/src/tint/ast/variable.h +++ b/src/tint/ast/variable.h @@ -40,7 +40,7 @@ namespace tint::ast { /// declaration, "override" declaration, "const" declaration, or formal parameter to a function. /// /// @see https://www.w3.org/TR/WGSL/#value-decls -class Variable : public Castable { +class Variable : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/variable_decl_statement.h b/src/tint/ast/variable_decl_statement.h index 99a9a5d346..77322995a8 100644 --- a/src/tint/ast/variable_decl_statement.h +++ b/src/tint/ast/variable_decl_statement.h @@ -21,7 +21,7 @@ namespace tint::ast { /// A variable declaration statement -class VariableDeclStatement final : public Castable { +class VariableDeclStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/while_statement.h b/src/tint/ast/while_statement.h index 360610aaac..6545a650ea 100644 --- a/src/tint/ast/while_statement.h +++ b/src/tint/ast/while_statement.h @@ -22,7 +22,7 @@ namespace tint::ast { class Expression; /// A while loop statement -class WhileStatement final : public Castable { +class WhileStatement final : public utils::Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/workgroup_attribute.h b/src/tint/ast/workgroup_attribute.h index 05cbb89cd3..8789df708f 100644 --- a/src/tint/ast/workgroup_attribute.h +++ b/src/tint/ast/workgroup_attribute.h @@ -28,7 +28,7 @@ class Expression; namespace tint::ast { /// A workgroup attribute -class WorkgroupAttribute final : public Castable { +class WorkgroupAttribute final : public utils::Castable { public: /// constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/clone_context.cc b/src/tint/clone_context.cc index a6f147846f..f2988d1b05 100644 --- a/src/tint/clone_context.cc +++ b/src/tint/clone_context.cc @@ -97,7 +97,7 @@ const tint::Cloneable* CloneContext::CloneCloneable(const Cloneable* object) { return object->Clone(this); } -void CloneContext::CheckedCastFailure(const Cloneable* got, const TypeInfo& expected) { +void CloneContext::CheckedCastFailure(const Cloneable* got, const utils::TypeInfo& expected) { TINT_ICE(Clone, Diagnostics()) << "Cloned object was not of the expected type\n" << "got: " << got->TypeInfo().name << "\n" << "expected: " << expected.name; diff --git a/src/tint/clone_context.h b/src/tint/clone_context.h index 901298218a..5f0073c5a8 100644 --- a/src/tint/clone_context.h +++ b/src/tint/clone_context.h @@ -21,10 +21,10 @@ #include #include -#include "src/tint/castable.h" #include "src/tint/debug.h" #include "src/tint/program_id.h" #include "src/tint/symbol.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/compiler_macros.h" #include "src/tint/utils/hashmap.h" #include "src/tint/utils/hashset.h" @@ -49,7 +49,7 @@ ProgramID ProgramIDOf(const Program*); ProgramID ProgramIDOf(const ProgramBuilder*); /// Cloneable is the base class for all objects that can be cloned -class Cloneable : public Castable { +class Cloneable : public utils::Castable { public: /// Constructor Cloneable(); @@ -308,18 +308,18 @@ class CloneContext { using TPtr = utils::traits::ParameterType; using T = typename std::remove_pointer::type; for (auto& transform : transforms_) { - bool already_registered = transform.typeinfo->Is(&TypeInfo::Of()) || - TypeInfo::Of().Is(transform.typeinfo); + bool already_registered = transform.typeinfo->Is(&utils::TypeInfo::Of()) || + utils::TypeInfo::Of().Is(transform.typeinfo); if (TINT_UNLIKELY(already_registered)) { - TINT_ICE(Clone, Diagnostics()) - << "ReplaceAll() called with a handler for type " << TypeInfo::Of().name - << " that is already handled by a handler for type " - << transform.typeinfo->name; + TINT_ICE(Clone, Diagnostics()) << "ReplaceAll() called with a handler for type " + << utils::TypeInfo::Of().name + << " that is already handled by a handler for type " + << transform.typeinfo->name; return *this; } } CloneableTransform transform; - transform.typeinfo = &TypeInfo::Of(); + transform.typeinfo = &utils::TypeInfo::Of(); transform.function = [=](const Cloneable* in) { return replacer(in->As()); }; transforms_.Push(std::move(transform)); return *this; @@ -554,8 +554,8 @@ class CloneContext { /// Destructor ~CloneableTransform(); - // TypeInfo of the Cloneable that the transform operates on - const TypeInfo* typeinfo; + // utils::TypeInfo of the Cloneable that the transform operates on + const utils::TypeInfo* typeinfo; std::function function; }; @@ -598,7 +598,7 @@ class CloneContext { if (TINT_LIKELY(cast)) { return cast; } - CheckedCastFailure(obj, TypeInfo::Of()); + CheckedCastFailure(obj, utils::TypeInfo::Of()); return nullptr; } @@ -608,7 +608,7 @@ class CloneContext { /// Adds an error diagnostic to Diagnostics() that the cloned object was not /// of the expected type. - void CheckedCastFailure(const Cloneable* got, const TypeInfo& expected); + void CheckedCastFailure(const Cloneable* got, const utils::TypeInfo& expected); /// @returns the diagnostic list of #dst diag::List& Diagnostics() const; diff --git a/src/tint/clone_context_test.cc b/src/tint/clone_context_test.cc index ec17e0de4b..4df5ade244 100644 --- a/src/tint/clone_context_test.cc +++ b/src/tint/clone_context_test.cc @@ -30,7 +30,7 @@ struct Allocator { utils::BlockAllocator alloc; }; -struct Node : public Castable { +struct Node : public utils::Castable { Node(Allocator* alloc, Symbol n, const Node* node_a = nullptr, @@ -55,7 +55,7 @@ struct Node : public Castable { } }; -struct Replaceable : public Castable { +struct Replaceable : public utils::Castable { Replaceable(Allocator* alloc, Symbol n, const Node* node_a = nullptr, @@ -64,18 +64,18 @@ struct Replaceable : public Castable { : Base(alloc, n, node_a, node_b, node_c) {} }; -struct Replacement : public Castable { +struct Replacement : public utils::Castable { Replacement(Allocator* alloc, Symbol n) : Base(alloc, n) {} }; -struct NotANode : public Castable { +struct NotANode : public utils::Castable { explicit NotANode(Allocator* alloc) : allocator(alloc) {} Allocator* const allocator; NotANode* Clone(CloneContext*) const override { return allocator->Create(); } }; -struct ProgramNode : public Castable { +struct ProgramNode : public utils::Castable { ProgramNode(Allocator* alloc, ProgramID id, ProgramID cloned_id) : allocator(alloc), program_id(id), cloned_program_id(cloned_id) {} @@ -1051,7 +1051,7 @@ TEST_F(CloneContextNodeTest, CloneIntoSameBuilder) { } TEST_F(CloneContextNodeTest, CloneWithReplaceAll_SameTypeTwice) { - std::string node_name = TypeInfo::Of().name; + std::string node_name = utils::TypeInfo::Of().name; EXPECT_FATAL_FAILURE( { @@ -1066,8 +1066,8 @@ TEST_F(CloneContextNodeTest, CloneWithReplaceAll_SameTypeTwice) { } TEST_F(CloneContextNodeTest, CloneWithReplaceAll_BaseThenDerived) { - std::string node_name = TypeInfo::Of().name; - std::string replaceable_name = TypeInfo::Of().name; + std::string node_name = utils::TypeInfo::Of().name; + std::string replaceable_name = utils::TypeInfo::Of().name; EXPECT_FATAL_FAILURE( { @@ -1082,8 +1082,8 @@ TEST_F(CloneContextNodeTest, CloneWithReplaceAll_BaseThenDerived) { } TEST_F(CloneContextNodeTest, CloneWithReplaceAll_DerivedThenBase) { - std::string node_name = TypeInfo::Of().name; - std::string replaceable_name = TypeInfo::Of().name; + std::string node_name = utils::TypeInfo::Of().name; + std::string replaceable_name = utils::TypeInfo::Of().name; EXPECT_FATAL_FAILURE( { diff --git a/src/tint/constant/composite.h b/src/tint/constant/composite.h index ef7233c5a3..7a50640d7d 100644 --- a/src/tint/constant/composite.h +++ b/src/tint/constant/composite.h @@ -15,10 +15,10 @@ #ifndef SRC_TINT_CONSTANT_COMPOSITE_H_ #define SRC_TINT_CONSTANT_COMPOSITE_H_ -#include "src/tint/castable.h" #include "src/tint/constant/value.h" #include "src/tint/number.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/hash.h" #include "src/tint/utils/vector.h" @@ -28,7 +28,7 @@ namespace tint::constant { /// Composite may be of a vector, matrix, array or structure type. /// If each element is the same type and value, then a Splat would be a more efficient constant /// implementation. Use CreateComposite() to create the appropriate type. -class Composite : public Castable { +class Composite : public utils::Castable { public: /// Constructor /// @param t the compsite type diff --git a/src/tint/constant/node.h b/src/tint/constant/node.h index 41d00e09e7..54ef94d245 100644 --- a/src/tint/constant/node.h +++ b/src/tint/constant/node.h @@ -15,12 +15,12 @@ #ifndef SRC_TINT_CONSTANT_NODE_H_ #define SRC_TINT_CONSTANT_NODE_H_ -#include "src/tint/castable.h" +#include "src/tint/utils/castable.h" namespace tint::constant { /// Node is the base class for all constant nodes -class Node : public Castable { +class Node : public utils::Castable { public: /// Constructor Node(); diff --git a/src/tint/constant/scalar.h b/src/tint/constant/scalar.h index fc6aef06de..ab5f8528ac 100644 --- a/src/tint/constant/scalar.h +++ b/src/tint/constant/scalar.h @@ -15,17 +15,17 @@ #ifndef SRC_TINT_CONSTANT_SCALAR_H_ #define SRC_TINT_CONSTANT_SCALAR_H_ -#include "src/tint/castable.h" #include "src/tint/constant/value.h" #include "src/tint/number.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/hash.h" namespace tint::constant { /// Scalar holds a single scalar or abstract-numeric value. template -class Scalar : public Castable, Value> { +class Scalar : public utils::Castable, Value> { public: static_assert(!std::is_same_v, T> || std::is_same_v, "T must be a Number or bool"); diff --git a/src/tint/constant/splat.h b/src/tint/constant/splat.h index a496235d32..d8e55a6764 100644 --- a/src/tint/constant/splat.h +++ b/src/tint/constant/splat.h @@ -15,9 +15,9 @@ #ifndef SRC_TINT_CONSTANT_SPLAT_H_ #define SRC_TINT_CONSTANT_SPLAT_H_ -#include "src/tint/castable.h" #include "src/tint/constant/composite.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/vector.h" namespace tint::constant { @@ -26,7 +26,7 @@ namespace tint::constant { /// /// Splat is used for zero-initializers, 'splat' initializers, or initializers where each element is /// identical. Splat may be of a vector, matrix, array or structure type. -class Splat : public Castable { +class Splat : public utils::Castable { public: /// Constructor /// @param t the splat type diff --git a/src/tint/constant/value.h b/src/tint/constant/value.h index eb29998fcc..fe1f78a83c 100644 --- a/src/tint/constant/value.h +++ b/src/tint/constant/value.h @@ -17,16 +17,16 @@ #include -#include "src/tint/castable.h" #include "src/tint/constant/clone_context.h" #include "src/tint/constant/node.h" #include "src/tint/number.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" namespace tint::constant { /// Value is the interface to a compile-time evaluated expression value. -class Value : public Castable { +class Value : public utils::Castable { public: /// Constructor Value(); diff --git a/src/tint/fuzzers/tint_ast_fuzzer/util.h b/src/tint/fuzzers/tint_ast_fuzzer/util.h index fe114f407e..b428d46b85 100644 --- a/src/tint/fuzzers/tint_ast_fuzzer/util.h +++ b/src/tint/fuzzers/tint_ast_fuzzer/util.h @@ -19,12 +19,12 @@ #include "src/tint/ast/module.h" #include "src/tint/ast/variable_decl_statement.h" -#include "src/tint/castable.h" #include "src/tint/program.h" #include "src/tint/sem/block_statement.h" #include "src/tint/sem/function.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/variable.h" +#include "src/tint/utils/castable.h" namespace tint::fuzzers::ast_fuzzer::util { /// @file diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index f2749f312a..246943d6b4 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -456,7 +456,7 @@ std::vector Inspector::GetWriteOnlyStorageTextureResourceBindin std::vector Inspector::GetTextureResourceBindings( const std::string& entry_point, - const tint::TypeInfo* texture_type, + const tint::utils::TypeInfo* texture_type, ResourceBinding::ResourceType resource_type) { auto* func = FindEntryPointByName(entry_point); if (!func) { @@ -485,19 +485,20 @@ std::vector Inspector::GetTextureResourceBindings( std::vector Inspector::GetDepthTextureResourceBindings( const std::string& entry_point) { - return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), + return GetTextureResourceBindings(entry_point, &utils::TypeInfo::Of(), ResourceBinding::ResourceType::kDepthTexture); } std::vector Inspector::GetDepthMultisampledTextureResourceBindings( const std::string& entry_point) { - return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), + return GetTextureResourceBindings(entry_point, + &utils::TypeInfo::Of(), ResourceBinding::ResourceType::kDepthMultisampledTexture); } std::vector Inspector::GetExternalTextureResourceBindings( const std::string& entry_point) { - return GetTextureResourceBindings(entry_point, &TypeInfo::Of(), + return GetTextureResourceBindings(entry_point, &utils::TypeInfo::Of(), ResourceBinding::ResourceType::kExternalTexture); } diff --git a/src/tint/inspector/inspector.h b/src/tint/inspector/inspector.h index 443bbab6a8..a4cfe6edb4 100644 --- a/src/tint/inspector/inspector.h +++ b/src/tint/inspector/inspector.h @@ -195,7 +195,7 @@ class Inspector { /// @returns vector of all of the bindings for depth textures. std::vector GetTextureResourceBindings( const std::string& entry_point, - const tint::TypeInfo* texture_type, + const tint::utils::TypeInfo* texture_type, ResourceBinding::ResourceType resource_type); /// @param entry_point name of the entry point to get information about. diff --git a/src/tint/ir/binary.h b/src/tint/ir/binary.h index bb74ea81cf..e39758fc92 100644 --- a/src/tint/ir/binary.h +++ b/src/tint/ir/binary.h @@ -15,16 +15,16 @@ #ifndef SRC_TINT_IR_BINARY_H_ #define SRC_TINT_IR_BINARY_H_ -#include "src/tint/castable.h" #include "src/tint/ir/instruction.h" #include "src/tint/symbol_table.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// An instruction in the IR. -class Binary : public Castable { +class Binary : public utils::Castable { public: /// The kind of instruction. enum class Kind { diff --git a/src/tint/ir/bitcast.h b/src/tint/ir/bitcast.h index 7e9f7dbcb1..7dcb495c6b 100644 --- a/src/tint/ir/bitcast.h +++ b/src/tint/ir/bitcast.h @@ -15,16 +15,16 @@ #ifndef SRC_TINT_IR_BITCAST_H_ #define SRC_TINT_IR_BITCAST_H_ -#include "src/tint/castable.h" #include "src/tint/ir/instruction.h" #include "src/tint/symbol_table.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// A bitcast instruction in the IR. -class Bitcast : public Castable { +class Bitcast : public utils::Castable { public: /// Constructor /// @param result the result value diff --git a/src/tint/ir/block.h b/src/tint/ir/block.h index 42581677e1..e83d43a698 100644 --- a/src/tint/ir/block.h +++ b/src/tint/ir/block.h @@ -25,7 +25,7 @@ namespace tint::ir { /// A flow node comprising a block of statements. The instructions in the block are a linear list of /// instructions to execute. The block will branch at the end. The only blocks which do not branch /// are the end blocks of functions. -class Block : public Castable { +class Block : public utils::Castable { public: /// Constructor Block(); diff --git a/src/tint/ir/builtin.h b/src/tint/ir/builtin.h index 4fc8a76e03..ee73ec6395 100644 --- a/src/tint/ir/builtin.h +++ b/src/tint/ir/builtin.h @@ -16,16 +16,16 @@ #define SRC_TINT_IR_BUILTIN_H_ #include "src/tint/builtin/function.h" -#include "src/tint/castable.h" #include "src/tint/ir/call.h" #include "src/tint/symbol_table.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// A value conversion instruction in the IR. -class Builtin : public Castable { +class Builtin : public utils::Castable { public: /// Constructor /// @param result the result value diff --git a/src/tint/ir/call.h b/src/tint/ir/call.h index e1f9d481c5..89c07cd192 100644 --- a/src/tint/ir/call.h +++ b/src/tint/ir/call.h @@ -15,16 +15,16 @@ #ifndef SRC_TINT_IR_CALL_H_ #define SRC_TINT_IR_CALL_H_ -#include "src/tint/castable.h" #include "src/tint/ir/instruction.h" #include "src/tint/symbol_table.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// A Call instruction in the IR. -class Call : public Castable { +class Call : public utils::Castable { public: /// Constructor /// @param result the result value diff --git a/src/tint/ir/constant.h b/src/tint/ir/constant.h index 7be3688d51..dd50facf58 100644 --- a/src/tint/ir/constant.h +++ b/src/tint/ir/constant.h @@ -23,7 +23,7 @@ namespace tint::ir { /// Constant in the IR. -class Constant : public Castable { +class Constant : public utils::Castable { public: /// Constructor /// @param val the value stored in the constant diff --git a/src/tint/ir/construct.h b/src/tint/ir/construct.h index 24449b689d..f6c7a0ad4a 100644 --- a/src/tint/ir/construct.h +++ b/src/tint/ir/construct.h @@ -15,16 +15,16 @@ #ifndef SRC_TINT_IR_CONSTRUCT_H_ #define SRC_TINT_IR_CONSTRUCT_H_ -#include "src/tint/castable.h" #include "src/tint/ir/call.h" #include "src/tint/symbol_table.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// A constructor instruction in the IR. -class Construct : public Castable { +class Construct : public utils::Castable { public: /// Constructor /// @param result the result value diff --git a/src/tint/ir/convert.h b/src/tint/ir/convert.h index 3b8878bbf4..15d118eaf9 100644 --- a/src/tint/ir/convert.h +++ b/src/tint/ir/convert.h @@ -15,16 +15,16 @@ #ifndef SRC_TINT_IR_CONVERT_H_ #define SRC_TINT_IR_CONVERT_H_ -#include "src/tint/castable.h" #include "src/tint/ir/call.h" #include "src/tint/symbol_table.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// A value conversion instruction in the IR. -class Convert : public Castable { +class Convert : public utils::Castable { public: /// Constructor /// @param result the result value diff --git a/src/tint/ir/flow_node.h b/src/tint/ir/flow_node.h index 019a8a0a17..2a91674559 100644 --- a/src/tint/ir/flow_node.h +++ b/src/tint/ir/flow_node.h @@ -15,13 +15,13 @@ #ifndef SRC_TINT_IR_FLOW_NODE_H_ #define SRC_TINT_IR_FLOW_NODE_H_ -#include "src/tint/castable.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/vector.h" namespace tint::ir { /// Base class for flow nodes -class FlowNode : public Castable { +class FlowNode : public utils::Castable { public: ~FlowNode() override; diff --git a/src/tint/ir/function.h b/src/tint/ir/function.h index c6032ba0f5..ab3c6ebd23 100644 --- a/src/tint/ir/function.h +++ b/src/tint/ir/function.h @@ -27,7 +27,7 @@ class Terminator; namespace tint::ir { /// An IR representation of a function -class Function : public Castable { +class Function : public utils::Castable { public: /// Constructor Function(); diff --git a/src/tint/ir/if.h b/src/tint/ir/if.h index 823700e573..255b165851 100644 --- a/src/tint/ir/if.h +++ b/src/tint/ir/if.h @@ -27,7 +27,7 @@ class Block; namespace tint::ir { /// A flow node representing an if statement. -class If : public Castable { +class If : public utils::Castable { public: /// Constructor If(); diff --git a/src/tint/ir/instruction.h b/src/tint/ir/instruction.h index 8ae2de43bd..8f58e5475a 100644 --- a/src/tint/ir/instruction.h +++ b/src/tint/ir/instruction.h @@ -15,15 +15,15 @@ #ifndef SRC_TINT_IR_INSTRUCTION_H_ #define SRC_TINT_IR_INSTRUCTION_H_ -#include "src/tint/castable.h" #include "src/tint/ir/value.h" #include "src/tint/symbol_table.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// An instruction in the IR. -class Instruction : public Castable { +class Instruction : public utils::Castable { public: Instruction(const Instruction& instr) = delete; Instruction(Instruction&& instr) = delete; diff --git a/src/tint/ir/loop.h b/src/tint/ir/loop.h index 2b026e6f37..e0066f4465 100644 --- a/src/tint/ir/loop.h +++ b/src/tint/ir/loop.h @@ -22,7 +22,7 @@ namespace tint::ir { /// Flow node describing a loop. -class Loop : public Castable { +class Loop : public utils::Castable { public: /// Constructor Loop(); diff --git a/src/tint/ir/switch.h b/src/tint/ir/switch.h index 6ba1d4cfab..2ff927ef25 100644 --- a/src/tint/ir/switch.h +++ b/src/tint/ir/switch.h @@ -24,7 +24,7 @@ namespace tint::ir { /// Flow node representing a switch statement -class Switch : public Castable { +class Switch : public utils::Castable { public: /// A case selector struct CaseSelector { diff --git a/src/tint/ir/temp.h b/src/tint/ir/temp.h index 94330999e4..31bc28489d 100644 --- a/src/tint/ir/temp.h +++ b/src/tint/ir/temp.h @@ -22,7 +22,7 @@ namespace tint::ir { /// Temporary value in the IR. -class Temp : public Castable { +class Temp : public utils::Castable { public: /// A value id. using Id = uint32_t; diff --git a/src/tint/ir/terminator.h b/src/tint/ir/terminator.h index 9f9aba05c2..35fbcee1f0 100644 --- a/src/tint/ir/terminator.h +++ b/src/tint/ir/terminator.h @@ -21,7 +21,7 @@ namespace tint::ir { /// Flow node used as the end of a function. Must only be used as the `end_target` in a function /// flow node. There are no instructions and no branches from this node. -class Terminator : public Castable { +class Terminator : public utils::Castable { public: /// Constructor Terminator(); diff --git a/src/tint/ir/user_call.h b/src/tint/ir/user_call.h index 34215ed931..8c99d894ee 100644 --- a/src/tint/ir/user_call.h +++ b/src/tint/ir/user_call.h @@ -15,16 +15,16 @@ #ifndef SRC_TINT_IR_USER_CALL_H_ #define SRC_TINT_IR_USER_CALL_H_ -#include "src/tint/castable.h" #include "src/tint/ir/call.h" #include "src/tint/symbol_table.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" namespace tint::ir { /// A user call instruction in the IR. -class UserCall : public Castable { +class UserCall : public utils::Castable { public: /// Constructor /// @param result the result value diff --git a/src/tint/ir/value.h b/src/tint/ir/value.h index 2d4fcb0b4f..b498e9d49c 100644 --- a/src/tint/ir/value.h +++ b/src/tint/ir/value.h @@ -15,9 +15,9 @@ #ifndef SRC_TINT_IR_VALUE_H_ #define SRC_TINT_IR_VALUE_H_ -#include "src/tint/castable.h" #include "src/tint/symbol_table.h" #include "src/tint/type/type.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/string_stream.h" #include "src/tint/utils/unique_vector.h" @@ -29,7 +29,7 @@ class Instruction; namespace tint::ir { /// Value in the IR. -class Value : public Castable { +class Value : public utils::Castable { public: /// Destructor ~Value() override; diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index e729a1724d..8061f749c4 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -693,7 +693,8 @@ class StructuredTraverser { /// A StatementBuilder for ast::SwitchStatement /// @see StatementBuilder -struct SwitchStatementBuilder final : public Castable { +struct SwitchStatementBuilder final + : public utils::Castable { /// Constructor /// @param cond the switch statement condition explicit SwitchStatementBuilder(const ast::Expression* cond) : condition(cond) {} @@ -717,7 +718,7 @@ struct SwitchStatementBuilder final : public Castable { +struct IfStatementBuilder final : public utils::Castable { /// Constructor /// @param c the if-statement condition explicit IfStatementBuilder(const ast::Expression* c) : cond(c) {} @@ -738,7 +739,7 @@ struct IfStatementBuilder final : public Castable { +struct LoopStatementBuilder final : public utils::Castable { /// @param builder the program builder /// @returns the built ast::LoopStatement ast::LoopStatement* Build(ProgramBuilder* builder) const override { diff --git a/src/tint/reader/spirv/function.h b/src/tint/reader/spirv/function.h index 11fc92ce7c..19452b1233 100644 --- a/src/tint/reader/spirv/function.h +++ b/src/tint/reader/spirv/function.h @@ -407,7 +407,7 @@ inline utils::StringStream& operator<<(utils::StringStream& o, const DefInfo& di /// become immutable. The builders may hold mutable state while the /// StatementBlock is being constructed, which becomes an immutable node on /// StatementBlock::Finalize(). -class StatementBuilder : public Castable { +class StatementBuilder : public utils::Castable { public: /// Constructor StatementBuilder() : Base(ProgramID(), ast::NodeID(), Source{}) {} diff --git a/src/tint/reader/spirv/parser_type.h b/src/tint/reader/spirv/parser_type.h index 8623be5137..d3295ee759 100644 --- a/src/tint/reader/spirv/parser_type.h +++ b/src/tint/reader/spirv/parser_type.h @@ -23,11 +23,11 @@ #include "src/tint/builtin/access.h" #include "src/tint/builtin/address_space.h" #include "src/tint/builtin/texel_format.h" -#include "src/tint/castable.h" #include "src/tint/symbol.h" #include "src/tint/type/sampler_kind.h" #include "src/tint/type/texture_dimension.h" #include "src/tint/utils/block_allocator.h" +#include "src/tint/utils/castable.h" // Forward declarations namespace tint { @@ -37,7 +37,7 @@ class ProgramBuilder; namespace tint::reader::spirv { /// Type is the base class for all types -class Type : public Castable { +class Type : public utils::Castable { public: /// Constructor Type(); @@ -97,7 +97,7 @@ class Type : public Castable { using TypeList = std::vector; /// `void` type -struct Void final : public Castable { +struct Void final : public utils::Castable { /// @param b the ProgramBuilder used to construct the AST types /// @returns the constructed ast::Type node for the given type ast::Type Build(ProgramBuilder& b) const override; @@ -109,7 +109,7 @@ struct Void final : public Castable { }; /// `bool` type -struct Bool final : public Castable { +struct Bool final : public utils::Castable { /// @param b the ProgramBuilder used to construct the AST types /// @returns the constructed ast::Type node for the given type ast::Type Build(ProgramBuilder& b) const override; @@ -121,7 +121,7 @@ struct Bool final : public Castable { }; /// `u32` type -struct U32 final : public Castable { +struct U32 final : public utils::Castable { /// @param b the ProgramBuilder used to construct the AST types /// @returns the constructed ast::Type node for the given type ast::Type Build(ProgramBuilder& b) const override; @@ -133,7 +133,7 @@ struct U32 final : public Castable { }; /// `f32` type -struct F32 final : public Castable { +struct F32 final : public utils::Castable { /// @param b the ProgramBuilder used to construct the AST types /// @returns the constructed ast::Type node for the given type ast::Type Build(ProgramBuilder& b) const override; @@ -145,7 +145,7 @@ struct F32 final : public Castable { }; /// `i32` type -struct I32 final : public Castable { +struct I32 final : public utils::Castable { /// @param b the ProgramBuilder used to construct the AST types /// @returns the constructed ast::Type node for the given type ast::Type Build(ProgramBuilder& b) const override; @@ -157,7 +157,7 @@ struct I32 final : public Castable { }; /// `ptr` type -struct Pointer final : public Castable { +struct Pointer final : public utils::Castable { /// Constructor /// @param ty the store type /// @param sc the pointer address space @@ -188,7 +188,7 @@ struct Pointer final : public Castable { /// `ref` type /// Note this has no AST representation, but is used for type tracking in the /// reader. -struct Reference final : public Castable { +struct Reference final : public utils::Castable { /// Constructor /// @param ty the referenced type /// @param sc the reference address space @@ -217,7 +217,7 @@ struct Reference final : public Castable { }; /// `vecN` type -struct Vector final : public Castable { +struct Vector final : public utils::Castable { /// Constructor /// @param ty the element type /// @param sz the number of elements in the vector @@ -243,7 +243,7 @@ struct Vector final : public Castable { }; /// `matNxM` type -struct Matrix final : public Castable { +struct Matrix final : public utils::Castable { /// Constructor /// @param ty the matrix element type /// @param c the number of columns in the matrix @@ -272,7 +272,7 @@ struct Matrix final : public Castable { }; /// `array` type -struct Array final : public Castable { +struct Array final : public utils::Castable { /// Constructor /// @param el the element type /// @param sz the number of elements in the array. 0 represents runtime-sized @@ -302,7 +302,7 @@ struct Array final : public Castable { }; /// `sampler` type -struct Sampler final : public Castable { +struct Sampler final : public utils::Castable { /// Constructor /// @param k the sampler kind explicit Sampler(type::SamplerKind k); @@ -325,7 +325,7 @@ struct Sampler final : public Castable { }; /// Base class for texture types -struct Texture : public Castable { +struct Texture : public utils::Castable { ~Texture() override; /// Constructor @@ -341,7 +341,7 @@ struct Texture : public Castable { }; /// `texture_depth_D` type -struct DepthTexture final : public Castable { +struct DepthTexture final : public utils::Castable { /// Constructor /// @param d the texture dimensions explicit DepthTexture(type::TextureDimension d); @@ -361,7 +361,7 @@ struct DepthTexture final : public Castable { }; /// `texture_depth_multisampled_D` type -struct DepthMultisampledTexture final : public Castable { +struct DepthMultisampledTexture final : public utils::Castable { /// Constructor /// @param d the texture dimensions explicit DepthMultisampledTexture(type::TextureDimension d); @@ -381,7 +381,7 @@ struct DepthMultisampledTexture final : public Castable` type -struct MultisampledTexture final : public Castable { +struct MultisampledTexture final : public utils::Castable { /// Constructor /// @param d the texture dimensions /// @param t the multisampled texture type @@ -405,7 +405,7 @@ struct MultisampledTexture final : public Castable }; /// `texture_D` type -struct SampledTexture final : public Castable { +struct SampledTexture final : public utils::Castable { /// Constructor /// @param d the texture dimensions /// @param t the sampled texture type @@ -429,7 +429,7 @@ struct SampledTexture final : public Castable { }; /// `texture_storage_D` type -struct StorageTexture final : public Castable { +struct StorageTexture final : public utils::Castable { /// Constructor /// @param d the texture dimensions /// @param f the storage image format @@ -457,7 +457,7 @@ struct StorageTexture final : public Castable { }; /// Base class for named types -struct Named : public Castable { +struct Named : public utils::Castable { /// Constructor /// @param n the type name explicit Named(Symbol n); @@ -479,7 +479,7 @@ struct Named : public Castable { }; /// `type T = N` type -struct Alias final : public Castable { +struct Alias final : public utils::Castable { /// Constructor /// @param n the alias name /// @param t the aliased type @@ -498,7 +498,7 @@ struct Alias final : public Castable { }; /// `struct N { ... };` type -struct Struct final : public Castable { +struct Struct final : public utils::Castable { /// Constructor /// @param n the struct name /// @param m the member types diff --git a/src/tint/resolver/attribute_validation_test.cc b/src/tint/resolver/attribute_validation_test.cc index 45dca0b93a..d6a2f0fc35 100644 --- a/src/tint/resolver/attribute_validation_test.cc +++ b/src/tint/resolver/attribute_validation_test.cc @@ -2185,7 +2185,7 @@ TEST_F(MustUseAttributeTest, UsedOnFnWithNoReturnValue) { namespace InternalAttributeDeps { namespace { -class TestAttribute : public Castable { +class TestAttribute : public utils::Castable { public: TestAttribute(ProgramID pid, ast::NodeID nid, const ast::IdentifierExpression* dep) : Base(pid, nid, utils::Vector{dep}) {} diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 62dde26784..6aa050b794 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -58,7 +58,7 @@ constexpr static const size_t kNumFixedParams = 8; constexpr static const size_t kNumFixedCandidates = 8; /// A special type that matches all TypeMatchers -class Any final : public Castable { +class Any final : public utils::Castable { public: Any() : Base(0u, type::Flags{}) {} ~Any() override = default; diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index bfe45c9037..1ec680d5ab 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -771,7 +771,7 @@ bool Resolver::AllocateOverridableConstantIds() { void Resolver::SetShadows() { for (auto it : dependencies_.shadows) { - CastableBase* b = sem_.Get(it.value); + utils::CastableBase* b = sem_.Get(it.value); if (TINT_UNLIKELY(!b)) { TINT_ICE(Resolver, diagnostics_) << "AST node '" << it.value->TypeInfo().name << "' had no semantic info\n" @@ -4265,7 +4265,8 @@ template SEM* Resolver::StatementScope(const ast::Statement* ast, SEM* sem, F&& callback) { builder_->Sem().Add(ast, sem); - auto* as_compound = As(sem); + auto* as_compound = + As(sem); // Helper to handle attributes that are supported on certain types of statement. auto handle_attributes = [&](auto* stmt, sem::Statement* sem_stmt, const char* use) { diff --git a/src/tint/resolver/validation_test.cc b/src/tint/resolver/validation_test.cc index 6485a6a331..6b84d85289 100644 --- a/src/tint/resolver/validation_test.cc +++ b/src/tint/resolver/validation_test.cc @@ -50,13 +50,13 @@ namespace { using ResolverValidationTest = ResolverTest; -class FakeStmt final : public Castable { +class FakeStmt final : public utils::Castable { public: FakeStmt(ProgramID pid, ast::NodeID nid, Source src) : Base(pid, nid, src) {} FakeStmt* Clone(CloneContext*) const override { return nullptr; } }; -class FakeExpr final : public Castable { +class FakeExpr final : public utils::Castable { public: FakeExpr(ProgramID pid, ast::NodeID nid, Source src) : Base(pid, nid, src) {} FakeExpr* Clone(CloneContext*) const override { return nullptr; } diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index 36d5139154..f72000b836 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -2508,7 +2508,7 @@ bool Validator::IncrementDecrementStatement(const ast::IncrementDecrementStateme } bool Validator::NoDuplicateAttributes(utils::VectorRef attributes) const { - utils::Hashmap seen; + utils::Hashmap seen; utils::Vector diagnostic_controls; for (auto* d : attributes) { if (auto* diag = d->As()) { diff --git a/src/tint/sem/array_count.cc b/src/tint/sem/array_count.cc index 90abb691ef..2f7d1e1290 100644 --- a/src/tint/sem/array_count.cc +++ b/src/tint/sem/array_count.cc @@ -22,7 +22,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::UnnamedOverrideArrayCount); namespace tint::sem { NamedOverrideArrayCount::NamedOverrideArrayCount(const GlobalVariable* var) - : Base(static_cast(TypeInfo::Of().full_hashcode)), + : Base(static_cast(utils::TypeInfo::Of().full_hashcode)), variable(var) {} NamedOverrideArrayCount::~NamedOverrideArrayCount() = default; @@ -43,7 +43,8 @@ type::ArrayCount* NamedOverrideArrayCount::Clone(type::CloneContext&) const { } UnnamedOverrideArrayCount::UnnamedOverrideArrayCount(const ValueExpression* e) - : Base(static_cast(TypeInfo::Of().full_hashcode)), expr(e) {} + : Base(static_cast(utils::TypeInfo::Of().full_hashcode)), + expr(e) {} UnnamedOverrideArrayCount::~UnnamedOverrideArrayCount() = default; bool UnnamedOverrideArrayCount::Equals(const UniqueNode& other) const { diff --git a/src/tint/sem/array_count.h b/src/tint/sem/array_count.h index a4143d8244..9f0cd536b9 100644 --- a/src/tint/sem/array_count.h +++ b/src/tint/sem/array_count.h @@ -29,7 +29,8 @@ namespace tint::sem { /// override N : i32; /// type arr = array /// ``` -class NamedOverrideArrayCount final : public Castable { +class NamedOverrideArrayCount final + : public utils::Castable { public: /// Constructor /// @param var the `override` variable @@ -58,7 +59,7 @@ class NamedOverrideArrayCount final : public Castable /// ``` class UnnamedOverrideArrayCount final - : public Castable { + : public utils::Castable { public: /// Constructor /// @param e the override expression diff --git a/src/tint/sem/block_statement.h b/src/tint/sem/block_statement.h index e5d4969a2e..9cf1e3ea2b 100644 --- a/src/tint/sem/block_statement.h +++ b/src/tint/sem/block_statement.h @@ -31,7 +31,7 @@ namespace tint::sem { /// Holds semantic information about a block, such as parent block and variables /// declared in the block. -class BlockStatement : public Castable { +class BlockStatement : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this block statement @@ -50,7 +50,8 @@ class BlockStatement : public Castable { }; /// The root block statement for a function -class FunctionBlockStatement final : public Castable { +class FunctionBlockStatement final + : public utils::Castable { public: /// Constructor /// @param function the owning function @@ -61,7 +62,7 @@ class FunctionBlockStatement final : public Castable { +class LoopBlockStatement final : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this block statement diff --git a/src/tint/sem/break_if_statement.h b/src/tint/sem/break_if_statement.h index c5b62dec54..dcab9bb46a 100644 --- a/src/tint/sem/break_if_statement.h +++ b/src/tint/sem/break_if_statement.h @@ -28,7 +28,7 @@ class ValueExpression; namespace tint::sem { /// Holds semantic information about a break-if statement -class BreakIfStatement final : public Castable { +class BreakIfStatement final : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this break-if statement diff --git a/src/tint/sem/builtin.h b/src/tint/sem/builtin.h index b535e72cfe..07c3ad1c27 100644 --- a/src/tint/sem/builtin.h +++ b/src/tint/sem/builtin.h @@ -77,7 +77,7 @@ bool IsAtomicBuiltin(builtin::Function i); bool IsDP4aBuiltin(builtin::Function i); /// Builtin holds the semantic information for a builtin function. -class Builtin final : public Castable { +class Builtin final : public utils::Castable { public: /// Constructor /// @param type the builtin type diff --git a/src/tint/sem/builtin_enum_expression.h b/src/tint/sem/builtin_enum_expression.h index 3a403fb44f..86c70c3393 100644 --- a/src/tint/sem/builtin_enum_expression.h +++ b/src/tint/sem/builtin_enum_expression.h @@ -26,7 +26,7 @@ namespace tint::sem { /// Base class for BuiltinEnumExpression. /// Useful for Is() queries. -class BuiltinEnumExpressionBase : public Castable { +class BuiltinEnumExpressionBase : public utils::Castable { public: /// Constructor /// @param declaration the AST node @@ -41,7 +41,7 @@ class BuiltinEnumExpressionBase : public Castable class BuiltinEnumExpression - : public Castable, BuiltinEnumExpressionBase> { + : public utils::Castable, BuiltinEnumExpressionBase> { public: /// Constructor /// @param declaration the AST node diff --git a/src/tint/sem/call.h b/src/tint/sem/call.h index 3079eb1966..f24899de60 100644 --- a/src/tint/sem/call.h +++ b/src/tint/sem/call.h @@ -26,7 +26,7 @@ namespace tint::sem { /// Call is the base class for semantic nodes that hold semantic information for /// ast::CallExpression nodes. -class Call final : public Castable { +class Call final : public utils::Castable { public: /// Constructor /// @param declaration the AST node diff --git a/src/tint/sem/call_target.h b/src/tint/sem/call_target.h index 096aa8f1f6..0bcb5d2e0e 100644 --- a/src/tint/sem/call_target.h +++ b/src/tint/sem/call_target.h @@ -67,7 +67,7 @@ struct CallTargetSignature { /// CallTarget is the base for callable functions, builtins, value constructors and value /// conversions. -class CallTarget : public Castable { +class CallTarget : public utils::Castable { public: /// Constructor /// @param stage the earliest evaluation stage for a call to this target diff --git a/src/tint/sem/expression.h b/src/tint/sem/expression.h index 884ff4dc5d..36b4b71c4e 100644 --- a/src/tint/sem/expression.h +++ b/src/tint/sem/expression.h @@ -26,7 +26,7 @@ class Statement; namespace tint::sem { /// Expression holds the semantic information for expression nodes. -class Expression : public Castable { +class Expression : public utils::Castable { public: /// Constructor /// @param declaration the AST node diff --git a/src/tint/sem/for_loop_statement.h b/src/tint/sem/for_loop_statement.h index 7e22912570..154e00da5d 100644 --- a/src/tint/sem/for_loop_statement.h +++ b/src/tint/sem/for_loop_statement.h @@ -28,7 +28,7 @@ class ValueExpression; namespace tint::sem { /// Holds semantic information about a for-loop statement -class ForLoopStatement final : public Castable { +class ForLoopStatement final : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this for-loop statement diff --git a/src/tint/sem/function.cc b/src/tint/sem/function.cc index 9484012ced..eab78e0cba 100644 --- a/src/tint/sem/function.cc +++ b/src/tint/sem/function.cc @@ -114,7 +114,7 @@ Function::VariableBindings Function::TransitivelyReferencedMultisampledTextureVa } Function::VariableBindings Function::TransitivelyReferencedVariablesOfType( - const tint::TypeInfo* type) const { + const tint::utils::TypeInfo* type) const { VariableBindings ret; for (auto* global : TransitivelyReferencedGlobals()) { auto* unwrapped_type = global->Type()->UnwrapRef(); diff --git a/src/tint/sem/function.h b/src/tint/sem/function.h index b157e7dff9..31390f7311 100644 --- a/src/tint/sem/function.h +++ b/src/tint/sem/function.h @@ -47,7 +47,7 @@ namespace tint::sem { using WorkgroupSize = std::array, 3>; /// Function holds the semantic information for function nodes. -class Function final : public Castable { +class Function final : public utils::Castable { public: /// A vector of [Variable*, sem::BindingPoint] pairs using VariableBindings = std::vector>; @@ -219,14 +219,14 @@ class Function final : public Castable { /// must be decorated with both binding and group attributes. /// @param type the type of the variables to find /// @returns the referenced variables - VariableBindings TransitivelyReferencedVariablesOfType(const tint::TypeInfo* type) const; + VariableBindings TransitivelyReferencedVariablesOfType(const tint::utils::TypeInfo* type) const; /// Retrieves any referenced variables of the given type. Note, the variables /// must be decorated with both binding and group attributes. /// @returns the referenced variables template VariableBindings TransitivelyReferencedVariablesOfType() const { - return TransitivelyReferencedVariablesOfType(&TypeInfo::Of()); + return TransitivelyReferencedVariablesOfType(&utils::TypeInfo::Of()); } /// Checks if the given entry point is an ancestor diff --git a/src/tint/sem/function_expression.h b/src/tint/sem/function_expression.h index de5ac5ad23..9d9e8ec863 100644 --- a/src/tint/sem/function_expression.h +++ b/src/tint/sem/function_expression.h @@ -26,7 +26,7 @@ namespace tint::sem { /// FunctionExpression holds the semantic information for expression nodes that resolve to /// functions. -class FunctionExpression : public Castable { +class FunctionExpression : public utils::Castable { public: /// Constructor /// @param declaration the AST node diff --git a/src/tint/sem/if_statement.h b/src/tint/sem/if_statement.h index 5b27fbaea5..42146fcee5 100644 --- a/src/tint/sem/if_statement.h +++ b/src/tint/sem/if_statement.h @@ -28,7 +28,7 @@ class ValueExpression; namespace tint::sem { /// Holds semantic information about an if statement -class IfStatement final : public Castable { +class IfStatement final : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this if statement diff --git a/src/tint/sem/index_accessor_expression.h b/src/tint/sem/index_accessor_expression.h index 8118659367..c2379f50a7 100644 --- a/src/tint/sem/index_accessor_expression.h +++ b/src/tint/sem/index_accessor_expression.h @@ -23,7 +23,8 @@ namespace tint::sem { /// IndexAccessorExpression holds the semantic information for a ast::IndexAccessorExpression node. -class IndexAccessorExpression final : public Castable { +class IndexAccessorExpression final + : public utils::Castable { public: /// Constructor /// @param declaration the AST node diff --git a/src/tint/sem/info.h b/src/tint/sem/info.h index be5061833b..9e5a139731 100644 --- a/src/tint/sem/info.h +++ b/src/tint/sem/info.h @@ -77,7 +77,7 @@ class Info { /// @param ast_node the AST node /// @returns a pointer to the semantic node if found, otherwise nullptr template > const RESULT* Get(const AST* ast_node) const { static_assert(std::is_same_v || @@ -141,7 +141,8 @@ class Info { /// Records that this variable (transitively) references the given override variable. /// @param from the item the variable is referenced from /// @param var the module-scope override variable - void AddTransitivelyReferencedOverride(const CastableBase* from, const GlobalVariable* var) { + void AddTransitivelyReferencedOverride(const utils::CastableBase* from, + const GlobalVariable* var) { if (referenced_overrides_.count(from) == 0) { referenced_overrides_.insert({from, TransitivelyReferenced{}}); } @@ -150,7 +151,8 @@ class Info { /// @param from the key to look up /// @returns all transitively referenced override variables or nullptr if none set - const TransitivelyReferenced* TransitivelyReferencedOverrides(const CastableBase* from) const { + const TransitivelyReferenced* TransitivelyReferencedOverrides( + const utils::CastableBase* from) const { if (referenced_overrides_.count(from) == 0) { return nullptr; } @@ -166,9 +168,9 @@ class Info { private: // AST node index to semantic node - std::vector nodes_; + std::vector nodes_; // Lists transitively referenced overrides for the given item - std::unordered_map referenced_overrides_; + std::unordered_map referenced_overrides_; // The semantic module sem::Module* module_ = nullptr; }; diff --git a/src/tint/sem/load.h b/src/tint/sem/load.h index e02e0505c9..674b631061 100644 --- a/src/tint/sem/load.h +++ b/src/tint/sem/load.h @@ -23,7 +23,7 @@ namespace tint::sem { /// Load is a semantic expression which represents the load of a reference to a non-reference value. /// Loads from reference types are implicit in WGSL, so the Load semantic node shares the same AST /// node as the inner semantic node. -class Load final : public Castable { +class Load final : public utils::Castable { public: /// Constructor /// @param reference the reference expression being loaded diff --git a/src/tint/sem/loop_statement.h b/src/tint/sem/loop_statement.h index 6dc7037fba..c09bbb5376 100644 --- a/src/tint/sem/loop_statement.h +++ b/src/tint/sem/loop_statement.h @@ -25,7 +25,7 @@ class LoopStatement; namespace tint::sem { /// Holds semantic information about a loop statement -class LoopStatement final : public Castable { +class LoopStatement final : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this loop statement @@ -41,7 +41,7 @@ class LoopStatement final : public Castable { /// Holds semantic information about a loop continuing block class LoopContinuingBlockStatement final - : public Castable { + : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this block statement diff --git a/src/tint/sem/materialize.h b/src/tint/sem/materialize.h index 4ce11909f4..c7b612f3e3 100644 --- a/src/tint/sem/materialize.h +++ b/src/tint/sem/materialize.h @@ -25,7 +25,7 @@ namespace tint::sem { /// the same AST node as the inner semantic node. /// Abstract numerics types may only be used by compile-time expressions, so a Materialize semantic /// node must have a valid Constant value. -class Materialize final : public Castable { +class Materialize final : public utils::Castable { public: /// Constructor /// @param expr the inner expression, being materialized diff --git a/src/tint/sem/member_accessor_expression.h b/src/tint/sem/member_accessor_expression.h index 7ed0a417d5..cea9f2d436 100644 --- a/src/tint/sem/member_accessor_expression.h +++ b/src/tint/sem/member_accessor_expression.h @@ -30,7 +30,7 @@ namespace tint::sem { /// MemberAccessorExpression holds the semantic information for a /// ast::MemberAccessorExpression node. -class MemberAccessorExpression : public Castable { +class MemberAccessorExpression : public utils::Castable { public: /// Destructor ~MemberAccessorExpression() override; @@ -64,7 +64,8 @@ class MemberAccessorExpression : public Castable { +class StructMemberAccess final + : public utils::Castable { public: /// Constructor /// @param declaration the AST node @@ -96,7 +97,7 @@ class StructMemberAccess final : public Castable { +class Swizzle final : public utils::Castable { public: /// Constructor /// @param declaration the AST node diff --git a/src/tint/sem/module.h b/src/tint/sem/module.h index ba4e0a91d1..172c22b142 100644 --- a/src/tint/sem/module.h +++ b/src/tint/sem/module.h @@ -29,7 +29,7 @@ namespace tint::sem { /// Module holds the top-level semantic types, functions and global variables /// used by a Program. -class Module final : public Castable { +class Module final : public utils::Castable { public: /// Constructor /// @param dep_ordered_decls the dependency-ordered module-scope declarations diff --git a/src/tint/sem/node.h b/src/tint/sem/node.h index 3f2df55f06..9a1c706afa 100644 --- a/src/tint/sem/node.h +++ b/src/tint/sem/node.h @@ -15,12 +15,12 @@ #ifndef SRC_TINT_SEM_NODE_H_ #define SRC_TINT_SEM_NODE_H_ -#include "src/tint/castable.h" +#include "src/tint/utils/castable.h" namespace tint::sem { /// Node is the base class for all semantic nodes -class Node : public Castable { +class Node : public utils::Castable { public: /// Constructor Node(); diff --git a/src/tint/sem/statement.h b/src/tint/sem/statement.h index 373b9f6017..a0eeb4488a 100644 --- a/src/tint/sem/statement.h +++ b/src/tint/sem/statement.h @@ -57,7 +57,7 @@ using FindFirstParentReturnType = typename FindFirstParentReturn::type } // namespace detail /// Statement holds the semantic information for a statement. -class Statement : public Castable { +class Statement : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this statement @@ -133,7 +133,7 @@ class Statement : public Castable { /// CompoundStatement is the base class of statements that can hold other /// statements. -class CompoundStatement : public Castable { +class CompoundStatement : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this statement diff --git a/src/tint/sem/struct.h b/src/tint/sem/struct.h index d1d20cc61a..2b437af102 100644 --- a/src/tint/sem/struct.h +++ b/src/tint/sem/struct.h @@ -38,7 +38,7 @@ class StructMember; namespace tint::sem { /// Struct holds the semantic information for structures. -class Struct final : public Castable { +class Struct final : public utils::Castable { public: /// Constructor /// @param declaration the AST structure declaration @@ -73,7 +73,7 @@ class Struct final : public Castable { }; /// StructMember holds the semantic information for structure members. -class StructMember final : public Castable { +class StructMember final : public utils::Castable { public: /// Constructor /// @param declaration the AST declaration node diff --git a/src/tint/sem/switch_statement.h b/src/tint/sem/switch_statement.h index 503d0a580f..68c754f563 100644 --- a/src/tint/sem/switch_statement.h +++ b/src/tint/sem/switch_statement.h @@ -37,7 +37,7 @@ class ValueExpression; namespace tint::sem { /// Holds semantic information about an switch statement -class SwitchStatement final : public Castable { +class SwitchStatement final : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this switch statement @@ -64,7 +64,7 @@ class SwitchStatement final : public Castable { +class CaseStatement final : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this case statement @@ -98,7 +98,7 @@ class CaseStatement final : public Castable { }; /// Holds semantic information about a switch case selector -class CaseSelector final : public Castable { +class CaseSelector final : public utils::Castable { public: /// Constructor /// @param decl the selector declaration diff --git a/src/tint/sem/type_expression.h b/src/tint/sem/type_expression.h index 0d4e43b71c..981be69900 100644 --- a/src/tint/sem/type_expression.h +++ b/src/tint/sem/type_expression.h @@ -25,7 +25,7 @@ class Type; namespace tint::sem { /// TypeExpression holds the semantic information for expression nodes that resolve to types. -class TypeExpression : public Castable { +class TypeExpression : public utils::Castable { public: /// Constructor /// @param declaration the AST node diff --git a/src/tint/sem/type_mappings.h b/src/tint/sem/type_mappings.h index efcd3a6fb8..4f312545cc 100644 --- a/src/tint/sem/type_mappings.h +++ b/src/tint/sem/type_mappings.h @@ -20,9 +20,9 @@ #include "src/tint/sem/builtin_enum_expression.h" // Forward declarations -namespace tint { +namespace tint::utils { class CastableBase; -} // namespace tint +} // namespace tint::utils namespace tint::ast { class AccessorExpression; class BinaryExpression; @@ -78,7 +78,7 @@ namespace tint::sem { struct TypeMappings { //! @cond Doxygen_Suppress BuiltinEnumExpression* operator()(ast::BuiltinAttribute*); - CastableBase* operator()(ast::Node*); + utils::CastableBase* operator()(ast::Node*); Expression* operator()(ast::Expression*); ForLoopStatement* operator()(ast::ForLoopStatement*); Function* operator()(ast::Function*); diff --git a/src/tint/sem/value_constructor.h b/src/tint/sem/value_constructor.h index 34c3b433c2..02fff3b9e8 100644 --- a/src/tint/sem/value_constructor.h +++ b/src/tint/sem/value_constructor.h @@ -21,7 +21,7 @@ namespace tint::sem { /// ValueConstructor is the CallTarget for a value constructor. -class ValueConstructor final : public Castable { +class ValueConstructor final : public utils::Castable { public: /// Constructor /// @param type the type that's being constructed diff --git a/src/tint/sem/value_conversion.h b/src/tint/sem/value_conversion.h index 2d2ab38949..890856e958 100644 --- a/src/tint/sem/value_conversion.h +++ b/src/tint/sem/value_conversion.h @@ -20,7 +20,7 @@ namespace tint::sem { /// ValueConversion is the CallTarget for a value conversion (cast). -class ValueConversion final : public Castable { +class ValueConversion final : public utils::Castable { public: /// Constructor /// @param type the target type of the cast diff --git a/src/tint/sem/value_expression.h b/src/tint/sem/value_expression.h index a6fb62494a..2059ae319f 100644 --- a/src/tint/sem/value_expression.h +++ b/src/tint/sem/value_expression.h @@ -29,7 +29,7 @@ class Variable; namespace tint::sem { /// ValueExpression holds the semantic information for expression nodes. -class ValueExpression : public Castable { +class ValueExpression : public utils::Castable { public: /// Constructor /// @param declaration the AST node diff --git a/src/tint/sem/variable.h b/src/tint/sem/variable.h index 7e70ca3d78..4cc0b1e8ee 100644 --- a/src/tint/sem/variable.h +++ b/src/tint/sem/variable.h @@ -45,7 +45,7 @@ namespace tint::sem { /// Variable is the base class for local variables, global variables and /// parameters. -class Variable : public Castable { +class Variable : public utils::Castable { public: /// Constructor /// @param declaration the AST declaration node @@ -108,7 +108,7 @@ class Variable : public Castable { }; /// LocalVariable is a function-scope variable -class LocalVariable final : public Castable { +class LocalVariable final : public utils::Castable { public: /// Constructor /// @param declaration the AST declaration node @@ -133,19 +133,19 @@ class LocalVariable final : public Castable { const sem::Statement* Statement() const { return statement_; } /// @returns the Type, Function or Variable that this local variable shadows - const CastableBase* Shadows() const { return shadows_; } + const utils::CastableBase* Shadows() const { return shadows_; } /// Sets the Type, Function or Variable that this local variable shadows /// @param shadows the Type, Function or Variable that this variable shadows - void SetShadows(const CastableBase* shadows) { shadows_ = shadows; } + void SetShadows(const utils::CastableBase* shadows) { shadows_ = shadows; } private: const sem::Statement* const statement_; - const CastableBase* shadows_ = nullptr; + const utils::CastableBase* shadows_ = nullptr; }; /// GlobalVariable is a module-scope variable -class GlobalVariable final : public Castable { +class GlobalVariable final : public utils::Castable { public: /// Constructor /// @param declaration the AST declaration node @@ -191,7 +191,7 @@ class GlobalVariable final : public Castable { }; /// Parameter is a function parameter -class Parameter final : public Castable { +class Parameter final : public utils::Castable { public: /// Constructor for function parameters /// @param declaration the AST declaration node @@ -232,11 +232,11 @@ class Parameter final : public Castable { void SetOwner(CallTarget const* owner) { owner_ = owner; } /// @returns the Type, Function or Variable that this local variable shadows - const CastableBase* Shadows() const { return shadows_; } + const utils::CastableBase* Shadows() const { return shadows_; } /// Sets the Type, Function or Variable that this local variable shadows /// @param shadows the Type, Function or Variable that this variable shadows - void SetShadows(const CastableBase* shadows) { shadows_ = shadows; } + void SetShadows(const utils::CastableBase* shadows) { shadows_ = shadows; } /// @returns the resource binding point for the parameter std::optional BindingPoint() const { return binding_point_; } @@ -248,14 +248,14 @@ class Parameter final : public Castable { const uint32_t index_; const ParameterUsage usage_; CallTarget const* owner_ = nullptr; - const CastableBase* shadows_ = nullptr; + const utils::CastableBase* shadows_ = nullptr; const std::optional binding_point_; const std::optional location_; }; /// VariableUser holds the semantic information for an identifier expression /// node that resolves to a variable. -class VariableUser final : public Castable { +class VariableUser final : public utils::Castable { public: /// Constructor /// @param declaration the AST identifier node diff --git a/src/tint/sem/while_statement.h b/src/tint/sem/while_statement.h index fa136bd2df..75d9d934a2 100644 --- a/src/tint/sem/while_statement.h +++ b/src/tint/sem/while_statement.h @@ -28,7 +28,7 @@ class ValueExpression; namespace tint::sem { /// Holds semantic information about a while statement -class WhileStatement final : public Castable { +class WhileStatement final : public utils::Castable { public: /// Constructor /// @param declaration the AST node for this while statement diff --git a/src/tint/switch.h b/src/tint/switch.h index cd2ccc87d0..df5bd95fe0 100644 --- a/src/tint/switch.h +++ b/src/tint/switch.h @@ -18,8 +18,8 @@ #include #include -#include "src/tint/castable.h" #include "src/tint/utils/bitcast.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/defer.h" namespace tint { @@ -67,7 +67,7 @@ constexpr int IndexOfDefaultCase() { /// Resolves to T if T is not nullptr_t, otherwise resolves to Ignore. template -using NullptrToIgnore = std::conditional_t, Ignore, T>; +using NullptrToIgnore = std::conditional_t, utils::Ignore, T>; /// Resolves to `const TYPE` if any of `CASE_RETURN_TYPES` are const or pointer-to-const, otherwise /// resolves to TYPE. @@ -92,7 +92,7 @@ struct SwitchReturnTypeImpl -struct SwitchReturnTypeImpl { +struct SwitchReturnTypeImpl { /// Resolves to the common type for all the cases return types. using type = std::common_type_t; }; @@ -108,10 +108,10 @@ struct SwitchReturnTypeImpl -struct SwitchReturnTypeImpl { +struct SwitchReturnTypeImpl { private: - using InferredType = - CastableCommonBase>...>; + using InferredType = utils::CastableCommonBase< + detail::NullptrToIgnore>...>; public: /// `const T*` or `T*`, where T is the common base type for all the castable case types. @@ -123,7 +123,7 @@ struct SwitchReturnTypeImpl { /// from the case return types. template using SwitchReturnType = typename SwitchReturnTypeImpl< - IsCastable>...>, + utils::IsCastable>...>, REQUESTED_TYPE, CASE_RETURN_TYPES...>::type; @@ -162,7 +162,9 @@ namespace tint { /// @param cases the switch cases /// @return the value returned by the called case. If no cases matched, then the zero value for the /// consistent case type. -template +template inline auto Switch(T* object, CASES&&... cases) { using ReturnType = detail::SwitchReturnType...>; static constexpr int kDefaultIndex = detail::IndexOfDefaultCase>(); @@ -203,7 +205,7 @@ inline auto Switch(T* object, CASES&&... cases) { ReturnStorage storage; auto* result = utils::Bitcast(&storage); - const TypeInfo& type_info = object->TypeInfo(); + const utils::TypeInfo& type_info = object->TypeInfo(); // Examines the parameter type of the case function. // If the parameter is a pointer type that `object` is of, or derives from, then that case diff --git a/src/tint/switch_bench.cc b/src/tint/switch_bench.cc index ea6098b03d..e73d98283f 100644 --- a/src/tint/switch_bench.cc +++ b/src/tint/switch_bench.cc @@ -21,46 +21,46 @@ namespace tint { namespace { -struct Base : public tint::Castable {}; -struct A : public tint::Castable {}; -struct AA : public tint::Castable {}; -struct AAA : public tint::Castable {}; -struct AAB : public tint::Castable {}; -struct AAC : public tint::Castable {}; -struct AB : public tint::Castable {}; -struct ABA : public tint::Castable {}; -struct ABB : public tint::Castable {}; -struct ABC : public tint::Castable {}; -struct AC : public tint::Castable {}; -struct ACA : public tint::Castable {}; -struct ACB : public tint::Castable {}; -struct ACC : public tint::Castable {}; -struct B : public tint::Castable {}; -struct BA : public tint::Castable {}; -struct BAA : public tint::Castable {}; -struct BAB : public tint::Castable {}; -struct BAC : public tint::Castable {}; -struct BB : public tint::Castable {}; -struct BBA : public tint::Castable {}; -struct BBB : public tint::Castable {}; -struct BBC : public tint::Castable {}; -struct BC : public tint::Castable {}; -struct BCA : public tint::Castable {}; -struct BCB : public tint::Castable {}; -struct BCC : public tint::Castable {}; -struct C : public tint::Castable {}; -struct CA : public tint::Castable {}; -struct CAA : public tint::Castable {}; -struct CAB : public tint::Castable {}; -struct CAC : public tint::Castable {}; -struct CB : public tint::Castable {}; -struct CBA : public tint::Castable {}; -struct CBB : public tint::Castable {}; -struct CBC : public tint::Castable {}; -struct CC : public tint::Castable {}; -struct CCA : public tint::Castable {}; -struct CCB : public tint::Castable {}; -struct CCC : public tint::Castable {}; +struct Base : public tint::utils::Castable {}; +struct A : public tint::utils::Castable {}; +struct AA : public tint::utils::Castable {}; +struct AAA : public tint::utils::Castable {}; +struct AAB : public tint::utils::Castable {}; +struct AAC : public tint::utils::Castable {}; +struct AB : public tint::utils::Castable {}; +struct ABA : public tint::utils::Castable {}; +struct ABB : public tint::utils::Castable {}; +struct ABC : public tint::utils::Castable {}; +struct AC : public tint::utils::Castable {}; +struct ACA : public tint::utils::Castable {}; +struct ACB : public tint::utils::Castable {}; +struct ACC : public tint::utils::Castable {}; +struct B : public tint::utils::Castable {}; +struct BA : public tint::utils::Castable {}; +struct BAA : public tint::utils::Castable {}; +struct BAB : public tint::utils::Castable {}; +struct BAC : public tint::utils::Castable {}; +struct BB : public tint::utils::Castable {}; +struct BBA : public tint::utils::Castable {}; +struct BBB : public tint::utils::Castable {}; +struct BBC : public tint::utils::Castable {}; +struct BC : public tint::utils::Castable {}; +struct BCA : public tint::utils::Castable {}; +struct BCB : public tint::utils::Castable {}; +struct BCC : public tint::utils::Castable {}; +struct C : public tint::utils::Castable {}; +struct CA : public tint::utils::Castable {}; +struct CAA : public tint::utils::Castable {}; +struct CAB : public tint::utils::Castable {}; +struct CAC : public tint::utils::Castable {}; +struct CB : public tint::utils::Castable {}; +struct CBA : public tint::utils::Castable {}; +struct CBB : public tint::utils::Castable {}; +struct CBC : public tint::utils::Castable {}; +struct CC : public tint::utils::Castable {}; +struct CCA : public tint::utils::Castable {}; +struct CCB : public tint::utils::Castable {}; +struct CCC : public tint::utils::Castable {}; using AllTypes = std::tuple {}; -struct Amphibian : public tint::Castable {}; -struct Mammal : public tint::Castable {}; -struct Reptile : public tint::Castable {}; -struct Frog : public tint::Castable {}; -struct Bear : public tint::Castable {}; -struct Lizard : public tint::Castable {}; -struct Gecko : public tint::Castable {}; -struct Iguana : public tint::Castable {}; +struct Animal : public tint::utils::Castable {}; +struct Amphibian : public tint::utils::Castable {}; +struct Mammal : public tint::utils::Castable {}; +struct Reptile : public tint::utils::Castable {}; +struct Frog : public tint::utils::Castable {}; +struct Bear : public tint::utils::Castable {}; +struct Lizard : public tint::utils::Castable {}; +struct Gecko : public tint::utils::Castable {}; +struct Iguana : public tint::utils::Castable {}; TEST(Castable, SwitchNoDefault) { std::unique_ptr frog = std::make_unique(); @@ -331,8 +331,8 @@ TEST(Castable, SwitchInferCastableReturnTypeWithDefault) { gecko.get(), // [](Mammal* p) { return p; }, // [](Amphibian* p) { return p; }, // - [](Default) -> CastableBase* { return nullptr; }); - static_assert(std::is_same_v); + [](Default) -> utils::CastableBase* { return nullptr; }); + static_assert(std::is_same_v); EXPECT_EQ(result, nullptr); } } @@ -444,12 +444,12 @@ TEST(Castable, SwitchExplicitCastableReturnTypeWithDefault) { EXPECT_EQ(result, nullptr); } { - auto* result = Switch( + auto* result = Switch( bear.get(), // [](Mammal* p) { return p; }, // [](Amphibian* p) { return const_cast(p); }, [](Default) { return nullptr; }); - static_assert(std::is_same_v); + static_assert(std::is_same_v); EXPECT_EQ(result, bear.get()); } { @@ -476,11 +476,11 @@ TEST(Castable, SwitchExplicitCastableReturnTypeWithoutDefault) { EXPECT_EQ(result, nullptr); } { - auto* result = Switch( + auto* result = Switch( bear.get(), // [](Mammal* p) { return p; }, // [](Amphibian* p) { return const_cast(p); }); // - static_assert(std::is_same_v); + static_assert(std::is_same_v); EXPECT_EQ(result, bear.get()); } { diff --git a/src/tint/transform/add_block_attribute.h b/src/tint/transform/add_block_attribute.h index d5e8c4e84c..3eeb148b43 100644 --- a/src/tint/transform/add_block_attribute.h +++ b/src/tint/transform/add_block_attribute.h @@ -24,11 +24,11 @@ namespace tint::transform { /// AddBlockAttribute is a transform that wrap the store type of a buffer into a struct if possible, /// then adds an `@internal(block)` attribute to the wrapper struct. -class AddBlockAttribute final : public Castable { +class AddBlockAttribute final : public utils::Castable { public: /// BlockAttribute is an InternalAttribute that is used to decorate a // structure that is used as a buffer in SPIR-V or GLSL. - class BlockAttribute final : public Castable { + class BlockAttribute final : public utils::Castable { public: /// Constructor /// @param program_id the identifier of the program that owns this node diff --git a/src/tint/transform/add_empty_entry_point.h b/src/tint/transform/add_empty_entry_point.h index 828f3b5222..709b574c6c 100644 --- a/src/tint/transform/add_empty_entry_point.h +++ b/src/tint/transform/add_empty_entry_point.h @@ -20,7 +20,7 @@ namespace tint::transform { /// Add an empty entry point to the module, if no other entry points exist. -class AddEmptyEntryPoint final : public Castable { +class AddEmptyEntryPoint final : public utils::Castable { public: /// Constructor AddEmptyEntryPoint(); diff --git a/src/tint/transform/array_length_from_uniform.cc b/src/tint/transform/array_length_from_uniform.cc index e0358b45b4..98d4a6bbe5 100644 --- a/src/tint/transform/array_length_from_uniform.cc +++ b/src/tint/transform/array_length_from_uniform.cc @@ -65,9 +65,10 @@ struct ArrayLengthFromUniform::State { ApplyResult Run() { auto* cfg = inputs.Get(); if (cfg == nullptr) { - b.Diagnostics().add_error(diag::System::Transform, - "missing transform data for " + - std::string(TypeInfo::Of().name)); + b.Diagnostics().add_error( + diag::System::Transform, + "missing transform data for " + + std::string(utils::TypeInfo::Of().name)); return Program(std::move(b)); } diff --git a/src/tint/transform/array_length_from_uniform.h b/src/tint/transform/array_length_from_uniform.h index 507ea37294..bb50dc04a6 100644 --- a/src/tint/transform/array_length_from_uniform.h +++ b/src/tint/transform/array_length_from_uniform.h @@ -52,7 +52,7 @@ namespace tint::transform { /// /// @note Depends on the following transforms to have been run first: /// * SimplifyPointers -class ArrayLengthFromUniform final : public Castable { +class ArrayLengthFromUniform final : public utils::Castable { public: /// Constructor ArrayLengthFromUniform(); @@ -60,7 +60,7 @@ class ArrayLengthFromUniform final : public Castable { + struct Config final : public utils::Castable { /// Constructor /// @param ubo_bp the binding point to use for the generated uniform buffer. explicit Config(sem::BindingPoint ubo_bp); @@ -85,7 +85,7 @@ class ArrayLengthFromUniform final : public Castable { + struct Result final : public utils::Castable { /// Constructor /// @param used_size_indices Indices into the UBO that are statically used. explicit Result(std::unordered_set used_size_indices); diff --git a/src/tint/transform/binding_remapper.h b/src/tint/transform/binding_remapper.h index 8fdba2a208..9eaedad90e 100644 --- a/src/tint/transform/binding_remapper.h +++ b/src/tint/transform/binding_remapper.h @@ -28,7 +28,7 @@ using BindingPoint = sem::BindingPoint; /// BindingRemapper is a transform used to remap resource binding points and /// access controls. -class BindingRemapper final : public Castable { +class BindingRemapper final : public utils::Castable { public: /// BindingPoints is a map of old binding point to new binding point using BindingPoints = std::unordered_map; @@ -38,7 +38,7 @@ class BindingRemapper final : public Castable { /// Remappings is consumed by the BindingRemapper transform. /// Data holds information about shader usage and constant buffer offsets. - struct Remappings final : public Castable { + struct Remappings final : public utils::Castable { /// Constructor /// @param bp a map of new binding points /// @param ac a map of new access controls diff --git a/src/tint/transform/builtin_polyfill.cc b/src/tint/transform/builtin_polyfill.cc index cc770ab783..9cbb65fc89 100644 --- a/src/tint/transform/builtin_polyfill.cc +++ b/src/tint/transform/builtin_polyfill.cc @@ -1251,7 +1251,8 @@ struct BuiltinPolyfill::State { auto* src_ty = conv->Source(); if (tint::Is(type::Type::ElementOf(src_ty))) { auto* dst_ty = conv->Target(); - if (tint::IsAnyOf(type::Type::ElementOf(dst_ty))) { + if (tint::utils::IsAnyOf( + type::Type::ElementOf(dst_ty))) { return f32_conv_polyfills.GetOrCreate(dst_ty, [&] { // return ConvF32ToIU32(src_ty, dst_ty); }); diff --git a/src/tint/transform/builtin_polyfill.h b/src/tint/transform/builtin_polyfill.h index dee0bec565..e42ba8f8d8 100644 --- a/src/tint/transform/builtin_polyfill.h +++ b/src/tint/transform/builtin_polyfill.h @@ -20,7 +20,7 @@ namespace tint::transform { /// Implements builtins for backends that do not have a native implementation. -class BuiltinPolyfill final : public Castable { +class BuiltinPolyfill final : public utils::Castable { public: /// Constructor BuiltinPolyfill(); @@ -89,7 +89,7 @@ class BuiltinPolyfill final : public Castable { /// Config is consumed by the BuiltinPolyfill transform. /// Config specifies the builtins that should be polyfilled. - struct Config final : public Castable { + struct Config final : public utils::Castable { /// Constructor /// @param b the list of builtins to polyfill explicit Config(const Builtins& b); diff --git a/src/tint/transform/calculate_array_length.h b/src/tint/transform/calculate_array_length.h index e5714a85cd..6ebb65cd3b 100644 --- a/src/tint/transform/calculate_array_length.h +++ b/src/tint/transform/calculate_array_length.h @@ -32,11 +32,12 @@ namespace tint::transform { /// /// @note Depends on the following transforms to have been run first: /// * SimplifyPointers -class CalculateArrayLength final : public Castable { +class CalculateArrayLength final : public utils::Castable { public: /// BufferSizeIntrinsic is an InternalAttribute that's applied to intrinsic /// functions used to obtain the runtime size of a storage buffer. - class BufferSizeIntrinsic final : public Castable { + class BufferSizeIntrinsic final + : public utils::Castable { public: /// Constructor /// @param program_id the identifier of the program that owns this node diff --git a/src/tint/transform/canonicalize_entry_point_io.h b/src/tint/transform/canonicalize_entry_point_io.h index fbfed5ebd8..85e9b225d3 100644 --- a/src/tint/transform/canonicalize_entry_point_io.h +++ b/src/tint/transform/canonicalize_entry_point_io.h @@ -82,7 +82,7 @@ namespace tint::transform { /// /// @note Depends on the following transforms to have been run first: /// * Unshadow -class CanonicalizeEntryPointIO final : public Castable { +class CanonicalizeEntryPointIO final : public utils::Castable { public: /// ShaderStyle is an enumerator of different ways to emit shader IO. enum class ShaderStyle { @@ -97,7 +97,7 @@ class CanonicalizeEntryPointIO final : public Castable { + struct Config final : public utils::Castable { /// Constructor /// @param style the approach to use for emitting shader IO. /// @param sample_mask an optional sample mask to combine with shader masks diff --git a/src/tint/transform/clamp_frag_depth.h b/src/tint/transform/clamp_frag_depth.h index 3e3f168ff7..88a7ee196f 100644 --- a/src/tint/transform/clamp_frag_depth.h +++ b/src/tint/transform/clamp_frag_depth.h @@ -54,7 +54,7 @@ namespace tint::transform { /// return clamp_frag_depth(0.0); /// } /// ``` -class ClampFragDepth final : public Castable { +class ClampFragDepth final : public utils::Castable { public: /// Constructor ClampFragDepth(); diff --git a/src/tint/transform/combine_samplers.cc b/src/tint/transform/combine_samplers.cc index 3e9aa7fd91..ebf81262ae 100644 --- a/src/tint/transform/combine_samplers.cc +++ b/src/tint/transform/combine_samplers.cc @@ -158,7 +158,7 @@ struct CombineSamplers::State { for (auto* global : ctx.src->AST().GlobalVariables()) { auto* global_sem = sem.Get(global)->As(); auto* type = ctx.src->TypeOf(global->type); - if (tint::IsAnyOf(type) && + if (tint::utils::IsAnyOf(type) && !type->Is()) { ctx.Remove(ctx.src->AST().GlobalDeclarations(), global); } else if (auto binding_point = global_sem->BindingPoint()) { diff --git a/src/tint/transform/combine_samplers.h b/src/tint/transform/combine_samplers.h index 6834abe77d..b521a557e2 100644 --- a/src/tint/transform/combine_samplers.h +++ b/src/tint/transform/combine_samplers.h @@ -52,7 +52,7 @@ namespace tint::transform { /// information needed to represent a combined sampler in GLSL /// (dimensionality, component type, etc). The GLSL writer outputs such /// (Tint) Textures as (GLSL) Samplers. -class CombineSamplers final : public Castable { +class CombineSamplers final : public utils::Castable { public: /// A pair of binding points. using SamplerTexturePair = sem::SamplerTexturePair; @@ -62,7 +62,7 @@ class CombineSamplers final : public Castable { /// The client-provided mapping from separate texture and sampler binding /// points to combined sampler binding point. - struct BindingInfo final : public Castable { + struct BindingInfo final : public utils::Castable { /// Constructor /// @param map the map of all (texture, sampler) -> (combined) pairs /// @param placeholder the binding point to use for placeholder samplers. diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index fb8dc62303..564451c3c7 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -62,7 +62,7 @@ bool ShouldRun(const Program* program) { /// Offset is a simple ast::Expression builder interface, used to build byte /// offsets for storage and uniform buffer accesses. -struct Offset : Castable { +struct Offset : utils::Castable { /// @returns builds and returns the ast::Expression in `ctx.dst` virtual const ast::Expression* Build(CloneContext& ctx) const = 0; }; @@ -86,7 +86,7 @@ struct OffsetExpr : Offset { /// OffsetLiteral is an implementation of Offset that constructs a u32 literal /// value. -struct OffsetLiteral final : Castable { +struct OffsetLiteral final : utils::Castable { uint32_t const literal = 0; explicit OffsetLiteral(uint32_t lit) : literal(lit) {} diff --git a/src/tint/transform/decompose_memory_access.h b/src/tint/transform/decompose_memory_access.h index f85ad6dadc..8f06726a6d 100644 --- a/src/tint/transform/decompose_memory_access.h +++ b/src/tint/transform/decompose_memory_access.h @@ -29,13 +29,13 @@ namespace tint::transform { /// DecomposeMemoryAccess is a transform used to replace storage and uniform buffer accesses with a /// combination of load, store or atomic functions on primitive types. -class DecomposeMemoryAccess final : public Castable { +class DecomposeMemoryAccess final : public utils::Castable { public: /// Intrinsic is an InternalAttribute that's used to decorate a stub function so that the HLSL /// transforms this into calls to /// `[RW]ByteAddressBuffer.Load[N]()` or `[RW]ByteAddressBuffer.Store[N]()`, /// with a possible cast. - class Intrinsic final : public Castable { + class Intrinsic final : public utils::Castable { public: /// Intrinsic op enum class Op { diff --git a/src/tint/transform/decompose_strided_array.h b/src/tint/transform/decompose_strided_array.h index 9555a9aa1d..aee75b00cb 100644 --- a/src/tint/transform/decompose_strided_array.h +++ b/src/tint/transform/decompose_strided_array.h @@ -27,7 +27,7 @@ namespace tint::transform { /// /// @note Depends on the following transforms to have been run first: /// * SimplifyPointers -class DecomposeStridedArray final : public Castable { +class DecomposeStridedArray final : public utils::Castable { public: /// Constructor DecomposeStridedArray(); diff --git a/src/tint/transform/decompose_strided_matrix.h b/src/tint/transform/decompose_strided_matrix.h index 947dfc653f..8fa0febdf9 100644 --- a/src/tint/transform/decompose_strided_matrix.h +++ b/src/tint/transform/decompose_strided_matrix.h @@ -27,7 +27,7 @@ namespace tint::transform { /// /// @note Depends on the following transforms to have been run first: /// * SimplifyPointers -class DecomposeStridedMatrix final : public Castable { +class DecomposeStridedMatrix final : public utils::Castable { public: /// Constructor DecomposeStridedMatrix(); diff --git a/src/tint/transform/demote_to_helper.h b/src/tint/transform/demote_to_helper.h index ba87febfd1..75909d211b 100644 --- a/src/tint/transform/demote_to_helper.h +++ b/src/tint/transform/demote_to_helper.h @@ -29,7 +29,7 @@ namespace tint::transform { /// @note Depends on the following transforms to have been run first: /// * PromoteSideEffectsToDecl /// * ExpandCompoundAssignment -class DemoteToHelper final : public Castable { +class DemoteToHelper final : public utils::Castable { public: /// Constructor DemoteToHelper(); diff --git a/src/tint/transform/direct_variable_access.h b/src/tint/transform/direct_variable_access.h index 34b6e91890..74aafa7f02 100644 --- a/src/tint/transform/direct_variable_access.h +++ b/src/tint/transform/direct_variable_access.h @@ -32,7 +32,7 @@ namespace tint::transform { /// comments in src/tint/transform/direct_variable_access.cc. /// /// @note DirectVariableAccess requires the transform::Unshadow transform to have been run first. -class DirectVariableAccess final : public Castable { +class DirectVariableAccess final : public utils::Castable { public: /// Constructor DirectVariableAccess(); @@ -49,7 +49,7 @@ class DirectVariableAccess final : public Castable { + struct Config final : public utils::Castable { /// Constructor /// @param options behavior of the transform explicit Config(const Options& options); diff --git a/src/tint/transform/disable_uniformity_analysis.h b/src/tint/transform/disable_uniformity_analysis.h index a9922af989..a2827c5969 100644 --- a/src/tint/transform/disable_uniformity_analysis.h +++ b/src/tint/transform/disable_uniformity_analysis.h @@ -20,7 +20,8 @@ namespace tint::transform { /// Disable uniformity analysis for the program. -class DisableUniformityAnalysis final : public Castable { +class DisableUniformityAnalysis final + : public utils::Castable { public: /// Constructor DisableUniformityAnalysis(); diff --git a/src/tint/transform/expand_compound_assignment.h b/src/tint/transform/expand_compound_assignment.h index 6b299c5216..ce5a36c8ae 100644 --- a/src/tint/transform/expand_compound_assignment.h +++ b/src/tint/transform/expand_compound_assignment.h @@ -38,7 +38,7 @@ namespace tint::transform { /// /// This transform also handles increment and decrement statements in the same /// manner, by replacing `i++` with `i = i + 1`. -class ExpandCompoundAssignment final : public Castable { +class ExpandCompoundAssignment final : public utils::Castable { public: /// Constructor ExpandCompoundAssignment(); diff --git a/src/tint/transform/first_index_offset.h b/src/tint/transform/first_index_offset.h index f84d8112da..dbf47aede2 100644 --- a/src/tint/transform/first_index_offset.h +++ b/src/tint/transform/first_index_offset.h @@ -57,12 +57,12 @@ namespace tint::transform { /// } /// ``` /// -class FirstIndexOffset final : public Castable { +class FirstIndexOffset final : public utils::Castable { public: /// BindingPoint is consumed by the FirstIndexOffset transform. /// BindingPoint specifies the binding point of the first index uniform /// buffer. - struct BindingPoint final : public Castable { + struct BindingPoint final : public utils::Castable { /// Constructor BindingPoint(); @@ -82,7 +82,7 @@ class FirstIndexOffset final : public Castable { /// Data is outputted by the FirstIndexOffset transform. /// Data holds information about shader usage and constant buffer offsets. - struct Data final : public Castable { + struct Data final : public utils::Castable { /// Constructor /// @param has_vtx_or_inst_index True if the shader uses vertex_index or /// instance_index diff --git a/src/tint/transform/for_loop_to_loop.h b/src/tint/transform/for_loop_to_loop.h index fe3db97482..8ed53c542d 100644 --- a/src/tint/transform/for_loop_to_loop.h +++ b/src/tint/transform/for_loop_to_loop.h @@ -21,7 +21,7 @@ namespace tint::transform { /// ForLoopToLoop is a Transform that converts a for-loop statement into a loop /// statement. This is required by the SPIR-V writer. -class ForLoopToLoop final : public Castable { +class ForLoopToLoop final : public utils::Castable { public: /// Constructor ForLoopToLoop(); diff --git a/src/tint/transform/localize_struct_array_assignment.h b/src/tint/transform/localize_struct_array_assignment.h index 169e33ca7a..8173fa87c7 100644 --- a/src/tint/transform/localize_struct_array_assignment.h +++ b/src/tint/transform/localize_struct_array_assignment.h @@ -28,7 +28,7 @@ namespace tint::transform { /// @note Depends on the following transforms to have been run first: /// * SimplifyPointers class LocalizeStructArrayAssignment final - : public Castable { + : public utils::Castable { public: /// Constructor LocalizeStructArrayAssignment(); diff --git a/src/tint/transform/manager.h b/src/tint/transform/manager.h index 64ca847034..a364c1a460 100644 --- a/src/tint/transform/manager.h +++ b/src/tint/transform/manager.h @@ -27,7 +27,7 @@ namespace tint::transform { /// The inner transforms will execute in the appended order. /// If any inner transform fails the manager will return immediately and /// the error can be retrieved with the Output's diagnostics. -class Manager final : public Castable { +class Manager final : public utils::Castable { public: /// Constructor Manager(); diff --git a/src/tint/transform/merge_return.h b/src/tint/transform/merge_return.h index f6db5c2ec9..fa9654b40f 100644 --- a/src/tint/transform/merge_return.h +++ b/src/tint/transform/merge_return.h @@ -20,7 +20,7 @@ namespace tint::transform { /// Merge return statements into a single return at the end of the function. -class MergeReturn final : public Castable { +class MergeReturn final : public utils::Castable { public: /// Constructor MergeReturn(); diff --git a/src/tint/transform/module_scope_var_to_entry_point_param.h b/src/tint/transform/module_scope_var_to_entry_point_param.h index 377151f854..4f4f562c2c 100644 --- a/src/tint/transform/module_scope_var_to_entry_point_param.h +++ b/src/tint/transform/module_scope_var_to_entry_point_param.h @@ -62,7 +62,7 @@ namespace tint::transform { /// } /// ``` class ModuleScopeVarToEntryPointParam final - : public Castable { + : public utils::Castable { public: /// Constructor ModuleScopeVarToEntryPointParam(); diff --git a/src/tint/transform/multiplanar_external_texture.h b/src/tint/transform/multiplanar_external_texture.h index 656d0adae9..c47c3457bc 100644 --- a/src/tint/transform/multiplanar_external_texture.h +++ b/src/tint/transform/multiplanar_external_texture.h @@ -37,7 +37,8 @@ namespace tint::transform { /// decoding, gamut conversion, and gamma encoding steps. Specifically // for BT.709 to SRGB conversion, it takes the fast path only doing the yuv->rgb // step and skipping all other steps. -class MultiplanarExternalTexture final : public Castable { +class MultiplanarExternalTexture final + : public utils::Castable { public: /// This struct identifies the binding groups and locations for new bindings to /// use when transforming a texture_external instance. @@ -51,7 +52,7 @@ class MultiplanarExternalTexture final : public Castable { + struct NewBindingPoints final : public utils::Castable { /// Constructor /// @param bm a map to the new binding slots to use. explicit NewBindingPoints(BindingsMap bm); diff --git a/src/tint/transform/num_workgroups_from_uniform.h b/src/tint/transform/num_workgroups_from_uniform.h index 25308f2294..049c1db4d2 100644 --- a/src/tint/transform/num_workgroups_from_uniform.h +++ b/src/tint/transform/num_workgroups_from_uniform.h @@ -44,7 +44,7 @@ namespace tint::transform { /// /// @note Depends on the following transforms to have been run first: /// * CanonicalizeEntryPointIO -class NumWorkgroupsFromUniform final : public Castable { +class NumWorkgroupsFromUniform final : public utils::Castable { public: /// Constructor NumWorkgroupsFromUniform(); @@ -52,7 +52,7 @@ class NumWorkgroupsFromUniform final : public Castable { + struct Config final : public utils::Castable { /// Constructor /// @param ubo_bp the binding point to use for the generated uniform buffer. If ubo_bp /// contains no value, a free binding point will be used to ensure the generated program is diff --git a/src/tint/transform/packed_vec3.h b/src/tint/transform/packed_vec3.h index 89e82867f2..d13111bf33 100644 --- a/src/tint/transform/packed_vec3.h +++ b/src/tint/transform/packed_vec3.h @@ -38,7 +38,7 @@ namespace tint::transform { /// /// @note Depends on the following transforms to have been run first: /// * ExpandCompoundAssignment -class PackedVec3 final : public Castable { +class PackedVec3 final : public utils::Castable { public: /// Constructor PackedVec3(); diff --git a/src/tint/transform/pad_structs.h b/src/tint/transform/pad_structs.h index 1add1d68e3..f5bf8cc469 100644 --- a/src/tint/transform/pad_structs.h +++ b/src/tint/transform/pad_structs.h @@ -24,7 +24,7 @@ namespace tint::transform { /// the offset= decoration. /// /// @note This transform requires the CanonicalizeEntryPointIO transform to have been run first. -class PadStructs final : public Castable { +class PadStructs final : public utils::Castable { public: /// Constructor PadStructs(); diff --git a/src/tint/transform/preserve_padding.h b/src/tint/transform/preserve_padding.h index 3bf0a352e4..e025c2e620 100644 --- a/src/tint/transform/preserve_padding.h +++ b/src/tint/transform/preserve_padding.h @@ -26,7 +26,7 @@ namespace tint::transform { /// assignments into element-wise assignments via helper functions. /// /// @note Assumes that the DirectVariableTransform will be run afterwards for backends that need it. -class PreservePadding final : public Castable { +class PreservePadding final : public utils::Castable { public: /// Constructor PreservePadding(); diff --git a/src/tint/transform/promote_initializers_to_let.h b/src/tint/transform/promote_initializers_to_let.h index b1bb291a1f..a08ad361b9 100644 --- a/src/tint/transform/promote_initializers_to_let.h +++ b/src/tint/transform/promote_initializers_to_let.h @@ -25,7 +25,7 @@ namespace tint::transform { /// array or structure. For example, the following is not immediately expressable for HLSL: /// `array(1, 2)[0]` /// @see crbug.com/tint/406 -class PromoteInitializersToLet final : public Castable { +class PromoteInitializersToLet final : public utils::Castable { public: /// Constructor PromoteInitializersToLet(); diff --git a/src/tint/transform/promote_side_effects_to_decl.cc b/src/tint/transform/promote_side_effects_to_decl.cc index 9db7e388e1..fef15ee676 100644 --- a/src/tint/transform/promote_side_effects_to_decl.cc +++ b/src/tint/transform/promote_side_effects_to_decl.cc @@ -52,7 +52,7 @@ class StateBase { // This first transform converts side-effecting for-loops to loops and else-ifs // to else {if}s so that the next transform, DecomposeSideEffects, can insert // hoisted expressions above their current location. -struct SimplifySideEffectStatements : Castable { +struct SimplifySideEffectStatements : tint::utils::Castable { ApplyResult Apply(const Program* src, const DataMap& inputs, DataMap& outputs) const override; }; @@ -87,7 +87,7 @@ Transform::ApplyResult SimplifySideEffectStatements::Apply(const Program* src, // Decomposes side-effecting expressions to ensure order of evaluation. This // handles both breaking down logical binary expressions for short-circuit // evaluation, as well as hoisting expressions to ensure order of evaluation. -struct DecomposeSideEffects : Castable { +struct DecomposeSideEffects : tint::utils::Castable { class CollectHoistsState; class DecomposeState; ApplyResult Apply(const Program* src, const DataMap& inputs, DataMap& outputs) const override; diff --git a/src/tint/transform/promote_side_effects_to_decl.h b/src/tint/transform/promote_side_effects_to_decl.h index 99e80c65b2..36426b6dfa 100644 --- a/src/tint/transform/promote_side_effects_to_decl.h +++ b/src/tint/transform/promote_side_effects_to_decl.h @@ -23,7 +23,7 @@ namespace tint::transform { /// declarations before the statement of usage with the goal of ensuring /// left-to-right order of evaluation, while respecting short-circuit /// evaluation. -class PromoteSideEffectsToDecl final : public Castable { +class PromoteSideEffectsToDecl final : public utils::Castable { public: /// Constructor PromoteSideEffectsToDecl(); diff --git a/src/tint/transform/remove_continue_in_switch.h b/src/tint/transform/remove_continue_in_switch.h index 10709069ed..a88851357d 100644 --- a/src/tint/transform/remove_continue_in_switch.h +++ b/src/tint/transform/remove_continue_in_switch.h @@ -23,7 +23,7 @@ namespace tint::transform { /// bool variable, and checking if the variable is set after the switch to /// continue. It is necessary to work around FXC "error X3708: continue cannot /// be used in a switch". See crbug.com/tint/1080. -class RemoveContinueInSwitch final : public Castable { +class RemoveContinueInSwitch final : public utils::Castable { public: /// Constructor RemoveContinueInSwitch(); diff --git a/src/tint/transform/remove_phonies.h b/src/tint/transform/remove_phonies.h index 99a049e3f2..7b1f9fd8f4 100644 --- a/src/tint/transform/remove_phonies.h +++ b/src/tint/transform/remove_phonies.h @@ -25,7 +25,7 @@ namespace tint::transform { /// RemovePhonies is a Transform that removes all phony-assignment statements, /// while preserving function call expressions in the RHS of the assignment that /// may have side-effects. It also removes calls to builtins that return a constant value. -class RemovePhonies final : public Castable { +class RemovePhonies final : public utils::Castable { public: /// Constructor RemovePhonies(); diff --git a/src/tint/transform/remove_unreachable_statements.h b/src/tint/transform/remove_unreachable_statements.h index f5848f5fd8..dd1054d17c 100644 --- a/src/tint/transform/remove_unreachable_statements.h +++ b/src/tint/transform/remove_unreachable_statements.h @@ -24,7 +24,8 @@ namespace tint::transform { /// RemoveUnreachableStatements is a Transform that removes all statements /// marked as unreachable. -class RemoveUnreachableStatements final : public Castable { +class RemoveUnreachableStatements final + : public utils::Castable { public: /// Constructor RemoveUnreachableStatements(); diff --git a/src/tint/transform/renamer.h b/src/tint/transform/renamer.h index 8a9f97e952..015e3864da 100644 --- a/src/tint/transform/renamer.h +++ b/src/tint/transform/renamer.h @@ -23,11 +23,11 @@ namespace tint::transform { /// Renamer is a Transform that renames all the symbols in a program. -class Renamer final : public Castable { +class Renamer final : public utils::Castable { public: /// Data is outputted by the Renamer transform. /// Data holds information about shader usage and constant buffer offsets. - struct Data final : public Castable { + struct Data final : public utils::Castable { /// Remappings is a map of old symbol name to new symbol name using Remappings = std::unordered_map; @@ -59,7 +59,7 @@ class Renamer final : public Castable { /// Optional configuration options for the transform. /// If omitted, then the renamer will use Target::kAll. - struct Config final : public Castable { + struct Config final : public utils::Castable { /// Constructor /// @param tgt the targets to rename /// @param keep_unicode if false, symbols with non-ascii code-points are diff --git a/src/tint/transform/robustness.h b/src/tint/transform/robustness.h index 596db4dc8f..e916b163ac 100644 --- a/src/tint/transform/robustness.h +++ b/src/tint/transform/robustness.h @@ -29,7 +29,7 @@ namespace tint::transform { /// * BuiltinPolyfill as 'clamp' and binary operators may need to be polyfilled. /// * CanonicalizeEntryPointIO as the transform does not support the 'in' and 'out' address /// spaces. -class Robustness final : public Castable { +class Robustness final : public utils::Castable { public: /// Robustness action for out-of-bounds indexing. enum class Action { @@ -45,7 +45,7 @@ class Robustness final : public Castable { }; /// Configuration options for the transform - struct Config final : public Castable { + struct Config final : public utils::Castable { /// Constructor Config(); diff --git a/src/tint/transform/simplify_pointers.h b/src/tint/transform/simplify_pointers.h index 6e040bb6d6..8783d4399f 100644 --- a/src/tint/transform/simplify_pointers.h +++ b/src/tint/transform/simplify_pointers.h @@ -31,7 +31,7 @@ namespace tint::transform { /// /// @note Depends on the following transforms to have been run first: /// * Unshadow -class SimplifyPointers final : public Castable { +class SimplifyPointers final : public utils::Castable { public: /// Constructor SimplifyPointers(); diff --git a/src/tint/transform/single_entry_point.h b/src/tint/transform/single_entry_point.h index 7aba5e8157..b91856bda8 100644 --- a/src/tint/transform/single_entry_point.h +++ b/src/tint/transform/single_entry_point.h @@ -25,10 +25,10 @@ namespace tint::transform { /// /// All module-scope variables, types, and functions that are not used by the /// target entry point will also be removed. -class SingleEntryPoint final : public Castable { +class SingleEntryPoint final : public utils::Castable { public: /// Configuration options for the transform - struct Config final : public Castable { + struct Config final : public utils::Castable { /// Constructor /// @param entry_point the name of the entry point to keep explicit Config(std::string entry_point = ""); diff --git a/src/tint/transform/spirv_atomic.h b/src/tint/transform/spirv_atomic.h index b524200c2b..907996bd30 100644 --- a/src/tint/transform/spirv_atomic.h +++ b/src/tint/transform/spirv_atomic.h @@ -32,7 +32,7 @@ namespace tint::transform { /// with calls to the WGSL atomic builtin. It also makes sure to replace variable declarations that /// are the target of the atomic operations with an atomic declaration of the same type. For /// structs, it creates a copy of the original struct with atomic members. -class SpirvAtomic final : public Castable { +class SpirvAtomic final : public utils::Castable { public: /// Constructor SpirvAtomic(); @@ -41,7 +41,7 @@ class SpirvAtomic final : public Castable { /// Stub is an attribute applied to stub SPIR-V reader generated functions that need to be /// translated to an atomic builtin. - class Stub final : public Castable { + class Stub final : public utils::Castable { public: /// @param pid the identifier of the program that owns this node /// @param nid the unique node identifier diff --git a/src/tint/transform/std140.h b/src/tint/transform/std140.h index 769932ffb3..ab1b31e1c0 100644 --- a/src/tint/transform/std140.h +++ b/src/tint/transform/std140.h @@ -28,7 +28,7 @@ namespace tint::transform { /// sufficient to have any WGSL structure be std140-layout conformant. /// /// @note This transform requires the PromoteSideEffectsToDecl transform to have been run first. -class Std140 final : public Castable { +class Std140 final : public utils::Castable { public: /// Constructor Std140(); diff --git a/src/tint/transform/substitute_override.h b/src/tint/transform/substitute_override.h index 853acc743b..10200ca14b 100644 --- a/src/tint/transform/substitute_override.h +++ b/src/tint/transform/substitute_override.h @@ -43,10 +43,10 @@ namespace tint::transform { /// ``` /// /// @see crbug.com/tint/1582 -class SubstituteOverride final : public Castable { +class SubstituteOverride final : public utils::Castable { public: /// Configuration options for the transform - struct Config final : public Castable { + struct Config final : public utils::Castable { /// Constructor Config(); diff --git a/src/tint/transform/texture_1d_to_2d.h b/src/tint/transform/texture_1d_to_2d.h index 999982143b..c742e2aa18 100644 --- a/src/tint/transform/texture_1d_to_2d.h +++ b/src/tint/transform/texture_1d_to_2d.h @@ -21,7 +21,7 @@ namespace tint::transform { /// This transform converts all 1D texture types and accesses to 2D. /// This is required for GLSL ES, which does not support 1D textures. -class Texture1DTo2D final : public Castable { +class Texture1DTo2D final : public utils::Castable { public: /// Constructor Texture1DTo2D(); diff --git a/src/tint/transform/transform.h b/src/tint/transform/transform.h index c9c1eee479..b498e82244 100644 --- a/src/tint/transform/transform.h +++ b/src/tint/transform/transform.h @@ -19,14 +19,14 @@ #include #include -#include "src/tint/castable.h" #include "src/tint/program.h" +#include "src/tint/utils/castable.h" namespace tint::transform { /// Data is the base class for transforms that accept extra input or emit extra /// output information along with a Program. -class Data : public Castable { +class Data : public utils::Castable { public: /// Constructor Data(); @@ -72,7 +72,7 @@ class DataMap { template void Put(std::unique_ptr&& data) { static_assert(std::is_base_of::value, "T does not derive from Data"); - map_[&TypeInfo::Of()] = std::move(data); + map_[&utils::TypeInfo::Of()] = std::move(data); } /// Creates the data of type `T` with the provided arguments and adds it into @@ -94,7 +94,7 @@ class DataMap { /// Put() template T* Get() { - auto it = map_.find(&TypeInfo::Of()); + auto it = map_.find(&utils::TypeInfo::Of()); if (it == map_.end()) { return nullptr; } @@ -122,7 +122,7 @@ class DataMap { PutAll(std::forward(remainder)...); } - std::unordered_map> map_; + std::unordered_map> map_; }; /// The return type of Run() @@ -151,7 +151,7 @@ class Output { }; /// Interface for Program transforms -class Transform : public Castable { +class Transform : public utils::Castable { public: /// Constructor Transform(); diff --git a/src/tint/transform/truncate_interstage_variables.cc b/src/tint/transform/truncate_interstage_variables.cc index b4ae24e2a1..269b171e4c 100644 --- a/src/tint/transform/truncate_interstage_variables.cc +++ b/src/tint/transform/truncate_interstage_variables.cc @@ -57,7 +57,7 @@ Transform::ApplyResult TruncateInterstageVariables::Apply(const Program* src, b.Diagnostics().add_error( diag::System::Transform, "missing transform data for " + - std::string(TypeInfo::Of().name)); + std::string(utils::TypeInfo::Of().name)); return Program(std::move(b)); } diff --git a/src/tint/transform/truncate_interstage_variables.h b/src/tint/transform/truncate_interstage_variables.h index bed226c603..f279eb33d4 100644 --- a/src/tint/transform/truncate_interstage_variables.h +++ b/src/tint/transform/truncate_interstage_variables.h @@ -88,10 +88,11 @@ namespace tint::transform { /// } /// ``` /// -class TruncateInterstageVariables final : public Castable { +class TruncateInterstageVariables final + : public utils::Castable { public: /// Configuration options for the transform - struct Config final : public Castable { + struct Config final : public utils::Castable { /// Constructor Config(); diff --git a/src/tint/transform/unshadow.h b/src/tint/transform/unshadow.h index 9030006cf1..313e556b50 100644 --- a/src/tint/transform/unshadow.h +++ b/src/tint/transform/unshadow.h @@ -20,7 +20,7 @@ namespace tint::transform { /// Unshadow is a Transform that renames any variables that shadow another variable. -class Unshadow final : public Castable { +class Unshadow final : public utils::Castable { public: /// Constructor Unshadow(); diff --git a/src/tint/transform/vectorize_matrix_conversions.h b/src/tint/transform/vectorize_matrix_conversions.h index c86240c1d9..2308eb1eea 100644 --- a/src/tint/transform/vectorize_matrix_conversions.h +++ b/src/tint/transform/vectorize_matrix_conversions.h @@ -20,7 +20,8 @@ namespace tint::transform { /// A transform that converts matrix conversions (between f32 and f16 matrices) to the vector form. -class VectorizeMatrixConversions final : public Castable { +class VectorizeMatrixConversions final + : public utils::Castable { public: /// Constructor VectorizeMatrixConversions(); diff --git a/src/tint/transform/vectorize_scalar_matrix_initializers.h b/src/tint/transform/vectorize_scalar_matrix_initializers.h index f9c0164e2f..f0aba6e8d8 100644 --- a/src/tint/transform/vectorize_scalar_matrix_initializers.h +++ b/src/tint/transform/vectorize_scalar_matrix_initializers.h @@ -21,7 +21,7 @@ namespace tint::transform { /// A transform that converts scalar matrix initializers to the vector form. class VectorizeScalarMatrixInitializers final - : public Castable { + : public utils::Castable { public: /// Constructor VectorizeScalarMatrixInitializers(); diff --git a/src/tint/transform/vertex_pulling.h b/src/tint/transform/vertex_pulling.h index c0f88a596e..d3849f7b20 100644 --- a/src/tint/transform/vertex_pulling.h +++ b/src/tint/transform/vertex_pulling.h @@ -137,10 +137,10 @@ using VertexStateDescriptor = std::vector; /// shader to use. /// /// The SingleEntryPoint transform must have run before VertexPulling. -class VertexPulling final : public Castable { +class VertexPulling final : public utils::Castable { public: /// Configuration options for the transform - struct Config final : public Castable { + struct Config final : public utils::Castable { /// Constructor Config(); diff --git a/src/tint/transform/while_to_loop.h b/src/tint/transform/while_to_loop.h index 187799a845..91e5b0c549 100644 --- a/src/tint/transform/while_to_loop.h +++ b/src/tint/transform/while_to_loop.h @@ -21,7 +21,7 @@ namespace tint::transform { /// WhileToLoop is a Transform that converts a while statement into a loop /// statement. This is required by the SPIR-V writer. -class WhileToLoop final : public Castable { +class WhileToLoop final : public utils::Castable { public: /// Constructor WhileToLoop(); diff --git a/src/tint/transform/zero_init_workgroup_memory.h b/src/tint/transform/zero_init_workgroup_memory.h index 64f4da8f1c..24ba226c78 100644 --- a/src/tint/transform/zero_init_workgroup_memory.h +++ b/src/tint/transform/zero_init_workgroup_memory.h @@ -22,7 +22,7 @@ namespace tint::transform { /// ZeroInitWorkgroupMemory is a transform that injects code at the top of entry /// points to zero-initialize workgroup memory used by that entry point (and all /// transitive functions called by that entry point) -class ZeroInitWorkgroupMemory final : public Castable { +class ZeroInitWorkgroupMemory final : public utils::Castable { public: /// Constructor ZeroInitWorkgroupMemory(); diff --git a/src/tint/type/abstract_float.cc b/src/tint/type/abstract_float.cc index 74e5d347a9..41e04306f2 100644 --- a/src/tint/type/abstract_float.cc +++ b/src/tint/type/abstract_float.cc @@ -21,7 +21,9 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::AbstractFloat); namespace tint::type { -AbstractFloat::AbstractFloat() : Base(utils::Hash(TypeInfo::Of().full_hashcode)) {} +AbstractFloat::AbstractFloat() + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode)) {} + AbstractFloat::~AbstractFloat() = default; bool AbstractFloat::Equals(const UniqueNode& other) const { diff --git a/src/tint/type/abstract_float.h b/src/tint/type/abstract_float.h index 2c6ac09c56..10d6f3a1c8 100644 --- a/src/tint/type/abstract_float.h +++ b/src/tint/type/abstract_float.h @@ -23,7 +23,7 @@ namespace tint::type { /// An abstract-float type. /// @see https://www.w3.org/TR/WGSL/#abstractFloat -class AbstractFloat final : public Castable { +class AbstractFloat final : public utils::Castable { public: /// Constructor AbstractFloat(); diff --git a/src/tint/type/abstract_int.cc b/src/tint/type/abstract_int.cc index 7fc883df45..6b9762293a 100644 --- a/src/tint/type/abstract_int.cc +++ b/src/tint/type/abstract_int.cc @@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::AbstractInt); namespace tint::type { -AbstractInt::AbstractInt() : Base(utils::Hash(TypeInfo::Of().full_hashcode)) {} +AbstractInt::AbstractInt() : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode)) {} AbstractInt::~AbstractInt() = default; diff --git a/src/tint/type/abstract_int.h b/src/tint/type/abstract_int.h index f1f67d86eb..aaaaadd775 100644 --- a/src/tint/type/abstract_int.h +++ b/src/tint/type/abstract_int.h @@ -23,7 +23,7 @@ namespace tint::type { /// An abstract-int type. /// @see https://www.w3.org/TR/WGSL/#abstractint -class AbstractInt final : public Castable { +class AbstractInt final : public utils::Castable { public: /// Constructor AbstractInt(); diff --git a/src/tint/type/abstract_numeric.h b/src/tint/type/abstract_numeric.h index 5b6b9f4dbf..217b2a2c9e 100644 --- a/src/tint/type/abstract_numeric.h +++ b/src/tint/type/abstract_numeric.h @@ -23,7 +23,7 @@ namespace tint::type { /// The base class for abstract-int and abstract-float types. /// @see https://www.w3.org/TR/WGSL/#types-for-creation-time-constants -class AbstractNumeric : public Castable { +class AbstractNumeric : public utils::Castable { public: /// Constructor /// @param hash the unique hash of the node diff --git a/src/tint/type/array.cc b/src/tint/type/array.cc index 71ec6b3b99..31893f8fa9 100644 --- a/src/tint/type/array.cc +++ b/src/tint/type/array.cc @@ -60,7 +60,7 @@ Array::Array(const Type* element, uint32_t size, uint32_t stride, uint32_t implicit_stride) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, count, align, size, stride), + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, count, align, size, stride), FlagsFrom(element, count)), element_(element), count_(count), diff --git a/src/tint/type/array.h b/src/tint/type/array.h index 79b8e3c104..c4004758fa 100644 --- a/src/tint/type/array.h +++ b/src/tint/type/array.h @@ -28,7 +28,7 @@ namespace tint::type { /// Array holds the type information for Array nodes. -class Array final : public Castable { +class Array final : public utils::Castable { public: /// An error message string stating that the array count was expected to be a constant /// expression. Used by multiple writers and transforms. diff --git a/src/tint/type/array_count.cc b/src/tint/type/array_count.cc index 8ddda4cd52..7b47300714 100644 --- a/src/tint/type/array_count.cc +++ b/src/tint/type/array_count.cc @@ -26,7 +26,8 @@ ArrayCount::ArrayCount(size_t hash) : Base(hash) {} ArrayCount::~ArrayCount() = default; ConstantArrayCount::ConstantArrayCount(uint32_t val) - : Base(static_cast(TypeInfo::Of().full_hashcode)), value(val) {} + : Base(static_cast(utils::TypeInfo::Of().full_hashcode)), + value(val) {} ConstantArrayCount::~ConstantArrayCount() = default; bool ConstantArrayCount::Equals(const UniqueNode& other) const { @@ -45,7 +46,7 @@ ConstantArrayCount* ConstantArrayCount::Clone(CloneContext& ctx) const { } RuntimeArrayCount::RuntimeArrayCount() - : Base(static_cast(TypeInfo::Of().full_hashcode)) {} + : Base(static_cast(utils::TypeInfo::Of().full_hashcode)) {} RuntimeArrayCount::~RuntimeArrayCount() = default; bool RuntimeArrayCount::Equals(const UniqueNode& other) const { diff --git a/src/tint/type/array_count.h b/src/tint/type/array_count.h index 94dc135363..172d2d31d2 100644 --- a/src/tint/type/array_count.h +++ b/src/tint/type/array_count.h @@ -25,7 +25,7 @@ namespace tint::type { /// An array count -class ArrayCount : public Castable { +class ArrayCount : public utils::Castable { public: ~ArrayCount() override; @@ -48,7 +48,7 @@ class ArrayCount : public Castable { /// const N = 123; /// type arr = array /// ``` -class ConstantArrayCount final : public Castable { +class ConstantArrayCount final : public utils::Castable { public: /// Constructor /// @param val the constant-expression value @@ -75,7 +75,7 @@ class ConstantArrayCount final : public Castable /// ``` /// type arr = array /// ``` -class RuntimeArrayCount final : public Castable { +class RuntimeArrayCount final : public utils::Castable { public: /// Constructor RuntimeArrayCount(); diff --git a/src/tint/type/atomic.cc b/src/tint/type/atomic.cc index a1d5da1022..01893015f0 100644 --- a/src/tint/type/atomic.cc +++ b/src/tint/type/atomic.cc @@ -26,7 +26,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Atomic); namespace tint::type { Atomic::Atomic(const type::Type* subtype) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, subtype), + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, subtype), type::Flags{ Flag::kCreationFixedFootprint, Flag::kFixedFootprint, diff --git a/src/tint/type/atomic.h b/src/tint/type/atomic.h index 4f304f07cb..a19239bea9 100644 --- a/src/tint/type/atomic.h +++ b/src/tint/type/atomic.h @@ -22,7 +22,7 @@ namespace tint::type { /// A atomic type. -class Atomic final : public Castable { +class Atomic final : public utils::Castable { public: /// Constructor /// @param subtype the atomic type diff --git a/src/tint/type/bool.cc b/src/tint/type/bool.cc index 6c972c32be..26741c5e87 100644 --- a/src/tint/type/bool.cc +++ b/src/tint/type/bool.cc @@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Bool); namespace tint::type { Bool::Bool() - : Base(static_cast(TypeInfo::Of().full_hashcode), + : Base(static_cast(utils::TypeInfo::Of().full_hashcode), type::Flags{ Flag::kConstructable, Flag::kCreationFixedFootprint, diff --git a/src/tint/type/bool.h b/src/tint/type/bool.h index 6173bbb45d..33906b845c 100644 --- a/src/tint/type/bool.h +++ b/src/tint/type/bool.h @@ -28,7 +28,7 @@ namespace tint::type { /// A boolean type -class Bool final : public Castable { +class Bool final : public utils::Castable { public: /// Constructor Bool(); diff --git a/src/tint/type/depth_multisampled_texture.cc b/src/tint/type/depth_multisampled_texture.cc index 765fec33e5..71099204b2 100644 --- a/src/tint/type/depth_multisampled_texture.cc +++ b/src/tint/type/depth_multisampled_texture.cc @@ -33,7 +33,7 @@ bool IsValidDepthDimension(TextureDimension dim) { } // namespace DepthMultisampledTexture::DepthMultisampledTexture(TextureDimension dim) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, dim), dim) { + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, dim), dim) { TINT_ASSERT(Type, IsValidDepthDimension(dim)); } diff --git a/src/tint/type/depth_multisampled_texture.h b/src/tint/type/depth_multisampled_texture.h index 4a6d3c2dd4..9a72d61947 100644 --- a/src/tint/type/depth_multisampled_texture.h +++ b/src/tint/type/depth_multisampled_texture.h @@ -23,7 +23,7 @@ namespace tint::type { /// A multisampled depth texture type. -class DepthMultisampledTexture final : public Castable { +class DepthMultisampledTexture final : public utils::Castable { public: /// Constructor /// @param dim the dimensionality of the texture diff --git a/src/tint/type/depth_texture.cc b/src/tint/type/depth_texture.cc index 1d6eab55e1..d4476fb281 100644 --- a/src/tint/type/depth_texture.cc +++ b/src/tint/type/depth_texture.cc @@ -34,7 +34,7 @@ bool IsValidDepthDimension(TextureDimension dim) { } // namespace DepthTexture::DepthTexture(TextureDimension dim) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, dim), dim) { + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, dim), dim) { TINT_ASSERT(Type, IsValidDepthDimension(dim)); } diff --git a/src/tint/type/depth_texture.h b/src/tint/type/depth_texture.h index 079b5fbc81..8e8c47ddf2 100644 --- a/src/tint/type/depth_texture.h +++ b/src/tint/type/depth_texture.h @@ -23,7 +23,7 @@ namespace tint::type { /// A depth texture type. -class DepthTexture final : public Castable { +class DepthTexture final : public utils::Castable { public: /// Constructor /// @param dim the dimensionality of the texture diff --git a/src/tint/type/external_texture.cc b/src/tint/type/external_texture.cc index 85469a7904..924d06ac9f 100644 --- a/src/tint/type/external_texture.cc +++ b/src/tint/type/external_texture.cc @@ -22,7 +22,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::ExternalTexture); namespace tint::type { ExternalTexture::ExternalTexture() - : Base(static_cast(TypeInfo::Of().full_hashcode), + : Base(static_cast(utils::TypeInfo::Of().full_hashcode), TextureDimension::k2d) {} ExternalTexture::~ExternalTexture() = default; diff --git a/src/tint/type/external_texture.h b/src/tint/type/external_texture.h index be46048457..219e7b8923 100644 --- a/src/tint/type/external_texture.h +++ b/src/tint/type/external_texture.h @@ -22,7 +22,7 @@ namespace tint::type { /// An external texture type -class ExternalTexture final : public Castable { +class ExternalTexture final : public utils::Castable { public: /// Constructor ExternalTexture(); diff --git a/src/tint/type/f16.cc b/src/tint/type/f16.cc index 842d147c73..288f14ac9e 100644 --- a/src/tint/type/f16.cc +++ b/src/tint/type/f16.cc @@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::F16); namespace tint::type { F16::F16() - : Base(static_cast(TypeInfo::Of().full_hashcode), + : Base(static_cast(utils::TypeInfo::Of().full_hashcode), type::Flags{ Flag::kConstructable, Flag::kCreationFixedFootprint, diff --git a/src/tint/type/f16.h b/src/tint/type/f16.h index 21100ffdb7..c7fc3eb798 100644 --- a/src/tint/type/f16.h +++ b/src/tint/type/f16.h @@ -22,7 +22,7 @@ namespace tint::type { /// A float 16 type -class F16 final : public Castable { +class F16 final : public utils::Castable { public: /// Constructor F16(); diff --git a/src/tint/type/f32.cc b/src/tint/type/f32.cc index b7c5135596..e3afcc768d 100644 --- a/src/tint/type/f32.cc +++ b/src/tint/type/f32.cc @@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::F32); namespace tint::type { F32::F32() - : Base(static_cast(TypeInfo::Of().full_hashcode), + : Base(static_cast(utils::TypeInfo::Of().full_hashcode), type::Flags{ Flag::kConstructable, Flag::kCreationFixedFootprint, diff --git a/src/tint/type/f32.h b/src/tint/type/f32.h index 397911d990..68b3c77234 100644 --- a/src/tint/type/f32.h +++ b/src/tint/type/f32.h @@ -22,7 +22,7 @@ namespace tint::type { /// A float 32 type -class F32 final : public Castable { +class F32 final : public utils::Castable { public: /// Constructor F32(); diff --git a/src/tint/type/i32.cc b/src/tint/type/i32.cc index 045706d8b0..66da527425 100644 --- a/src/tint/type/i32.cc +++ b/src/tint/type/i32.cc @@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::I32); namespace tint::type { I32::I32() - : Base(static_cast(TypeInfo::Of().full_hashcode), + : Base(static_cast(utils::TypeInfo::Of().full_hashcode), type::Flags{ Flag::kConstructable, Flag::kCreationFixedFootprint, diff --git a/src/tint/type/i32.h b/src/tint/type/i32.h index ddf59b4bd9..563ee693a6 100644 --- a/src/tint/type/i32.h +++ b/src/tint/type/i32.h @@ -22,7 +22,7 @@ namespace tint::type { /// A signed int 32 type. -class I32 final : public Castable { +class I32 final : public utils::Castable { public: /// Constructor I32(); diff --git a/src/tint/type/matrix.cc b/src/tint/type/matrix.cc index 59dfaa9abc..35664f3741 100644 --- a/src/tint/type/matrix.cc +++ b/src/tint/type/matrix.cc @@ -26,7 +26,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Matrix); namespace tint::type { Matrix::Matrix(const Vector* column_type, uint32_t columns) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, columns, column_type), + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, columns, column_type), type::Flags{ Flag::kConstructable, Flag::kCreationFixedFootprint, diff --git a/src/tint/type/matrix.h b/src/tint/type/matrix.h index c6707a2a2a..1519d6abcd 100644 --- a/src/tint/type/matrix.h +++ b/src/tint/type/matrix.h @@ -27,7 +27,7 @@ class Vector; namespace tint::type { /// A matrix type -class Matrix final : public Castable { +class Matrix final : public utils::Castable { public: /// Constructor /// @param column_type the type of a column of the matrix diff --git a/src/tint/type/multisampled_texture.cc b/src/tint/type/multisampled_texture.cc index b63c68113e..850b11b561 100644 --- a/src/tint/type/multisampled_texture.cc +++ b/src/tint/type/multisampled_texture.cc @@ -26,7 +26,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::MultisampledTexture); namespace tint::type { MultisampledTexture::MultisampledTexture(TextureDimension dim, const Type* type) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, dim, type), dim), + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, dim, type), dim), type_(type) { TINT_ASSERT(Type, type_); } diff --git a/src/tint/type/multisampled_texture.h b/src/tint/type/multisampled_texture.h index d6c2e50423..89575eea6a 100644 --- a/src/tint/type/multisampled_texture.h +++ b/src/tint/type/multisampled_texture.h @@ -23,7 +23,7 @@ namespace tint::type { /// A multisampled texture type. -class MultisampledTexture final : public Castable { +class MultisampledTexture final : public utils::Castable { public: /// Constructor /// @param dim the dimensionality of the texture diff --git a/src/tint/type/node.h b/src/tint/type/node.h index eddcb27795..237c3ec4f2 100644 --- a/src/tint/type/node.h +++ b/src/tint/type/node.h @@ -15,12 +15,12 @@ #ifndef SRC_TINT_TYPE_NODE_H_ #define SRC_TINT_TYPE_NODE_H_ -#include "src/tint/castable.h" +#include "src/tint/utils/castable.h" namespace tint::type { /// Node is the base class for all type nodes -class Node : public Castable { +class Node : public utils::Castable { public: /// Constructor Node(); diff --git a/src/tint/type/pointer.cc b/src/tint/type/pointer.cc index 2922b0e797..636f8e522a 100644 --- a/src/tint/type/pointer.cc +++ b/src/tint/type/pointer.cc @@ -26,8 +26,9 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Pointer); namespace tint::type { Pointer::Pointer(const Type* subtype, builtin::AddressSpace address_space, builtin::Access access) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, address_space, subtype, access), - type::Flags{}), + : Base( + utils::Hash(utils::TypeInfo::Of().full_hashcode, address_space, subtype, access), + type::Flags{}), subtype_(subtype), address_space_(address_space), access_(access) { diff --git a/src/tint/type/pointer.h b/src/tint/type/pointer.h index 0eed27ceb0..80626e99ea 100644 --- a/src/tint/type/pointer.h +++ b/src/tint/type/pointer.h @@ -24,7 +24,7 @@ namespace tint::type { /// A pointer type. -class Pointer final : public Castable { +class Pointer final : public utils::Castable { public: /// Constructor /// @param subtype the pointee type diff --git a/src/tint/type/reference.cc b/src/tint/type/reference.cc index bf2d22ce4e..e0fd92a30d 100644 --- a/src/tint/type/reference.cc +++ b/src/tint/type/reference.cc @@ -27,7 +27,10 @@ namespace tint::type { Reference::Reference(const Type* subtype, builtin::AddressSpace address_space, builtin::Access access) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, address_space, subtype, access), + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, + address_space, + subtype, + access), type::Flags{}), subtype_(subtype), address_space_(address_space), diff --git a/src/tint/type/reference.h b/src/tint/type/reference.h index 794b48b413..617b2ca1aa 100644 --- a/src/tint/type/reference.h +++ b/src/tint/type/reference.h @@ -24,7 +24,7 @@ namespace tint::type { /// A reference type. -class Reference final : public Castable { +class Reference final : public utils::Castable { public: /// Constructor /// @param subtype the pointee type diff --git a/src/tint/type/sampled_texture.cc b/src/tint/type/sampled_texture.cc index 8a4e440f46..2fb29f62b6 100644 --- a/src/tint/type/sampled_texture.cc +++ b/src/tint/type/sampled_texture.cc @@ -26,7 +26,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::SampledTexture); namespace tint::type { SampledTexture::SampledTexture(TextureDimension dim, const Type* type) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, dim, type), dim), type_(type) { + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, dim, type), dim), + type_(type) { TINT_ASSERT(Type, type_); } diff --git a/src/tint/type/sampled_texture.h b/src/tint/type/sampled_texture.h index 35208b7336..346741f65d 100644 --- a/src/tint/type/sampled_texture.h +++ b/src/tint/type/sampled_texture.h @@ -23,7 +23,7 @@ namespace tint::type { /// A sampled texture type. -class SampledTexture final : public Castable { +class SampledTexture final : public utils::Castable { public: /// Constructor /// @param dim the dimensionality of the texture diff --git a/src/tint/type/sampler.cc b/src/tint/type/sampler.cc index 271b8be6d2..2ad8f0ceaa 100644 --- a/src/tint/type/sampler.cc +++ b/src/tint/type/sampler.cc @@ -22,7 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Sampler); namespace tint::type { Sampler::Sampler(SamplerKind kind) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, kind), type::Flags{}), kind_(kind) {} + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, kind), type::Flags{}), + kind_(kind) {} Sampler::~Sampler() = default; diff --git a/src/tint/type/sampler.h b/src/tint/type/sampler.h index 9a3554f965..d9f7286c07 100644 --- a/src/tint/type/sampler.h +++ b/src/tint/type/sampler.h @@ -23,7 +23,7 @@ namespace tint::type { /// A sampler type. -class Sampler final : public Castable { +class Sampler final : public utils::Castable { public: /// Constructor /// @param kind the kind of sampler diff --git a/src/tint/type/storage_texture.cc b/src/tint/type/storage_texture.cc index 7aa84c1a0c..cd4145280f 100644 --- a/src/tint/type/storage_texture.cc +++ b/src/tint/type/storage_texture.cc @@ -29,7 +29,8 @@ StorageTexture::StorageTexture(TextureDimension dim, builtin::TexelFormat format, builtin::Access access, Type* subtype) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, dim, format, access), dim), + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, dim, format, access), + dim), texel_format_(format), access_(access), subtype_(subtype) {} diff --git a/src/tint/type/storage_texture.h b/src/tint/type/storage_texture.h index 206e40331c..abd580cd42 100644 --- a/src/tint/type/storage_texture.h +++ b/src/tint/type/storage_texture.h @@ -30,7 +30,7 @@ class Manager; namespace tint::type { /// A storage texture type. -class StorageTexture final : public Castable { +class StorageTexture final : public utils::Castable { public: /// Constructor /// @param dim the dimensionality of the texture diff --git a/src/tint/type/struct.cc b/src/tint/type/struct.cc index bffaa215a7..e5c8d4ce6d 100644 --- a/src/tint/type/struct.cc +++ b/src/tint/type/struct.cc @@ -58,7 +58,7 @@ Struct::Struct(tint::Source source, uint32_t align, uint32_t size, uint32_t size_no_padding) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, name), FlagsFrom(members)), + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, name), FlagsFrom(members)), source_(source), name_(name), members_(std::move(members)), diff --git a/src/tint/type/struct.h b/src/tint/type/struct.h index 035ea7cc07..ea459f50ec 100644 --- a/src/tint/type/struct.h +++ b/src/tint/type/struct.h @@ -45,7 +45,7 @@ enum class PipelineStageUsage { }; /// Struct holds the Type information for structures. -class Struct : public Castable { +class Struct : public utils::Castable { public: /// Constructor /// @param source the source of the structure @@ -164,7 +164,7 @@ class Struct : public Castable { }; /// StructMember holds the type information for structure members. -class StructMember : public Castable { +class StructMember : public utils::Castable { public: /// Constructor /// @param source the source of the struct member diff --git a/src/tint/type/texture.h b/src/tint/type/texture.h index e7cbe81e66..db99ae5087 100644 --- a/src/tint/type/texture.h +++ b/src/tint/type/texture.h @@ -21,7 +21,7 @@ namespace tint::type { /// A texture type. -class Texture : public Castable { +class Texture : public utils::Castable { public: /// Constructor /// @param hash the unique hash of the node diff --git a/src/tint/type/type.h b/src/tint/type/type.h index 083934e761..b6f34a6423 100644 --- a/src/tint/type/type.h +++ b/src/tint/type/type.h @@ -47,7 +47,7 @@ enum Flag { using Flags = utils::EnumSet; /// Base class for a type in the system -class Type : public Castable { +class Type : public utils::Castable { public: /// Destructor ~Type() override; diff --git a/src/tint/type/u32.cc b/src/tint/type/u32.cc index f1eaf66a87..4e40c73dcc 100644 --- a/src/tint/type/u32.cc +++ b/src/tint/type/u32.cc @@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::U32); namespace tint::type { U32::U32() - : Base(static_cast(TypeInfo::Of().full_hashcode), + : Base(static_cast(utils::TypeInfo::Of().full_hashcode), type::Flags{ Flag::kConstructable, Flag::kCreationFixedFootprint, diff --git a/src/tint/type/u32.h b/src/tint/type/u32.h index 456436ac32..de9b5506ae 100644 --- a/src/tint/type/u32.h +++ b/src/tint/type/u32.h @@ -22,7 +22,7 @@ namespace tint::type { /// A unsigned int 32 type. -class U32 final : public Castable { +class U32 final : public utils::Castable { public: /// Constructor U32(); diff --git a/src/tint/type/unique_node.h b/src/tint/type/unique_node.h index 1fd6011240..0e642dfc07 100644 --- a/src/tint/type/unique_node.h +++ b/src/tint/type/unique_node.h @@ -25,7 +25,7 @@ namespace tint::type { /// Deduplication is achieved by comparing a temporary object to the set of existing objects, using /// Hash() and Equals(). If an existing object is found, then the pointer to that object is /// returned, otherwise a new object is constructed, added to the Manager's set and returned. -class UniqueNode : public Castable { +class UniqueNode : public utils::Castable { public: /// Constructor /// @param hash the immutable hash for the node diff --git a/src/tint/type/vector.cc b/src/tint/type/vector.cc index 3ee68e91f7..9c5bebdf6e 100644 --- a/src/tint/type/vector.cc +++ b/src/tint/type/vector.cc @@ -25,7 +25,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Vector); namespace tint::type { Vector::Vector(Type const* subtype, uint32_t width, bool packed /* = false */) - : Base(utils::Hash(TypeInfo::Of().full_hashcode, width, subtype, packed), + : Base(utils::Hash(utils::TypeInfo::Of().full_hashcode, width, subtype, packed), type::Flags{ Flag::kConstructable, Flag::kCreationFixedFootprint, diff --git a/src/tint/type/vector.h b/src/tint/type/vector.h index 04e349ad5a..47b5c40b44 100644 --- a/src/tint/type/vector.h +++ b/src/tint/type/vector.h @@ -22,7 +22,7 @@ namespace tint::type { /// A vector type. -class Vector : public Castable { +class Vector : public utils::Castable { public: /// Constructor /// @param subtype the vector element type diff --git a/src/tint/type/void.cc b/src/tint/type/void.cc index c562a5280e..2b8ddf7659 100644 --- a/src/tint/type/void.cc +++ b/src/tint/type/void.cc @@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Void); namespace tint::type { -Void::Void() : Base(static_cast(TypeInfo::Of().full_hashcode), type::Flags{}) {} +Void::Void() + : Base(static_cast(utils::TypeInfo::Of().full_hashcode), type::Flags{}) {} Void::~Void() = default; diff --git a/src/tint/type/void.h b/src/tint/type/void.h index b24ea9fdff..0215c08936 100644 --- a/src/tint/type/void.h +++ b/src/tint/type/void.h @@ -22,7 +22,7 @@ namespace tint::type { /// A void type -class Void final : public Castable { +class Void final : public utils::Castable { public: /// Constructor Void(); diff --git a/src/tint/castable.cc b/src/tint/utils/castable.cc similarity index 81% rename from src/tint/castable.cc rename to src/tint/utils/castable.cc index 40c32da64a..b7756b33bd 100644 --- a/src/tint/castable.cc +++ b/src/tint/utils/castable.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/castable.h" +#include "src/tint/utils/castable.h" -namespace tint { +namespace tint::utils { /// The unique TypeInfo for the CastableBase type /// @return doxygen-thinks-this-static-field-is-a-function :( @@ -22,12 +22,12 @@ template <> const TypeInfo detail::TypeInfoOf::info{ nullptr, "CastableBase", - tint::TypeInfo::HashCodeOf(), - tint::TypeInfo::FullHashCodeOf(), + tint::utils::TypeInfo::HashCodeOf(), + tint::utils::TypeInfo::FullHashCodeOf(), }; CastableBase::CastableBase(const CastableBase&) = default; CastableBase::~CastableBase() = default; -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/castable.h b/src/tint/utils/castable.h similarity index 92% rename from src/tint/castable.h rename to src/tint/utils/castable.h index 33d6139679..abe761048d 100644 --- a/src/tint/castable.h +++ b/src/tint/utils/castable.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_CASTABLE_H_ -#define SRC_TINT_CASTABLE_H_ +#ifndef SRC_TINT_UTILS_CASTABLE_H_ +#define SRC_TINT_UTILS_CASTABLE_H_ #include #include @@ -42,20 +42,20 @@ TINT_CASTABLE_PUSH_DISABLE_WARNINGS(); // Forward declarations -namespace tint { +namespace tint::utils { class CastableBase; /// Ignore is used as a special type used for skipping over types for trait /// helper functions. class Ignore {}; -} // namespace tint +} // namespace tint::utils -namespace tint::detail { +namespace tint::utils::detail { template struct TypeInfoOf; -} // namespace tint::detail +} // namespace tint::utils::detail -namespace tint { +namespace tint::utils { /// True if all template types that are not Ignore derive from CastableBase template @@ -64,15 +64,15 @@ static constexpr bool IsCastable = !(std::is_same_v && ...); /// Helper macro to instantiate the TypeInfo template for `CLASS`. -#define TINT_INSTANTIATE_TYPEINFO(CLASS) \ - TINT_CASTABLE_PUSH_DISABLE_WARNINGS(); \ - template <> \ - const tint::TypeInfo tint::detail::TypeInfoOf::info{ \ - &tint::detail::TypeInfoOf::info, \ - #CLASS, \ - tint::TypeInfo::HashCodeOf(), \ - tint::TypeInfo::FullHashCodeOf(), \ - }; \ +#define TINT_INSTANTIATE_TYPEINFO(CLASS) \ + TINT_CASTABLE_PUSH_DISABLE_WARNINGS(); \ + template <> \ + const tint::utils::TypeInfo tint::utils::detail::TypeInfoOf::info{ \ + &tint::utils::detail::TypeInfoOf::info, \ + #CLASS, \ + tint::utils::TypeInfo::HashCodeOf(), \ + tint::utils::TypeInfo::FullHashCodeOf(), \ + }; \ TINT_CASTABLE_POP_DISABLE_WARNINGS() /// Bit flags that can be passed to the template parameter `FLAGS` of Is() and As(). @@ -127,7 +127,7 @@ struct TypeInfo { /// @param object the object type to test from, which must be, or derive from type `FROM`. /// @see CastFlags template - static inline bool Is(const tint::TypeInfo* object) { + static inline bool Is(const tint::utils::TypeInfo* object) { constexpr const bool downcast = std::is_base_of::value; constexpr const bool upcast = std::is_base_of::value; constexpr const bool nocast = std::is_same::value; @@ -155,7 +155,7 @@ struct TypeInfo { /// @param type the test type info /// @returns true if the class with this TypeInfo is of, or derives from the /// class with the given TypeInfo. - inline bool Is(const tint::TypeInfo* type) const { + inline bool Is(const tint::utils::TypeInfo* type) const { if (!Maybe(type->hashcode, full_hashcode)) { return false; } @@ -346,12 +346,12 @@ class CastableBase { CastableBase& operator=(const CastableBase& other) = default; /// @returns the TypeInfo of the object - inline const tint::TypeInfo& TypeInfo() const { return *type_info_; } + inline const tint::utils::TypeInfo& TypeInfo() const { return *type_info_; } /// @returns true if this object is of, or derives from the class `TO` template inline bool Is() const { - return tint::Is(this); + return tint::utils::Is(this); } /// @returns true if this object is of, or derives from the class `TO` and pred(const TO*) @@ -360,13 +360,13 @@ class CastableBase { /// derives from the class `TO`. template inline bool Is(Pred&& pred) const { - return tint::Is(this, std::forward(pred)); + return tint::utils::Is(this, std::forward(pred)); } /// @returns true if this object is of, or derives from any of the `TO` classes. template inline bool IsAnyOf() const { - return tint::IsAnyOf(this); + return tint::utils::IsAnyOf(this); } /// @returns this object dynamically cast to the type `TO` or `nullptr` if this object does not @@ -374,7 +374,7 @@ class CastableBase { /// @see CastFlags template inline TO* As() { - return tint::As(this); + return tint::utils::As(this); } /// @returns this object dynamically cast to the type `TO` or `nullptr` if this object does not @@ -382,14 +382,14 @@ class CastableBase { /// @see CastFlags template inline const TO* As() const { - return tint::As(this); + return tint::utils::As(this); } protected: CastableBase() = default; /// The type information for the object - const tint::TypeInfo* type_info_ = nullptr; + const tint::utils::TypeInfo* type_info_ = nullptr; }; /// Castable is a helper to derive `CLASS` from `BASE`, automatically implementing the Is() and As() @@ -433,7 +433,7 @@ class Castable : public BASE { /// @see CastFlags template inline bool Is() const { - return tint::Is(static_cast(this)); + return tint::utils::Is(static_cast(this)); } /// @returns true if this object is of, or derives from the class `TO` and @@ -443,14 +443,15 @@ class Castable : public BASE { template inline bool Is(Pred&& pred) const { using TO = typename std::remove_pointer>::type; - return tint::Is(static_cast(this), std::forward(pred)); + return tint::utils::Is(static_cast(this), + std::forward(pred)); } /// @returns true if this object is of, or derives from any of the `TO` /// classes. template inline bool IsAnyOf() const { - return tint::IsAnyOf(static_cast(this)); + return tint::utils::IsAnyOf(static_cast(this)); } /// @returns this object dynamically cast to the type `TO` or `nullptr` if @@ -458,7 +459,7 @@ class Castable : public BASE { /// @see CastFlags template inline TO* As() { - return tint::As(this); + return tint::utils::As(this); } /// @returns this object dynamically cast to the type `TO` or `nullptr` if @@ -466,7 +467,7 @@ class Castable : public BASE { /// @see CastFlags template inline const TO* As() const { - return tint::As(this); + return tint::utils::As(this); } }; @@ -530,8 +531,15 @@ struct CastableCommonBaseImpl { template using CastableCommonBase = detail::CastableCommonBase; +} // namespace tint::utils + +namespace tint { + +using utils::As; +using utils::Is; + } // namespace tint TINT_CASTABLE_POP_DISABLE_WARNINGS(); -#endif // SRC_TINT_CASTABLE_H_ +#endif // SRC_TINT_UTILS_CASTABLE_H_ diff --git a/src/tint/castable_test.cc b/src/tint/utils/castable_test.cc similarity index 94% rename from src/tint/castable_test.cc rename to src/tint/utils/castable_test.cc index 57bd904f90..419e506b36 100644 --- a/src/tint/castable_test.cc +++ b/src/tint/utils/castable_test.cc @@ -12,25 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/castable.h" +#include "src/tint/utils/castable.h" #include #include #include "gtest/gtest.h" -namespace tint { +namespace tint::utils { namespace { -struct Animal : public tint::Castable {}; -struct Amphibian : public tint::Castable {}; -struct Mammal : public tint::Castable {}; -struct Reptile : public tint::Castable {}; -struct Frog : public tint::Castable {}; -struct Bear : public tint::Castable {}; -struct Lizard : public tint::Castable {}; -struct Gecko : public tint::Castable {}; -struct Iguana : public tint::Castable {}; +struct Animal : public tint::utils::Castable {}; +struct Amphibian : public tint::utils::Castable {}; +struct Mammal : public tint::utils::Castable {}; +struct Reptile : public tint::utils::Castable {}; +struct Frog : public tint::utils::Castable {}; +struct Bear : public tint::utils::Castable {}; +struct Lizard : public tint::utils::Castable {}; +struct Gecko : public tint::utils::Castable {}; +struct Iguana : public tint::utils::Castable {}; TEST(CastableBase, Is) { std::unique_ptr frog = std::make_unique(); @@ -291,4 +291,4 @@ TINT_INSTANTIATE_TYPEINFO(Bear); TINT_INSTANTIATE_TYPEINFO(Lizard); TINT_INSTANTIATE_TYPEINFO(Gecko); -} // namespace tint +} // namespace tint::utils diff --git a/src/tint/utils/slice.h b/src/tint/utils/slice.h index 9737cad633..ad4dbcf26b 100644 --- a/src/tint/utils/slice.h +++ b/src/tint/utils/slice.h @@ -18,8 +18,8 @@ #include #include -#include "src/tint/castable.h" #include "src/tint/utils/bitcast.h" +#include "src/tint/utils/castable.h" #include "src/tint/utils/traits.h" namespace tint::utils { diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index f2c59e499f..cd3834f5e6 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -91,7 +91,7 @@ namespace { const char kTempNamePrefix[] = "tint_tmp"; bool last_is_break(const ast::BlockStatement* stmts) { - return IsAnyOf(stmts->Last()); + return utils::IsAnyOf(stmts->Last()); } bool IsRelational(tint::ast::BinaryOp op) { diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index 8b9bde81a3..5cce6a147c 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -330,7 +330,7 @@ bool GeneratorImpl::Generate() { return false; } - const TypeInfo* last_kind = nullptr; + const utils::TypeInfo* last_kind = nullptr; size_t last_padding_line = 0; auto* mod = builder_.Sem().Module(); @@ -2794,7 +2794,7 @@ bool GeneratorImpl::EmitCase(const ast::SwitchStatement* s, size_t case_idx) { return false; } - if (!tint::IsAnyOf(stmt->body->Last())) { + if (!tint::utils::IsAnyOf(stmt->body->Last())) { line() << "break;"; } diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index f86a14422e..df9ff4bf55 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -90,7 +90,7 @@ namespace tint::writer::msl { namespace { bool last_is_break(const ast::BlockStatement* stmts) { - return IsAnyOf(stmts->Last()); + return utils::IsAnyOf(stmts->Last()); } void PrintF32(utils::StringStream& out, float value) {