mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 05:27:49 +00:00
Add type determiner infrastructure.
This CL adds the Context object, variable ScopeStack and a Function map into the type determiner. The sample app is also updated to verify the module produced before passing to the type determiner. Bug: tint:5 Change-Id: Ib4af4e4305ee8a306f48e1bd328eaf3ad006fd9a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18823 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
dan sinclair
parent
a32315cb73
commit
fa9dbf0dda
@@ -16,7 +16,10 @@
|
||||
|
||||
namespace tint {
|
||||
|
||||
TypeDeterminer::TypeDeterminer() = default;
|
||||
TypeDeterminer::TypeDeterminer(Context* ctx) : ctx_(*ctx) {
|
||||
// TODO(dsinclair): Temporary usage to avoid compiler warning
|
||||
static_cast<void>(ctx_.type_mgr());
|
||||
}
|
||||
|
||||
TypeDeterminer::~TypeDeterminer() = default;
|
||||
|
||||
|
||||
@@ -16,16 +16,26 @@
|
||||
#define SRC_TYPE_DETERMINER_H_
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "src/ast/module.h"
|
||||
#include "src/context.h"
|
||||
#include "src/scope_stack.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
class Function;
|
||||
class Variable;
|
||||
|
||||
} // namespace ast
|
||||
|
||||
/// Determines types for all items in the given tint module
|
||||
class TypeDeterminer {
|
||||
public:
|
||||
/// Constructor
|
||||
TypeDeterminer();
|
||||
/// @param ctx the tint context
|
||||
explicit TypeDeterminer(Context* ctx);
|
||||
~TypeDeterminer();
|
||||
|
||||
/// Runs the type determiner
|
||||
@@ -37,7 +47,10 @@ class TypeDeterminer {
|
||||
const std::string& error() { return error_; }
|
||||
|
||||
private:
|
||||
Context& ctx_;
|
||||
std::string error_;
|
||||
ScopeStack<ast::Variable*> variable_stack_;
|
||||
std::unordered_map<std::string, ast::Function*> name_to_function_;
|
||||
};
|
||||
|
||||
} // namespace tint
|
||||
|
||||
Reference in New Issue
Block a user