mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 00:47:13 +00:00
Remove sem::Alias
With the parsers now using ast::Types, nothing should be producing these any more. This change also removes Resolver::Canonical(), which is now unneeded as there are no sem::Aliases to remove. Bug: tint:724 Change-Id: I0c1a49f49372c1fcc37864502f07c5c76328d471 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50304 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
cbbe576415
commit
a34fa0ecb7
@@ -166,7 +166,7 @@ TEST_F(ResolverAssignmentValidationTest,
|
||||
// alias myint = i32;
|
||||
// var a :myint = 2;
|
||||
// a = 2
|
||||
auto myint = ty.alias("myint", ty.i32());
|
||||
auto* myint = ty.alias("myint", ty.i32());
|
||||
AST().AddConstructedType(myint);
|
||||
auto* var = Var("a", myint, ast::StorageClass::kNone, Expr(2));
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ TEST_F(ResolverControlBlockValidationTest, SwitchCaseAlias_Pass) {
|
||||
// default: {}
|
||||
// }
|
||||
|
||||
auto my_int = ty.alias("MyInt", ty.u32());
|
||||
auto* my_int = ty.alias("MyInt", ty.u32());
|
||||
auto* var = Var("a", my_int, ast::StorageClass::kNone, Expr(2u));
|
||||
|
||||
ast::CaseSelectorList default_csl;
|
||||
|
||||
@@ -157,7 +157,7 @@ TEST_F(ResolverFunctionValidationTest,
|
||||
FunctionTypeMustMatchReturnStatementTypeF32Alias_pass) {
|
||||
// type myf32 = f32;
|
||||
// fn func -> myf32 { return 2.0; }
|
||||
auto myf32 = ty.alias("myf32", ty.f32());
|
||||
auto* myf32 = ty.alias("myf32", ty.f32());
|
||||
AST().AddConstructedType(myf32);
|
||||
Func("func", ast::VariableList{}, myf32,
|
||||
ast::StatementList{
|
||||
@@ -172,7 +172,7 @@ TEST_F(ResolverFunctionValidationTest,
|
||||
FunctionTypeMustMatchReturnStatementTypeF32Alias_fail) {
|
||||
// type myf32 = f32;
|
||||
// fn func -> myf32 { return 2; }
|
||||
auto myf32 = ty.alias("myf32", ty.f32());
|
||||
auto* myf32 = ty.alias("myf32", ty.f32());
|
||||
AST().AddConstructedType(myf32);
|
||||
Func("func", ast::VariableList{}, myf32,
|
||||
ast::StatementList{
|
||||
|
||||
@@ -57,12 +57,12 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverHostShareableValidationTest, Aliases) {
|
||||
auto a1 = ty.alias("a1", ty.bool_());
|
||||
auto* a1 = ty.alias("a1", ty.bool_());
|
||||
AST().AddConstructedType(a1);
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", a1)},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
auto ac = ty.access(ast::AccessControl::kReadOnly, s);
|
||||
auto a2 = ty.alias("a2", ac);
|
||||
auto* a2 = ty.alias("a2", ac);
|
||||
AST().AddConstructedType(a2);
|
||||
Global(Source{{56, 78}}, "g", a2, ast::StorageClass::kStorage);
|
||||
|
||||
@@ -104,14 +104,14 @@ TEST_F(ResolverHostShareableValidationTest, NoError) {
|
||||
Member(Source{{2, 1}}, "y1", ty.vec3<f32>()),
|
||||
Member(Source{{3, 1}}, "z1", ty.array<i32, 4>()),
|
||||
});
|
||||
auto a1 = ty.alias("a1", i1);
|
||||
auto* a1 = ty.alias("a1", i1);
|
||||
AST().AddConstructedType(a1);
|
||||
auto* i2 = Structure("I2", {
|
||||
Member(Source{{4, 1}}, "x2", ty.mat2x2<f32>()),
|
||||
Member(Source{{5, 1}}, "y2", i1),
|
||||
Member(Source{{6, 1}}, "z2", ty.mat3x2<i32>()),
|
||||
});
|
||||
auto a2 = ty.alias("a2", i2);
|
||||
auto* a2 = ty.alias("a2", i2);
|
||||
AST().AddConstructedType(a2);
|
||||
auto* i3 = Structure("I3", {
|
||||
Member(Source{{4, 1}}, "x3", a1),
|
||||
|
||||
@@ -79,14 +79,6 @@ TEST_F(ResolverIsHostShareable, Pointer) {
|
||||
r()->IsHostShareable(ty.pointer<i32>(ast::StorageClass::kPrivate)));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, AliasVoid) {
|
||||
EXPECT_FALSE(r()->IsHostShareable(ty.alias("a", ty.void_())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, AliasI32) {
|
||||
EXPECT_TRUE(r()->IsHostShareable(ty.alias("a", ty.i32())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsHostShareable, AccessControlVoid) {
|
||||
EXPECT_FALSE(r()->IsHostShareable(
|
||||
ty.access(ast::AccessControl::kReadOnly, ty.void_())));
|
||||
|
||||
@@ -63,14 +63,6 @@ TEST_F(ResolverIsStorableTest, Pointer) {
|
||||
EXPECT_FALSE(r()->IsStorable(ty.pointer<i32>(ast::StorageClass::kPrivate)));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsStorableTest, AliasVoid) {
|
||||
EXPECT_FALSE(r()->IsStorable(ty.alias("a", ty.void_())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsStorableTest, AliasI32) {
|
||||
EXPECT_TRUE(r()->IsStorable(ty.alias("a", ty.i32())));
|
||||
}
|
||||
|
||||
TEST_F(ResolverIsStorableTest, AccessControlVoid) {
|
||||
EXPECT_FALSE(r()->IsStorable(
|
||||
create<sem::AccessControl>(ast::AccessControl::kReadOnly, ty.void_())));
|
||||
|
||||
@@ -430,8 +430,8 @@ Resolver::VariableInfo* Resolver::Variable(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* ctype = Canonical(const_cast<sem::Type*>(type));
|
||||
auto* info = variable_infos_.Create(var, ctype, type_name);
|
||||
auto* info =
|
||||
variable_infos_.Create(var, const_cast<sem::Type*>(type), type_name);
|
||||
variable_to_info_.emplace(var, info);
|
||||
|
||||
return info;
|
||||
@@ -797,7 +797,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func,
|
||||
}
|
||||
|
||||
// Check that we saw a pipeline IO attribute iff we need one.
|
||||
if (Canonical(ty)->Is<sem::Struct>()) {
|
||||
if (ty->Is<sem::Struct>()) {
|
||||
if (pipeline_io_attribute) {
|
||||
diagnostics_.add_error(
|
||||
"entry point IO attributes must not be used on structure " +
|
||||
@@ -823,7 +823,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func,
|
||||
// of numeric scalars.
|
||||
// Testing for being a struct is handled by the if portion above.
|
||||
if (!pipeline_io_attribute->Is<ast::BuiltinDecoration>()) {
|
||||
if (!Canonical(ty)->is_numeric_scalar_or_vector()) {
|
||||
if (!ty->is_numeric_scalar_or_vector()) {
|
||||
diagnostics_.add_error(
|
||||
"User defined entry point IO types must be a numeric scalar, "
|
||||
"a numeric vector, or a structure",
|
||||
@@ -846,12 +846,11 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto* str = Canonical(ty)->As<sem::Struct>()) {
|
||||
if (auto* str = ty->As<sem::Struct>()) {
|
||||
// Validate the decorations for each struct members, and also check for
|
||||
// invalid member types.
|
||||
for (auto* member : str->Members()) {
|
||||
auto* member_ty = Canonical(member->Type());
|
||||
if (member_ty->Is<sem::Struct>()) {
|
||||
if (member->Type()->Is<sem::Struct>()) {
|
||||
diagnostics_.add_error(
|
||||
"entry point IO types cannot contain nested structures",
|
||||
member->Declaration()->source());
|
||||
@@ -859,7 +858,9 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func,
|
||||
builder_->Symbols().NameFor(func->symbol()),
|
||||
func->source());
|
||||
return false;
|
||||
} else if (auto* arr = member_ty->As<sem::Array>()) {
|
||||
}
|
||||
|
||||
if (auto* arr = member->Type()->As<sem::Array>()) {
|
||||
if (arr->IsRuntimeSized()) {
|
||||
diagnostics_.add_error(
|
||||
"entry point IO types cannot contain runtime sized arrays",
|
||||
@@ -873,7 +874,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func,
|
||||
}
|
||||
|
||||
if (!validate_entry_point_decorations_inner(
|
||||
member->Declaration()->decorations(), member_ty,
|
||||
member->Declaration()->decorations(), member->Type(),
|
||||
member->Declaration()->source(), param_or_ret, true)) {
|
||||
diagnostics_.add_note("while analysing entry point " +
|
||||
builder_->Symbols().NameFor(func->symbol()),
|
||||
@@ -992,8 +993,6 @@ bool Resolver::Function(ast::Function* func) {
|
||||
info->return_type->FriendlyName(builder_->Symbols());
|
||||
}
|
||||
|
||||
info->return_type = Canonical(info->return_type);
|
||||
|
||||
if (auto* str = info->return_type->As<sem::Struct>()) {
|
||||
if (!ApplyStorageClassUsageToType(ast::StorageClass::kNone, str,
|
||||
func->source())) {
|
||||
@@ -1746,11 +1745,8 @@ bool Resolver::ValidateBinary(ast::BinaryExpression* expr) {
|
||||
using Matrix = sem::Matrix;
|
||||
using Vector = sem::Vector;
|
||||
|
||||
auto* lhs_declared_type = TypeOf(expr->lhs())->UnwrapAll();
|
||||
auto* rhs_declared_type = TypeOf(expr->rhs())->UnwrapAll();
|
||||
|
||||
auto* lhs_type = Canonical(const_cast<sem::Type*>(lhs_declared_type));
|
||||
auto* rhs_type = Canonical(const_cast<sem::Type*>(rhs_declared_type));
|
||||
auto* lhs_type = const_cast<sem::Type*>(TypeOf(expr->lhs())->UnwrapAll());
|
||||
auto* rhs_type = const_cast<sem::Type*>(TypeOf(expr->rhs())->UnwrapAll());
|
||||
|
||||
auto* lhs_vec = lhs_type->As<Vector>();
|
||||
auto* lhs_vec_elem_type = lhs_vec ? lhs_vec->type() : nullptr;
|
||||
@@ -1895,9 +1891,9 @@ bool Resolver::ValidateBinary(ast::BinaryExpression* expr) {
|
||||
|
||||
diagnostics_.add_error(
|
||||
"Binary expression operand types are invalid for this operation: " +
|
||||
lhs_declared_type->FriendlyName(builder_->Symbols()) + " " +
|
||||
lhs_type->FriendlyName(builder_->Symbols()) + " " +
|
||||
FriendlyName(expr->op()) + " " +
|
||||
rhs_declared_type->FriendlyName(builder_->Symbols()),
|
||||
rhs_type->FriendlyName(builder_->Symbols()),
|
||||
expr->source());
|
||||
return false;
|
||||
}
|
||||
@@ -2142,7 +2138,6 @@ void Resolver::SetType(ast::Expression* expr,
|
||||
TINT_ICE(builder_->Diagnostics())
|
||||
<< "SetType() called twice for the same expression";
|
||||
}
|
||||
type = Canonical(type);
|
||||
expr_info_.emplace(expr, ExpressionInfo{type, type_name, current_statement_});
|
||||
}
|
||||
|
||||
@@ -2262,13 +2257,12 @@ bool Resolver::DefaultAlignAndSize(const sem::Type* ty,
|
||||
/*vec4*/ 16,
|
||||
};
|
||||
|
||||
auto* cty = Canonical(const_cast<sem::Type*>(ty));
|
||||
if (cty->is_scalar()) {
|
||||
if (ty->is_scalar()) {
|
||||
// Note: Also captures booleans, but these are not host-shareable.
|
||||
align = 4;
|
||||
size = 4;
|
||||
return true;
|
||||
} else if (auto* vec = cty->As<sem::Vector>()) {
|
||||
} else if (auto* vec = ty->As<sem::Vector>()) {
|
||||
if (vec->size() < 2 || vec->size() > 4) {
|
||||
TINT_UNREACHABLE(diagnostics_)
|
||||
<< "Invalid vector size: vec" << vec->size();
|
||||
@@ -2277,7 +2271,7 @@ bool Resolver::DefaultAlignAndSize(const sem::Type* ty,
|
||||
align = vector_align[vec->size()];
|
||||
size = vector_size[vec->size()];
|
||||
return true;
|
||||
} else if (auto* mat = cty->As<sem::Matrix>()) {
|
||||
} else if (auto* mat = ty->As<sem::Matrix>()) {
|
||||
if (mat->columns() < 2 || mat->columns() > 4 || mat->rows() < 2 ||
|
||||
mat->rows() > 4) {
|
||||
TINT_UNREACHABLE(diagnostics_)
|
||||
@@ -2287,11 +2281,11 @@ bool Resolver::DefaultAlignAndSize(const sem::Type* ty,
|
||||
align = vector_align[mat->rows()];
|
||||
size = vector_align[mat->rows()] * mat->columns();
|
||||
return true;
|
||||
} else if (auto* s = cty->As<sem::Struct>()) {
|
||||
} else if (auto* s = ty->As<sem::Struct>()) {
|
||||
align = s->Align();
|
||||
size = s->Size();
|
||||
return true;
|
||||
} else if (auto* a = cty->As<sem::Array>()) {
|
||||
} else if (auto* a = ty->As<sem::Array>()) {
|
||||
align = a->Align();
|
||||
size = a->SizeInBytes();
|
||||
return true;
|
||||
@@ -2818,45 +2812,6 @@ std::string Resolver::VectorPretty(uint32_t size,
|
||||
return vec_type.FriendlyName(builder_->Symbols());
|
||||
}
|
||||
|
||||
sem::Type* Resolver::Canonical(sem::Type* type) {
|
||||
using AccessControl = sem::AccessControl;
|
||||
using Alias = sem::Alias;
|
||||
using Matrix = sem::Matrix;
|
||||
using Type = sem::Type;
|
||||
using Vector = sem::Vector;
|
||||
|
||||
if (!type) {
|
||||
TINT_ICE(diagnostics_) << "Canonical() called with nullptr";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::function<Type*(Type*)> make_canonical;
|
||||
make_canonical = [&](Type* t) -> sem::Type* {
|
||||
// Unwrap alias sequence
|
||||
Type* ct = t;
|
||||
while (auto* p = ct->As<Alias>()) {
|
||||
ct = p->type();
|
||||
}
|
||||
|
||||
if (auto* v = ct->As<Vector>()) {
|
||||
return builder_->create<Vector>(make_canonical(v->type()), v->size());
|
||||
}
|
||||
if (auto* m = ct->As<Matrix>()) {
|
||||
auto* column_type =
|
||||
builder_->create<sem::Vector>(make_canonical(m->type()), m->rows());
|
||||
return builder_->create<Matrix>(column_type, m->columns());
|
||||
}
|
||||
if (auto* ac = ct->As<AccessControl>()) {
|
||||
return builder_->create<AccessControl>(ac->access_control(),
|
||||
make_canonical(ac->type()));
|
||||
}
|
||||
return ct;
|
||||
};
|
||||
|
||||
return utils::GetOrCreate(type_to_canonical_, type,
|
||||
[&] { return make_canonical(type); });
|
||||
}
|
||||
|
||||
void Resolver::Mark(const ast::Node* node) {
|
||||
if (node == nullptr) {
|
||||
TINT_ICE(diagnostics_) << "Resolver::Mark() called with nullptr";
|
||||
|
||||
@@ -83,12 +83,6 @@ class Resolver {
|
||||
/// structure member or array element of type `lhs`
|
||||
static bool IsValidAssignment(const sem::Type* lhs, const sem::Type* rhs);
|
||||
|
||||
/// @param type the input type
|
||||
/// @returns the canonical type for `type`; that is, a type with all aliases
|
||||
/// removed. For example, `Canonical(alias<alias<vec3<alias<f32>>>>)` is
|
||||
/// `vec3<f32>`.
|
||||
sem::Type* Canonical(sem::Type* type);
|
||||
|
||||
private:
|
||||
/// Structure holding semantic information about a variable.
|
||||
/// Used to build the sem::Variable nodes at the end of resolving.
|
||||
@@ -351,7 +345,6 @@ class Resolver {
|
||||
std::unordered_map<const ast::Variable*, VariableInfo*> variable_to_info_;
|
||||
std::unordered_map<ast::CallExpression*, FunctionCallInfo> function_calls_;
|
||||
std::unordered_map<const ast::Expression*, ExpressionInfo> expr_info_;
|
||||
std::unordered_map<sem::Type*, sem::Type*> type_to_canonical_;
|
||||
std::unordered_map<Symbol, sem::Type*> named_types_;
|
||||
std::unordered_set<const ast::Node*> marked_;
|
||||
FunctionInfo* current_function_ = nullptr;
|
||||
|
||||
@@ -260,7 +260,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
||||
auto my_int = ty.alias("MyInt", ty.i32());
|
||||
auto* my_int = ty.alias("MyInt", ty.i32());
|
||||
AST().AddConstructedType(my_int);
|
||||
auto* var = Var("my_var", my_int, ast::StorageClass::kNone, Expr(2));
|
||||
auto* init = var->constructor();
|
||||
@@ -408,7 +408,7 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Array) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Expr_ArrayAccessor_Alias_Array) {
|
||||
auto aary = ty.alias("myarrty", ty.array<f32, 3>());
|
||||
auto* aary = ty.alias("myarrty", ty.array<f32, 3>());
|
||||
AST().AddConstructedType(aary);
|
||||
|
||||
Global("my_var", aary, ast::StorageClass::kFunction);
|
||||
@@ -909,7 +909,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct) {
|
||||
TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) {
|
||||
auto* st = Structure("S", {Member("first_member", ty.i32()),
|
||||
Member("second_member", ty.f32())});
|
||||
auto alias = ty.alias("alias", st);
|
||||
auto* alias = ty.alias("alias", st);
|
||||
AST().AddConstructedType(alias);
|
||||
Global("my_struct", alias, ast::StorageClass::kInput);
|
||||
|
||||
@@ -1234,18 +1234,18 @@ TEST_P(Expr_Binary_Test_WithAlias_Valid, All) {
|
||||
// For vectors and matrices, wrap the sub type in an alias
|
||||
auto make_alias = [this](ast::Type* type) -> ast::Type* {
|
||||
if (auto* v = type->As<ast::Vector>()) {
|
||||
auto alias = ty.alias(Symbols().New(), v->type());
|
||||
auto* alias = ty.alias(Symbols().New(), v->type());
|
||||
AST().AddConstructedType(alias);
|
||||
return ty.vec(alias, v->size());
|
||||
}
|
||||
if (auto* m = type->As<ast::Matrix>()) {
|
||||
auto alias = ty.alias(Symbols().New(), m->type());
|
||||
auto* alias = ty.alias(Symbols().New(), m->type());
|
||||
AST().AddConstructedType(alias);
|
||||
return ty.mat(alias, m->columns(), m->rows());
|
||||
}
|
||||
auto alias = ty.alias(Symbols().New(), type);
|
||||
auto* alias = ty.alias(Symbols().New(), type);
|
||||
AST().AddConstructedType(alias);
|
||||
return ty.type_name(alias.ast->name());
|
||||
return ty.type_name(alias->name());
|
||||
};
|
||||
|
||||
// Wrap in alias
|
||||
|
||||
@@ -75,7 +75,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) {
|
||||
TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) {
|
||||
// type a = bool;
|
||||
// var<storage> g : [[access(read)]] a;
|
||||
auto a = ty.alias("a", ty.bool_());
|
||||
auto* a = ty.alias("a", ty.bool_());
|
||||
AST().AddConstructedType(a);
|
||||
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage);
|
||||
|
||||
@@ -131,10 +131,10 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) {
|
||||
// var<storage> g : a2;
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
auto a1 = ty.alias("a1", s);
|
||||
auto* a1 = ty.alias("a1", s);
|
||||
AST().AddConstructedType(a1);
|
||||
auto ac = ty.access(ast::AccessControl::kReadOnly, a1);
|
||||
auto a2 = ty.alias("a2", ac);
|
||||
auto* a2 = ty.alias("a2", ac);
|
||||
AST().AddConstructedType(a2);
|
||||
Global(Source{{56, 78}}, "g", a2, ast::StorageClass::kStorage);
|
||||
|
||||
@@ -183,7 +183,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) {
|
||||
TEST_F(ResolverStorageClassValidationTest, UniformBufferBoolAlias) {
|
||||
// type a = bool;
|
||||
// var<uniform> g : [[access(read)]] a;
|
||||
auto a = ty.alias("a", ty.bool_());
|
||||
auto* a = ty.alias("a", ty.bool_());
|
||||
AST().AddConstructedType(a);
|
||||
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform);
|
||||
|
||||
@@ -224,7 +224,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Aliases) {
|
||||
// var<uniform> g : a1;
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
auto a1 = ty.alias("a1", s);
|
||||
auto* a1 = ty.alias("a1", s);
|
||||
AST().AddConstructedType(a1);
|
||||
Global(Source{{56, 78}}, "g", a1, ast::StorageClass::kUniform);
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ TEST_F(ResolverStructLayoutTest, Scalars) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverStructLayoutTest, Alias) {
|
||||
auto alias_a = ty.alias("a", ty.f32());
|
||||
auto* alias_a = ty.alias("a", ty.f32());
|
||||
AST().AddConstructedType(alias_a);
|
||||
auto alias_b = ty.alias("b", ty.f32());
|
||||
auto* alias_b = ty.alias("b", ty.f32());
|
||||
AST().AddConstructedType(alias_b);
|
||||
|
||||
auto* s = Structure("S", {
|
||||
|
||||
@@ -158,7 +158,7 @@ TEST_F(ResolverPipelineStageUseTest, StructUsedMultipleStages) {
|
||||
|
||||
TEST_F(ResolverPipelineStageUseTest, StructUsedAsShaderParamViaAlias) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
||||
auto s_alias = ty.alias("S_alias", s);
|
||||
auto* s_alias = ty.alias("S_alias", s);
|
||||
AST().AddConstructedType(s_alias);
|
||||
|
||||
Func("main", {Param("param", s_alias)}, ty.void_(), {},
|
||||
@@ -174,7 +174,7 @@ TEST_F(ResolverPipelineStageUseTest, StructUsedAsShaderParamViaAlias) {
|
||||
|
||||
TEST_F(ResolverPipelineStageUseTest, StructUsedAsShaderReturnTypeViaAlias) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
||||
auto s_alias = ty.alias("S_alias", s);
|
||||
auto* s_alias = ty.alias("S_alias", s);
|
||||
AST().AddConstructedType(s_alias);
|
||||
|
||||
Func("main", {}, s_alias, {Return(Construct(s_alias, Expr(0.f)))},
|
||||
|
||||
@@ -78,7 +78,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableFromGlobal) {
|
||||
|
||||
TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalAlias) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||
auto a = ty.alias("A", s);
|
||||
auto* a = ty.alias("A", s);
|
||||
AST().AddConstructedType(a);
|
||||
Global("g", a, ast::StorageClass::kPrivate);
|
||||
|
||||
@@ -131,7 +131,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableFromLocal) {
|
||||
|
||||
TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalAlias) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||
auto a = ty.alias("A", s);
|
||||
auto* a = ty.alias("A", s);
|
||||
AST().AddConstructedType(a);
|
||||
WrapInFunction(Var("g", a, ast::StorageClass::kFunction));
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsNotLast_Fail) {
|
||||
// a: u32;
|
||||
//}
|
||||
|
||||
auto alias = ty.alias("RTArr", ty.array<u32>());
|
||||
auto* alias = ty.alias("RTArr", ty.array<u32>());
|
||||
AST().AddConstructedType(alias);
|
||||
|
||||
Structure("s",
|
||||
@@ -458,7 +458,7 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) {
|
||||
// b: RTArr;
|
||||
//}
|
||||
|
||||
auto alias = ty.alias("RTArr", ty.array<u32>());
|
||||
auto* alias = ty.alias("RTArr", ty.array<u32>());
|
||||
AST().AddConstructedType(alias);
|
||||
|
||||
Structure("s",
|
||||
|
||||
@@ -178,7 +178,7 @@ TEST_F(ResolverValidationTest,
|
||||
|
||||
TEST_F(ResolverValidationTest,
|
||||
Stmt_VariableDecl_MismatchedTypeScalarConstructor_Alias) {
|
||||
auto my_int = ty.alias("MyInt", ty.i32());
|
||||
auto* my_int = ty.alias("MyInt", ty.i32());
|
||||
AST().AddConstructedType(my_int);
|
||||
u32 unsigned_value = 2u; // Type does not match variable type
|
||||
auto* var =
|
||||
@@ -1699,7 +1699,7 @@ TEST_F(ResolverValidationTest,
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Error) {
|
||||
auto alias = ty.alias("UnsignedInt", ty.u32());
|
||||
auto* alias = ty.alias("UnsignedInt", ty.u32());
|
||||
AST().AddConstructedType(alias);
|
||||
Global("uint_var", alias, ast::StorageClass::kInput);
|
||||
|
||||
@@ -1713,8 +1713,8 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Error) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Success) {
|
||||
auto f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto vec2_alias = ty.alias("VectorFloat2", ty.vec2<f32>());
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* vec2_alias = ty.alias("VectorFloat2", ty.vec2<f32>());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
AST().AddConstructedType(vec2_alias);
|
||||
Global("my_f32", f32_alias, ast::StorageClass::kInput);
|
||||
@@ -1726,7 +1726,7 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Success) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Error) {
|
||||
auto f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
// vec2<Float32>(1.0f, 1u)
|
||||
@@ -1745,7 +1745,7 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Error) {
|
||||
|
||||
TEST_F(ResolverValidationTest,
|
||||
Expr_Constructor_Vector_ElementTypeAlias_Success) {
|
||||
auto f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
// vec2<Float32>(1.0f, 1.0f)
|
||||
@@ -1759,7 +1759,7 @@ TEST_F(ResolverValidationTest,
|
||||
|
||||
TEST_F(ResolverValidationTest,
|
||||
Expr_Constructor_Vector_ArgumentElementTypeAlias_Error) {
|
||||
auto f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
// vec3<u32>(vec<Float32>(), 1.0f)
|
||||
@@ -1777,7 +1777,7 @@ TEST_F(ResolverValidationTest,
|
||||
|
||||
TEST_F(ResolverValidationTest,
|
||||
Expr_Constructor_Vector_ArgumentElementTypeAlias_Success) {
|
||||
auto f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
// vec3<f32>(vec<Float32>(), 1.0f)
|
||||
@@ -2008,7 +2008,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Error) {
|
||||
// matNxM<Float32>(vecM<u32>(), ...); with N arguments
|
||||
|
||||
const auto param = GetParam();
|
||||
auto f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
ast::ExpressionList args;
|
||||
@@ -2034,7 +2034,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Success) {
|
||||
// matNxM<Float32>(vecM<f32>(), ...); with N arguments
|
||||
|
||||
const auto param = GetParam();
|
||||
auto f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
ast::ExpressionList args;
|
||||
@@ -2053,7 +2053,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Success) {
|
||||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Expr_MatrixConstructor_ArgumentTypeAlias_Error) {
|
||||
auto alias = ty.alias("VectorUnsigned2", ty.vec2<u32>());
|
||||
auto* alias = ty.alias("VectorUnsigned2", ty.vec2<u32>());
|
||||
AST().AddConstructedType(alias);
|
||||
auto* tc = mat2x2<f32>(
|
||||
create<ast::TypeConstructorExpression>(
|
||||
@@ -2071,7 +2071,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) {
|
||||
const auto param = GetParam();
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto vec_type = ty.vec<f32>(param.rows);
|
||||
auto vec_alias = ty.alias("VectorFloat2", vec_type);
|
||||
auto* vec_alias = ty.alias("VectorFloat2", vec_type);
|
||||
AST().AddConstructedType(vec_alias);
|
||||
|
||||
ast::ExpressionList args;
|
||||
@@ -2090,7 +2090,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) {
|
||||
TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentElementTypeAlias_Error) {
|
||||
const auto param = GetParam();
|
||||
auto matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto f32_alias = ty.alias("UnsignedInt", ty.u32());
|
||||
auto* f32_alias = ty.alias("UnsignedInt", ty.u32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
ast::ExpressionList args;
|
||||
@@ -2114,7 +2114,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentElementTypeAlias_Error) {
|
||||
TEST_P(MatrixConstructorTest,
|
||||
Expr_Constructor_ArgumentElementTypeAlias_Success) {
|
||||
const auto param = GetParam();
|
||||
auto f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
|
||||
ast::ExpressionList args;
|
||||
|
||||
Reference in New Issue
Block a user