From 88091d3d17e1ecf9ca326f571242adce17172ed8 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 17 Nov 2020 21:40:59 +0000 Subject: [PATCH] [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 Commit-Queue: dan sinclair Auto-Submit: Ryan Harrison Reviewed-by: dan sinclair --- src/transform/manager.cc | 18 +++++++++++++++++- src/transform/manager.h | 6 ++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/transform/manager.cc b/src/transform/manager.cc index a7b336463d..24476051f4 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 @@ 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; } diff --git a/src/transform/manager.h b/src/transform/manager.h index 2848ec9a57..9f88e83e6a 100644 --- a/src/transform/manager.h +++ b/src/transform/manager.h @@ -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> transforms_; std::string error_;