tint: Have ast::CallExpression use ast::Identifier
Instead of ast::IdentifierExpression.
The name is not an expression, as it resolves to a function, builtin or
type.
Bug: tint:1257
Change-Id: I13143f2bbc208e9e2934dad20fe5c9aa59520b68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118341
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/ast/call_expression_test.cc b/src/tint/ast/call_expression_test.cc
index 8b5b6a9..774d6a2 100644
--- a/src/tint/ast/call_expression_test.cc
+++ b/src/tint/ast/call_expression_test.cc
@@ -21,13 +21,13 @@
using CallExpressionTest = TestHelper;
TEST_F(CallExpressionTest, CreationIdentifier) {
- auto* func = Expr("func");
+ auto* func = Ident("func");
utils::Vector params{
Expr("param1"),
Expr("param2"),
};
- auto* stmt = create<CallExpression>(func, params);
+ auto* stmt = Call(func, params);
EXPECT_EQ(stmt->target.name, func);
EXPECT_EQ(stmt->target.type, nullptr);
@@ -38,8 +38,8 @@
}
TEST_F(CallExpressionTest, CreationIdentifier_WithSource) {
- auto* func = Expr("func");
- auto* stmt = create<CallExpression>(Source{{20, 2}}, func, utils::Empty);
+ auto* func = Ident("func");
+ auto* stmt = Call(Source{{20, 2}}, func);
EXPECT_EQ(stmt->target.name, func);
EXPECT_EQ(stmt->target.type, nullptr);
@@ -55,7 +55,7 @@
Expr("param2"),
};
- auto* stmt = create<CallExpression>(type, params);
+ auto* stmt = Construct(type, params);
EXPECT_EQ(stmt->target.name, nullptr);
EXPECT_EQ(stmt->target.type, type);
@@ -67,7 +67,7 @@
TEST_F(CallExpressionTest, CreationType_WithSource) {
auto* type = ty.f32();
- auto* stmt = create<CallExpression>(Source{{20, 2}}, type, utils::Empty);
+ auto* stmt = Construct(Source{{20, 2}}, type);
EXPECT_EQ(stmt->target.name, nullptr);
EXPECT_EQ(stmt->target.type, type);
@@ -77,8 +77,8 @@
}
TEST_F(CallExpressionTest, IsCall) {
- auto* func = Expr("func");
- auto* stmt = create<CallExpression>(func, utils::Empty);
+ auto* func = Ident("func");
+ auto* stmt = Call(func);
EXPECT_TRUE(stmt->Is<CallExpression>());
}
@@ -86,7 +86,7 @@
EXPECT_FATAL_FAILURE(
{
ProgramBuilder b;
- b.create<CallExpression>(static_cast<IdentifierExpression*>(nullptr), utils::Empty);
+ b.Call(static_cast<Identifier*>(nullptr));
},
"internal compiler error");
}
@@ -95,7 +95,7 @@
EXPECT_FATAL_FAILURE(
{
ProgramBuilder b;
- b.create<CallExpression>(static_cast<Type*>(nullptr), utils::Empty);
+ b.Construct(static_cast<Type*>(nullptr));
},
"internal compiler error");
}
@@ -104,11 +104,11 @@
EXPECT_FATAL_FAILURE(
{
ProgramBuilder b;
- b.create<CallExpression>(b.Expr("func"), utils::Vector{
- b.Expr("param1"),
- nullptr,
- b.Expr("param2"),
- });
+ b.Call(b.Ident("func"), utils::Vector{
+ b.Expr("param1"),
+ nullptr,
+ b.Expr("param2"),
+ });
},
"internal compiler error");
}
@@ -118,7 +118,7 @@
{
ProgramBuilder b1;
ProgramBuilder b2;
- b1.create<CallExpression>(b2.Expr("func"), utils::Empty);
+ b1.Call(b2.Ident("func"));
},
"internal compiler error");
}
@@ -128,7 +128,7 @@
{
ProgramBuilder b1;
ProgramBuilder b2;
- b1.create<CallExpression>(b2.ty.f32(), utils::Empty);
+ b1.Construct(b2.ty.f32());
},
"internal compiler error");
}
@@ -138,7 +138,7 @@
{
ProgramBuilder b1;
ProgramBuilder b2;
- b1.create<CallExpression>(b1.Expr("func"), utils::Vector{b2.Expr("param1")});
+ b1.Call(b1.Ident("func"), b2.Expr("param1"));
},
"internal compiler error");
}