[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>
This commit is contained in:
Ryan Harrison 2020-11-17 21:40:59 +00:00 committed by Commit Bot service account
parent bd7ab2cd5f
commit 88091d3d17
2 changed files with 23 additions and 1 deletions

View File

@ -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 @@ bool Manager::Run() {
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;
}

View File

@ -31,7 +31,11 @@ namespace transform {
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 @@ class Manager {
std::string error() const { return error_; }
private:
Context* context_;
ast::Module* module_;
std::vector<std::unique_ptr<Transformer>> transforms_;
std::string error_;