ast: Rename UnaryOp::kDereference to kIndirection

This is what it is (currently) called in the spec

Bug: tint:727
Change-Id: Ie24f42499ed20c0c45ef4e9474bc6bb6a19bfa36
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51181
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2021-05-17 14:48:37 +00:00 committed by Commit Bot service account
parent ac90829e1c
commit 85bdf1753e
14 changed files with 20 additions and 20 deletions

View File

@ -23,8 +23,8 @@ std::ostream& operator<<(std::ostream& out, UnaryOp mod) {
out << "address-of"; out << "address-of";
break; break;
} }
case UnaryOp::kDereference: { case UnaryOp::kIndirection: {
out << "dereference"; out << "indirection";
break; break;
} }
case UnaryOp::kNegation: { case UnaryOp::kNegation: {

View File

@ -23,7 +23,7 @@ namespace ast {
/// The unary op /// The unary op
enum class UnaryOp { enum class UnaryOp {
kAddressOf, // &EXPR kAddressOf, // &EXPR
kDereference, // *EXPR kIndirection, // *EXPR
kNegation, // -EXPR kNegation, // -EXPR
kNot, // !EXPR kNot, // !EXPR
}; };

View File

@ -2325,7 +2325,7 @@ Maybe<ast::Expression*> ParserImpl::unary_expression() {
} else if (match(Token::Type::kBang)) { } else if (match(Token::Type::kBang)) {
op = ast::UnaryOp::kNot; op = ast::UnaryOp::kNot;
} else if (match(Token::Type::kStar)) { } else if (match(Token::Type::kStar)) {
op = ast::UnaryOp::kDereference; op = ast::UnaryOp::kIndirection;
} else if (match(Token::Type::kAnd)) { } else if (match(Token::Type::kAnd)) {
op = ast::UnaryOp::kAddressOf; op = ast::UnaryOp::kAddressOf;
} else { } else {

View File

@ -85,7 +85,7 @@ TEST_F(ParserImplTest, UnaryExpression_Dereference) {
ASSERT_TRUE(e->Is<ast::UnaryOpExpression>()); ASSERT_TRUE(e->Is<ast::UnaryOpExpression>());
auto* u = e->As<ast::UnaryOpExpression>(); auto* u = e->As<ast::UnaryOpExpression>();
EXPECT_EQ(u->op(), ast::UnaryOp::kDereference); EXPECT_EQ(u->op(), ast::UnaryOp::kIndirection);
EXPECT_TRUE(u->expr()->Is<ast::IdentifierExpression>()); EXPECT_TRUE(u->expr()->Is<ast::IdentifierExpression>());
} }
@ -113,7 +113,7 @@ TEST_F(ParserImplTest, UnaryExpression_Dereference_Precedence) {
ASSERT_TRUE(e->Is<ast::UnaryOpExpression>()); ASSERT_TRUE(e->Is<ast::UnaryOpExpression>());
auto* u = e->As<ast::UnaryOpExpression>(); auto* u = e->As<ast::UnaryOpExpression>();
EXPECT_EQ(u->op(), ast::UnaryOp::kDereference); EXPECT_EQ(u->op(), ast::UnaryOp::kIndirection);
EXPECT_TRUE(u->expr()->Is<ast::MemberAccessorExpression>()); EXPECT_TRUE(u->expr()->Is<ast::MemberAccessorExpression>());
} }

View File

@ -129,7 +129,7 @@ void Hlsl::AddEmptyEntryPoint(CloneContext& ctx) const {
return; return;
} }
} }
ctx.dst->Func(ctx.dst->Symbols().New("tint_unused_entry_point"), {}, ctx.dst->Func(ctx.dst->Symbols().New("unused_entry_point"), {},
ctx.dst->ty.void_(), {}, ctx.dst->ty.void_(), {},
{ctx.dst->Stage(ast::PipelineStage::kCompute)}); {ctx.dst->Stage(ast::PipelineStage::kCompute)});
} }

View File

@ -282,7 +282,7 @@ TEST_F(HlslTest, AddEmptyEntryPoint) {
auto* expect = R"( auto* expect = R"(
[[stage(compute)]] [[stage(compute)]]
fn tint_unused_entry_point() { fn unused_entry_point() {
} }
)"; )";

View File

@ -285,7 +285,7 @@ void Spirv::AddEmptyEntryPoint(CloneContext& ctx) const {
return; return;
} }
} }
ctx.dst->Func("_tint_unused_entry_point", {}, ctx.dst->ty.void_(), {}, ctx.dst->Func(ctx.dst->Sym("unused_entry_point"), {}, ctx.dst->ty.void_(), {},
{ctx.dst->Stage(ast::PipelineStage::kCompute)}); {ctx.dst->Stage(ast::PipelineStage::kCompute)});
} }

View File

@ -693,7 +693,7 @@ TEST_F(SpirvTest, AddEmptyEntryPoint) {
auto* expect = R"( auto* expect = R"(
[[stage(compute)]] [[stage(compute)]]
fn _tint_unused_entry_point() { fn unused_entry_point() {
} }
)"; )";

View File

@ -2599,7 +2599,7 @@ bool GeneratorImpl::EmitUnaryOp(std::ostream& pre,
std::ostream& out, std::ostream& out,
ast::UnaryOpExpression* expr) { ast::UnaryOpExpression* expr) {
switch (expr->op()) { switch (expr->op()) {
case ast::UnaryOp::kDereference: case ast::UnaryOp::kIndirection:
case ast::UnaryOp::kAddressOf: case ast::UnaryOp::kAddressOf:
// TODO(crbug.com/tint/183) - support pointers // TODO(crbug.com/tint/183) - support pointers
return EmitExpression(pre, out, expr->expr()); return EmitExpression(pre, out, expr->expr());

View File

@ -46,7 +46,7 @@ INSTANTIATE_TEST_SUITE_P(
HlslGeneratorImplTest_UnaryOp, HlslGeneratorImplTest_UnaryOp,
HlslUnaryOpTest, HlslUnaryOpTest,
testing::Values(UnaryOpData{"", ast::UnaryOp::kAddressOf}, testing::Values(UnaryOpData{"", ast::UnaryOp::kAddressOf},
UnaryOpData{"", ast::UnaryOp::kDereference}, UnaryOpData{"", ast::UnaryOp::kIndirection},
UnaryOpData{"!", ast::UnaryOp::kNot}, UnaryOpData{"!", ast::UnaryOp::kNot},
UnaryOpData{"-", ast::UnaryOp::kNegation})); UnaryOpData{"-", ast::UnaryOp::kNegation}));

View File

@ -2151,12 +2151,12 @@ bool GeneratorImpl::EmitStructType(const sem::Struct* str) {
bool GeneratorImpl::EmitUnaryOp(ast::UnaryOpExpression* expr) { bool GeneratorImpl::EmitUnaryOp(ast::UnaryOpExpression* expr) {
switch (expr->op()) { switch (expr->op()) {
case ast::UnaryOp::kDereference:
out_ << "*";
break;
case ast::UnaryOp::kAddressOf: case ast::UnaryOp::kAddressOf:
out_ << "&"; out_ << "&";
break; break;
case ast::UnaryOp::kIndirection:
out_ << "*";
break;
case ast::UnaryOp::kNot: case ast::UnaryOp::kNot:
out_ << "!"; out_ << "!";
break; break;

View File

@ -44,7 +44,7 @@ INSTANTIATE_TEST_SUITE_P(
MslGeneratorImplTest, MslGeneratorImplTest,
MslUnaryOpTest, MslUnaryOpTest,
testing::Values(UnaryOpData{"&", ast::UnaryOp::kAddressOf}, testing::Values(UnaryOpData{"&", ast::UnaryOp::kAddressOf},
UnaryOpData{"*", ast::UnaryOp::kDereference}, UnaryOpData{"*", ast::UnaryOp::kIndirection},
UnaryOpData{"!", ast::UnaryOp::kNot}, UnaryOpData{"!", ast::UnaryOp::kNot},
UnaryOpData{"-", ast::UnaryOp::kNegation})); UnaryOpData{"-", ast::UnaryOp::kNegation}));

View File

@ -709,12 +709,12 @@ bool GeneratorImpl::EmitBinary(ast::BinaryExpression* expr) {
bool GeneratorImpl::EmitUnaryOp(ast::UnaryOpExpression* expr) { bool GeneratorImpl::EmitUnaryOp(ast::UnaryOpExpression* expr) {
switch (expr->op()) { switch (expr->op()) {
case ast::UnaryOp::kDereference:
out_ << "*";
break;
case ast::UnaryOp::kAddressOf: case ast::UnaryOp::kAddressOf:
out_ << "&"; out_ << "&";
break; break;
case ast::UnaryOp::kIndirection:
out_ << "*";
break;
case ast::UnaryOp::kNot: case ast::UnaryOp::kNot:
out_ << "!"; out_ << "!";
break; break;

View File

@ -48,7 +48,7 @@ INSTANTIATE_TEST_SUITE_P(
WgslGeneratorImplTest, WgslGeneratorImplTest,
WgslUnaryOpTest, WgslUnaryOpTest,
testing::Values(UnaryOpData{"&", ast::UnaryOp::kAddressOf}, testing::Values(UnaryOpData{"&", ast::UnaryOp::kAddressOf},
UnaryOpData{"*", ast::UnaryOp::kDereference}, UnaryOpData{"*", ast::UnaryOp::kIndirection},
UnaryOpData{"!", ast::UnaryOp::kNot}, UnaryOpData{"!", ast::UnaryOp::kNot},
UnaryOpData{"-", ast::UnaryOp::kNegation})); UnaryOpData{"-", ast::UnaryOp::kNegation}));