Remove IdentifierExpression::name().
This CL removes the name method from IdentifierExpression. The usages have been converted over to the symbol. Change-Id: Id751c2fc4a43bd5414fbaf8a8a66ecffb3838e48 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36801 Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
4ac6568821
commit
e65e4bd2c5
|
@ -42,8 +42,6 @@ class IdentifierExpression : public Castable<IdentifierExpression, Expression> {
|
||||||
|
|
||||||
/// @returns the symbol for the identifier
|
/// @returns the symbol for the identifier
|
||||||
Symbol symbol() const { return sym_; }
|
Symbol symbol() const { return sym_; }
|
||||||
/// @returns the name part of the identifier
|
|
||||||
std::string name() const { return name_; }
|
|
||||||
|
|
||||||
/// Sets the intrinsic for this identifier
|
/// Sets the intrinsic for this identifier
|
||||||
/// @param i the intrinsic to set
|
/// @param i the intrinsic to set
|
||||||
|
|
|
@ -25,13 +25,11 @@ using IdentifierExpressionTest = TestHelper;
|
||||||
TEST_F(IdentifierExpressionTest, Creation) {
|
TEST_F(IdentifierExpressionTest, Creation) {
|
||||||
auto* i = Expr("ident");
|
auto* i = Expr("ident");
|
||||||
EXPECT_EQ(i->symbol(), Symbol(1));
|
EXPECT_EQ(i->symbol(), Symbol(1));
|
||||||
EXPECT_EQ(i->name(), "ident");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IdentifierExpressionTest, Creation_WithSource) {
|
TEST_F(IdentifierExpressionTest, Creation_WithSource) {
|
||||||
auto* i = Expr(Source{Source::Location{20, 2}}, "ident");
|
auto* i = Expr(Source{Source::Location{20, 2}}, "ident");
|
||||||
EXPECT_EQ(i->symbol(), Symbol(1));
|
EXPECT_EQ(i->symbol(), Symbol(1));
|
||||||
EXPECT_EQ(i->name(), "ident");
|
|
||||||
|
|
||||||
auto src = i->source();
|
auto src = i->source();
|
||||||
EXPECT_EQ(src.range.begin.line, 20u);
|
EXPECT_EQ(src.range.begin.line, 20u);
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Plus) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Minus) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, AndExpression_Parses) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToVariable) {
|
||||||
|
|
||||||
ASSERT_TRUE(e->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(e->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = e->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = e->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(e->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(e->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(e->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(e->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
|
||||||
|
|
||||||
ASSERT_TRUE(mem->member()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(mem->member()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = mem->member()->As<ast::IdentifierExpression>();
|
auto* ident = mem->member()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "d");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("d"));
|
||||||
|
|
||||||
ASSERT_TRUE(mem->structure()->Is<ast::ArrayAccessorExpression>());
|
ASSERT_TRUE(mem->structure()->Is<ast::ArrayAccessorExpression>());
|
||||||
auto* ary = mem->structure()->As<ast::ArrayAccessorExpression>();
|
auto* ary = mem->structure()->As<ast::ArrayAccessorExpression>();
|
||||||
|
@ -93,18 +93,18 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
|
||||||
mem = ary->array()->As<ast::MemberAccessorExpression>();
|
mem = ary->array()->As<ast::MemberAccessorExpression>();
|
||||||
ASSERT_TRUE(mem->member()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(mem->member()->Is<ast::IdentifierExpression>());
|
||||||
ident = mem->member()->As<ast::IdentifierExpression>();
|
ident = mem->member()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "c");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("c"));
|
||||||
|
|
||||||
ASSERT_TRUE(mem->structure()->Is<ast::MemberAccessorExpression>());
|
ASSERT_TRUE(mem->structure()->Is<ast::MemberAccessorExpression>());
|
||||||
mem = mem->structure()->As<ast::MemberAccessorExpression>();
|
mem = mem->structure()->As<ast::MemberAccessorExpression>();
|
||||||
|
|
||||||
ASSERT_TRUE(mem->structure()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(mem->structure()->Is<ast::IdentifierExpression>());
|
||||||
ident = mem->structure()->As<ast::IdentifierExpression>();
|
ident = mem->structure()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(mem->member()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(mem->member()->Is<ast::IdentifierExpression>());
|
||||||
ident = mem->member()->As<ast::IdentifierExpression>();
|
ident = mem->member()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "b");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, AssignmentStmt_MissingEqual) {
|
TEST_F(ParserImplTest, AssignmentStmt_MissingEqual) {
|
||||||
|
|
|
@ -37,8 +37,8 @@ TEST_F(ParserImplTest, Statement_Call) {
|
||||||
auto* c = e->As<ast::CallStatement>()->expr();
|
auto* c = e->As<ast::CallStatement>()->expr();
|
||||||
|
|
||||||
ASSERT_TRUE(c->func()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(c->func()->Is<ast::IdentifierExpression>());
|
||||||
auto* func = c->func()->As<ast::IdentifierExpression>();
|
auto* ident = c->func()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(func->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
EXPECT_EQ(c->params().size(), 0u);
|
EXPECT_EQ(c->params().size(), 0u);
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ TEST_F(ParserImplTest, Statement_Call_WithParams) {
|
||||||
auto* c = e->As<ast::CallStatement>()->expr();
|
auto* c = e->As<ast::CallStatement>()->expr();
|
||||||
|
|
||||||
ASSERT_TRUE(c->func()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(c->func()->Is<ast::IdentifierExpression>());
|
||||||
auto* func = c->func()->As<ast::IdentifierExpression>();
|
auto* ident = c->func()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(func->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
EXPECT_EQ(c->params().size(), 3u);
|
EXPECT_EQ(c->params().size(), 3u);
|
||||||
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, EqualityExpression_Parses_Equal) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, EqualityExpression_Parses_NotEqual) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, ExclusiveOrExpression_Parses) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, InclusiveOrExpression_Parses) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, LogicalAndExpression_Parses) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, LogicalOrExpression_Parses) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Divide) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Modulo) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_ConstantIndex) {
|
||||||
|
|
||||||
ASSERT_TRUE(ary->array()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(ary->array()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = ary->array()->As<ast::IdentifierExpression>();
|
auto* ident = ary->array()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(ary->idx_expr()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(ary->idx_expr()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(ary->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(ary->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -64,7 +64,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_ExpressionIndex) {
|
||||||
|
|
||||||
ASSERT_TRUE(ary->array()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(ary->array()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = ary->array()->As<ast::IdentifierExpression>();
|
auto* ident = ary->array()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(ary->idx_expr()->Is<ast::BinaryExpression>());
|
ASSERT_TRUE(ary->idx_expr()->Is<ast::BinaryExpression>());
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_Empty) {
|
||||||
|
|
||||||
ASSERT_TRUE(c->func()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(c->func()->Is<ast::IdentifierExpression>());
|
||||||
auto* func = c->func()->As<ast::IdentifierExpression>();
|
auto* func = c->func()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(func->name(), "a");
|
EXPECT_EQ(func->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
EXPECT_EQ(c->params().size(), 0u);
|
EXPECT_EQ(c->params().size(), 0u);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_WithArgs) {
|
||||||
|
|
||||||
ASSERT_TRUE(c->func()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(c->func()->Is<ast::IdentifierExpression>());
|
||||||
auto* func = c->func()->As<ast::IdentifierExpression>();
|
auto* func = c->func()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(func->name(), "test");
|
EXPECT_EQ(func->symbol(), p->get_module().RegisterSymbol("test"));
|
||||||
|
|
||||||
EXPECT_EQ(c->params().size(), 3u);
|
EXPECT_EQ(c->params().size(), 3u);
|
||||||
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
||||||
|
@ -179,10 +179,12 @@ TEST_F(ParserImplTest, PostfixExpression_MemberAccessor) {
|
||||||
|
|
||||||
auto* m = e->As<ast::MemberAccessorExpression>();
|
auto* m = e->As<ast::MemberAccessorExpression>();
|
||||||
ASSERT_TRUE(m->structure()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(m->structure()->Is<ast::IdentifierExpression>());
|
||||||
EXPECT_EQ(m->structure()->As<ast::IdentifierExpression>()->name(), "a");
|
EXPECT_EQ(m->structure()->As<ast::IdentifierExpression>()->symbol(),
|
||||||
|
p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(m->member()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(m->member()->Is<ast::IdentifierExpression>());
|
||||||
EXPECT_EQ(m->member()->As<ast::IdentifierExpression>()->name(), "b");
|
EXPECT_EQ(m->member()->As<ast::IdentifierExpression>()->symbol(),
|
||||||
|
p->get_module().RegisterSymbol("b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, PostfixExpression_MemberAccesssor_InvalidIdent) {
|
TEST_F(ParserImplTest, PostfixExpression_MemberAccesssor_InvalidIdent) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Ident) {
|
||||||
ASSERT_NE(e.value, nullptr);
|
ASSERT_NE(e.value, nullptr);
|
||||||
ASSERT_TRUE(e->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(e->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = e->As<ast::IdentifierExpression>();
|
auto* ident = e->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) {
|
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_LessThan) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThan) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_LessThanEqual) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -108,7 +108,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThanEqual) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftLeft) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftRight) {
|
||||||
|
|
||||||
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(rel->lhs()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
auto* ident = rel->lhs()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(rel->rhs()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -38,7 +38,7 @@ TEST_F(ParserImplTest, UnaryExpression_Postix) {
|
||||||
auto* ary = e->As<ast::ArrayAccessorExpression>();
|
auto* ary = e->As<ast::ArrayAccessorExpression>();
|
||||||
ASSERT_TRUE(ary->array()->Is<ast::IdentifierExpression>());
|
ASSERT_TRUE(ary->array()->Is<ast::IdentifierExpression>());
|
||||||
auto* ident = ary->array()->As<ast::IdentifierExpression>();
|
auto* ident = ary->array()->As<ast::IdentifierExpression>();
|
||||||
EXPECT_EQ(ident->name(), "a");
|
EXPECT_EQ(ident->symbol(), p->get_module().RegisterSymbol("a"));
|
||||||
|
|
||||||
ASSERT_TRUE(ary->idx_expr()->Is<ast::ConstructorExpression>());
|
ASSERT_TRUE(ary->idx_expr()->Is<ast::ConstructorExpression>());
|
||||||
ASSERT_TRUE(ary->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
ASSERT_TRUE(ary->idx_expr()->Is<ast::ScalarConstructorExpression>());
|
||||||
|
|
|
@ -504,8 +504,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
ast::CallExpression* expr) {
|
ast::CallExpression* expr) {
|
||||||
if (ast::intrinsic::IsDerivative(ident->intrinsic())) {
|
if (ast::intrinsic::IsDerivative(ident->intrinsic())) {
|
||||||
if (expr->params().size() != 1) {
|
if (expr->params().size() != 1) {
|
||||||
set_error(expr->source(),
|
set_error(expr->source(), "incorrect number of parameters for " +
|
||||||
"incorrect number of parameters for " + ident->name());
|
mod_->SymbolToName(ident->symbol()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,8 +525,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
}
|
}
|
||||||
if (ast::intrinsic::IsFloatClassificationIntrinsic(ident->intrinsic())) {
|
if (ast::intrinsic::IsFloatClassificationIntrinsic(ident->intrinsic())) {
|
||||||
if (expr->params().size() != 1) {
|
if (expr->params().size() != 1) {
|
||||||
set_error(expr->source(),
|
set_error(expr->source(), "incorrect number of parameters for " +
|
||||||
"incorrect number of parameters for " + ident->name());
|
mod_->SymbolToName(ident->symbol()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +548,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
if (!texture_param->result_type()
|
if (!texture_param->result_type()
|
||||||
->UnwrapPtrIfNeeded()
|
->UnwrapPtrIfNeeded()
|
||||||
->Is<ast::type::Texture>()) {
|
->Is<ast::type::Texture>()) {
|
||||||
set_error(expr->source(), "invalid first argument for " + ident->name());
|
set_error(expr->source(), "invalid first argument for " +
|
||||||
|
mod_->SymbolToName(ident->symbol()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ast::type::Texture* texture = texture_param->result_type()
|
ast::type::Texture* texture = texture_param->result_type()
|
||||||
|
@ -658,9 +659,10 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
|
|
||||||
if (expr->params().size() != param.count) {
|
if (expr->params().size() != param.count) {
|
||||||
set_error(expr->source(),
|
set_error(expr->source(),
|
||||||
"incorrect number of parameters for " + ident->name() +
|
"incorrect number of parameters for " +
|
||||||
", got " + std::to_string(expr->params().size()) +
|
mod_->SymbolToName(ident->symbol()) + ", got " +
|
||||||
" and expected " + std::to_string(param.count));
|
std::to_string(expr->params().size()) + " and expected " +
|
||||||
|
std::to_string(param.count));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,8 +703,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
}
|
}
|
||||||
if (ident->intrinsic() == ast::Intrinsic::kOuterProduct) {
|
if (ident->intrinsic() == ast::Intrinsic::kOuterProduct) {
|
||||||
if (expr->params().size() != 2) {
|
if (expr->params().size() != 2) {
|
||||||
set_error(expr->source(),
|
set_error(expr->source(), "incorrect number of parameters for " +
|
||||||
"incorrect number of parameters for " + ident->name());
|
mod_->SymbolToName(ident->symbol()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +712,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
auto* param1_type = expr->params()[1]->result_type()->UnwrapPtrIfNeeded();
|
auto* param1_type = expr->params()[1]->result_type()->UnwrapPtrIfNeeded();
|
||||||
if (!param0_type->Is<ast::type::Vector>() ||
|
if (!param0_type->Is<ast::type::Vector>() ||
|
||||||
!param1_type->Is<ast::type::Vector>()) {
|
!param1_type->Is<ast::type::Vector>()) {
|
||||||
set_error(expr->source(), "invalid parameter type for " + ident->name());
|
set_error(expr->source(), "invalid parameter type for " +
|
||||||
|
mod_->SymbolToName(ident->symbol()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,7 +726,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
if (ident->intrinsic() == ast::Intrinsic::kSelect) {
|
if (ident->intrinsic() == ast::Intrinsic::kSelect) {
|
||||||
if (expr->params().size() != 3) {
|
if (expr->params().size() != 3) {
|
||||||
set_error(expr->source(), "incorrect number of parameters for " +
|
set_error(expr->source(), "incorrect number of parameters for " +
|
||||||
ident->name() + " expected 3 got " +
|
mod_->SymbolToName(ident->symbol()) +
|
||||||
|
" expected 3 got " +
|
||||||
std::to_string(expr->params().size()));
|
std::to_string(expr->params().size()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -742,13 +746,14 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
error_ = "unable to find intrinsic " + ident->name();
|
error_ = "unable to find intrinsic " + mod_->SymbolToName(ident->symbol());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expr->params().size() != data->param_count) {
|
if (expr->params().size() != data->param_count) {
|
||||||
set_error(expr->source(), "incorrect number of parameters for " +
|
set_error(expr->source(), "incorrect number of parameters for " +
|
||||||
ident->name() + ". Expected " +
|
mod_->SymbolToName(ident->symbol()) +
|
||||||
|
". Expected " +
|
||||||
std::to_string(data->param_count) + " got " +
|
std::to_string(data->param_count) + " got " +
|
||||||
std::to_string(expr->params().size()));
|
std::to_string(expr->params().size()));
|
||||||
return false;
|
return false;
|
||||||
|
@ -764,7 +769,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
if (!result_types.back()->is_float_scalar_or_vector() &&
|
if (!result_types.back()->is_float_scalar_or_vector() &&
|
||||||
!result_types.back()->is_integer_scalar_or_vector()) {
|
!result_types.back()->is_integer_scalar_or_vector()) {
|
||||||
set_error(expr->source(),
|
set_error(expr->source(),
|
||||||
"incorrect type for " + ident->name() + ". " +
|
"incorrect type for " +
|
||||||
|
mod_->SymbolToName(ident->symbol()) + ". " +
|
||||||
"Requires float or int, scalar or vector values");
|
"Requires float or int, scalar or vector values");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -772,7 +778,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
case IntrinsicDataType::kFloatScalarOrVector:
|
case IntrinsicDataType::kFloatScalarOrVector:
|
||||||
if (!result_types.back()->is_float_scalar_or_vector()) {
|
if (!result_types.back()->is_float_scalar_or_vector()) {
|
||||||
set_error(expr->source(),
|
set_error(expr->source(),
|
||||||
"incorrect type for " + ident->name() + ". " +
|
"incorrect type for " +
|
||||||
|
mod_->SymbolToName(ident->symbol()) + ". " +
|
||||||
"Requires float scalar or float vector values");
|
"Requires float scalar or float vector values");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -781,14 +788,16 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
case IntrinsicDataType::kIntScalarOrVector:
|
case IntrinsicDataType::kIntScalarOrVector:
|
||||||
if (!result_types.back()->is_integer_scalar_or_vector()) {
|
if (!result_types.back()->is_integer_scalar_or_vector()) {
|
||||||
set_error(expr->source(),
|
set_error(expr->source(),
|
||||||
"incorrect type for " + ident->name() + ". " +
|
"incorrect type for " +
|
||||||
|
mod_->SymbolToName(ident->symbol()) + ". " +
|
||||||
"Requires integer scalar or integer vector values");
|
"Requires integer scalar or integer vector values");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IntrinsicDataType::kFloatVector:
|
case IntrinsicDataType::kFloatVector:
|
||||||
if (!result_types.back()->is_float_vector()) {
|
if (!result_types.back()->is_float_vector()) {
|
||||||
set_error(expr->source(), "incorrect type for " + ident->name() +
|
set_error(expr->source(), "incorrect type for " +
|
||||||
|
mod_->SymbolToName(ident->symbol()) +
|
||||||
". " + "Requires float vector values");
|
". " + "Requires float vector values");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -796,7 +805,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
result_types.back()->As<ast::type::Vector>()->size() !=
|
result_types.back()->As<ast::type::Vector>()->size() !=
|
||||||
data->vector_size) {
|
data->vector_size) {
|
||||||
set_error(expr->source(), "incorrect vector size for " +
|
set_error(expr->source(), "incorrect vector size for " +
|
||||||
ident->name() + ". " + "Requires " +
|
mod_->SymbolToName(ident->symbol()) +
|
||||||
|
". " + "Requires " +
|
||||||
std::to_string(data->vector_size) +
|
std::to_string(data->vector_size) +
|
||||||
" elements");
|
" elements");
|
||||||
return false;
|
return false;
|
||||||
|
@ -804,7 +814,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
break;
|
break;
|
||||||
case IntrinsicDataType::kMatrix:
|
case IntrinsicDataType::kMatrix:
|
||||||
if (!result_types.back()->Is<ast::type::Matrix>()) {
|
if (!result_types.back()->Is<ast::type::Matrix>()) {
|
||||||
set_error(expr->source(), "incorrect type for " + ident->name() +
|
set_error(expr->source(), "incorrect type for " +
|
||||||
|
mod_->SymbolToName(ident->symbol()) +
|
||||||
". Requires matrix value");
|
". Requires matrix value");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -815,8 +826,8 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
||||||
// Verify all the parameter types match
|
// Verify all the parameter types match
|
||||||
for (size_t i = 1; i < data->param_count; ++i) {
|
for (size_t i = 1; i < data->param_count; ++i) {
|
||||||
if (result_types[0] != result_types[i]) {
|
if (result_types[0] != result_types[i]) {
|
||||||
set_error(expr->source(),
|
set_error(expr->source(), "mismatched parameter types for " +
|
||||||
"mismatched parameter types for " + ident->name());
|
mod_->SymbolToName(ident->symbol()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -891,143 +902,144 @@ bool TypeDeterminer::DetermineIdentifier(ast::IdentifierExpression* expr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TypeDeterminer::SetIntrinsicIfNeeded(ast::IdentifierExpression* ident) {
|
bool TypeDeterminer::SetIntrinsicIfNeeded(ast::IdentifierExpression* ident) {
|
||||||
if (ident->name() == "abs") {
|
auto name = mod_->SymbolToName(ident->symbol());
|
||||||
|
if (name == "abs") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kAbs);
|
ident->set_intrinsic(ast::Intrinsic::kAbs);
|
||||||
} else if (ident->name() == "acos") {
|
} else if (name == "acos") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kAcos);
|
ident->set_intrinsic(ast::Intrinsic::kAcos);
|
||||||
} else if (ident->name() == "all") {
|
} else if (name == "all") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kAll);
|
ident->set_intrinsic(ast::Intrinsic::kAll);
|
||||||
} else if (ident->name() == "any") {
|
} else if (name == "any") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kAny);
|
ident->set_intrinsic(ast::Intrinsic::kAny);
|
||||||
} else if (ident->name() == "arrayLength") {
|
} else if (name == "arrayLength") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kArrayLength);
|
ident->set_intrinsic(ast::Intrinsic::kArrayLength);
|
||||||
} else if (ident->name() == "asin") {
|
} else if (name == "asin") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kAsin);
|
ident->set_intrinsic(ast::Intrinsic::kAsin);
|
||||||
} else if (ident->name() == "atan") {
|
} else if (name == "atan") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kAtan);
|
ident->set_intrinsic(ast::Intrinsic::kAtan);
|
||||||
} else if (ident->name() == "atan2") {
|
} else if (name == "atan2") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kAtan2);
|
ident->set_intrinsic(ast::Intrinsic::kAtan2);
|
||||||
} else if (ident->name() == "ceil") {
|
} else if (name == "ceil") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kCeil);
|
ident->set_intrinsic(ast::Intrinsic::kCeil);
|
||||||
} else if (ident->name() == "clamp") {
|
} else if (name == "clamp") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kClamp);
|
ident->set_intrinsic(ast::Intrinsic::kClamp);
|
||||||
} else if (ident->name() == "cos") {
|
} else if (name == "cos") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kCos);
|
ident->set_intrinsic(ast::Intrinsic::kCos);
|
||||||
} else if (ident->name() == "cosh") {
|
} else if (name == "cosh") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kCosh);
|
ident->set_intrinsic(ast::Intrinsic::kCosh);
|
||||||
} else if (ident->name() == "countOneBits") {
|
} else if (name == "countOneBits") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kCountOneBits);
|
ident->set_intrinsic(ast::Intrinsic::kCountOneBits);
|
||||||
} else if (ident->name() == "cross") {
|
} else if (name == "cross") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kCross);
|
ident->set_intrinsic(ast::Intrinsic::kCross);
|
||||||
} else if (ident->name() == "determinant") {
|
} else if (name == "determinant") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDeterminant);
|
ident->set_intrinsic(ast::Intrinsic::kDeterminant);
|
||||||
} else if (ident->name() == "distance") {
|
} else if (name == "distance") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDistance);
|
ident->set_intrinsic(ast::Intrinsic::kDistance);
|
||||||
} else if (ident->name() == "dot") {
|
} else if (name == "dot") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDot);
|
ident->set_intrinsic(ast::Intrinsic::kDot);
|
||||||
} else if (ident->name() == "dpdx") {
|
} else if (name == "dpdx") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDpdx);
|
ident->set_intrinsic(ast::Intrinsic::kDpdx);
|
||||||
} else if (ident->name() == "dpdxCoarse") {
|
} else if (name == "dpdxCoarse") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDpdxCoarse);
|
ident->set_intrinsic(ast::Intrinsic::kDpdxCoarse);
|
||||||
} else if (ident->name() == "dpdxFine") {
|
} else if (name == "dpdxFine") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDpdxFine);
|
ident->set_intrinsic(ast::Intrinsic::kDpdxFine);
|
||||||
} else if (ident->name() == "dpdy") {
|
} else if (name == "dpdy") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDpdy);
|
ident->set_intrinsic(ast::Intrinsic::kDpdy);
|
||||||
} else if (ident->name() == "dpdyCoarse") {
|
} else if (name == "dpdyCoarse") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDpdyCoarse);
|
ident->set_intrinsic(ast::Intrinsic::kDpdyCoarse);
|
||||||
} else if (ident->name() == "dpdyFine") {
|
} else if (name == "dpdyFine") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kDpdyFine);
|
ident->set_intrinsic(ast::Intrinsic::kDpdyFine);
|
||||||
} else if (ident->name() == "exp") {
|
} else if (name == "exp") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kExp);
|
ident->set_intrinsic(ast::Intrinsic::kExp);
|
||||||
} else if (ident->name() == "exp2") {
|
} else if (name == "exp2") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kExp2);
|
ident->set_intrinsic(ast::Intrinsic::kExp2);
|
||||||
} else if (ident->name() == "faceForward") {
|
} else if (name == "faceForward") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kFaceForward);
|
ident->set_intrinsic(ast::Intrinsic::kFaceForward);
|
||||||
} else if (ident->name() == "floor") {
|
} else if (name == "floor") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kFloor);
|
ident->set_intrinsic(ast::Intrinsic::kFloor);
|
||||||
} else if (ident->name() == "fma") {
|
} else if (name == "fma") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kFma);
|
ident->set_intrinsic(ast::Intrinsic::kFma);
|
||||||
} else if (ident->name() == "fract") {
|
} else if (name == "fract") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kFract);
|
ident->set_intrinsic(ast::Intrinsic::kFract);
|
||||||
} else if (ident->name() == "frexp") {
|
} else if (name == "frexp") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kFrexp);
|
ident->set_intrinsic(ast::Intrinsic::kFrexp);
|
||||||
} else if (ident->name() == "fwidth") {
|
} else if (name == "fwidth") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kFwidth);
|
ident->set_intrinsic(ast::Intrinsic::kFwidth);
|
||||||
} else if (ident->name() == "fwidthCoarse") {
|
} else if (name == "fwidthCoarse") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kFwidthCoarse);
|
ident->set_intrinsic(ast::Intrinsic::kFwidthCoarse);
|
||||||
} else if (ident->name() == "fwidthFine") {
|
} else if (name == "fwidthFine") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kFwidthFine);
|
ident->set_intrinsic(ast::Intrinsic::kFwidthFine);
|
||||||
} else if (ident->name() == "inverseSqrt") {
|
} else if (name == "inverseSqrt") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kInverseSqrt);
|
ident->set_intrinsic(ast::Intrinsic::kInverseSqrt);
|
||||||
} else if (ident->name() == "isFinite") {
|
} else if (name == "isFinite") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kIsFinite);
|
ident->set_intrinsic(ast::Intrinsic::kIsFinite);
|
||||||
} else if (ident->name() == "isInf") {
|
} else if (name == "isInf") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kIsInf);
|
ident->set_intrinsic(ast::Intrinsic::kIsInf);
|
||||||
} else if (ident->name() == "isNan") {
|
} else if (name == "isNan") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kIsNan);
|
ident->set_intrinsic(ast::Intrinsic::kIsNan);
|
||||||
} else if (ident->name() == "isNormal") {
|
} else if (name == "isNormal") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kIsNormal);
|
ident->set_intrinsic(ast::Intrinsic::kIsNormal);
|
||||||
} else if (ident->name() == "ldexp") {
|
} else if (name == "ldexp") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kLdexp);
|
ident->set_intrinsic(ast::Intrinsic::kLdexp);
|
||||||
} else if (ident->name() == "length") {
|
} else if (name == "length") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kLength);
|
ident->set_intrinsic(ast::Intrinsic::kLength);
|
||||||
} else if (ident->name() == "log") {
|
} else if (name == "log") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kLog);
|
ident->set_intrinsic(ast::Intrinsic::kLog);
|
||||||
} else if (ident->name() == "log2") {
|
} else if (name == "log2") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kLog2);
|
ident->set_intrinsic(ast::Intrinsic::kLog2);
|
||||||
} else if (ident->name() == "max") {
|
} else if (name == "max") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kMax);
|
ident->set_intrinsic(ast::Intrinsic::kMax);
|
||||||
} else if (ident->name() == "min") {
|
} else if (name == "min") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kMin);
|
ident->set_intrinsic(ast::Intrinsic::kMin);
|
||||||
} else if (ident->name() == "mix") {
|
} else if (name == "mix") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kMix);
|
ident->set_intrinsic(ast::Intrinsic::kMix);
|
||||||
} else if (ident->name() == "modf") {
|
} else if (name == "modf") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kModf);
|
ident->set_intrinsic(ast::Intrinsic::kModf);
|
||||||
} else if (ident->name() == "normalize") {
|
} else if (name == "normalize") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kNormalize);
|
ident->set_intrinsic(ast::Intrinsic::kNormalize);
|
||||||
} else if (ident->name() == "outerProduct") {
|
} else if (name == "outerProduct") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kOuterProduct);
|
ident->set_intrinsic(ast::Intrinsic::kOuterProduct);
|
||||||
} else if (ident->name() == "pow") {
|
} else if (name == "pow") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kPow);
|
ident->set_intrinsic(ast::Intrinsic::kPow);
|
||||||
} else if (ident->name() == "reflect") {
|
} else if (name == "reflect") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kReflect);
|
ident->set_intrinsic(ast::Intrinsic::kReflect);
|
||||||
} else if (ident->name() == "reverseBits") {
|
} else if (name == "reverseBits") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kReverseBits);
|
ident->set_intrinsic(ast::Intrinsic::kReverseBits);
|
||||||
} else if (ident->name() == "round") {
|
} else if (name == "round") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kRound);
|
ident->set_intrinsic(ast::Intrinsic::kRound);
|
||||||
} else if (ident->name() == "select") {
|
} else if (name == "select") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kSelect);
|
ident->set_intrinsic(ast::Intrinsic::kSelect);
|
||||||
} else if (ident->name() == "sign") {
|
} else if (name == "sign") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kSign);
|
ident->set_intrinsic(ast::Intrinsic::kSign);
|
||||||
} else if (ident->name() == "sin") {
|
} else if (name == "sin") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kSin);
|
ident->set_intrinsic(ast::Intrinsic::kSin);
|
||||||
} else if (ident->name() == "sinh") {
|
} else if (name == "sinh") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kSinh);
|
ident->set_intrinsic(ast::Intrinsic::kSinh);
|
||||||
} else if (ident->name() == "smoothStep") {
|
} else if (name == "smoothStep") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kSmoothStep);
|
ident->set_intrinsic(ast::Intrinsic::kSmoothStep);
|
||||||
} else if (ident->name() == "sqrt") {
|
} else if (name == "sqrt") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kSqrt);
|
ident->set_intrinsic(ast::Intrinsic::kSqrt);
|
||||||
} else if (ident->name() == "step") {
|
} else if (name == "step") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kStep);
|
ident->set_intrinsic(ast::Intrinsic::kStep);
|
||||||
} else if (ident->name() == "tan") {
|
} else if (name == "tan") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTan);
|
ident->set_intrinsic(ast::Intrinsic::kTan);
|
||||||
} else if (ident->name() == "tanh") {
|
} else if (name == "tanh") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTanh);
|
ident->set_intrinsic(ast::Intrinsic::kTanh);
|
||||||
} else if (ident->name() == "textureLoad") {
|
} else if (name == "textureLoad") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTextureLoad);
|
ident->set_intrinsic(ast::Intrinsic::kTextureLoad);
|
||||||
} else if (ident->name() == "textureStore") {
|
} else if (name == "textureStore") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTextureStore);
|
ident->set_intrinsic(ast::Intrinsic::kTextureStore);
|
||||||
} else if (ident->name() == "textureSample") {
|
} else if (name == "textureSample") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTextureSample);
|
ident->set_intrinsic(ast::Intrinsic::kTextureSample);
|
||||||
} else if (ident->name() == "textureSampleBias") {
|
} else if (name == "textureSampleBias") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTextureSampleBias);
|
ident->set_intrinsic(ast::Intrinsic::kTextureSampleBias);
|
||||||
} else if (ident->name() == "textureSampleCompare") {
|
} else if (name == "textureSampleCompare") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTextureSampleCompare);
|
ident->set_intrinsic(ast::Intrinsic::kTextureSampleCompare);
|
||||||
} else if (ident->name() == "textureSampleGrad") {
|
} else if (name == "textureSampleGrad") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTextureSampleGrad);
|
ident->set_intrinsic(ast::Intrinsic::kTextureSampleGrad);
|
||||||
} else if (ident->name() == "textureSampleLevel") {
|
} else if (name == "textureSampleLevel") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTextureSampleLevel);
|
ident->set_intrinsic(ast::Intrinsic::kTextureSampleLevel);
|
||||||
} else if (ident->name() == "trunc") {
|
} else if (name == "trunc") {
|
||||||
ident->set_intrinsic(ast::Intrinsic::kTrunc);
|
ident->set_intrinsic(ast::Intrinsic::kTrunc);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -81,21 +81,6 @@ bool last_is_break_or_fallthrough(const ast::BlockStatement* stmts) {
|
||||||
stmts->last()->Is<ast::FallthroughStatement>();
|
stmts->last()->Is<ast::FallthroughStatement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_buffer_name(ast::Expression* expr) {
|
|
||||||
for (;;) {
|
|
||||||
if (auto* ident = expr->As<ast::IdentifierExpression>()) {
|
|
||||||
return ident->name();
|
|
||||||
} else if (auto* member = expr->As<ast::MemberAccessorExpression>()) {
|
|
||||||
expr = member->structure();
|
|
||||||
} else if (auto* array = expr->As<ast::ArrayAccessorExpression>()) {
|
|
||||||
expr = array->array();
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t convert_swizzle_to_index(const std::string& swizzle) {
|
uint32_t convert_swizzle_to_index(const std::string& swizzle) {
|
||||||
if (swizzle == "r" || swizzle == "x") {
|
if (swizzle == "r" || swizzle == "x") {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -684,17 +669,18 @@ bool GeneratorImpl::EmitCall(std::ostream& pre,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto name = ident->name();
|
auto name = namer_->NameFor(ident->symbol());
|
||||||
auto caller_sym = module_->GetSymbol(name);
|
auto caller_sym = ident->symbol();
|
||||||
auto it = ep_func_name_remapped_.find(current_ep_sym_.to_str() + "_" +
|
auto it = ep_func_name_remapped_.find(current_ep_sym_.to_str() + "_" +
|
||||||
caller_sym.to_str());
|
caller_sym.to_str());
|
||||||
if (it != ep_func_name_remapped_.end()) {
|
if (it != ep_func_name_remapped_.end()) {
|
||||||
name = it->second;
|
name = it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* func = module_->FindFunctionBySymbol(module_->GetSymbol(ident->name()));
|
auto* func = module_->FindFunctionBySymbol(ident->symbol());
|
||||||
if (func == nullptr) {
|
if (func == nullptr) {
|
||||||
error_ = "Unable to find function: " + name;
|
error_ =
|
||||||
|
"Unable to find function: " + module_->SymbolToName(ident->symbol());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,7 +768,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error_ = "Internal compiler error: Unhandled texture intrinsic '" +
|
error_ = "Internal compiler error: Unhandled texture intrinsic '" +
|
||||||
ident->name() + "'";
|
module_->SymbolToName(ident->symbol()) + "'";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,7 +871,7 @@ std::string GeneratorImpl::generate_builtin_name(ast::CallExpression* expr) {
|
||||||
case ast::Intrinsic::kMax:
|
case ast::Intrinsic::kMax:
|
||||||
case ast::Intrinsic::kMin:
|
case ast::Intrinsic::kMin:
|
||||||
case ast::Intrinsic::kClamp:
|
case ast::Intrinsic::kClamp:
|
||||||
out = ident->name();
|
out = module_->SymbolToName(ident->symbol());
|
||||||
break;
|
break;
|
||||||
case ast::Intrinsic::kFaceForward:
|
case ast::Intrinsic::kFaceForward:
|
||||||
out = "faceforward";
|
out = "faceforward";
|
||||||
|
@ -900,7 +886,8 @@ std::string GeneratorImpl::generate_builtin_name(ast::CallExpression* expr) {
|
||||||
out = "smoothstep";
|
out = "smoothstep";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error_ = "Unknown builtin method: " + ident->name();
|
error_ =
|
||||||
|
"Unknown builtin method: " + module_->SymbolToName(ident->symbol());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1948,9 +1935,12 @@ bool GeneratorImpl::is_storage_buffer_access(
|
||||||
ast::MemberAccessorExpression* expr) {
|
ast::MemberAccessorExpression* expr) {
|
||||||
auto* structure = expr->structure();
|
auto* structure = expr->structure();
|
||||||
auto* data_type = structure->result_type()->UnwrapAll();
|
auto* data_type = structure->result_type()->UnwrapAll();
|
||||||
|
// TODO(dsinclair): Swizzle
|
||||||
|
//
|
||||||
// If the data is a multi-element swizzle then we will not load the swizzle
|
// If the data is a multi-element swizzle then we will not load the swizzle
|
||||||
// portion through the Load command.
|
// portion through the Load command.
|
||||||
if (data_type->Is<ast::type::Vector>() && expr->member()->name().size() > 1) {
|
if (data_type->Is<ast::type::Vector>() &&
|
||||||
|
module_->SymbolToName(expr->member()->symbol()).size() > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2364,6 +2354,21 @@ bool GeneratorImpl::EmitProgramConstVariable(std::ostream& out,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GeneratorImpl::get_buffer_name(ast::Expression* expr) {
|
||||||
|
for (;;) {
|
||||||
|
if (auto* ident = expr->As<ast::IdentifierExpression>()) {
|
||||||
|
return namer_->NameFor(ident->symbol());
|
||||||
|
} else if (auto* member = expr->As<ast::MemberAccessorExpression>()) {
|
||||||
|
expr = member->structure();
|
||||||
|
} else if (auto* array = expr->As<ast::ArrayAccessorExpression>()) {
|
||||||
|
expr = array->array();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace hlsl
|
} // namespace hlsl
|
||||||
} // namespace writer
|
} // namespace writer
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
|
@ -387,6 +387,7 @@ class GeneratorImpl {
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string current_ep_var_name(VarType type);
|
std::string current_ep_var_name(VarType type);
|
||||||
|
std::string get_buffer_name(ast::Expression* expr);
|
||||||
|
|
||||||
std::string error_;
|
std::string error_;
|
||||||
size_t indent_ = 0;
|
size_t indent_ = 0;
|
||||||
|
|
|
@ -563,17 +563,18 @@ bool GeneratorImpl::EmitCall(ast::CallExpression* expr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto name = ident->name();
|
auto name = namer_->NameFor(ident->symbol());
|
||||||
auto caller_sym = module_->GetSymbol(name);
|
auto caller_sym = ident->symbol();
|
||||||
auto it = ep_func_name_remapped_.find(current_ep_sym_.to_str() + "_" +
|
auto it = ep_func_name_remapped_.find(current_ep_sym_.to_str() + "_" +
|
||||||
caller_sym.to_str());
|
caller_sym.to_str());
|
||||||
if (it != ep_func_name_remapped_.end()) {
|
if (it != ep_func_name_remapped_.end()) {
|
||||||
name = it->second;
|
name = it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* func = module_->FindFunctionBySymbol(module_->GetSymbol(ident->name()));
|
auto* func = module_->FindFunctionBySymbol(ident->symbol());
|
||||||
if (func == nullptr) {
|
if (func == nullptr) {
|
||||||
error_ = "Unable to find function: " + name;
|
error_ =
|
||||||
|
"Unable to find function: " + module_->SymbolToName(ident->symbol());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +679,7 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr) {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error_ = "Internal compiler error: Unhandled texture intrinsic '" +
|
error_ = "Internal compiler error: Unhandled texture intrinsic '" +
|
||||||
ident->name() + "'";
|
module_->SymbolToName(ident->symbol()) + "'";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,7 +806,7 @@ std::string GeneratorImpl::generate_builtin_name(
|
||||||
case ast::Intrinsic::kTrunc:
|
case ast::Intrinsic::kTrunc:
|
||||||
case ast::Intrinsic::kSign:
|
case ast::Intrinsic::kSign:
|
||||||
case ast::Intrinsic::kClamp:
|
case ast::Intrinsic::kClamp:
|
||||||
out += ident->name();
|
out += module_->SymbolToName(ident->symbol());
|
||||||
break;
|
break;
|
||||||
case ast::Intrinsic::kAbs:
|
case ast::Intrinsic::kAbs:
|
||||||
if (ident->result_type()->Is<ast::type::F32>()) {
|
if (ident->result_type()->Is<ast::type::F32>()) {
|
||||||
|
@ -841,7 +842,8 @@ std::string GeneratorImpl::generate_builtin_name(
|
||||||
out += "rsqrt";
|
out += "rsqrt";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error_ = "Unknown import method: " + ident->name();
|
error_ =
|
||||||
|
"Unknown import method: " + module_->SymbolToName(ident->symbol());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -441,12 +441,6 @@ bool Builder::GenerateEntryPoint(ast::Function* func, uint32_t id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(dsinclair): This should be using the namer to update the entry point
|
|
||||||
// name to a non-user provided string. Disable for now until we can update
|
|
||||||
// the inspector and land the same change in MSL / HLSL to all roll into Dawn
|
|
||||||
// at the same time.
|
|
||||||
// OperandList operands = {Operand::Int(stage), Operand::Int(id),
|
|
||||||
// Operand::String(func->name())};
|
|
||||||
OperandList operands = {Operand::Int(stage), Operand::Int(id),
|
OperandList operands = {Operand::Int(stage), Operand::Int(id),
|
||||||
Operand::String(namer_->NameFor(func->symbol()))};
|
Operand::String(namer_->NameFor(func->symbol()))};
|
||||||
|
|
||||||
|
@ -1119,7 +1113,8 @@ uint32_t Builder::GenerateIdentifierExpression(
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_ = "unable to find variable with identifier: " + expr->name();
|
error_ = "unable to find variable with identifier: " +
|
||||||
|
mod_->SymbolToName(expr->symbol());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1821,7 +1816,8 @@ uint32_t Builder::GenerateCallExpression(ast::CallExpression* expr) {
|
||||||
|
|
||||||
auto func_id = func_symbol_to_id_[ident->symbol().value()];
|
auto func_id = func_symbol_to_id_[ident->symbol().value()];
|
||||||
if (func_id == 0) {
|
if (func_id == 0) {
|
||||||
error_ = "unable to find called function: " + ident->name();
|
error_ = "unable to find called function: " +
|
||||||
|
mod_->SymbolToName(ident->symbol());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ops.push_back(Operand::Int(func_id));
|
ops.push_back(Operand::Int(func_id));
|
||||||
|
@ -1951,7 +1947,7 @@ uint32_t Builder::GenerateIntrinsic(ast::IdentifierExpression* ident,
|
||||||
auto inst_id =
|
auto inst_id =
|
||||||
intrinsic_to_glsl_method(ident->result_type(), ident->intrinsic());
|
intrinsic_to_glsl_method(ident->result_type(), ident->intrinsic());
|
||||||
if (inst_id == 0) {
|
if (inst_id == 0) {
|
||||||
error_ = "unknown method " + ident->name();
|
error_ = "unknown method " + mod_->SymbolToName(ident->symbol());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1962,7 +1958,8 @@ uint32_t Builder::GenerateIntrinsic(ast::IdentifierExpression* ident,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op == spv::Op::OpNop) {
|
if (op == spv::Op::OpNop) {
|
||||||
error_ = "unable to determine operator for: " + ident->name();
|
error_ = "unable to determine operator for: " +
|
||||||
|
mod_->SymbolToName(ident->symbol());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2173,7 +2170,8 @@ bool Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op == spv::Op::OpNop) {
|
if (op == spv::Op::OpNop) {
|
||||||
error_ = "unable to determine operator for: " + ident->name();
|
error_ = "unable to determine operator for: " +
|
||||||
|
mod_->SymbolToName(ident->symbol());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ bool GeneratorImpl::EmitLiteral(ast::Literal* lit) {
|
||||||
|
|
||||||
bool GeneratorImpl::EmitIdentifier(ast::IdentifierExpression* expr) {
|
bool GeneratorImpl::EmitIdentifier(ast::IdentifierExpression* expr) {
|
||||||
auto* ident = expr->As<ast::IdentifierExpression>();
|
auto* ident = expr->As<ast::IdentifierExpression>();
|
||||||
out_ << ident->name();
|
out_ << module_.SymbolToName(ident->symbol());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue