Add TypeDeterminer::Run()

This is a temporary function to help with Dawn migration.
It will be removed after the migration to using Program and ProgramBuilder is complete.

Bug: tint:390
Change-Id: I98c73a6b8102eebf48a889315a376195f9379f63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38556
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/type_determiner.cc b/src/type_determiner.cc
index 6752c31..fd4d657 100644
--- a/src/type_determiner.cc
+++ b/src/type_determiner.cc
@@ -66,6 +66,17 @@
 
 TypeDeterminer::~TypeDeterminer() = default;
 
+diag::List TypeDeterminer::Run(Program* program) {
+  TypeDeterminer td(program);
+  if (!td.Determine()) {
+    diag::Diagnostic err;
+    err.severity = diag::Severity::Error;
+    err.message = td.error();
+    return {err};
+  }
+  return {};
+}
+
 void TypeDeterminer::set_error(const Source& src, const std::string& msg) {
   error_ = "";
   if (src.range.begin.line > 0) {
diff --git a/src/type_determiner.h b/src/type_determiner.h
index 3c38d6c..be1e8ec 100644
--- a/src/type_determiner.h
+++ b/src/type_determiner.h
@@ -20,6 +20,7 @@
 #include <vector>
 
 #include "src/ast/module.h"
+#include "src/diagnostic/diagnostic.h"
 #include "src/program.h"
 #include "src/scope_stack.h"
 #include "src/type/storage_texture_type.h"
@@ -54,6 +55,14 @@
   /// Destructor
   ~TypeDeterminer();
 
+  /// Run the type determiner on `program`, replacing the Program with a new
+  /// program containing type information.
+  /// [TEMPORARY] - Exists for making incremental changes.
+  /// @param program a pointer to the program variable that will be read from
+  /// and assigned to.
+  /// @returns a list of diagnostic messages
+  static diag::List Run(Program* program);
+
   /// @returns error messages from the type determiner
   const std::string& error() { return error_; }