Move type_manager to the ast dir/namespace
First step to moving this to the `ast::Module`. Also remove a bunch of redundant includes to `type_manager.h` as this is already included in `context.h` Bug: tint:307 Bug: tint:337 Change-Id: Ic4baffa7b76ddefa29f56f758c25b1003ef40888 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33665 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
4c32dd9735
commit
3e67c5dba6
6
BUILD.gn
6
BUILD.gn
|
@ -371,6 +371,8 @@ source_set("libtint_core_src") {
|
|||
"src/ast/type_constructor_expression.h",
|
||||
"src/ast/type_decoration.cc",
|
||||
"src/ast/type_decoration.h",
|
||||
"src/ast/type_manager.cc",
|
||||
"src/ast/type_manager.h",
|
||||
"src/ast/uint_literal.cc",
|
||||
"src/ast/uint_literal.h",
|
||||
"src/ast/unary_op.cc",
|
||||
|
@ -416,8 +418,6 @@ source_set("libtint_core_src") {
|
|||
"src/transform/vertex_pulling_transform.h",
|
||||
"src/type_determiner.cc",
|
||||
"src/type_determiner.h",
|
||||
"src/type_manager.cc",
|
||||
"src/type_manager.h",
|
||||
"src/validator/validator.cc",
|
||||
"src/validator/validator.h",
|
||||
"src/validator/validator_impl.cc",
|
||||
|
@ -797,6 +797,7 @@ source_set("tint_unittests_core_src") {
|
|||
"src/ast/type/u32_type_test.cc",
|
||||
"src/ast/type/vector_type_test.cc",
|
||||
"src/ast/type_constructor_expression_test.cc",
|
||||
"src/ast/type_manager_test.cc",
|
||||
"src/ast/uint_literal_test.cc",
|
||||
"src/ast/unary_op_expression_test.cc",
|
||||
"src/ast/variable_decl_statement_test.cc",
|
||||
|
@ -810,7 +811,6 @@ source_set("tint_unittests_core_src") {
|
|||
"src/transform/bound_array_accessors_transform_test.cc",
|
||||
"src/transform/vertex_pulling_transform_test.cc",
|
||||
"src/type_determiner_test.cc",
|
||||
"src/type_manager_test.cc",
|
||||
"src/validator/validator_control_block_test.cc",
|
||||
"src/validator/validator_function_test.cc",
|
||||
"src/validator/validator_test.cc",
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
// headers will need to be moved to include/tint/.
|
||||
|
||||
#include "src/ast/pipeline_stage.h"
|
||||
#include "src/ast/type_manager.h"
|
||||
#include "src/context.h"
|
||||
#include "src/diagnostic/printer.h"
|
||||
#include "src/inspector/inspector.h"
|
||||
|
@ -28,7 +29,6 @@
|
|||
#include "src/transform/manager.h"
|
||||
#include "src/transform/vertex_pulling_transform.h"
|
||||
#include "src/type_determiner.h"
|
||||
#include "src/type_manager.h"
|
||||
#include "src/validator/validator.h"
|
||||
#include "src/writer/writer.h"
|
||||
|
||||
|
|
|
@ -192,6 +192,8 @@ set(TINT_LIB_SRCS
|
|||
ast/type/vector_type.h
|
||||
ast/type/void_type.cc
|
||||
ast/type/void_type.h
|
||||
ast/type_manager.cc
|
||||
ast/type_manager.h
|
||||
ast/uint_literal.cc
|
||||
ast/uint_literal.h
|
||||
ast/unary_op.cc
|
||||
|
@ -237,8 +239,6 @@ set(TINT_LIB_SRCS
|
|||
transform/vertex_pulling_transform.h
|
||||
type_determiner.cc
|
||||
type_determiner.h
|
||||
type_manager.cc
|
||||
type_manager.h
|
||||
validator/validator.cc
|
||||
validator/validator.h
|
||||
validator/validator_impl.cc
|
||||
|
@ -407,6 +407,7 @@ set(TINT_TEST_SRCS
|
|||
ast/type/u32_type_test.cc
|
||||
ast/type/vector_type_test.cc
|
||||
ast/type_constructor_expression_test.cc
|
||||
ast/type_manager_test.cc
|
||||
ast/uint_literal_test.cc
|
||||
ast/unary_op_expression_test.cc
|
||||
ast/variable_decl_statement_test.cc
|
||||
|
@ -420,7 +421,6 @@ set(TINT_TEST_SRCS
|
|||
transform/bound_array_accessors_transform_test.cc
|
||||
transform/vertex_pulling_transform_test.cc
|
||||
type_determiner_test.cc
|
||||
type_manager_test.cc
|
||||
validator/validator_control_block_test.cc
|
||||
validator/validator_function_test.cc
|
||||
validator/validator_test.cc
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/type_manager.h"
|
||||
#include "src/ast/type_manager.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
TypeManager::TypeManager() = default;
|
||||
|
||||
|
@ -35,4 +36,5 @@ ast::type::Type* TypeManager::Get(std::unique_ptr<ast::type::Type> type) {
|
|||
return types_.find(name)->second.get();
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
|
@ -12,8 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_TYPE_MANAGER_H_
|
||||
#define SRC_TYPE_MANAGER_H_
|
||||
#ifndef SRC_AST_TYPE_MANAGER_H_
|
||||
#define SRC_AST_TYPE_MANAGER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -23,6 +23,7 @@
|
|||
#include "src/ast/type/type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
/// The type manager holds all the pointers to the known types.
|
||||
class TypeManager {
|
||||
|
@ -58,6 +59,7 @@ class TypeManager {
|
|||
std::unordered_map<std::string, std::unique_ptr<ast::type::Type>> types_;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
||||
#endif // SRC_TYPE_MANAGER_H_
|
||||
#endif // SRC_AST_TYPE_MANAGER_H_
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/type_manager.h"
|
||||
#include "src/ast/type_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
|
@ -25,14 +25,14 @@ namespace {
|
|||
using TypeManagerTest = testing::Test;
|
||||
|
||||
TEST_F(TypeManagerTest, GetUnregistered) {
|
||||
TypeManager tm;
|
||||
ast::TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
ASSERT_NE(t, nullptr);
|
||||
EXPECT_TRUE(t->IsI32());
|
||||
}
|
||||
|
||||
TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
|
||||
TypeManager tm;
|
||||
ast::TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
ASSERT_NE(t, nullptr);
|
||||
EXPECT_TRUE(t->IsI32());
|
||||
|
@ -42,7 +42,7 @@ TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
|
|||
}
|
||||
|
||||
TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
|
||||
TypeManager tm;
|
||||
ast::TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
ASSERT_NE(t, nullptr);
|
||||
EXPECT_TRUE(t->IsI32());
|
||||
|
@ -54,7 +54,7 @@ TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
|
|||
}
|
||||
|
||||
TEST_F(TypeManagerTest, ResetClearsPreviousData) {
|
||||
TypeManager tm;
|
||||
ast::TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
ASSERT_NE(t, nullptr);
|
||||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include "src/ast/node.h"
|
||||
#include "src/namer.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "src/ast/type_manager.h"
|
||||
#include "src/namer.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
|
||||
|
@ -46,13 +46,13 @@ class Context {
|
|||
void Reset();
|
||||
|
||||
/// @returns the Type Manager
|
||||
TypeManager& type_mgr() { return type_mgr_; }
|
||||
ast::TypeManager& type_mgr() { return type_mgr_; }
|
||||
|
||||
/// @returns the namer object
|
||||
Namer* namer() const { return namer_.get(); }
|
||||
|
||||
private:
|
||||
TypeManager type_mgr_;
|
||||
ast::TypeManager type_mgr_;
|
||||
std::unique_ptr<Namer> namer_;
|
||||
};
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@
|
|||
#include "src/reader/spirv/enum_converter.h"
|
||||
#include "src/reader/spirv/function.h"
|
||||
#include "src/reader/spirv/usage.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "src/reader/spirv/parser_impl.h"
|
||||
#include "src/reader/spirv/parser_impl_test_helper.h"
|
||||
#include "src/reader/spirv/spirv_tools_helpers_test.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "src/reader/spirv/parser_impl.h"
|
||||
#include "src/reader/spirv/parser_impl_test_helper.h"
|
||||
#include "src/reader/spirv/spirv_tools_helpers_test.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
#include "src/ast/variable_decl_statement.h"
|
||||
#include "src/ast/workgroup_decoration.h"
|
||||
#include "src/reader/wgsl/lexer.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "src/ast/type/void_type.h"
|
||||
#include "src/reader/wgsl/parser_impl.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "src/ast/variable.h"
|
||||
#include "src/reader/wgsl/parser_impl.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "src/ast/unary_op_expression.h"
|
||||
#include "src/reader/wgsl/parser_impl.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/reader/wgsl/parser_impl.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/reader/wgsl/parser_impl.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -46,7 +46,7 @@ class ParserImplTest : public testing::Test {
|
|||
}
|
||||
|
||||
/// @returns the type manager
|
||||
TypeManager* tm() { return &(ctx_.type_mgr()); }
|
||||
ast::TypeManager* tm() { return &(ctx_.type_mgr()); }
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Source::File>> files_;
|
||||
|
@ -72,7 +72,7 @@ class ParserImplTestWithParam : public testing::TestWithParam<T> {
|
|||
}
|
||||
|
||||
/// @returns the type manager
|
||||
TypeManager* tm() { return &(ctx_.type_mgr()); }
|
||||
ast::TypeManager* tm() { return &(ctx_.type_mgr()); }
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Source::File>> files_;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/reader/wgsl/parser_impl.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "src/ast/type/vector_type.h"
|
||||
#include "src/reader/wgsl/parser_impl.h"
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "src/ast/unary_op_expression.h"
|
||||
#include "src/ast/variable.h"
|
||||
#include "src/ast/variable_decl_statement.h"
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
namespace transform {
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "src/type_manager.h"
|
||||
|
||||
namespace tint {
|
||||
|
||||
ValidatorTestHelper::ValidatorTestHelper() {
|
||||
|
|
Loading…
Reference in New Issue