[transform] Add calling type determiner in manager
This is the first step into migrating away from callers of transforms
knowing that they have to re-run the type determiner.
This CL adds a new constructor that allows the caller to pass in the
context and module and conditionally calling the determiner.
Once downstream users have converted, the old constructor can be
removed, along with hacks to call the determiner in transforms.
Bug: tint:330
Change-Id: Iec49e6d27f92a651cb1e46681a3b3f8fae105164
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33124
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/transform/manager.cc b/src/transform/manager.cc
index a7b3364..2447605 100644
--- a/src/transform/manager.cc
+++ b/src/transform/manager.cc
@@ -14,10 +14,15 @@
#include "src/transform/manager.h"
+#include "src/type_determiner.h"
+
namespace tint {
namespace transform {
-Manager::Manager() = default;
+Manager::Manager() : context_(nullptr), module_(nullptr) {}
+
+Manager::Manager(Context* context, ast::Module* module)
+ : context_(context), module_(module) {}
Manager::~Manager() = default;
@@ -28,6 +33,17 @@
return false;
}
}
+
+ if (context_ != nullptr && module_ != nullptr) {
+ // The transformed have potentially inserted nodes into the AST, so the type
+ // determinater needs to be run.
+ TypeDeterminer td(context_, module_);
+ if (!td.Determine()) {
+ error_ = td.error();
+ return false;
+ }
+ }
+
return true;
}
diff --git a/src/transform/manager.h b/src/transform/manager.h
index 2848ec9..9f88e83 100644
--- a/src/transform/manager.h
+++ b/src/transform/manager.h
@@ -31,7 +31,11 @@
class Manager {
public:
/// Constructor
+ /// DEPRECATED
Manager();
+ /// @param ctx the tint context
+ /// @param mod the module to transform
+ Manager(Context* context, ast::Module* module);
~Manager();
/// Add pass to the manager
@@ -48,6 +52,8 @@
std::string error() const { return error_; }
private:
+ Context* context_;
+ ast::Module* module_;
std::vector<std::unique_ptr<Transformer>> transforms_;
std::string error_;