mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
ast: Add 'Expression' suffix to literals (2/2)
Literals are now expressions, so in keeping with all the other
expression types, suffix the class name with Expression.
I'm not overly keen on requiring everything to have an Expression
suffix, but consistency is better than personal preference.
Note: this should have been part of 30848b6, but I managed to drop
this change instead of squashing it. Opps.
Bug: tint:888
Change-Id: Idfaf96abe165a6bf5028e60a160e7408aa2bf9db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68943
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
@@ -330,9 +330,9 @@ struct DecomposeMemoryAccess::State {
|
||||
/// @param expr the expression to convert to an Offset
|
||||
/// @returns an Offset for the given ast::Expression
|
||||
const Offset* ToOffset(const ast::Expression* expr) {
|
||||
if (auto* u32 = expr->As<ast::UintLiteral>()) {
|
||||
if (auto* u32 = expr->As<ast::UintLiteralExpression>()) {
|
||||
return offsets_.Create<OffsetLiteral>(u32->value);
|
||||
} else if (auto* i32 = expr->As<ast::SintLiteral>()) {
|
||||
} else if (auto* i32 = expr->As<ast::SintLiteralExpression>()) {
|
||||
if (i32->value > 0) {
|
||||
return offsets_.Create<OffsetLiteral>(i32->value);
|
||||
}
|
||||
|
||||
@@ -81,8 +81,10 @@ void FoldConstants::Run(CloneContext& ctx, const DataMap&, DataMap&) {
|
||||
}
|
||||
|
||||
if (ty->is_scalar()) {
|
||||
return value.WithScalarAt(
|
||||
0, [&](auto&& s) -> const ast::Literal* { return ctx.dst->Expr(s); });
|
||||
return value.WithScalarAt(0,
|
||||
[&](auto&& s) -> const ast::LiteralExpression* {
|
||||
return ctx.dst->Expr(s);
|
||||
});
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -37,7 +37,7 @@ const ast::VariableDeclStatement* AsTrivialLetDecl(const ast::Statement* stmt) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* ctor = var->constructor;
|
||||
if (!IsAnyOf<ast::IdentifierExpression, ast::Literal>(ctor)) {
|
||||
if (!IsAnyOf<ast::IdentifierExpression, ast::LiteralExpression>(ctor)) {
|
||||
return nullptr;
|
||||
}
|
||||
return var_decl;
|
||||
|
||||
@@ -46,7 +46,7 @@ void CollectSavedArrayIndices(const Program* program,
|
||||
if (auto* a = expr->As<ast::IndexAccessorExpression>()) {
|
||||
CollectSavedArrayIndices(program, a->object, cb);
|
||||
|
||||
if (!a->index->Is<ast::Literal>()) {
|
||||
if (!a->index->Is<ast::LiteralExpression>()) {
|
||||
cb(a->index);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -84,7 +84,7 @@ TEST_F(CreateASTTypeForTest, ArrayImplicitStride) {
|
||||
ASSERT_TRUE(arr->As<ast::Array>()->type->Is<ast::F32>());
|
||||
ASSERT_EQ(arr->As<ast::Array>()->decorations.size(), 0u);
|
||||
|
||||
auto* size = arr->As<ast::Array>()->count->As<ast::IntLiteral>();
|
||||
auto* size = arr->As<ast::Array>()->count->As<ast::IntLiteralExpression>();
|
||||
ASSERT_NE(size, nullptr);
|
||||
EXPECT_EQ(size->ValueAsI32(), 2);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ TEST_F(CreateASTTypeForTest, ArrayNonImplicitStride) {
|
||||
->stride,
|
||||
64u);
|
||||
|
||||
auto* size = arr->As<ast::Array>()->count->As<ast::IntLiteral>();
|
||||
auto* size = arr->As<ast::Array>()->count->As<ast::IntLiteralExpression>();
|
||||
ASSERT_NE(size, nullptr);
|
||||
EXPECT_EQ(size->ValueAsI32(), 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user