ast: Migrate to using ast::Type

Remove all sem::Type references from the AST.
ConstructedTypes are now all AST types.

The parsers will still create semantic types, but these are now disjoint
and ignored.
The parsers will be updated with future changes to stop creating these
semantic types.

Resolver creates semantic types from the AST types. Most downstream
logic continues to use the semantic types, however transforms will now
need to rebuild AST type information instead of reassigning semantic
information, as semantic nodes are fully rebuilt by the Resolver.

Bug: tint:724
Change-Id: I4ce03a075f13c77648cda5c3691bae202752ecc5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49747
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-05-05 09:09:41 +00:00
committed by Commit Bot service account
parent 781de097eb
commit 02ebf0dcae
72 changed files with 1267 additions and 1091 deletions

View File

@@ -28,12 +28,11 @@ namespace sem {
namespace {
ParameterList GetParameters(ast::Function* ast) {
ParameterList GetParameters(const std::vector<const Variable*>& params) {
ParameterList parameters;
parameters.reserve(ast->params().size());
for (auto* param : ast->params()) {
parameters.emplace_back(
Parameter{param->declared_type(), Parameter::Usage::kNone});
parameters.reserve(params.size());
for (auto* param : params) {
parameters.emplace_back(Parameter{param->Type(), Parameter::Usage::kNone});
}
return parameters;
}
@@ -47,7 +46,7 @@ Function::Function(ast::Function* declaration,
std::vector<const Variable*> local_referenced_module_vars,
std::vector<const ast::ReturnStatement*> return_statements,
std::vector<Symbol> ancestor_entry_points)
: Base(return_type, GetParameters(declaration)),
: Base(return_type, GetParameters(parameters)),
declaration_(declaration),
parameters_(std::move(parameters)),
referenced_module_vars_(std::move(referenced_module_vars)),

View File

@@ -30,10 +30,6 @@ Variable::Variable(const ast::Variable* declaration,
Variable::~Variable() = default;
sem::Type* Variable::DeclaredType() const {
return declaration_->declared_type();
}
VariableUser::VariableUser(ast::IdentifierExpression* declaration,
const sem::Type* type,
Statement* statement,

View File

@@ -54,9 +54,6 @@ class Variable : public Castable<Variable, Node> {
/// @returns the canonical type for the variable
sem::Type* Type() const { return const_cast<sem::Type*>(type_); }
/// @returns the AST node's type. May be nullptr.
sem::Type* DeclaredType() const;
/// @returns the storage class for the variable
ast::StorageClass StorageClass() const { return storage_class_; }