tint: Replace all remaining AST types with ast::Type
This CL removes the following AST nodes:
* ast::Array
* ast::Atomic
* ast::Matrix
* ast::MultisampledTexture
* ast::Pointer
* ast::SampledTexture
* ast::Texture
* ast::TypeName
* ast::Vector
ast::Type, which used to be the base class for all AST types, is now a
thin wrapper around ast::IdentifierExpression. All types are now
referred to using their type name.
The resolver now handles type resolution and validation of the types
listed above based on the TemplateIdentifier arguments.
Other changes:
* ProgramBuilder has undergone substantial refactoring.
* ProgramBuilder helpers for type inferencing is now more explicit.
Instead of passing 'nullptr', a new 'Infer' template argument is
passed.
* ast::CheckIdentifier() is used for more tests that check identifiers,
including types.
Bug: tint:1810
Change-Id: I8e739ef49435dc1c20a462f3ec5ba265661a7edb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118723
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/ast/bitcast_expression_test.cc b/src/tint/ast/bitcast_expression_test.cc
index 1a446f3..d288a77 100644
--- a/src/tint/ast/bitcast_expression_test.cc
+++ b/src/tint/ast/bitcast_expression_test.cc
@@ -24,17 +24,15 @@
TEST_F(BitcastExpressionTest, Create) {
auto* expr = Expr("expr");
-
- auto* exp = create<BitcastExpression>(ty.f32(), expr);
- ASSERT_TRUE(exp->type->Is<ast::TypeName>());
- EXPECT_EQ(Symbols().NameFor(exp->type->As<ast::TypeName>()->name->symbol), "f32");
+ auto* exp = Bitcast(ty.f32(), expr);
+ CheckIdentifier(Symbols(), exp->type, "f32");
ASSERT_EQ(exp->expr, expr);
}
TEST_F(BitcastExpressionTest, CreateWithSource) {
auto* expr = Expr("expr");
- auto* exp = create<BitcastExpression>(Source{Source::Location{20, 2}}, ty.f32(), expr);
+ auto* exp = Bitcast(Source{Source::Location{20, 2}}, ty.f32(), expr);
auto src = exp->source;
EXPECT_EQ(src.range.begin.line, 20u);
EXPECT_EQ(src.range.begin.column, 2u);
@@ -43,7 +41,7 @@
TEST_F(BitcastExpressionTest, IsBitcast) {
auto* expr = Expr("expr");
- auto* exp = create<BitcastExpression>(ty.f32(), expr);
+ auto* exp = Bitcast(ty.f32(), expr);
EXPECT_TRUE(exp->Is<BitcastExpression>());
}
@@ -51,7 +49,7 @@
EXPECT_FATAL_FAILURE(
{
ProgramBuilder b;
- b.create<BitcastExpression>(nullptr, b.Expr("idx"));
+ b.Bitcast(ast::Type(), "idx");
},
"internal compiler error");
}
@@ -60,7 +58,7 @@
EXPECT_FATAL_FAILURE(
{
ProgramBuilder b;
- b.create<BitcastExpression>(b.ty.f32(), nullptr);
+ b.Bitcast(b.ty.f32(), nullptr);
},
"internal compiler error");
}
@@ -70,7 +68,7 @@
{
ProgramBuilder b1;
ProgramBuilder b2;
- b1.create<BitcastExpression>(b1.ty.f32(), b2.Expr("idx"));
+ b1.Bitcast(b1.ty.f32(), b2.Expr("idx"));
},
"internal compiler error");
}