From be610ba987f5ed8ca3ebbde2d8bff8fad03ba99b Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 25 Jan 2021 22:09:18 +0000 Subject: [PATCH] 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 Commit-Queue: Ben Clayton --- src/type_determiner.cc | 11 +++++++++++ src/type_determiner.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/src/type_determiner.cc b/src/type_determiner.cc index 6752c31f98..fd4d657475 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -66,6 +66,17 @@ TypeDeterminer::TypeDeterminer(Program* program) 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 3c38d6c0b6..be1e8ec441 100644 --- a/src/type_determiner.h +++ b/src/type_determiner.h @@ -20,6 +20,7 @@ #include #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 @@ class TypeDeterminer { /// 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_; }