mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 17:35:30 +00:00
Move TypeManager from tint::Context to ast::Module
Bug: tint:307 Bug: tint:337 Change-Id: I726cdf89182813ba6f468f8ac35e5d44b22e1e1f Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33666 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
3e67c5dba6
commit
0fb5168fc7
@@ -26,7 +26,7 @@ TypesBuilder::TypesBuilder(TypeManager* tm)
|
||||
tm_(tm) {}
|
||||
|
||||
Builder::Builder(tint::Context* c, tint::ast::Module* m)
|
||||
: ctx(c), mod(m), ty(&c->type_mgr()) {}
|
||||
: ctx(c), mod(m), ty(&m->type_mgr()) {}
|
||||
Builder::~Builder() = default;
|
||||
|
||||
ast::Variable* Builder::Var(const std::string& name,
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "src/ast/function.h"
|
||||
#include "src/ast/type/alias_type.h"
|
||||
#include "src/ast/type_manager.h"
|
||||
#include "src/ast/variable.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -77,6 +78,9 @@ class Module {
|
||||
/// @returns a string representation of the module
|
||||
std::string to_str() const;
|
||||
|
||||
/// @returns the Type Manager
|
||||
ast::TypeManager& type_mgr() { return type_mgr_; }
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
@@ -99,6 +103,7 @@ class Module {
|
||||
std::vector<type::Type*> constructed_types_;
|
||||
FunctionList functions_;
|
||||
std::vector<std::unique_ptr<ast::Node>> ast_nodes_;
|
||||
ast::TypeManager type_mgr_;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
||||
@@ -79,10 +79,10 @@ TEST_F(StorageTextureTypeTest, TypeName) {
|
||||
|
||||
TEST_F(StorageTextureTypeTest, F32Type) {
|
||||
Context ctx;
|
||||
ast::type::Type* s = ctx.type_mgr().Get(std::make_unique<StorageTextureType>(
|
||||
ast::Module mod;
|
||||
ast::type::Type* s = mod.type_mgr().Get(std::make_unique<StorageTextureType>(
|
||||
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
||||
ImageFormat::kRgba32Float));
|
||||
ast::Module mod;
|
||||
TypeDeterminer td(&ctx, &mod);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
@@ -93,10 +93,10 @@ TEST_F(StorageTextureTypeTest, F32Type) {
|
||||
|
||||
TEST_F(StorageTextureTypeTest, U32Type) {
|
||||
Context ctx;
|
||||
ast::type::Type* s = ctx.type_mgr().Get(std::make_unique<StorageTextureType>(
|
||||
ast::Module mod;
|
||||
ast::type::Type* s = mod.type_mgr().Get(std::make_unique<StorageTextureType>(
|
||||
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
||||
ImageFormat::kRgba8Unorm));
|
||||
ast::Module mod;
|
||||
TypeDeterminer td(&ctx, &mod);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
@@ -107,10 +107,10 @@ TEST_F(StorageTextureTypeTest, U32Type) {
|
||||
|
||||
TEST_F(StorageTextureTypeTest, I32Type) {
|
||||
Context ctx;
|
||||
ast::type::Type* s = ctx.type_mgr().Get(std::make_unique<StorageTextureType>(
|
||||
ast::Module mod;
|
||||
ast::type::Type* s = mod.type_mgr().Get(std::make_unique<StorageTextureType>(
|
||||
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
||||
ImageFormat::kRgba32Sint));
|
||||
ast::Module mod;
|
||||
TypeDeterminer td(&ctx, &mod);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace tint {
|
||||
namespace ast {
|
||||
|
||||
TypeManager::TypeManager() = default;
|
||||
|
||||
TypeManager::TypeManager(TypeManager&&) = default;
|
||||
TypeManager::~TypeManager() = default;
|
||||
|
||||
void TypeManager::Reset() {
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace ast {
|
||||
class TypeManager {
|
||||
public:
|
||||
TypeManager();
|
||||
/// Move constructor
|
||||
TypeManager(TypeManager&&);
|
||||
~TypeManager();
|
||||
|
||||
/// Clears all registered types.
|
||||
|
||||
Reference in New Issue
Block a user