diff --git a/include/tint/tint.h b/include/tint/tint.h index cd01ae82b2..c71682f86a 100644 --- a/include/tint/tint.h +++ b/include/tint/tint.h @@ -34,7 +34,7 @@ #include "src/tint/transform/single_entry_point.h" #include "src/tint/transform/substitute_override.h" #include "src/tint/transform/vertex_pulling.h" -#include "src/tint/type/type_manager.h" +#include "src/tint/type/manager.h" #include "src/tint/writer/flatten_bindings.h" #include "src/tint/writer/writer.h" diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 4db828927f..930958bac3 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -564,6 +564,7 @@ libtint_source_set("libtint_core_all_src") { "type/f16.h", "type/f32.h", "type/i32.h", + "type/manager.h", "type/matrix.h", "type/multisampled_texture.h", "type/node.h", @@ -576,7 +577,6 @@ libtint_source_set("libtint_core_all_src") { "type/struct.h", "type/texture.h", "type/type.h", - "type/type_manager.h", "type/u32.h", "type/vector.h", "type/void.h", @@ -721,6 +721,8 @@ libtint_source_set("libtint_type_src") { "type/f32.h", "type/i32.cc", "type/i32.h", + "type/manager.cc", + "type/manager.h", "type/matrix.cc", "type/matrix.h", "type/multisampled_texture.cc", @@ -745,8 +747,6 @@ libtint_source_set("libtint_type_src") { "type/texture.h", "type/type.cc", "type/type.h", - "type/type_manager.cc", - "type/type_manager.h", "type/u32.cc", "type/u32.h", "type/vector.cc", @@ -1223,6 +1223,7 @@ if (tint_build_unittests) { "type/f16_test.cc", "type/f32_test.cc", "type/i32_test.cc", + "type/manager_test.cc", "type/matrix_test.cc", "type/multisampled_texture_test.cc", "type/pointer_test.cc", @@ -1233,7 +1234,6 @@ if (tint_build_unittests) { "type/storage_texture_test.cc", "type/struct_test.cc", "type/texture_test.cc", - "type/type_manager_test.cc", "type/type_test.cc", "type/u32_test.cc", "type/vector_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 708d765ce5..7dd09c24ee 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -478,6 +478,8 @@ list(APPEND TINT_LIB_SRCS type/f32.h type/i32.cc type/i32.h + type/manager.cc + type/manager.h type/matrix.cc type/matrix.h type/multisampled_texture.cc @@ -500,8 +502,6 @@ list(APPEND TINT_LIB_SRCS type/texture.h type/type.cc type/type.h - type/type_manager.cc - type/type_manager.h type/u32.cc type/u32.h type/vector.cc @@ -942,6 +942,7 @@ if(TINT_BUILD_TESTS) type/f16_test.cc type/f32_test.cc type/i32_test.cc + type/manager_test.cc type/matrix_test.cc type/multisampled_texture_test.cc type/pointer_test.cc @@ -952,7 +953,6 @@ if(TINT_BUILD_TESTS) type/struct_test.cc type/texture_test.cc type/type_test.cc - type/type_manager_test.cc type/u32_test.cc type/vector_test.cc utils/bitcast_test.cc diff --git a/src/tint/program.h b/src/tint/program.h index 025db672ec..2b10f3bd48 100644 --- a/src/tint/program.h +++ b/src/tint/program.h @@ -23,7 +23,7 @@ #include "src/tint/sem/constant.h" #include "src/tint/sem/info.h" #include "src/tint/symbol_table.h" -#include "src/tint/type/type_manager.h" +#include "src/tint/type/manager.h" // Forward Declarations namespace tint { @@ -73,7 +73,7 @@ class Program { ast::NodeID HighestASTNodeID() const { return highest_node_id_; } /// @returns a reference to the program's types - const type::TypeManager& Types() const { + const type::Manager& Types() const { AssertNotMoved(); return types_; } @@ -180,7 +180,7 @@ class Program { ProgramID id_; ast::NodeID highest_node_id_; - type::TypeManager types_; + type::Manager types_; ASTNodeAllocator ast_nodes_; SemNodeAllocator sem_nodes_; ConstantAllocator constant_nodes_; diff --git a/src/tint/program_builder.cc b/src/tint/program_builder.cc index 244e735f59..87c6a4c67d 100644 --- a/src/tint/program_builder.cc +++ b/src/tint/program_builder.cc @@ -70,7 +70,7 @@ ProgramBuilder ProgramBuilder::Wrap(const Program* program) { ProgramBuilder builder; builder.id_ = program->ID(); builder.last_ast_node_id_ = program->HighestASTNodeID(); - builder.types_ = type::TypeManager::Wrap(program->Types()); + builder.types_ = type::Manager::Wrap(program->Types()); builder.ast_ = builder.create(program->AST().source, program->AST().GlobalDeclarations()); builder.sem_ = sem::Info::Wrap(program->Sem()); diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index feacc38b69..a2ca5b43d5 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -299,13 +299,13 @@ class ProgramBuilder { ProgramID ID() const { return id_; } /// @returns a reference to the program's types - type::TypeManager& Types() { + type::Manager& Types() { AssertNotMoved(); return types_; } /// @returns a reference to the program's types - const type::TypeManager& Types() const { + const type::Manager& Types() const { AssertNotMoved(); return types_; } @@ -3247,7 +3247,7 @@ class ProgramBuilder { private: ProgramID id_; ast::NodeID last_ast_node_id_ = ast::NodeID{static_cast(0) - 1}; - type::TypeManager types_; + type::Manager types_; ASTNodeAllocator ast_nodes_; SemNodeAllocator sem_nodes_; ConstantAllocator constant_nodes_; diff --git a/src/tint/type/type_manager.cc b/src/tint/type/manager.cc similarity index 73% rename from src/tint/type/type_manager.cc rename to src/tint/type/manager.cc index 766725c7c5..2c455eb726 100644 --- a/src/tint/type/type_manager.cc +++ b/src/tint/type/manager.cc @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/type/type_manager.h" +#include "src/tint/type/manager.h" namespace tint::type { -TypeManager::TypeManager() = default; -TypeManager::TypeManager(TypeManager&&) = default; -TypeManager& TypeManager::operator=(TypeManager&& rhs) = default; -TypeManager::~TypeManager() = default; +Manager::Manager() = default; +Manager::Manager(Manager&&) = default; +Manager& Manager::operator=(Manager&& rhs) = default; +Manager::~Manager() = default; } // namespace tint::type diff --git a/src/tint/type/type_manager.h b/src/tint/type/manager.h similarity index 93% rename from src/tint/type/type_manager.h rename to src/tint/type/manager.h index 4c643d3b4e..2e587c332a 100644 --- a/src/tint/type/type_manager.h +++ b/src/tint/type/manager.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_TYPE_TYPE_MANAGER_H_ -#define SRC_TINT_TYPE_TYPE_MANAGER_H_ +#ifndef SRC_TINT_TYPE_MANAGER_H_ +#define SRC_TINT_TYPE_MANAGER_H_ #include #include @@ -29,24 +29,24 @@ namespace tint::type { /// The type manager holds all the pointers to the known types. -class TypeManager final { +class Manager final { public: /// Iterator is the type returned by begin() and end() using TypeIterator = utils::BlockAllocator::ConstIterator; /// Constructor - TypeManager(); + Manager(); /// Move constructor - TypeManager(TypeManager&&); + Manager(Manager&&); /// Move assignment operator /// @param rhs the Manager to move /// @return this Manager - TypeManager& operator=(TypeManager&& rhs); + Manager& operator=(Manager&& rhs); /// Destructor - ~TypeManager(); + ~Manager(); /// Wrap returns a new Manager created with the types of `inner`. /// The Manager returned by Wrap is intended to temporarily extend the types @@ -57,8 +57,8 @@ class TypeManager final { /// function. See crbug.com/tint/460. /// @param inner the immutable Manager to extend /// @return the Manager that wraps `inner` - static TypeManager Wrap(const TypeManager& inner) { - TypeManager out; + static Manager Wrap(const Manager& inner) { + Manager out; out.types_.Wrap(inner.types_); out.nodes_.Wrap(inner.nodes_); return out; @@ -149,4 +149,4 @@ struct equal_to { } // namespace std -#endif // SRC_TINT_TYPE_TYPE_MANAGER_H_ +#endif // SRC_TINT_TYPE_MANAGER_H_ diff --git a/src/tint/type/type_manager_test.cc b/src/tint/type/manager_test.cc similarity index 77% rename from src/tint/type/type_manager_test.cc rename to src/tint/type/manager_test.cc index 90d7fdc865..4fb2179cd8 100644 --- a/src/tint/type/type_manager_test.cc +++ b/src/tint/type/manager_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/type/type_manager.h" +#include "src/tint/type/manager.h" #include "gtest/gtest.h" #include "src/tint/type/i32.h" @@ -31,17 +31,17 @@ size_t count(const T& range_loopable) { return n; } -using TypeManagerTest = testing::Test; +using ManagerTest = testing::Test; -TEST_F(TypeManagerTest, GetUnregistered) { - TypeManager tm; +TEST_F(ManagerTest, GetUnregistered) { + Manager tm; auto* t = tm.Get(); ASSERT_NE(t, nullptr); EXPECT_TRUE(t->Is()); } -TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) { - TypeManager tm; +TEST_F(ManagerTest, GetSameTypeReturnsSamePtr) { + Manager tm; auto* t = tm.Get(); ASSERT_NE(t, nullptr); EXPECT_TRUE(t->Is()); @@ -50,8 +50,8 @@ TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) { EXPECT_EQ(t, t2); } -TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) { - TypeManager tm; +TEST_F(ManagerTest, GetDifferentTypeReturnsDifferentPtr) { + Manager tm; Type* t = tm.Get(); ASSERT_NE(t, nullptr); EXPECT_TRUE(t->Is()); @@ -62,17 +62,17 @@ TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) { EXPECT_TRUE(t2->Is()); } -TEST_F(TypeManagerTest, Find) { - TypeManager tm; +TEST_F(ManagerTest, Find) { + Manager tm; auto* created = tm.Get(); EXPECT_EQ(tm.Find(), nullptr); EXPECT_EQ(tm.Find(), created); } -TEST_F(TypeManagerTest, WrapDoesntAffectInner) { - TypeManager inner; - TypeManager outer = TypeManager::Wrap(inner); +TEST_F(ManagerTest, WrapDoesntAffectInner) { + Manager inner; + Manager outer = Manager::Wrap(inner); inner.Get(); diff --git a/src/tint/type/storage_texture.cc b/src/tint/type/storage_texture.cc index 8e8ed3d90c..2bd2c28c90 100644 --- a/src/tint/type/storage_texture.cc +++ b/src/tint/type/storage_texture.cc @@ -48,7 +48,7 @@ std::string StorageTexture::FriendlyName(const SymbolTable&) const { return out.str(); } -Type* StorageTexture::SubtypeFor(ast::TexelFormat format, TypeManager& type_mgr) { +Type* StorageTexture::SubtypeFor(ast::TexelFormat format, Manager& type_mgr) { switch (format) { case ast::TexelFormat::kR32Uint: case ast::TexelFormat::kRgba8Uint: diff --git a/src/tint/type/storage_texture.h b/src/tint/type/storage_texture.h index 4189ebe239..0e597754c5 100644 --- a/src/tint/type/storage_texture.h +++ b/src/tint/type/storage_texture.h @@ -23,7 +23,7 @@ // Forward declarations namespace tint::type { -class TypeManager; +class Manager; } // namespace tint::type namespace tint::type { @@ -67,9 +67,9 @@ class StorageTexture final : public Castable { std::string FriendlyName(const SymbolTable& symbols) const override; /// @param format the storage texture image format - /// @param type_mgr the TypeManager used to build the returned type + /// @param type_mgr the Manager used to build the returned type /// @returns the storage texture subtype for the given TexelFormat - static Type* SubtypeFor(ast::TexelFormat format, TypeManager& type_mgr); + static Type* SubtypeFor(ast::TexelFormat format, Manager& type_mgr); private: ast::TexelFormat const texel_format_;