ast/type: Remove Type suffix from all types
They already exist in a `ast::type` namespace, so `ast::type::BlahType` is just stuttering.
This is more important now that Is<> and As<> use the full type name.
Change-Id: I7c661fe58cdc33ba7e9a95c82c996a799786661f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34321
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/ast/access_control.cc b/src/ast/access_control.cc
index ce0d619..9a70a64 100644
--- a/src/ast/access_control.cc
+++ b/src/ast/access_control.cc
@@ -19,15 +19,15 @@
std::ostream& operator<<(std::ostream& out, AccessControl access) {
switch (access) {
- case AccessControl::kReadOnly: {
+ case ast::AccessControl::kReadOnly: {
out << "read_only";
break;
}
- case AccessControl::kReadWrite: {
+ case ast::AccessControl::kReadWrite: {
out << "read_write";
break;
}
- case AccessControl::kWriteOnly: {
+ case ast::AccessControl::kWriteOnly: {
out << "write_only";
break;
}
diff --git a/src/ast/access_decoration.h b/src/ast/access_decoration.h
index 37a400e..8e45062 100644
--- a/src/ast/access_decoration.h
+++ b/src/ast/access_decoration.h
@@ -41,7 +41,7 @@
void to_str(std::ostream& out, size_t indent) const override;
private:
- AccessControl value_ = AccessControl::kReadWrite;
+ AccessControl value_ = ast::AccessControl::kReadWrite;
};
} // namespace ast
diff --git a/src/ast/access_decoration_test.cc b/src/ast/access_decoration_test.cc
index 4a15fa4..36c030d 100644
--- a/src/ast/access_decoration_test.cc
+++ b/src/ast/access_decoration_test.cc
@@ -25,17 +25,17 @@
using AccessDecorationTest = TestHelper;
TEST_F(AccessDecorationTest, Creation) {
- AccessDecoration d{AccessControl::kWriteOnly, Source{}};
- EXPECT_EQ(AccessControl::kWriteOnly, d.value());
+ AccessDecoration d{ast::AccessControl::kWriteOnly, Source{}};
+ EXPECT_EQ(ast::AccessControl::kWriteOnly, d.value());
}
TEST_F(AccessDecorationTest, Is) {
- AccessDecoration d{AccessControl::kReadWrite, Source{}};
+ AccessDecoration d{ast::AccessControl::kReadWrite, Source{}};
EXPECT_FALSE(d.IsAccess());
}
TEST_F(AccessDecorationTest, ToStr) {
- AccessDecoration d{AccessControl::kReadOnly, Source{}};
+ AccessDecoration d{ast::AccessControl::kReadOnly, Source{}};
std::ostringstream out;
d.to_str(out, 0);
EXPECT_EQ(out.str(), R"(AccessDecoration{read}
diff --git a/src/ast/bitcast_expression_test.cc b/src/ast/bitcast_expression_test.cc
index a07eee7..51d48c9 100644
--- a/src/ast/bitcast_expression_test.cc
+++ b/src/ast/bitcast_expression_test.cc
@@ -25,7 +25,7 @@
using BitcastExpressionTest = TestHelper;
TEST_F(BitcastExpressionTest, Create) {
- type::F32Type f32;
+ type::F32 f32;
auto* expr = create<IdentifierExpression>("expr");
BitcastExpression exp(&f32, expr);
@@ -34,7 +34,7 @@
}
TEST_F(BitcastExpressionTest, CreateWithSource) {
- type::F32Type f32;
+ type::F32 f32;
auto* expr = create<IdentifierExpression>("expr");
BitcastExpression exp(Source{Source::Location{20, 2}}, &f32, expr);
@@ -49,7 +49,7 @@
}
TEST_F(BitcastExpressionTest, IsValid) {
- type::F32Type f32;
+ type::F32 f32;
auto* expr = create<IdentifierExpression>("expr");
BitcastExpression exp(&f32, expr);
@@ -65,7 +65,7 @@
}
TEST_F(BitcastExpressionTest, IsValid_MissingExpr) {
- type::F32Type f32;
+ type::F32 f32;
BitcastExpression exp;
exp.set_type(&f32);
@@ -73,14 +73,14 @@
}
TEST_F(BitcastExpressionTest, IsValid_InvalidExpr) {
- type::F32Type f32;
+ type::F32 f32;
auto* expr = create<IdentifierExpression>("");
BitcastExpression e(&f32, expr);
EXPECT_FALSE(e.IsValid());
}
TEST_F(BitcastExpressionTest, ToStr) {
- type::F32Type f32;
+ type::F32 f32;
auto* expr = create<IdentifierExpression>("expr");
BitcastExpression exp(&f32, expr);
diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc
index ca2ff78..186d71e 100644
--- a/src/ast/bool_literal_test.cc
+++ b/src/ast/bool_literal_test.cc
@@ -28,7 +28,7 @@
using BoolLiteralTest = TestHelper;
TEST_F(BoolLiteralTest, True) {
- type::BoolType bool_type;
+ type::Bool bool_type;
BoolLiteral b{&bool_type, true};
ASSERT_TRUE(b.Is<BoolLiteral>());
ASSERT_TRUE(b.IsTrue());
@@ -36,7 +36,7 @@
}
TEST_F(BoolLiteralTest, False) {
- type::BoolType bool_type;
+ type::Bool bool_type;
BoolLiteral b{&bool_type, false};
ASSERT_TRUE(b.Is<BoolLiteral>());
ASSERT_FALSE(b.IsTrue());
@@ -44,7 +44,7 @@
}
TEST_F(BoolLiteralTest, Is) {
- type::BoolType bool_type;
+ type::Bool bool_type;
BoolLiteral b{&bool_type, false};
Literal* l = &b;
EXPECT_TRUE(l->Is<BoolLiteral>());
@@ -56,7 +56,7 @@
}
TEST_F(BoolLiteralTest, ToStr) {
- type::BoolType bool_type;
+ type::Bool bool_type;
BoolLiteral t{&bool_type, true};
BoolLiteral f{&bool_type, false};
diff --git a/src/ast/builder.cc b/src/ast/builder.cc
index eca0c04..cdc6835 100644
--- a/src/ast/builder.cc
+++ b/src/ast/builder.cc
@@ -18,11 +18,11 @@
namespace ast {
TypesBuilder::TypesBuilder(Module* mod)
- : bool_(mod->create<type::BoolType>()),
- f32(mod->create<type::F32Type>()),
- i32(mod->create<type::I32Type>()),
- u32(mod->create<type::U32Type>()),
- void_(mod->create<type::VoidType>()),
+ : bool_(mod->create<type::Bool>()),
+ f32(mod->create<type::F32>()),
+ i32(mod->create<type::I32>()),
+ u32(mod->create<type::U32>()),
+ void_(mod->create<type::Void>()),
mod_(mod) {}
Builder::Builder(Context* c, Module* m) : ctx(c), mod(m), ty(m) {}
diff --git a/src/ast/builder.h b/src/ast/builder.h
index 7ea6078..7551f92 100644
--- a/src/ast/builder.h
+++ b/src/ast/builder.h
@@ -52,15 +52,15 @@
explicit TypesBuilder(Module* mod);
/// A boolean type
- type::BoolType* const bool_;
+ type::Bool* const bool_;
/// A f32 type
- type::F32Type* const f32;
+ type::F32* const f32;
/// A i32 type
- type::I32Type* const i32;
+ type::I32* const i32;
/// A u32 type
- type::U32Type* const u32;
+ type::U32* const u32;
/// A void type
- type::VoidType* const void_;
+ type::Void* const void_;
/// @return the tint AST type for the C type `T`.
template <typename T>
@@ -70,86 +70,86 @@
/// @return the tint AST type for a 2-element vector of the C type `T`.
template <typename T>
- type::VectorType* vec2() const {
- return mod_->create<type::VectorType>(Of<T>(), 2);
+ type::Vector* vec2() const {
+ return mod_->create<type::Vector>(Of<T>(), 2);
}
/// @return the tint AST type for a 3-element vector of the C type `T`.
template <typename T>
- type::VectorType* vec3() const {
- return mod_->create<type::VectorType>(Of<T>(), 3);
+ type::Vector* vec3() const {
+ return mod_->create<type::Vector>(Of<T>(), 3);
}
/// @return the tint AST type for a 4-element vector of the C type `T`.
template <typename T>
type::Type* vec4() const {
- return mod_->create<type::VectorType>(Of<T>(), 4);
+ return mod_->create<type::Vector>(Of<T>(), 4);
}
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat2x2() const {
- return mod_->create<type::MatrixType>(Of<T>(), 2, 2);
+ type::Matrix* mat2x2() const {
+ return mod_->create<type::Matrix>(Of<T>(), 2, 2);
}
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat2x3() const {
- return mod_->create<type::MatrixType>(Of<T>(), 3, 2);
+ type::Matrix* mat2x3() const {
+ return mod_->create<type::Matrix>(Of<T>(), 3, 2);
}
/// @return the tint AST type for a 2x4 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat2x4() const {
- return mod_->create<type::MatrixType>(Of<T>(), 4, 2);
+ type::Matrix* mat2x4() const {
+ return mod_->create<type::Matrix>(Of<T>(), 4, 2);
}
/// @return the tint AST type for a 3x2 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat3x2() const {
- return mod_->create<type::MatrixType>(Of<T>(), 2, 3);
+ type::Matrix* mat3x2() const {
+ return mod_->create<type::Matrix>(Of<T>(), 2, 3);
}
/// @return the tint AST type for a 3x3 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat3x3() const {
- return mod_->create<type::MatrixType>(Of<T>(), 3, 3);
+ type::Matrix* mat3x3() const {
+ return mod_->create<type::Matrix>(Of<T>(), 3, 3);
}
/// @return the tint AST type for a 3x4 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat3x4() const {
- return mod_->create<type::MatrixType>(Of<T>(), 4, 3);
+ type::Matrix* mat3x4() const {
+ return mod_->create<type::Matrix>(Of<T>(), 4, 3);
}
/// @return the tint AST type for a 4x2 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat4x2() const {
- return mod_->create<type::MatrixType>(Of<T>(), 2, 4);
+ type::Matrix* mat4x2() const {
+ return mod_->create<type::Matrix>(Of<T>(), 2, 4);
}
/// @return the tint AST type for a 4x3 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat4x3() const {
- return mod_->create<type::MatrixType>(Of<T>(), 3, 4);
+ type::Matrix* mat4x3() const {
+ return mod_->create<type::Matrix>(Of<T>(), 3, 4);
}
/// @return the tint AST type for a 4x4 matrix of the C type `T`.
template <typename T>
- type::MatrixType* mat4x4() const {
- return mod_->create<type::MatrixType>(Of<T>(), 4, 4);
+ type::Matrix* mat4x4() const {
+ return mod_->create<type::Matrix>(Of<T>(), 4, 4);
}
/// @param subtype the array element type
/// @param n the array size. 0 represents unbounded
/// @return the tint AST type for a array of size `n` of type `T`
- type::ArrayType* array(type::Type* subtype, uint32_t n) const {
- return mod_->create<type::ArrayType>(subtype, n);
+ type::Array* array(type::Type* subtype, uint32_t n) const {
+ return mod_->create<type::Array>(subtype, n);
}
/// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0>
- type::ArrayType* array() const {
+ type::Array* array() const {
return array(Of<T>(), N);
}
diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc
index 8b6e6d9..5600173 100644
--- a/src/ast/case_statement_test.cc
+++ b/src/ast/case_statement_test.cc
@@ -29,7 +29,7 @@
using CaseStatementTest = TestHelper;
TEST_F(CaseStatementTest, Creation_i32) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList b;
auto* selector = create<SintLiteral>(&i32, 2);
@@ -47,7 +47,7 @@
}
TEST_F(CaseStatementTest, Creation_u32) {
- type::U32Type u32;
+ type::U32 u32;
CaseSelectorList b;
auto* selector = create<SintLiteral>(&u32, 2);
@@ -65,7 +65,7 @@
}
TEST_F(CaseStatementTest, Creation_WithSource) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList b;
b.push_back(create<SintLiteral>(&i32, 2));
@@ -88,7 +88,7 @@
}
TEST_F(CaseStatementTest, IsDefault_WithSelectors) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList b;
b.push_back(create<SintLiteral>(&i32, 2));
@@ -108,7 +108,7 @@
}
TEST_F(CaseStatementTest, IsValid_NullBodyStatement) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList b;
b.push_back(create<SintLiteral>(&i32, 2));
@@ -121,7 +121,7 @@
}
TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList b;
b.push_back(create<SintLiteral>(&i32, 2));
@@ -133,7 +133,7 @@
}
TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList b;
b.push_back(create<SintLiteral>(&i32, -2));
@@ -150,7 +150,7 @@
}
TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) {
- type::U32Type u32;
+ type::U32 u32;
CaseSelectorList b;
b.push_back(create<UintLiteral>(&u32, 2));
@@ -167,7 +167,7 @@
}
TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList b;
b.push_back(create<SintLiteral>(&i32, 1));
diff --git a/src/ast/decorated_variable_test.cc b/src/ast/decorated_variable_test.cc
index e9c2a52..63a4340 100644
--- a/src/ast/decorated_variable_test.cc
+++ b/src/ast/decorated_variable_test.cc
@@ -33,7 +33,7 @@
using DecoratedVariableTest = TestHelper;
TEST_F(DecoratedVariableTest, Creation) {
- type::I32Type t;
+ type::I32 t;
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
DecoratedVariable dv(var);
@@ -48,7 +48,7 @@
TEST_F(DecoratedVariableTest, CreationWithSource) {
Source s{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}};
- type::F32Type t;
+ type::F32 t;
auto* var = create<Variable>(s, "i", StorageClass::kPrivate, &t);
DecoratedVariable dv(var);
@@ -62,7 +62,7 @@
}
TEST_F(DecoratedVariableTest, NoDecorations) {
- type::I32Type t;
+ type::I32 t;
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
DecoratedVariable dv(var);
EXPECT_FALSE(dv.HasLocationDecoration());
@@ -71,7 +71,7 @@
}
TEST_F(DecoratedVariableTest, WithDecorations) {
- type::F32Type t;
+ type::F32 t;
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
DecoratedVariable dv(var);
@@ -88,7 +88,7 @@
}
TEST_F(DecoratedVariableTest, ConstantId) {
- type::F32Type t;
+ type::F32 t;
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
DecoratedVariable dv(var);
@@ -100,7 +100,7 @@
}
TEST_F(DecoratedVariableTest, IsValid) {
- type::I32Type t;
+ type::I32 t;
auto* var = create<Variable>("my_var", StorageClass::kNone, &t);
DecoratedVariable dv(var);
EXPECT_TRUE(dv.IsValid());
@@ -112,7 +112,7 @@
}
TEST_F(DecoratedVariableTest, to_str) {
- type::F32Type t;
+ type::F32 t;
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
DecoratedVariable dv(var);
dv.set_constructor(create<IdentifierExpression>("expr"));
diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc
index 2e60b39..40ac0e0 100644
--- a/src/ast/else_statement_test.cc
+++ b/src/ast/else_statement_test.cc
@@ -28,7 +28,7 @@
using ElseStatementTest = TestHelper;
TEST_F(ElseStatementTest, Creation) {
- type::BoolType bool_type;
+ type::Bool bool_type;
auto* cond = create<ScalarConstructorExpression>(
create<BoolLiteral>(&bool_type, true));
auto* body = create<BlockStatement>();
@@ -55,7 +55,7 @@
}
TEST_F(ElseStatementTest, HasCondition) {
- type::BoolType bool_type;
+ type::Bool bool_type;
auto* cond = create<ScalarConstructorExpression>(
create<BoolLiteral>(&bool_type, true));
ElseStatement e(cond, create<BlockStatement>());
@@ -104,7 +104,7 @@
}
TEST_F(ElseStatementTest, ToStr) {
- type::BoolType bool_type;
+ type::Bool bool_type;
auto* cond = create<ScalarConstructorExpression>(
create<BoolLiteral>(&bool_type, true));
auto* body = create<BlockStatement>();
diff --git a/src/ast/expression_test.cc b/src/ast/expression_test.cc
index c6337a4..62538e8 100644
--- a/src/ast/expression_test.cc
+++ b/src/ast/expression_test.cc
@@ -33,23 +33,23 @@
using ExpressionTest = TestHelper;
TEST_F(ExpressionTest, set_result_type) {
- type::I32Type i32;
+ type::I32 i32;
Expr e;
e.set_result_type(&i32);
ASSERT_NE(e.result_type(), nullptr);
- EXPECT_TRUE(e.result_type()->Is<type::I32Type>());
+ EXPECT_TRUE(e.result_type()->Is<type::I32>());
}
TEST_F(ExpressionTest, set_result_type_alias) {
- type::I32Type i32;
- type::AliasType a("a", &i32);
- type::AliasType b("b", &a);
+ type::I32 i32;
+ type::Alias a("a", &i32);
+ type::Alias b("b", &a);
Expr e;
e.set_result_type(&b);
ASSERT_NE(e.result_type(), nullptr);
- EXPECT_TRUE(e.result_type()->Is<type::I32Type>());
+ EXPECT_TRUE(e.result_type()->Is<type::I32>());
}
} // namespace
diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc
index ffc9361..77b03f6 100644
--- a/src/ast/float_literal_test.cc
+++ b/src/ast/float_literal_test.cc
@@ -28,14 +28,14 @@
using FloatLiteralTest = TestHelper;
TEST_F(FloatLiteralTest, Value) {
- type::F32Type f32;
+ type::F32 f32;
FloatLiteral f{&f32, 47.2f};
ASSERT_TRUE(f.Is<FloatLiteral>());
EXPECT_EQ(f.value(), 47.2f);
}
TEST_F(FloatLiteralTest, Is) {
- type::F32Type f32;
+ type::F32 f32;
FloatLiteral f{&f32, 42.f};
Literal* l = &f;
EXPECT_FALSE(l->Is<BoolLiteral>());
@@ -47,14 +47,14 @@
}
TEST_F(FloatLiteralTest, ToStr) {
- type::F32Type f32;
+ type::F32 f32;
FloatLiteral f{&f32, 42.1f};
EXPECT_EQ(f.to_str(), "42.099998");
}
TEST_F(FloatLiteralTest, ToName) {
- type::F32Type f32;
+ type::F32 f32;
FloatLiteral f{&f32, 42.1f};
EXPECT_EQ(f.name(), "__float42.0999985");
}
diff --git a/src/ast/function.cc b/src/ast/function.cc
index b251a7d..6c9f5d4 100644
--- a/src/ast/function.cc
+++ b/src/ast/function.cc
@@ -282,9 +282,8 @@
for (auto* var : referenced_module_variables()) {
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
- if (!var->Is<DecoratedVariable>() ||
- !unwrapped_type->Is<type::SamplerType>() ||
- unwrapped_type->As<type::SamplerType>()->kind() != kind) {
+ if (!var->Is<DecoratedVariable>() || !unwrapped_type->Is<type::Sampler>() ||
+ unwrapped_type->As<type::Sampler>()->kind() != kind) {
continue;
}
@@ -312,14 +311,12 @@
for (auto* var : referenced_module_variables()) {
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
- if (!var->Is<DecoratedVariable>() ||
- !unwrapped_type->Is<type::TextureType>()) {
+ if (!var->Is<DecoratedVariable>() || !unwrapped_type->Is<type::Texture>()) {
continue;
}
- if ((multisampled &&
- !unwrapped_type->Is<type::MultisampledTextureType>()) ||
- (!multisampled && !unwrapped_type->Is<type::SampledTextureType>())) {
+ if ((multisampled && !unwrapped_type->Is<type::MultisampledTexture>()) ||
+ (!multisampled && !unwrapped_type->Is<type::SampledTexture>())) {
continue;
}
diff --git a/src/ast/function_test.cc b/src/ast/function_test.cc
index d94f928..c307284 100644
--- a/src/ast/function_test.cc
+++ b/src/ast/function_test.cc
@@ -33,8 +33,8 @@
using FunctionTest = TestHelper;
TEST_F(FunctionTest, Creation) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -48,8 +48,8 @@
}
TEST_F(FunctionTest, Creation_WithSource) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -62,8 +62,8 @@
}
TEST_F(FunctionTest, AddDuplicateReferencedVariables) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
Variable v("var", StorageClass::kInput, &i32);
Function f("func", VariableList{}, &void_type, create<BlockStatement>());
@@ -82,8 +82,8 @@
}
TEST_F(FunctionTest, GetReferenceLocations) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
DecoratedVariable loc1(create<Variable>("loc1", StorageClass::kInput, &i32));
loc1.set_decorations({create<LocationDecoration>(0, Source{})});
@@ -118,8 +118,8 @@
}
TEST_F(FunctionTest, GetReferenceBuiltins) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
DecoratedVariable loc1(create<Variable>("loc1", StorageClass::kInput, &i32));
loc1.set_decorations({create<LocationDecoration>(0, Source{})});
@@ -154,7 +154,7 @@
}
TEST_F(FunctionTest, AddDuplicateEntryPoints) {
- type::VoidType void_type;
+ type::Void void_type;
Function f("func", VariableList{}, &void_type, create<BlockStatement>());
f.add_ancestor_entry_point("main");
@@ -167,8 +167,8 @@
}
TEST_F(FunctionTest, IsValid) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -182,8 +182,8 @@
}
TEST_F(FunctionTest, IsValid_EmptyName) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -193,7 +193,7 @@
}
TEST_F(FunctionTest, IsValid_MissingReturnType) {
- type::I32Type i32;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -203,8 +203,8 @@
}
TEST_F(FunctionTest, IsValid_NullParam) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -215,7 +215,7 @@
}
TEST_F(FunctionTest, IsValid_InvalidParam) {
- type::VoidType void_type;
+ type::Void void_type;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, nullptr));
@@ -225,8 +225,8 @@
}
TEST_F(FunctionTest, IsValid_NullBodyStatement) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -241,8 +241,8 @@
}
TEST_F(FunctionTest, IsValid_InvalidBodyStatement) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -257,8 +257,8 @@
}
TEST_F(FunctionTest, ToStr) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
auto* block = create<BlockStatement>();
block->append(create<DiscardStatement>());
@@ -277,8 +277,8 @@
}
TEST_F(FunctionTest, ToStr_WithDecoration) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
auto* block = create<BlockStatement>();
block->append(create<DiscardStatement>());
@@ -299,8 +299,8 @@
}
TEST_F(FunctionTest, ToStr_WithParams) {
- type::VoidType void_type;
- type::I32Type i32;
+ type::Void void_type;
+ type::I32 i32;
VariableList params;
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
@@ -328,16 +328,16 @@
}
TEST_F(FunctionTest, TypeName) {
- type::VoidType void_type;
+ type::Void void_type;
Function f("func", {}, &void_type, create<BlockStatement>());
EXPECT_EQ(f.type_name(), "__func__void");
}
TEST_F(FunctionTest, TypeName_WithParams) {
- type::VoidType void_type;
- type::I32Type i32;
- type::F32Type f32;
+ type::Void void_type;
+ type::I32 i32;
+ type::F32 f32;
VariableList params;
params.push_back(create<Variable>("var1", StorageClass::kNone, &i32));
@@ -348,7 +348,7 @@
}
TEST_F(FunctionTest, GetLastStatement) {
- type::VoidType void_type;
+ type::Void void_type;
VariableList params;
auto* body = create<BlockStatement>();
@@ -361,7 +361,7 @@
}
TEST_F(FunctionTest, GetLastStatement_nullptr) {
- type::VoidType void_type;
+ type::Void void_type;
VariableList params;
auto* body = create<BlockStatement>();
@@ -372,7 +372,7 @@
}
TEST_F(FunctionTest, WorkgroupSize_NoneSet) {
- type::VoidType void_type;
+ type::Void void_type;
Function f("f", {}, &void_type, create<BlockStatement>());
uint32_t x = 0;
uint32_t y = 0;
@@ -384,7 +384,7 @@
}
TEST_F(FunctionTest, WorkgroupSize) {
- type::VoidType void_type;
+ type::Void void_type;
Function f("f", {}, &void_type, create<BlockStatement>());
f.add_decoration(create<WorkgroupDecoration>(2u, 4u, 6u, Source{}));
diff --git a/src/ast/int_literal_test.cc b/src/ast/int_literal_test.cc
index 70d399a..3a1eb75 100644
--- a/src/ast/int_literal_test.cc
+++ b/src/ast/int_literal_test.cc
@@ -30,13 +30,13 @@
using IntLiteralTest = TestHelper;
TEST_F(IntLiteralTest, Sint_IsInt) {
- type::I32Type i32;
+ type::I32 i32;
SintLiteral i{&i32, 47};
ASSERT_TRUE(i.Is<IntLiteral>());
}
TEST_F(IntLiteralTest, Uint_IsInt) {
- type::I32Type i32;
+ type::I32 i32;
UintLiteral i{&i32, 42};
EXPECT_TRUE(i.Is<IntLiteral>());
}
diff --git a/src/ast/module.cc b/src/ast/module.cc
index c11bbd7..748a984 100644
--- a/src/ast/module.cc
+++ b/src/ast/module.cc
@@ -56,17 +56,17 @@
if (ty == nullptr) {
return false;
}
- if (ty->Is<type::AliasType>()) {
- auto* alias = ty->As<type::AliasType>();
+ if (ty->Is<type::Alias>()) {
+ auto* alias = ty->As<type::Alias>();
if (alias->type() == nullptr) {
return false;
}
- if (alias->type()->Is<type::StructType>() &&
- alias->type()->As<type::StructType>()->name().empty()) {
+ if (alias->type()->Is<type::Struct>() &&
+ alias->type()->As<type::Struct>()->name().empty()) {
return false;
}
- } else if (ty->Is<type::StructType>()) {
- auto* str = ty->As<type::StructType>();
+ } else if (ty->Is<type::Struct>()) {
+ auto* str = ty->As<type::Struct>();
if (str->name().empty()) {
return false;
}
@@ -91,14 +91,14 @@
for (size_t i = 0; i < indent; ++i) {
out << " ";
}
- if (ty->Is<type::AliasType>()) {
- auto* alias = ty->As<type::AliasType>();
+ if (ty->Is<type::Alias>()) {
+ auto* alias = ty->As<type::Alias>();
out << alias->name() << " -> " << alias->type()->type_name() << std::endl;
- if (alias->type()->Is<type::StructType>()) {
- alias->type()->As<type::StructType>()->impl()->to_str(out, indent);
+ if (alias->type()->Is<type::Struct>()) {
+ alias->type()->As<type::Struct>()->impl()->to_str(out, indent);
}
- } else if (ty->Is<type::StructType>()) {
- auto* str = ty->As<type::StructType>();
+ } else if (ty->Is<type::Struct>()) {
+ auto* str = ty->As<type::Struct>();
out << str->name() << " ";
str->impl()->to_str(out, indent);
}
diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc
index cf05d4e..0bdbf49 100644
--- a/src/ast/module_test.cc
+++ b/src/ast/module_test.cc
@@ -45,7 +45,7 @@
}
TEST_F(ModuleTest, LookupFunction) {
- type::F32Type f32;
+ type::F32 f32;
Module m;
auto* func =
@@ -65,7 +65,7 @@
}
TEST_F(ModuleTest, IsValid_GlobalVariable) {
- type::F32Type f32;
+ type::F32 f32;
auto* var = create<Variable>("var", StorageClass::kInput, &f32);
Module m;
@@ -88,8 +88,8 @@
}
TEST_F(ModuleTest, IsValid_Alias) {
- type::F32Type f32;
- type::AliasType alias("alias", &f32);
+ type::F32 f32;
+ type::Alias alias("alias", &f32);
Module m;
m.AddConstructedType(&alias);
@@ -103,9 +103,9 @@
}
TEST_F(ModuleTest, IsValid_Struct) {
- type::F32Type f32;
- type::StructType st("name", {});
- type::AliasType alias("name", &st);
+ type::F32 f32;
+ type::Struct st("name", {});
+ type::Alias alias("name", &st);
Module m;
m.AddConstructedType(&alias);
@@ -113,9 +113,9 @@
}
TEST_F(ModuleTest, IsValid_Struct_EmptyName) {
- type::F32Type f32;
- type::StructType st("", {});
- type::AliasType alias("name", &st);
+ type::F32 f32;
+ type::Struct st("", {});
+ type::Alias alias("name", &st);
Module m;
m.AddConstructedType(&alias);
@@ -123,7 +123,7 @@
}
TEST_F(ModuleTest, IsValid_Function) {
- type::F32Type f32;
+ type::F32 f32;
auto* func =
create<Function>("main", VariableList(), &f32, create<BlockStatement>());
diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc
index 8c151ee..1ae8c83 100644
--- a/src/ast/null_literal_test.cc
+++ b/src/ast/null_literal_test.cc
@@ -28,7 +28,7 @@
using NullLiteralTest = TestHelper;
TEST_F(NullLiteralTest, Is) {
- type::I32Type i32;
+ type::I32 i32;
NullLiteral i{&i32};
Literal* l = &i;
EXPECT_FALSE(l->Is<BoolLiteral>());
@@ -40,14 +40,14 @@
}
TEST_F(NullLiteralTest, ToStr) {
- type::I32Type i32;
+ type::I32 i32;
NullLiteral i{&i32};
EXPECT_EQ(i.to_str(), "null __i32");
}
TEST_F(NullLiteralTest, Name_I32) {
- type::I32Type i32;
+ type::I32 i32;
NullLiteral i{&i32};
EXPECT_EQ("__null__i32", i.name());
}
diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc
index d7184c6..60e4185 100644
--- a/src/ast/scalar_constructor_expression_test.cc
+++ b/src/ast/scalar_constructor_expression_test.cc
@@ -25,14 +25,14 @@
using ScalarConstructorExpressionTest = TestHelper;
TEST_F(ScalarConstructorExpressionTest, Creation) {
- type::BoolType bool_type;
+ type::Bool bool_type;
auto* b = create<BoolLiteral>(&bool_type, true);
ScalarConstructorExpression c(b);
EXPECT_EQ(c.literal(), b);
}
TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) {
- type::BoolType bool_type;
+ type::Bool bool_type;
auto* b = create<BoolLiteral>(&bool_type, true);
ScalarConstructorExpression c(Source{Source::Location{20, 2}}, b);
auto src = c.source();
@@ -41,7 +41,7 @@
}
TEST_F(ScalarConstructorExpressionTest, IsValid) {
- type::BoolType bool_type;
+ type::Bool bool_type;
auto* b = create<BoolLiteral>(&bool_type, true);
ScalarConstructorExpression c(b);
EXPECT_TRUE(c.IsValid());
@@ -53,7 +53,7 @@
}
TEST_F(ScalarConstructorExpressionTest, ToStr) {
- type::BoolType bool_type;
+ type::Bool bool_type;
auto* b = create<BoolLiteral>(&bool_type, true);
ScalarConstructorExpression c(b);
std::ostringstream out;
diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc
index 7a8972f..09b4a34 100644
--- a/src/ast/sint_literal_test.cc
+++ b/src/ast/sint_literal_test.cc
@@ -29,14 +29,14 @@
using SintLiteralTest = TestHelper;
TEST_F(SintLiteralTest, Value) {
- type::I32Type i32;
+ type::I32 i32;
SintLiteral i{&i32, 47};
ASSERT_TRUE(i.Is<SintLiteral>());
EXPECT_EQ(i.value(), 47);
}
TEST_F(SintLiteralTest, Is) {
- type::I32Type i32;
+ type::I32 i32;
SintLiteral i{&i32, 42};
Literal* l = &i;
EXPECT_FALSE(l->Is<BoolLiteral>());
@@ -47,20 +47,20 @@
}
TEST_F(SintLiteralTest, ToStr) {
- type::I32Type i32;
+ type::I32 i32;
SintLiteral i{&i32, -42};
EXPECT_EQ(i.to_str(), "-42");
}
TEST_F(SintLiteralTest, Name_I32) {
- type::I32Type i32;
+ type::I32 i32;
SintLiteral i{&i32, 2};
EXPECT_EQ("__sint__i32_2", i.name());
}
TEST_F(SintLiteralTest, Name_U32) {
- type::U32Type u32;
+ type::U32 u32;
SintLiteral i{&u32, 2};
EXPECT_EQ("__sint__u32_2", i.name());
}
diff --git a/src/ast/struct_member_test.cc b/src/ast/struct_member_test.cc
index 18a71eb..88b2eae 100644
--- a/src/ast/struct_member_test.cc
+++ b/src/ast/struct_member_test.cc
@@ -28,7 +28,7 @@
using StructMemberTest = TestHelper;
TEST_F(StructMemberTest, Creation) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberDecorationList decorations;
decorations.emplace_back(create<StructMemberOffsetDecoration>(4, Source{}));
@@ -44,7 +44,7 @@
}
TEST_F(StructMemberTest, CreationWithSource) {
- type::I32Type i32;
+ type::I32 i32;
Source s{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}};
StructMember st{s, "a", &i32, {}};
@@ -58,13 +58,13 @@
}
TEST_F(StructMemberTest, IsValid) {
- type::I32Type i32;
+ type::I32 i32;
StructMember st{"a", &i32, {}};
EXPECT_TRUE(st.IsValid());
}
TEST_F(StructMemberTest, IsValid_EmptyName) {
- type::I32Type i32;
+ type::I32 i32;
StructMember st{"", &i32, {}};
EXPECT_FALSE(st.IsValid());
}
@@ -75,7 +75,7 @@
}
TEST_F(StructMemberTest, IsValid_Null_Decoration) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberDecorationList decorations;
decorations.emplace_back(create<StructMemberOffsetDecoration>(4, Source{}));
decorations.push_back(nullptr);
@@ -85,7 +85,7 @@
}
TEST_F(StructMemberTest, ToStr) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberDecorationList decorations;
decorations.emplace_back(create<StructMemberOffsetDecoration>(4, Source{}));
@@ -96,7 +96,7 @@
}
TEST_F(StructMemberTest, ToStrNoDecorations) {
- type::I32Type i32;
+ type::I32 i32;
StructMember st{"a", &i32, {}};
std::ostringstream out;
st.to_str(out, 2);
diff --git a/src/ast/struct_test.cc b/src/ast/struct_test.cc
index 33f0697..11e9bb8 100644
--- a/src/ast/struct_test.cc
+++ b/src/ast/struct_test.cc
@@ -30,7 +30,7 @@
using StructTest = TestHelper;
TEST_F(StructTest, Creation) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberList members;
members.push_back(
create<StructMember>("a", &i32, StructMemberDecorationList()));
@@ -45,7 +45,7 @@
}
TEST_F(StructTest, Creation_WithDecorations) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberList members;
members.push_back(
@@ -65,7 +65,7 @@
}
TEST_F(StructTest, CreationWithSourceAndDecorations) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberList members;
members.emplace_back(
@@ -92,7 +92,7 @@
}
TEST_F(StructTest, IsValid_Null_StructMember) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberList members;
members.push_back(
@@ -104,7 +104,7 @@
}
TEST_F(StructTest, IsValid_Invalid_StructMember) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberList members;
members.push_back(
@@ -115,7 +115,7 @@
}
TEST_F(StructTest, ToStr) {
- type::I32Type i32;
+ type::I32 i32;
StructMemberList members;
members.emplace_back(
diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc
index 7627a0b..14d90e6 100644
--- a/src/ast/switch_statement_test.cc
+++ b/src/ast/switch_statement_test.cc
@@ -29,7 +29,7 @@
using SwitchStatementTest = TestHelper;
TEST_F(SwitchStatementTest, Creation) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(&i32, 1));
@@ -61,7 +61,7 @@
}
TEST_F(SwitchStatementTest, IsValid) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(&i32, 2));
@@ -75,7 +75,7 @@
}
TEST_F(SwitchStatementTest, IsValid_Null_Condition) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(&i32, 2));
@@ -89,7 +89,7 @@
}
TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(&i32, 2));
@@ -103,7 +103,7 @@
}
TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(&i32, 2));
@@ -145,7 +145,7 @@
}
TEST_F(SwitchStatementTest, ToStr) {
- type::I32Type i32;
+ type::I32 i32;
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(&i32, 2));
diff --git a/src/ast/type/access_control_type.cc b/src/ast/type/access_control_type.cc
index 4e59370..a419efb 100644
--- a/src/ast/type/access_control_type.cc
+++ b/src/ast/type/access_control_type.cc
@@ -20,38 +20,37 @@
namespace ast {
namespace type {
-AccessControlType::AccessControlType(AccessControl access, Type* subtype)
+AccessControl::AccessControl(ast::AccessControl access, Type* subtype)
: access_(access), subtype_(subtype) {
assert(subtype_);
- assert(!subtype_->Is<AccessControlType>());
+ assert(!subtype_->Is<AccessControl>());
}
-AccessControlType::AccessControlType(AccessControlType&&) = default;
+AccessControl::AccessControl(AccessControl&&) = default;
-AccessControlType::~AccessControlType() = default;
+AccessControl::~AccessControl() = default;
-std::string AccessControlType::type_name() const {
+std::string AccessControl::type_name() const {
std::string name = "__access_control_";
switch (access_) {
- case AccessControl::kReadOnly:
+ case ast::AccessControl::kReadOnly:
name += "read_only";
break;
- case AccessControl::kWriteOnly:
+ case ast::AccessControl::kWriteOnly:
name += "write_only";
break;
- case AccessControl::kReadWrite:
+ case ast::AccessControl::kReadWrite:
name += "read_write";
break;
}
return name + subtype_->type_name();
}
-uint64_t AccessControlType::MinBufferBindingSize(
- MemoryLayout mem_layout) const {
+uint64_t AccessControl::MinBufferBindingSize(MemoryLayout mem_layout) const {
return subtype_->MinBufferBindingSize(mem_layout);
}
-uint64_t AccessControlType::BaseAlignment(MemoryLayout mem_layout) const {
+uint64_t AccessControl::BaseAlignment(MemoryLayout mem_layout) const {
return subtype_->BaseAlignment(mem_layout);
}
diff --git a/src/ast/type/access_control_type.h b/src/ast/type/access_control_type.h
index 9e31d67..c5828a6 100644
--- a/src/ast/type/access_control_type.h
+++ b/src/ast/type/access_control_type.h
@@ -25,25 +25,25 @@
namespace type {
/// An access control type. Holds an access setting and pointer to another type.
-class AccessControlType : public Castable<AccessControlType, Type> {
+class AccessControl : public Castable<AccessControl, Type> {
public:
/// Constructor
/// @param access the access control setting
/// @param subtype the access controlled type
- AccessControlType(AccessControl access, Type* subtype);
+ AccessControl(ast::AccessControl access, Type* subtype);
/// Move constructor
- AccessControlType(AccessControlType&&);
- ~AccessControlType() override;
+ AccessControl(AccessControl&&);
+ ~AccessControl() override;
/// @returns true if the access control is read only
- bool IsReadOnly() const { return access_ == AccessControl::kReadOnly; }
+ bool IsReadOnly() const { return access_ == ast::AccessControl::kReadOnly; }
/// @returns true if the access control is write only
- bool IsWriteOnly() const { return access_ == AccessControl::kWriteOnly; }
+ bool IsWriteOnly() const { return access_ == ast::AccessControl::kWriteOnly; }
/// @returns true if the access control is read/write
- bool IsReadWrite() const { return access_ == AccessControl::kReadWrite; }
+ bool IsReadWrite() const { return access_ == ast::AccessControl::kReadWrite; }
/// @returns the access control value
- AccessControl access_control() const { return access_; }
+ ast::AccessControl access_control() const { return access_; }
/// @returns the subtype type
Type* type() const { return subtype_; }
@@ -61,7 +61,7 @@
uint64_t BaseAlignment(MemoryLayout mem_layout) const override;
private:
- AccessControl access_ = AccessControl::kReadOnly;
+ ast::AccessControl access_ = ast::AccessControl::kReadOnly;
Type* subtype_ = nullptr;
};
diff --git a/src/ast/type/access_control_type_test.cc b/src/ast/type/access_control_type_test.cc
index ded04fb..b49f64c 100644
--- a/src/ast/type/access_control_type_test.cc
+++ b/src/ast/type/access_control_type_test.cc
@@ -39,38 +39,38 @@
namespace type {
namespace {
-using AccessControlTypeTest = TestHelper;
+using AccessControlTest = TestHelper;
-TEST_F(AccessControlTypeTest, Create) {
- U32Type u32;
- AccessControlType a{AccessControl::kReadWrite, &u32};
+TEST_F(AccessControlTest, Create) {
+ U32 u32;
+ AccessControl a{ast::AccessControl::kReadWrite, &u32};
EXPECT_TRUE(a.IsReadWrite());
EXPECT_EQ(a.type(), &u32);
}
-TEST_F(AccessControlTypeTest, Is) {
- I32Type i32;
+TEST_F(AccessControlTest, Is) {
+ I32 i32;
- AccessControlType at{AccessControl::kReadOnly, &i32};
+ AccessControl at{ast::AccessControl::kReadOnly, &i32};
Type* ty = &at;
- EXPECT_TRUE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_TRUE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(AccessControlTypeTest, AccessRead) {
- I32Type i32;
- AccessControlType at{AccessControl::kReadOnly, &i32};
+TEST_F(AccessControlTest, AccessRead) {
+ I32 i32;
+ AccessControl at{ast::AccessControl::kReadOnly, &i32};
EXPECT_TRUE(at.IsReadOnly());
EXPECT_FALSE(at.IsWriteOnly());
EXPECT_FALSE(at.IsReadWrite());
@@ -78,9 +78,9 @@
EXPECT_EQ(at.type_name(), "__access_control_read_only__i32");
}
-TEST_F(AccessControlTypeTest, AccessWrite) {
- I32Type i32;
- AccessControlType at{AccessControl::kWriteOnly, &i32};
+TEST_F(AccessControlTest, AccessWrite) {
+ I32 i32;
+ AccessControl at{ast::AccessControl::kWriteOnly, &i32};
EXPECT_FALSE(at.IsReadOnly());
EXPECT_TRUE(at.IsWriteOnly());
EXPECT_FALSE(at.IsReadWrite());
@@ -88,9 +88,9 @@
EXPECT_EQ(at.type_name(), "__access_control_write_only__i32");
}
-TEST_F(AccessControlTypeTest, AccessReadWrite) {
- I32Type i32;
- AccessControlType at{AccessControl::kReadWrite, &i32};
+TEST_F(AccessControlTest, AccessReadWrite) {
+ I32 i32;
+ AccessControl at{ast::AccessControl::kReadWrite, &i32};
EXPECT_FALSE(at.IsReadOnly());
EXPECT_FALSE(at.IsWriteOnly());
EXPECT_TRUE(at.IsReadWrite());
@@ -98,34 +98,34 @@
EXPECT_EQ(at.type_name(), "__access_control_read_write__i32");
}
-TEST_F(AccessControlTypeTest, MinBufferBindingSizeU32) {
- U32Type u32;
- AccessControlType at{AccessControl::kReadOnly, &u32};
+TEST_F(AccessControlTest, MinBufferBindingSizeU32) {
+ U32 u32;
+ AccessControl at{ast::AccessControl::kReadOnly, &u32};
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(AccessControlTypeTest, MinBufferBindingSizeArray) {
- U32Type u32;
- ArrayType array(&u32, 4);
+TEST_F(AccessControlTest, MinBufferBindingSizeArray) {
+ U32 u32;
+ Array array(&u32, 4);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
- AccessControlType at{AccessControl::kReadOnly, &array};
+ AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(AccessControlTypeTest, MinBufferBindingSizeRuntimeArray) {
- U32Type u32;
- ArrayType array(&u32);
+TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) {
+ U32 u32;
+ Array array(&u32);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
- AccessControlType at{AccessControl::kReadOnly, &array};
+ AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(AccessControlTypeTest, MinBufferBindingSizeStruct) {
- U32Type u32;
+TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
+ U32 u32;
StructMemberList members;
StructMemberDecorationList deco;
@@ -138,41 +138,41 @@
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
- AccessControlType at{AccessControl::kReadOnly, &struct_type};
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
+ AccessControl at{ast::AccessControl::kReadOnly, &struct_type};
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(8u, at.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(AccessControlTypeTest, BaseAlignmentU32) {
- U32Type u32;
- AccessControlType at{AccessControl::kReadOnly, &u32};
+TEST_F(AccessControlTest, BaseAlignmentU32) {
+ U32 u32;
+ AccessControl at{ast::AccessControl::kReadOnly, &u32};
EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
}
-TEST_F(AccessControlTypeTest, BaseAlignmentArray) {
- U32Type u32;
- ArrayType array(&u32, 4);
+TEST_F(AccessControlTest, BaseAlignmentArray) {
+ U32 u32;
+ Array array(&u32, 4);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
- AccessControlType at{AccessControl::kReadOnly, &array};
+ AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
}
-TEST_F(AccessControlTypeTest, BaseAlignmentRuntimeArray) {
- U32Type u32;
- ArrayType array(&u32);
+TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) {
+ U32 u32;
+ Array array(&u32);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
- AccessControlType at{AccessControl::kReadOnly, &array};
+ AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
}
-TEST_F(AccessControlTypeTest, BaseAlignmentStruct) {
- U32Type u32;
+TEST_F(AccessControlTest, BaseAlignmentStruct) {
+ U32 u32;
StructMemberList members;
{
@@ -187,9 +187,9 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
- AccessControlType at{AccessControl::kReadOnly, &struct_type};
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
+ AccessControl at{ast::AccessControl::kReadOnly, &struct_type};
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kStorageBuffer));
}
diff --git a/src/ast/type/alias_type.cc b/src/ast/type/alias_type.cc
index f2fece8..955f12f 100644
--- a/src/ast/type/alias_type.cc
+++ b/src/ast/type/alias_type.cc
@@ -20,24 +20,24 @@
namespace ast {
namespace type {
-AliasType::AliasType(const std::string& name, Type* subtype)
+Alias::Alias(const std::string& name, Type* subtype)
: name_(name), subtype_(subtype) {
assert(subtype_);
}
-AliasType::AliasType(AliasType&&) = default;
+Alias::Alias(Alias&&) = default;
-AliasType::~AliasType() = default;
+Alias::~Alias() = default;
-std::string AliasType::type_name() const {
+std::string Alias::type_name() const {
return "__alias_" + name_ + subtype_->type_name();
}
-uint64_t AliasType::MinBufferBindingSize(MemoryLayout mem_layout) const {
+uint64_t Alias::MinBufferBindingSize(MemoryLayout mem_layout) const {
return subtype_->MinBufferBindingSize(mem_layout);
}
-uint64_t AliasType::BaseAlignment(MemoryLayout mem_layout) const {
+uint64_t Alias::BaseAlignment(MemoryLayout mem_layout) const {
return subtype_->BaseAlignment(mem_layout);
}
diff --git a/src/ast/type/alias_type.h b/src/ast/type/alias_type.h
index 1476b59..7d4840a 100644
--- a/src/ast/type/alias_type.h
+++ b/src/ast/type/alias_type.h
@@ -24,15 +24,15 @@
namespace type {
/// A type alias type. Holds a name and pointer to another type.
-class AliasType : public Castable<AliasType, Type> {
+class Alias : public Castable<Alias, Type> {
public:
/// Constructor
/// @param name the alias name
/// @param subtype the alias'd type
- AliasType(const std::string& name, Type* subtype);
+ Alias(const std::string& name, Type* subtype);
/// Move constructor
- AliasType(AliasType&&);
- ~AliasType() override;
+ Alias(Alias&&);
+ ~Alias() override;
/// @returns the alias name
const std::string& name() const { return name_; }
diff --git a/src/ast/type/alias_type_test.cc b/src/ast/type/alias_type_test.cc
index e2e5c6a..7979efa 100644
--- a/src/ast/type/alias_type_test.cc
+++ b/src/ast/type/alias_type_test.cc
@@ -40,155 +40,155 @@
namespace type {
namespace {
-using AliasTypeTest = TestHelper;
+using AliasTest = TestHelper;
-TEST_F(AliasTypeTest, Create) {
- U32Type u32;
- AliasType a{"a_type", &u32};
+TEST_F(AliasTest, Create) {
+ U32 u32;
+ Alias a{"a_type", &u32};
EXPECT_EQ(a.name(), "a_type");
EXPECT_EQ(a.type(), &u32);
}
-TEST_F(AliasTypeTest, Is) {
- I32Type i32;
+TEST_F(AliasTest, Is) {
+ I32 i32;
- AliasType at{"a", &i32};
+ Alias at{"a", &i32};
Type* ty = &at;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_TRUE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_TRUE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(AliasTypeTest, TypeName) {
- I32Type i32;
- AliasType at{"Particle", &i32};
+TEST_F(AliasTest, TypeName) {
+ I32 i32;
+ Alias at{"Particle", &i32};
EXPECT_EQ(at.type_name(), "__alias_Particle__i32");
}
-TEST_F(AliasTypeTest, UnwrapIfNeeded_Alias) {
- U32Type u32;
- AliasType a{"a_type", &u32};
+TEST_F(AliasTest, UnwrapIfNeeded_Alias) {
+ U32 u32;
+ Alias a{"a_type", &u32};
EXPECT_EQ(a.name(), "a_type");
EXPECT_EQ(a.type(), &u32);
EXPECT_EQ(a.UnwrapIfNeeded(), &u32);
EXPECT_EQ(u32.UnwrapIfNeeded(), &u32);
}
-TEST_F(AliasTypeTest, UnwrapIfNeeded_AccessControl) {
- U32Type u32;
- AccessControlType a{AccessControl::kReadOnly, &u32};
+TEST_F(AliasTest, UnwrapIfNeeded_AccessControl) {
+ U32 u32;
+ AccessControl a{ast::AccessControl::kReadOnly, &u32};
EXPECT_EQ(a.type(), &u32);
EXPECT_EQ(a.UnwrapIfNeeded(), &u32);
}
-TEST_F(AliasTypeTest, UnwrapIfNeeded_MultiLevel) {
- U32Type u32;
- AliasType a{"a_type", &u32};
- AliasType aa{"aa_type", &a};
+TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel) {
+ U32 u32;
+ Alias a{"a_type", &u32};
+ Alias aa{"aa_type", &a};
EXPECT_EQ(aa.name(), "aa_type");
EXPECT_EQ(aa.type(), &a);
EXPECT_EQ(aa.UnwrapIfNeeded(), &u32);
}
-TEST_F(AliasTypeTest, UnwrapIfNeeded_MultiLevel_AliasAccessControl) {
- U32Type u32;
- AliasType a{"a_type", &u32};
- AccessControlType aa{AccessControl::kReadWrite, &a};
+TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel_AliasAccessControl) {
+ U32 u32;
+ Alias a{"a_type", &u32};
+ AccessControl aa{ast::AccessControl::kReadWrite, &a};
EXPECT_EQ(aa.type(), &a);
EXPECT_EQ(aa.UnwrapIfNeeded(), &u32);
}
-TEST_F(AliasTypeTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
- U32Type u32;
- AliasType a{"a_type", &u32};
- AliasType aa{"aa_type", &a};
- PointerType paa{&aa, StorageClass::kUniform};
- AliasType apaa{"paa_type", &paa};
- AliasType aapaa{"aapaa_type", &apaa};
+TEST_F(AliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
+ U32 u32;
+ Alias a{"a_type", &u32};
+ Alias aa{"aa_type", &a};
+ Pointer paa{&aa, StorageClass::kUniform};
+ Alias apaa{"paa_type", &paa};
+ Alias aapaa{"aapaa_type", &apaa};
EXPECT_EQ(aapaa.name(), "aapaa_type");
EXPECT_EQ(aapaa.type(), &apaa);
EXPECT_EQ(aapaa.UnwrapAll(), &u32);
EXPECT_EQ(u32.UnwrapAll(), &u32);
}
-TEST_F(AliasTypeTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) {
- U32Type u32;
- AliasType a{"a_type", &u32};
- AliasType aa{"aa_type", &a};
- PointerType paa{&aa, StorageClass::kUniform};
- PointerType ppaa{&paa, StorageClass::kUniform};
- AliasType appaa{"appaa_type", &ppaa};
+TEST_F(AliasTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) {
+ U32 u32;
+ Alias a{"a_type", &u32};
+ Alias aa{"aa_type", &a};
+ Pointer paa{&aa, StorageClass::kUniform};
+ Pointer ppaa{&paa, StorageClass::kUniform};
+ Alias appaa{"appaa_type", &ppaa};
EXPECT_EQ(appaa.UnwrapAll(), &paa);
}
-TEST_F(AliasTypeTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
- U32Type u32;
- AliasType a{"a_type", &u32};
- AliasType aa{"aa_type", &a};
- PointerType paa{&aa, StorageClass::kUniform};
- AliasType apaa{"apaa_type", &paa};
- AliasType aapaa{"aapaa_type", &apaa};
- PointerType paapaa{&aapaa, StorageClass::kUniform};
- AliasType apaapaa{"apaapaa_type", &paapaa};
+TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
+ U32 u32;
+ Alias a{"a_type", &u32};
+ Alias aa{"aa_type", &a};
+ Pointer paa{&aa, StorageClass::kUniform};
+ Alias apaa{"apaa_type", &paa};
+ Alias aapaa{"aapaa_type", &apaa};
+ Pointer paapaa{&aapaa, StorageClass::kUniform};
+ Alias apaapaa{"apaapaa_type", &paapaa};
EXPECT_EQ(apaapaa.UnwrapAll(), &paa);
}
-TEST_F(AliasTypeTest, UnwrapAll_AccessControlPointer) {
- U32Type u32;
- AccessControlType a{AccessControl::kReadOnly, &u32};
- PointerType pa{&a, StorageClass::kUniform};
+TEST_F(AliasTest, UnwrapAll_AccessControlPointer) {
+ U32 u32;
+ AccessControl a{ast::AccessControl::kReadOnly, &u32};
+ Pointer pa{&a, StorageClass::kUniform};
EXPECT_EQ(pa.type(), &a);
EXPECT_EQ(pa.UnwrapAll(), &u32);
EXPECT_EQ(u32.UnwrapAll(), &u32);
}
-TEST_F(AliasTypeTest, UnwrapAll_PointerAccessControl) {
- U32Type u32;
- PointerType p{&u32, StorageClass::kUniform};
- AccessControlType a{AccessControl::kReadOnly, &p};
+TEST_F(AliasTest, UnwrapAll_PointerAccessControl) {
+ U32 u32;
+ Pointer p{&u32, StorageClass::kUniform};
+ AccessControl a{ast::AccessControl::kReadOnly, &p};
EXPECT_EQ(a.type(), &p);
EXPECT_EQ(a.UnwrapAll(), &u32);
EXPECT_EQ(u32.UnwrapAll(), &u32);
}
-TEST_F(AliasTypeTest, MinBufferBindingSizeU32) {
- U32Type u32;
- AliasType alias{"alias", &u32};
+TEST_F(AliasTest, MinBufferBindingSizeU32) {
+ U32 u32;
+ Alias alias{"alias", &u32};
EXPECT_EQ(4u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(AliasTypeTest, MinBufferBindingSizeArray) {
- U32Type u32;
- ArrayType array(&u32, 4);
+TEST_F(AliasTest, MinBufferBindingSizeArray) {
+ U32 u32;
+ Array array(&u32, 4);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
- AliasType alias{"alias", &array};
+ Alias alias{"alias", &array};
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(AliasTypeTest, MinBufferBindingSizeRuntimeArray) {
- U32Type u32;
- ArrayType array(&u32);
+TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
+ U32 u32;
+ Array array(&u32);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
- AliasType alias{"alias", &array};
+ Alias alias{"alias", &array};
EXPECT_EQ(4u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(AliasTypeTest, MinBufferBindingSizeStruct) {
- U32Type u32;
+TEST_F(AliasTest, MinBufferBindingSizeStruct) {
+ U32 u32;
StructMemberList members;
{
@@ -203,41 +203,41 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
- AliasType alias{"alias", &struct_type};
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
+ Alias alias{"alias", &struct_type};
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(8u, alias.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(AliasTypeTest, BaseAlignmentU32) {
- U32Type u32;
- AliasType alias{"alias", &u32};
+TEST_F(AliasTest, BaseAlignmentU32) {
+ U32 u32;
+ Alias alias{"alias", &u32};
EXPECT_EQ(4u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
}
-TEST_F(AliasTypeTest, BaseAlignmentArray) {
- U32Type u32;
- ArrayType array(&u32, 4);
+TEST_F(AliasTest, BaseAlignmentArray) {
+ U32 u32;
+ Array array(&u32, 4);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
- AliasType alias{"alias", &array};
+ Alias alias{"alias", &array};
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
}
-TEST_F(AliasTypeTest, BaseAlignmentRuntimeArray) {
- U32Type u32;
- ArrayType array(&u32);
+TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
+ U32 u32;
+ Array array(&u32);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
- AliasType alias{"alias", &array};
+ Alias alias{"alias", &array};
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
}
-TEST_F(AliasTypeTest, BaseAlignmentStruct) {
- U32Type u32;
+TEST_F(AliasTest, BaseAlignmentStruct) {
+ U32 u32;
StructMemberList members;
{
@@ -252,9 +252,9 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
- AliasType alias{"alias", &struct_type};
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
+ Alias alias{"alias", &struct_type};
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, alias.BaseAlignment(MemoryLayout::kStorageBuffer));
}
diff --git a/src/ast/type/array_type.cc b/src/ast/type/array_type.cc
index 2b4bb80..3883e0e 100644
--- a/src/ast/type/array_type.cc
+++ b/src/ast/type/array_type.cc
@@ -23,16 +23,15 @@
namespace ast {
namespace type {
-ArrayType::ArrayType(Type* subtype) : subtype_(subtype) {}
+Array::Array(Type* subtype) : subtype_(subtype) {}
-ArrayType::ArrayType(Type* subtype, uint32_t size)
- : subtype_(subtype), size_(size) {}
+Array::Array(Type* subtype, uint32_t size) : subtype_(subtype), size_(size) {}
-ArrayType::ArrayType(ArrayType&&) = default;
+Array::Array(Array&&) = default;
-ArrayType::~ArrayType() = default;
+Array::~Array() = default;
-uint64_t ArrayType::MinBufferBindingSize(MemoryLayout mem_layout) const {
+uint64_t Array::MinBufferBindingSize(MemoryLayout mem_layout) const {
if (!has_array_stride()) {
// Arrays in buffers are required to have a stride.
return 0;
@@ -52,7 +51,7 @@
}
}
-uint64_t ArrayType::BaseAlignment(MemoryLayout mem_layout) const {
+uint64_t Array::BaseAlignment(MemoryLayout mem_layout) const {
if (mem_layout == MemoryLayout::kUniformBuffer) {
float aligment = 16; // for a vec4
float unaligned = static_cast<float>(subtype_->BaseAlignment(mem_layout));
@@ -63,7 +62,7 @@
return 0;
}
-uint32_t ArrayType::array_stride() const {
+uint32_t Array::array_stride() const {
for (auto* deco : decos_) {
if (auto* stride = deco->As<StrideDecoration>()) {
return stride->stride();
@@ -72,7 +71,7 @@
return 0;
}
-bool ArrayType::has_array_stride() const {
+bool Array::has_array_stride() const {
for (auto* deco : decos_) {
if (deco->Is<StrideDecoration>()) {
return true;
@@ -81,7 +80,7 @@
return false;
}
-std::string ArrayType::type_name() const {
+std::string Array::type_name() const {
assert(subtype_);
std::string type_name = "__array" + subtype_->type_name();
diff --git a/src/ast/type/array_type.h b/src/ast/type/array_type.h
index c44393b..ef6f6c2 100644
--- a/src/ast/type/array_type.h
+++ b/src/ast/type/array_type.h
@@ -28,18 +28,18 @@
namespace type {
/// An array type. If size is zero then it is a runtime array.
-class ArrayType : public Castable<ArrayType, Type> {
+class Array : public Castable<Array, Type> {
public:
/// Constructor for runtime array
/// @param subtype the type of the array elements
- explicit ArrayType(Type* subtype);
+ explicit Array(Type* subtype);
/// Constructor
/// @param subtype the type of the array elements
/// @param size the number of elements in the array
- ArrayType(Type* subtype, uint32_t size);
+ Array(Type* subtype, uint32_t size);
/// Move constructor
- ArrayType(ArrayType&&);
- ~ArrayType() override;
+ Array(Array&&);
+ ~Array() override;
/// @returns true if this is a runtime array.
/// i.e. the size is determined at runtime
diff --git a/src/ast/type/array_type_test.cc b/src/ast/type/array_type_test.cc
index 7a3d351..3dbcdda 100644
--- a/src/ast/type/array_type_test.cc
+++ b/src/ast/type/array_type_test.cc
@@ -35,111 +35,111 @@
namespace type {
namespace {
-using ArrayTypeTest = TestHelper;
+using ArrayTest = TestHelper;
-TEST_F(ArrayTypeTest, CreateSizedArray) {
- U32Type u32;
- ArrayType arr{&u32, 3};
+TEST_F(ArrayTest, CreateSizedArray) {
+ U32 u32;
+ Array arr{&u32, 3};
EXPECT_EQ(arr.type(), &u32);
EXPECT_EQ(arr.size(), 3u);
- EXPECT_TRUE(arr.Is<ArrayType>());
+ EXPECT_TRUE(arr.Is<Array>());
EXPECT_FALSE(arr.IsRuntimeArray());
}
-TEST_F(ArrayTypeTest, CreateRuntimeArray) {
- U32Type u32;
- ArrayType arr{&u32};
+TEST_F(ArrayTest, CreateRuntimeArray) {
+ U32 u32;
+ Array arr{&u32};
EXPECT_EQ(arr.type(), &u32);
EXPECT_EQ(arr.size(), 0u);
- EXPECT_TRUE(arr.Is<ArrayType>());
+ EXPECT_TRUE(arr.Is<Array>());
EXPECT_TRUE(arr.IsRuntimeArray());
}
-TEST_F(ArrayTypeTest, Is) {
- I32Type i32;
+TEST_F(ArrayTest, Is) {
+ I32 i32;
- ArrayType arr{&i32, 3};
+ Array arr{&i32, 3};
Type* ty = &arr;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_TRUE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_TRUE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(ArrayTypeTest, TypeName) {
- I32Type i32;
- ArrayType arr{&i32};
+TEST_F(ArrayTest, TypeName) {
+ I32 i32;
+ Array arr{&i32};
EXPECT_EQ(arr.type_name(), "__array__i32");
}
-TEST_F(ArrayTypeTest, TypeName_RuntimeArray) {
- I32Type i32;
- ArrayType arr{&i32, 3};
+TEST_F(ArrayTest, TypeName_RuntimeArray) {
+ I32 i32;
+ Array arr{&i32, 3};
EXPECT_EQ(arr.type_name(), "__array__i32_3");
}
-TEST_F(ArrayTypeTest, TypeName_WithStride) {
- I32Type i32;
+TEST_F(ArrayTest, TypeName_WithStride) {
+ I32 i32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(16, Source{}));
- ArrayType arr{&i32, 3};
+ Array arr{&i32, 3};
arr.set_decorations(decos);
EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
}
-TEST_F(ArrayTypeTest, MinBufferBindingSizeNoStride) {
- U32Type u32;
- ArrayType arr(&u32, 4);
+TEST_F(ArrayTest, MinBufferBindingSizeNoStride) {
+ U32 u32;
+ Array arr(&u32, 4);
EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(ArrayTypeTest, MinBufferBindingSizeArray) {
- U32Type u32;
+TEST_F(ArrayTest, MinBufferBindingSizeArray) {
+ U32 u32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
- ArrayType arr(&u32, 4);
+ Array arr(&u32, 4);
arr.set_decorations(decos);
EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(ArrayTypeTest, MinBufferBindingSizeRuntimeArray) {
- U32Type u32;
+TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) {
+ U32 u32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
- ArrayType arr(&u32);
+ Array arr(&u32);
arr.set_decorations(decos);
EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(ArrayTypeTest, BaseAlignmentArray) {
- U32Type u32;
+TEST_F(ArrayTest, BaseAlignmentArray) {
+ U32 u32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
- ArrayType arr(&u32, 4);
+ Array arr(&u32, 4);
arr.set_decorations(decos);
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(ArrayTypeTest, BaseAlignmentRuntimeArray) {
- U32Type u32;
+TEST_F(ArrayTest, BaseAlignmentRuntimeArray) {
+ U32 u32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
- ArrayType arr(&u32);
+ Array arr(&u32);
arr.set_decorations(decos);
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
diff --git a/src/ast/type/bool_type.cc b/src/ast/type/bool_type.cc
index 7accedf..55bbc35 100644
--- a/src/ast/type/bool_type.cc
+++ b/src/ast/type/bool_type.cc
@@ -18,13 +18,13 @@
namespace ast {
namespace type {
-BoolType::BoolType() = default;
+Bool::Bool() = default;
-BoolType::BoolType(BoolType&&) = default;
+Bool::Bool(Bool&&) = default;
-BoolType::~BoolType() = default;
+Bool::~Bool() = default;
-std::string BoolType::type_name() const {
+std::string Bool::type_name() const {
return "__bool";
}
diff --git a/src/ast/type/bool_type.h b/src/ast/type/bool_type.h
index 5e7ccf6..92b08ed 100644
--- a/src/ast/type/bool_type.h
+++ b/src/ast/type/bool_type.h
@@ -24,13 +24,13 @@
namespace type {
/// A boolean type
-class BoolType : public Castable<BoolType, Type> {
+class Bool : public Castable<Bool, Type> {
public:
/// Constructor
- BoolType();
+ Bool();
/// Move constructor
- BoolType(BoolType&&);
- ~BoolType() override;
+ Bool(Bool&&);
+ ~Bool() override;
/// @returns the name for this type
std::string type_name() const override;
diff --git a/src/ast/type/bool_type_test.cc b/src/ast/type/bool_type_test.cc
index 52e64a7..d6c6f25 100644
--- a/src/ast/type/bool_type_test.cc
+++ b/src/ast/type/bool_type_test.cc
@@ -31,33 +31,33 @@
namespace type {
namespace {
-using BoolTypeTest = TestHelper;
+using BoolTest = TestHelper;
-TEST_F(BoolTypeTest, Is) {
- BoolType b;
+TEST_F(BoolTest, Is) {
+ Bool b;
Type* ty = &b;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_TRUE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_TRUE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(BoolTypeTest, TypeName) {
- BoolType b;
+TEST_F(BoolTest, TypeName) {
+ Bool b;
EXPECT_EQ(b.type_name(), "__bool");
}
-TEST_F(BoolTypeTest, MinBufferBindingSize) {
- BoolType b;
+TEST_F(BoolTest, MinBufferBindingSize) {
+ Bool b;
EXPECT_EQ(0u, b.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/depth_texture_type.cc b/src/ast/type/depth_texture_type.cc
index 95a954f..c6153ee 100644
--- a/src/ast/type/depth_texture_type.cc
+++ b/src/ast/type/depth_texture_type.cc
@@ -33,15 +33,15 @@
} // namespace
-DepthTextureType::DepthTextureType(TextureDimension dim) : Base(dim) {
+DepthTexture::DepthTexture(TextureDimension dim) : Base(dim) {
assert(IsValidDepthDimension(dim));
}
-DepthTextureType::DepthTextureType(DepthTextureType&&) = default;
+DepthTexture::DepthTexture(DepthTexture&&) = default;
-DepthTextureType::~DepthTextureType() = default;
+DepthTexture::~DepthTexture() = default;
-std::string DepthTextureType::type_name() const {
+std::string DepthTexture::type_name() const {
std::ostringstream out;
out << "__depth_texture_" << dim();
return out.str();
diff --git a/src/ast/type/depth_texture_type.h b/src/ast/type/depth_texture_type.h
index 4f58fb0..49a0a1c 100644
--- a/src/ast/type/depth_texture_type.h
+++ b/src/ast/type/depth_texture_type.h
@@ -24,14 +24,14 @@
namespace type {
/// A depth texture type.
-class DepthTextureType : public Castable<DepthTextureType, TextureType> {
+class DepthTexture : public Castable<DepthTexture, Texture> {
public:
/// Constructor
/// @param dim the dimensionality of the texture
- explicit DepthTextureType(TextureDimension dim);
+ explicit DepthTexture(TextureDimension dim);
/// Move constructor
- DepthTextureType(DepthTextureType&&);
- ~DepthTextureType() override;
+ DepthTexture(DepthTexture&&);
+ ~DepthTexture() override;
/// @returns the name for this type
std::string type_name() const override;
diff --git a/src/ast/type/depth_texture_type_test.cc b/src/ast/type/depth_texture_type_test.cc
index 4b39585..b956f89 100644
--- a/src/ast/type/depth_texture_type_test.cc
+++ b/src/ast/type/depth_texture_type_test.cc
@@ -34,46 +34,46 @@
namespace type {
namespace {
-using DepthTextureTypeTest = TestHelper;
+using DepthTextureTest = TestHelper;
-TEST_F(DepthTextureTypeTest, Is) {
- DepthTextureType d(TextureDimension::kCube);
+TEST_F(DepthTextureTest, Is) {
+ DepthTexture d(TextureDimension::kCube);
Type* ty = &d;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_TRUE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_TRUE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(DepthTextureTypeTest, IsTextureType) {
- DepthTextureType d(TextureDimension::kCube);
- TextureType* ty = &d;
- EXPECT_TRUE(ty->Is<DepthTextureType>());
- EXPECT_FALSE(ty->Is<SampledTextureType>());
- EXPECT_FALSE(ty->Is<StorageTextureType>());
+TEST_F(DepthTextureTest, IsTexture) {
+ DepthTexture d(TextureDimension::kCube);
+ Texture* ty = &d;
+ EXPECT_TRUE(ty->Is<DepthTexture>());
+ EXPECT_FALSE(ty->Is<SampledTexture>());
+ EXPECT_FALSE(ty->Is<StorageTexture>());
}
-TEST_F(DepthTextureTypeTest, Dim) {
- DepthTextureType d(TextureDimension::kCube);
+TEST_F(DepthTextureTest, Dim) {
+ DepthTexture d(TextureDimension::kCube);
EXPECT_EQ(d.dim(), TextureDimension::kCube);
}
-TEST_F(DepthTextureTypeTest, TypeName) {
- DepthTextureType d(TextureDimension::kCube);
+TEST_F(DepthTextureTest, TypeName) {
+ DepthTexture d(TextureDimension::kCube);
EXPECT_EQ(d.type_name(), "__depth_texture_cube");
}
-TEST_F(DepthTextureTypeTest, MinBufferBindingSize) {
- DepthTextureType d(TextureDimension::kCube);
+TEST_F(DepthTextureTest, MinBufferBindingSize) {
+ DepthTexture d(TextureDimension::kCube);
EXPECT_EQ(0u, d.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/f32_type.cc b/src/ast/type/f32_type.cc
index 08e37c2..7712aec 100644
--- a/src/ast/type/f32_type.cc
+++ b/src/ast/type/f32_type.cc
@@ -18,21 +18,21 @@
namespace ast {
namespace type {
-F32Type::F32Type() = default;
+F32::F32() = default;
-F32Type::F32Type(F32Type&&) = default;
+F32::F32(F32&&) = default;
-F32Type::~F32Type() = default;
+F32::~F32() = default;
-std::string F32Type::type_name() const {
+std::string F32::type_name() const {
return "__f32";
}
-uint64_t F32Type::MinBufferBindingSize(MemoryLayout) const {
+uint64_t F32::MinBufferBindingSize(MemoryLayout) const {
return 4;
}
-uint64_t F32Type::BaseAlignment(MemoryLayout) const {
+uint64_t F32::BaseAlignment(MemoryLayout) const {
return 4;
}
diff --git a/src/ast/type/f32_type.h b/src/ast/type/f32_type.h
index e5ceb7f..92f25f0 100644
--- a/src/ast/type/f32_type.h
+++ b/src/ast/type/f32_type.h
@@ -24,13 +24,13 @@
namespace type {
/// A float 32 type
-class F32Type : public Castable<F32Type, Type> {
+class F32 : public Castable<F32, Type> {
public:
/// Constructor
- F32Type();
+ F32();
/// Move constructor
- F32Type(F32Type&&);
- ~F32Type() override;
+ F32(F32&&);
+ ~F32() override;
/// @returns the name for this type
std::string type_name() const override;
diff --git a/src/ast/type/f32_type_test.cc b/src/ast/type/f32_type_test.cc
index 8d356ee..0570b7e 100644
--- a/src/ast/type/f32_type_test.cc
+++ b/src/ast/type/f32_type_test.cc
@@ -31,38 +31,38 @@
namespace type {
namespace {
-using F32TypeTest = TestHelper;
+using F32Test = TestHelper;
-TEST_F(F32TypeTest, Is) {
- F32Type f;
+TEST_F(F32Test, Is) {
+ F32 f;
Type* ty = &f;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_TRUE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_TRUE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(F32TypeTest, TypeName) {
- F32Type f;
+TEST_F(F32Test, TypeName) {
+ F32 f;
EXPECT_EQ(f.type_name(), "__f32");
}
-TEST_F(F32TypeTest, MinBufferBindingSize) {
- F32Type f;
+TEST_F(F32Test, MinBufferBindingSize) {
+ F32 f;
EXPECT_EQ(4u, f.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(F32TypeTest, BaseAlignment) {
- F32Type f;
+TEST_F(F32Test, BaseAlignment) {
+ F32 f;
EXPECT_EQ(4u, f.BaseAlignment(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/i32_type.cc b/src/ast/type/i32_type.cc
index c3c2838..eced6b6 100644
--- a/src/ast/type/i32_type.cc
+++ b/src/ast/type/i32_type.cc
@@ -18,21 +18,21 @@
namespace ast {
namespace type {
-I32Type::I32Type() = default;
+I32::I32() = default;
-I32Type::I32Type(I32Type&&) = default;
+I32::I32(I32&&) = default;
-I32Type::~I32Type() = default;
+I32::~I32() = default;
-std::string I32Type::type_name() const {
+std::string I32::type_name() const {
return "__i32";
}
-uint64_t I32Type::MinBufferBindingSize(MemoryLayout) const {
+uint64_t I32::MinBufferBindingSize(MemoryLayout) const {
return 4;
}
-uint64_t I32Type::BaseAlignment(MemoryLayout) const {
+uint64_t I32::BaseAlignment(MemoryLayout) const {
return 4;
}
diff --git a/src/ast/type/i32_type.h b/src/ast/type/i32_type.h
index e1b9d9f..4ad0115 100644
--- a/src/ast/type/i32_type.h
+++ b/src/ast/type/i32_type.h
@@ -24,13 +24,13 @@
namespace type {
/// A signed int 32 type.
-class I32Type : public Castable<I32Type, Type> {
+class I32 : public Castable<I32, Type> {
public:
/// Constructor
- I32Type();
+ I32();
/// Move constructor
- I32Type(I32Type&&);
- ~I32Type() override;
+ I32(I32&&);
+ ~I32() override;
/// @returns the name for this type
std::string type_name() const override;
diff --git a/src/ast/type/i32_type_test.cc b/src/ast/type/i32_type_test.cc
index fc9c75a..0333d01 100644
--- a/src/ast/type/i32_type_test.cc
+++ b/src/ast/type/i32_type_test.cc
@@ -31,38 +31,38 @@
namespace type {
namespace {
-using I32TypeTest = TestHelper;
+using I32Test = TestHelper;
-TEST_F(I32TypeTest, Is) {
- I32Type i;
+TEST_F(I32Test, Is) {
+ I32 i;
Type* ty = &i;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_TRUE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_TRUE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(I32TypeTest, TypeName) {
- I32Type i;
+TEST_F(I32Test, TypeName) {
+ I32 i;
EXPECT_EQ(i.type_name(), "__i32");
}
-TEST_F(I32TypeTest, MinBufferBindingSize) {
- I32Type i;
+TEST_F(I32Test, MinBufferBindingSize) {
+ I32 i;
EXPECT_EQ(4u, i.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(I32TypeTest, BaseAlignment) {
- I32Type i;
+TEST_F(I32Test, BaseAlignment) {
+ I32 i;
EXPECT_EQ(4u, i.BaseAlignment(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/matrix_type.cc b/src/ast/type/matrix_type.cc
index da2ef68..7065b7f 100644
--- a/src/ast/type/matrix_type.cc
+++ b/src/ast/type/matrix_type.cc
@@ -23,7 +23,7 @@
namespace ast {
namespace type {
-MatrixType::MatrixType(Type* subtype, uint32_t rows, uint32_t columns)
+Matrix::Matrix(Type* subtype, uint32_t rows, uint32_t columns)
: subtype_(subtype), rows_(rows), columns_(columns) {
assert(rows > 1);
assert(rows < 5);
@@ -31,24 +31,24 @@
assert(columns < 5);
}
-MatrixType::MatrixType(MatrixType&&) = default;
+Matrix::Matrix(Matrix&&) = default;
-MatrixType::~MatrixType() = default;
+Matrix::~Matrix() = default;
-std::string MatrixType::type_name() const {
+std::string Matrix::type_name() const {
return "__mat_" + std::to_string(rows_) + "_" + std::to_string(columns_) +
subtype_->type_name();
}
-uint64_t MatrixType::MinBufferBindingSize(MemoryLayout mem_layout) const {
- VectorType vec(subtype_, rows_);
+uint64_t Matrix::MinBufferBindingSize(MemoryLayout mem_layout) const {
+ Vector vec(subtype_, rows_);
return (columns_ - 1) * vec.BaseAlignment(mem_layout) +
vec.MinBufferBindingSize(mem_layout);
}
-uint64_t MatrixType::BaseAlignment(MemoryLayout mem_layout) const {
- VectorType vec(subtype_, rows_);
- ArrayType arr(&vec, columns_);
+uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const {
+ Vector vec(subtype_, rows_);
+ Array arr(&vec, columns_);
return arr.BaseAlignment(mem_layout);
}
diff --git a/src/ast/type/matrix_type.h b/src/ast/type/matrix_type.h
index d08d09e..2943a03 100644
--- a/src/ast/type/matrix_type.h
+++ b/src/ast/type/matrix_type.h
@@ -24,16 +24,16 @@
namespace type {
/// A matrix type
-class MatrixType : public Castable<MatrixType, Type> {
+class Matrix : public Castable<Matrix, Type> {
public:
/// Constructor
/// @param subtype type matrix type
/// @param rows the number of rows in the matrix
/// @param columns the number of columns in the matrix
- MatrixType(Type* subtype, uint32_t rows, uint32_t columns);
+ Matrix(Type* subtype, uint32_t rows, uint32_t columns);
/// Move constructor
- MatrixType(MatrixType&&);
- ~MatrixType() override;
+ Matrix(Matrix&&);
+ ~Matrix() override;
/// @returns the type of the matrix
Type* type() const { return subtype_; }
diff --git a/src/ast/type/matrix_type_test.cc b/src/ast/type/matrix_type_test.cc
index 514d61d..fb4c1a7 100644
--- a/src/ast/type/matrix_type_test.cc
+++ b/src/ast/type/matrix_type_test.cc
@@ -31,93 +31,93 @@
namespace type {
namespace {
-using MatrixTypeTest = TestHelper;
+using MatrixTest = TestHelper;
-TEST_F(MatrixTypeTest, Creation) {
- I32Type i32;
- MatrixType m{&i32, 2, 4};
+TEST_F(MatrixTest, Creation) {
+ I32 i32;
+ Matrix m{&i32, 2, 4};
EXPECT_EQ(m.type(), &i32);
EXPECT_EQ(m.rows(), 2u);
EXPECT_EQ(m.columns(), 4u);
}
-TEST_F(MatrixTypeTest, Is) {
- I32Type i32;
- MatrixType m{&i32, 2, 3};
+TEST_F(MatrixTest, Is) {
+ I32 i32;
+ Matrix m{&i32, 2, 3};
Type* ty = &m;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_TRUE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_TRUE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(MatrixTypeTest, TypeName) {
- I32Type i32;
- MatrixType m{&i32, 2, 3};
+TEST_F(MatrixTest, TypeName) {
+ I32 i32;
+ Matrix m{&i32, 2, 3};
EXPECT_EQ(m.type_name(), "__mat_2_3__i32");
}
-TEST_F(MatrixTypeTest, MinBufferBindingSize4x2) {
- I32Type i32;
- MatrixType m{&i32, 4, 2};
+TEST_F(MatrixTest, MinBufferBindingSize4x2) {
+ I32 i32;
+ Matrix m{&i32, 4, 2};
EXPECT_EQ(32u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(32u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(MatrixTypeTest, MinBufferBindingSize3x2) {
- I32Type i32;
- MatrixType m{&i32, 3, 2};
+TEST_F(MatrixTest, MinBufferBindingSize3x2) {
+ I32 i32;
+ Matrix m{&i32, 3, 2};
EXPECT_EQ(28u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(28u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(MatrixTypeTest, MinBufferBindingSize2x3) {
- I32Type i32;
- MatrixType m{&i32, 2, 3};
+TEST_F(MatrixTest, MinBufferBindingSize2x3) {
+ I32 i32;
+ Matrix m{&i32, 2, 3};
EXPECT_EQ(24u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(24u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(MatrixTypeTest, MinBufferBindingSize2x2) {
- I32Type i32;
- MatrixType m{&i32, 2, 2};
+TEST_F(MatrixTest, MinBufferBindingSize2x2) {
+ I32 i32;
+ Matrix m{&i32, 2, 2};
EXPECT_EQ(16u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(MatrixTypeTest, BaseAlignment4x2) {
- I32Type i32;
- MatrixType m{&i32, 4, 2};
+TEST_F(MatrixTest, BaseAlignment4x2) {
+ I32 i32;
+ Matrix m{&i32, 4, 2};
EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(MatrixTypeTest, BaseAlignment3x2) {
- I32Type i32;
- MatrixType m{&i32, 3, 2};
+TEST_F(MatrixTest, BaseAlignment3x2) {
+ I32 i32;
+ Matrix m{&i32, 3, 2};
EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(MatrixTypeTest, BaseAlignment2x3) {
- I32Type i32;
- MatrixType m{&i32, 2, 3};
+TEST_F(MatrixTest, BaseAlignment2x3) {
+ I32 i32;
+ Matrix m{&i32, 2, 3};
EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(8u, m.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(MatrixTypeTest, BaseAlignment2x2) {
- I32Type i32;
- MatrixType m{&i32, 2, 2};
+TEST_F(MatrixTest, BaseAlignment2x2) {
+ I32 i32;
+ Matrix m{&i32, 2, 2};
EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(8u, m.BaseAlignment(MemoryLayout::kStorageBuffer));
}
diff --git a/src/ast/type/multisampled_texture_type.cc b/src/ast/type/multisampled_texture_type.cc
index bcca076..d73ad18 100644
--- a/src/ast/type/multisampled_texture_type.cc
+++ b/src/ast/type/multisampled_texture_type.cc
@@ -21,19 +21,16 @@
namespace ast {
namespace type {
-MultisampledTextureType::MultisampledTextureType(TextureDimension dim,
- Type* type)
+MultisampledTexture::MultisampledTexture(TextureDimension dim, Type* type)
: Base(dim), type_(type) {
assert(type_);
}
-MultisampledTextureType::MultisampledTextureType(MultisampledTextureType&&) =
- default;
+MultisampledTexture::MultisampledTexture(MultisampledTexture&&) = default;
-MultisampledTextureType::~MultisampledTextureType() = default;
+MultisampledTexture::~MultisampledTexture() = default;
-
-std::string MultisampledTextureType::type_name() const {
+std::string MultisampledTexture::type_name() const {
std::ostringstream out;
out << "__multisampled_texture_" << dim() << type_->type_name();
return out.str();
diff --git a/src/ast/type/multisampled_texture_type.h b/src/ast/type/multisampled_texture_type.h
index 2cebe1f..351e9f8 100644
--- a/src/ast/type/multisampled_texture_type.h
+++ b/src/ast/type/multisampled_texture_type.h
@@ -24,16 +24,15 @@
namespace type {
/// A multisampled texture type.
-class MultisampledTextureType
- : public Castable<MultisampledTextureType, TextureType> {
+class MultisampledTexture : public Castable<MultisampledTexture, Texture> {
public:
/// Constructor
/// @param dim the dimensionality of the texture
/// @param type the data type of the multisampled texture
- MultisampledTextureType(TextureDimension dim, Type* type);
+ MultisampledTexture(TextureDimension dim, Type* type);
/// Move constructor
- MultisampledTextureType(MultisampledTextureType&&);
- ~MultisampledTextureType() override;
+ MultisampledTexture(MultisampledTexture&&);
+ ~MultisampledTexture() override;
/// @returns the subtype of the sampled texture
Type* type() const { return type_; }
diff --git a/src/ast/type/multisampled_texture_type_test.cc b/src/ast/type/multisampled_texture_type_test.cc
index 8b1aa21..99bb0e5 100644
--- a/src/ast/type/multisampled_texture_type_test.cc
+++ b/src/ast/type/multisampled_texture_type_test.cc
@@ -34,58 +34,58 @@
namespace type {
namespace {
-using MultisampledTextureTypeTest = TestHelper;
+using MultisampledTextureTest = TestHelper;
-TEST_F(MultisampledTextureTypeTest, Is) {
- F32Type f32;
- MultisampledTextureType s(TextureDimension::kCube, &f32);
+TEST_F(MultisampledTextureTest, Is) {
+ F32 f32;
+ MultisampledTexture s(TextureDimension::kCube, &f32);
Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_TRUE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_TRUE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(MultisampledTextureTypeTest, IsTextureType) {
- F32Type f32;
- MultisampledTextureType s(TextureDimension::kCube, &f32);
- TextureType* ty = &s;
- EXPECT_FALSE(ty->Is<DepthTextureType>());
- EXPECT_TRUE(ty->Is<MultisampledTextureType>());
- EXPECT_FALSE(ty->Is<SampledTextureType>());
- EXPECT_FALSE(ty->Is<StorageTextureType>());
+TEST_F(MultisampledTextureTest, IsTexture) {
+ F32 f32;
+ MultisampledTexture s(TextureDimension::kCube, &f32);
+ Texture* ty = &s;
+ EXPECT_FALSE(ty->Is<DepthTexture>());
+ EXPECT_TRUE(ty->Is<MultisampledTexture>());
+ EXPECT_FALSE(ty->Is<SampledTexture>());
+ EXPECT_FALSE(ty->Is<StorageTexture>());
}
-TEST_F(MultisampledTextureTypeTest, Dim) {
- F32Type f32;
- MultisampledTextureType s(TextureDimension::k3d, &f32);
+TEST_F(MultisampledTextureTest, Dim) {
+ F32 f32;
+ MultisampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), TextureDimension::k3d);
}
-TEST_F(MultisampledTextureTypeTest, Type) {
- F32Type f32;
- MultisampledTextureType s(TextureDimension::k3d, &f32);
+TEST_F(MultisampledTextureTest, Type) {
+ F32 f32;
+ MultisampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.type(), &f32);
}
-TEST_F(MultisampledTextureTypeTest, TypeName) {
- F32Type f32;
- MultisampledTextureType s(TextureDimension::k3d, &f32);
+TEST_F(MultisampledTextureTest, TypeName) {
+ F32 f32;
+ MultisampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.type_name(), "__multisampled_texture_3d__f32");
}
-TEST_F(MultisampledTextureTypeTest, MinBufferBindingSize) {
- F32Type f32;
- MultisampledTextureType s(TextureDimension::k3d, &f32);
+TEST_F(MultisampledTextureTest, MinBufferBindingSize) {
+ F32 f32;
+ MultisampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/pointer_type.cc b/src/ast/type/pointer_type.cc
index a577e78..7453491 100644
--- a/src/ast/type/pointer_type.cc
+++ b/src/ast/type/pointer_type.cc
@@ -18,18 +18,18 @@
namespace ast {
namespace type {
-PointerType::PointerType(Type* subtype, StorageClass storage_class)
+Pointer::Pointer(Type* subtype, StorageClass storage_class)
: subtype_(subtype), storage_class_(storage_class) {}
-std::string PointerType::type_name() const {
+std::string Pointer::type_name() const {
std::ostringstream out;
out << "__ptr_" << storage_class_ << subtype_->type_name();
return out.str();
}
-PointerType::PointerType(PointerType&&) = default;
+Pointer::Pointer(Pointer&&) = default;
-PointerType::~PointerType() = default;
+Pointer::~Pointer() = default;
} // namespace type
} // namespace ast
diff --git a/src/ast/type/pointer_type.h b/src/ast/type/pointer_type.h
index 9dbf71b..07a3c6b 100644
--- a/src/ast/type/pointer_type.h
+++ b/src/ast/type/pointer_type.h
@@ -26,15 +26,15 @@
namespace type {
/// A pointer type.
-class PointerType : public Castable<PointerType, Type> {
+class Pointer : public Castable<Pointer, Type> {
public:
/// Construtor
/// @param subtype the pointee type
/// @param storage_class the storage class of the pointer
- explicit PointerType(Type* subtype, StorageClass storage_class);
+ explicit Pointer(Type* subtype, StorageClass storage_class);
/// Move constructor
- PointerType(PointerType&&);
- ~PointerType() override;
+ Pointer(Pointer&&);
+ ~Pointer() override;
/// @returns the pointee type
Type* type() const { return subtype_; }
diff --git a/src/ast/type/pointer_type_test.cc b/src/ast/type/pointer_type_test.cc
index f50a6a7..0089c43 100644
--- a/src/ast/type/pointer_type_test.cc
+++ b/src/ast/type/pointer_type_test.cc
@@ -31,37 +31,37 @@
namespace type {
namespace {
-using PointerTypeTest = TestHelper;
+using PointerTest = TestHelper;
-TEST_F(PointerTypeTest, Creation) {
- I32Type i32;
- PointerType p{&i32, StorageClass::kStorageBuffer};
+TEST_F(PointerTest, Creation) {
+ I32 i32;
+ Pointer p{&i32, StorageClass::kStorageBuffer};
EXPECT_EQ(p.type(), &i32);
EXPECT_EQ(p.storage_class(), StorageClass::kStorageBuffer);
}
-TEST_F(PointerTypeTest, Is) {
- I32Type i32;
- PointerType p{&i32, StorageClass::kFunction};
+TEST_F(PointerTest, Is) {
+ I32 i32;
+ Pointer p{&i32, StorageClass::kFunction};
Type* ty = &p;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_TRUE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_TRUE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(PointerTypeTest, TypeName) {
- I32Type i32;
- PointerType p{&i32, StorageClass::kWorkgroup};
+TEST_F(PointerTest, TypeName) {
+ I32 i32;
+ Pointer p{&i32, StorageClass::kWorkgroup};
EXPECT_EQ(p.type_name(), "__ptr_workgroup__i32");
}
diff --git a/src/ast/type/sampled_texture_type.cc b/src/ast/type/sampled_texture_type.cc
index dc03beb..490a586 100644
--- a/src/ast/type/sampled_texture_type.cc
+++ b/src/ast/type/sampled_texture_type.cc
@@ -21,16 +21,16 @@
namespace ast {
namespace type {
-SampledTextureType::SampledTextureType(TextureDimension dim, Type* type)
+SampledTexture::SampledTexture(TextureDimension dim, Type* type)
: Base(dim), type_(type) {
assert(type_);
}
-SampledTextureType::SampledTextureType(SampledTextureType&&) = default;
+SampledTexture::SampledTexture(SampledTexture&&) = default;
-SampledTextureType::~SampledTextureType() = default;
+SampledTexture::~SampledTexture() = default;
-std::string SampledTextureType::type_name() const {
+std::string SampledTexture::type_name() const {
std::ostringstream out;
out << "__sampled_texture_" << dim() << type_->type_name();
return out.str();
diff --git a/src/ast/type/sampled_texture_type.h b/src/ast/type/sampled_texture_type.h
index a270a95..3c6abaf 100644
--- a/src/ast/type/sampled_texture_type.h
+++ b/src/ast/type/sampled_texture_type.h
@@ -24,15 +24,15 @@
namespace type {
/// A sampled texture type.
-class SampledTextureType : public Castable<SampledTextureType, TextureType> {
+class SampledTexture : public Castable<SampledTexture, Texture> {
public:
/// Constructor
/// @param dim the dimensionality of the texture
/// @param type the data type of the sampled texture
- SampledTextureType(TextureDimension dim, Type* type);
+ SampledTexture(TextureDimension dim, Type* type);
/// Move constructor
- SampledTextureType(SampledTextureType&&);
- ~SampledTextureType() override;
+ SampledTexture(SampledTexture&&);
+ ~SampledTexture() override;
/// @returns the subtype of the sampled texture
Type* type() const { return type_; }
diff --git a/src/ast/type/sampled_texture_type_test.cc b/src/ast/type/sampled_texture_type_test.cc
index f0049a4..5c6bcb4 100644
--- a/src/ast/type/sampled_texture_type_test.cc
+++ b/src/ast/type/sampled_texture_type_test.cc
@@ -33,57 +33,57 @@
namespace type {
namespace {
-using SampledTextureTypeTest = TestHelper;
+using SampledTextureTest = TestHelper;
-TEST_F(SampledTextureTypeTest, Is) {
- F32Type f32;
- SampledTextureType s(TextureDimension::kCube, &f32);
+TEST_F(SampledTextureTest, Is) {
+ F32 f32;
+ SampledTexture s(TextureDimension::kCube, &f32);
Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_TRUE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_TRUE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(SampledTextureTypeTest, IsTextureType) {
- F32Type f32;
- SampledTextureType s(TextureDimension::kCube, &f32);
- TextureType* ty = &s;
- EXPECT_FALSE(ty->Is<DepthTextureType>());
- EXPECT_TRUE(ty->Is<SampledTextureType>());
- EXPECT_FALSE(ty->Is<StorageTextureType>());
+TEST_F(SampledTextureTest, IsTexture) {
+ F32 f32;
+ SampledTexture s(TextureDimension::kCube, &f32);
+ Texture* ty = &s;
+ EXPECT_FALSE(ty->Is<DepthTexture>());
+ EXPECT_TRUE(ty->Is<SampledTexture>());
+ EXPECT_FALSE(ty->Is<StorageTexture>());
}
-TEST_F(SampledTextureTypeTest, Dim) {
- F32Type f32;
- SampledTextureType s(TextureDimension::k3d, &f32);
+TEST_F(SampledTextureTest, Dim) {
+ F32 f32;
+ SampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), TextureDimension::k3d);
}
-TEST_F(SampledTextureTypeTest, Type) {
- F32Type f32;
- SampledTextureType s(TextureDimension::k3d, &f32);
+TEST_F(SampledTextureTest, Type) {
+ F32 f32;
+ SampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.type(), &f32);
}
-TEST_F(SampledTextureTypeTest, TypeName) {
- F32Type f32;
- SampledTextureType s(TextureDimension::k3d, &f32);
+TEST_F(SampledTextureTest, TypeName) {
+ F32 f32;
+ SampledTexture s(TextureDimension::k3d, &f32);
EXPECT_EQ(s.type_name(), "__sampled_texture_3d__f32");
}
-TEST_F(SampledTextureTypeTest, MinBufferBindingSize) {
- F32Type f32;
- SampledTextureType s(TextureDimension::kCube, &f32);
+TEST_F(SampledTextureTest, MinBufferBindingSize) {
+ F32 f32;
+ SampledTexture s(TextureDimension::kCube, &f32);
EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/sampler_type.cc b/src/ast/type/sampler_type.cc
index c183b43..5d61348 100644
--- a/src/ast/type/sampler_type.cc
+++ b/src/ast/type/sampler_type.cc
@@ -30,13 +30,13 @@
return out;
}
-SamplerType::SamplerType(SamplerKind kind) : kind_(kind) {}
+Sampler::Sampler(SamplerKind kind) : kind_(kind) {}
-SamplerType::SamplerType(SamplerType&&) = default;
+Sampler::Sampler(Sampler&&) = default;
-SamplerType::~SamplerType() = default;
+Sampler::~Sampler() = default;
-std::string SamplerType::type_name() const {
+std::string Sampler::type_name() const {
return std::string("__sampler_") +
(kind_ == SamplerKind::kSampler ? "sampler" : "comparison");
}
diff --git a/src/ast/type/sampler_type.h b/src/ast/type/sampler_type.h
index c83c44a..0d2b914 100644
--- a/src/ast/type/sampler_type.h
+++ b/src/ast/type/sampler_type.h
@@ -34,14 +34,14 @@
std::ostream& operator<<(std::ostream& out, SamplerKind kind);
/// A sampler type.
-class SamplerType : public Castable<SamplerType, Type> {
+class Sampler : public Castable<Sampler, Type> {
public:
/// Constructor
/// @param kind the kind of sampler
- explicit SamplerType(SamplerKind kind);
+ explicit Sampler(SamplerKind kind);
/// Move constructor
- SamplerType(SamplerType&&);
- ~SamplerType() override;
+ Sampler(Sampler&&);
+ ~Sampler() override;
/// @returns the sampler type
SamplerKind kind() const { return kind_; }
diff --git a/src/ast/type/sampler_type_test.cc b/src/ast/type/sampler_type_test.cc
index 2353c8a..9641aec 100644
--- a/src/ast/type/sampler_type_test.cc
+++ b/src/ast/type/sampler_type_test.cc
@@ -32,49 +32,49 @@
namespace type {
namespace {
-using SamplerTypeTest = TestHelper;
+using SamplerTest = TestHelper;
-TEST_F(SamplerTypeTest, Creation) {
- SamplerType s{SamplerKind::kSampler};
+TEST_F(SamplerTest, Creation) {
+ Sampler s{SamplerKind::kSampler};
EXPECT_EQ(s.kind(), SamplerKind::kSampler);
}
-TEST_F(SamplerTypeTest, Creation_ComparisonSampler) {
- SamplerType s{SamplerKind::kComparisonSampler};
+TEST_F(SamplerTest, Creation_ComparisonSampler) {
+ Sampler s{SamplerKind::kComparisonSampler};
EXPECT_EQ(s.kind(), SamplerKind::kComparisonSampler);
EXPECT_TRUE(s.IsComparison());
}
-TEST_F(SamplerTypeTest, Is) {
- SamplerType s{SamplerKind::kSampler};
+TEST_F(SamplerTest, Is) {
+ Sampler s{SamplerKind::kSampler};
Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_TRUE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_TRUE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(SamplerTypeTest, TypeName_Sampler) {
- SamplerType s{SamplerKind::kSampler};
+TEST_F(SamplerTest, TypeName_Sampler) {
+ Sampler s{SamplerKind::kSampler};
EXPECT_EQ(s.type_name(), "__sampler_sampler");
}
-TEST_F(SamplerTypeTest, TypeName_Comparison) {
- SamplerType s{SamplerKind::kComparisonSampler};
+TEST_F(SamplerTest, TypeName_Comparison) {
+ Sampler s{SamplerKind::kComparisonSampler};
EXPECT_EQ(s.type_name(), "__sampler_comparison");
}
-TEST_F(SamplerTypeTest, MinBufferBindingSize) {
- SamplerType s{SamplerKind::kSampler};
+TEST_F(SamplerTest, MinBufferBindingSize) {
+ Sampler s{SamplerKind::kSampler};
EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/storage_texture_type.cc b/src/ast/type/storage_texture_type.cc
index 963e491..72fd648 100644
--- a/src/ast/type/storage_texture_type.cc
+++ b/src/ast/type/storage_texture_type.cc
@@ -150,26 +150,26 @@
return out;
}
-StorageTextureType::StorageTextureType(TextureDimension dim,
- AccessControl access,
- ImageFormat format)
+StorageTexture::StorageTexture(TextureDimension dim,
+ ast::AccessControl access,
+ ImageFormat format)
: Base(dim), access_(access), image_format_(format) {
assert(IsValidStorageDimension(dim));
}
-void StorageTextureType::set_type(Type* const type) {
+void StorageTexture::set_type(Type* const type) {
type_ = type;
}
-Type* StorageTextureType::type() const {
+Type* StorageTexture::type() const {
return type_;
}
-StorageTextureType::StorageTextureType(StorageTextureType&&) = default;
+StorageTexture::StorageTexture(StorageTexture&&) = default;
-StorageTextureType::~StorageTextureType() = default;
+StorageTexture::~StorageTexture() = default;
-std::string StorageTextureType::type_name() const {
+std::string StorageTexture::type_name() const {
std::ostringstream out;
out << "__storage_texture_" << access_ << "_" << dim() << "_"
<< image_format_;
diff --git a/src/ast/type/storage_texture_type.h b/src/ast/type/storage_texture_type.h
index 84d6e6e..d454539 100644
--- a/src/ast/type/storage_texture_type.h
+++ b/src/ast/type/storage_texture_type.h
@@ -66,19 +66,19 @@
std::ostream& operator<<(std::ostream& out, ImageFormat dim);
/// A storage texture type.
-class StorageTextureType : public Castable<StorageTextureType, TextureType> {
+class StorageTexture : public Castable<StorageTexture, Texture> {
public:
/// Constructor
/// @param dim the dimensionality of the texture
/// @param access the access type for the texture
/// @param format the image format of the texture
- StorageTextureType(TextureDimension dim,
- AccessControl access,
- ImageFormat format);
+ StorageTexture(TextureDimension dim,
+ ast::AccessControl access,
+ ImageFormat format);
/// Move constructor
- StorageTextureType(StorageTextureType&&);
- ~StorageTextureType() override;
+ StorageTexture(StorageTexture&&);
+ ~StorageTexture() override;
/// @param type the subtype of the storage texture
void set_type(Type* const type);
@@ -87,7 +87,7 @@
Type* type() const;
/// @returns the storage access
- AccessControl access() const { return access_; }
+ ast::AccessControl access() const { return access_; }
/// @returns the image format
ImageFormat image_format() const { return image_format_; }
@@ -97,7 +97,7 @@
private:
Type* type_ = nullptr;
- AccessControl access_ = AccessControl::kReadOnly;
+ ast::AccessControl access_ = ast::AccessControl::kReadOnly;
ImageFormat image_format_ = ImageFormat::kRgba32Float;
};
diff --git a/src/ast/type/storage_texture_type_test.cc b/src/ast/type/storage_texture_type_test.cc
index 2664f1d..6eb20a5 100644
--- a/src/ast/type/storage_texture_type_test.cc
+++ b/src/ast/type/storage_texture_type_test.cc
@@ -37,107 +37,105 @@
namespace type {
namespace {
-using StorageTextureTypeTest = TestHelper;
+using StorageTextureTest = TestHelper;
-TEST_F(StorageTextureTypeTest, Is) {
- StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly,
- ImageFormat::kRgba32Float);
+TEST_F(StorageTextureTest, Is) {
+ StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Float);
Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_TRUE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_TRUE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(StorageTextureTypeTest, IsTextureType) {
- StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly,
- ImageFormat::kRgba32Float);
- TextureType* ty = &s;
- EXPECT_FALSE(ty->Is<DepthTextureType>());
- EXPECT_FALSE(ty->Is<SampledTextureType>());
- EXPECT_TRUE(ty->Is<StorageTextureType>());
+TEST_F(StorageTextureTest, IsTexture) {
+ StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Float);
+ Texture* ty = &s;
+ EXPECT_FALSE(ty->Is<DepthTexture>());
+ EXPECT_FALSE(ty->Is<SampledTexture>());
+ EXPECT_TRUE(ty->Is<StorageTexture>());
}
-TEST_F(StorageTextureTypeTest, Dim) {
- StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly,
- ImageFormat::kRgba32Float);
+TEST_F(StorageTextureTest, Dim) {
+ StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Float);
EXPECT_EQ(s.dim(), TextureDimension::k2dArray);
}
-TEST_F(StorageTextureTypeTest, Access) {
- StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly,
- ImageFormat::kRgba32Float);
- EXPECT_EQ(s.access(), AccessControl::kReadOnly);
+TEST_F(StorageTextureTest, Access) {
+ StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Float);
+ EXPECT_EQ(s.access(), ast::AccessControl::kReadOnly);
}
-TEST_F(StorageTextureTypeTest, Format) {
- StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly,
- ImageFormat::kRgba32Float);
+TEST_F(StorageTextureTest, Format) {
+ StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Float);
EXPECT_EQ(s.image_format(), ImageFormat::kRgba32Float);
}
-TEST_F(StorageTextureTypeTest, TypeName) {
- StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly,
- ImageFormat::kRgba32Float);
+TEST_F(StorageTextureTest, TypeName) {
+ StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Float);
EXPECT_EQ(s.type_name(), "__storage_texture_read_only_2d_array_rgba32float");
}
-TEST_F(StorageTextureTypeTest, F32Type) {
+TEST_F(StorageTextureTest, F32) {
Context ctx;
Module mod;
- Type* s = mod.create<StorageTextureType>(TextureDimension::k2dArray,
- AccessControl::kReadOnly,
- ImageFormat::kRgba32Float);
+ Type* s = mod.create<StorageTexture>(TextureDimension::k2dArray,
+ ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Float);
TypeDeterminer td(&ctx, &mod);
ASSERT_TRUE(td.Determine()) << td.error();
- ASSERT_TRUE(s->Is<TextureType>());
- ASSERT_TRUE(s->Is<StorageTextureType>());
- EXPECT_TRUE(
- s->As<TextureType>()->As<StorageTextureType>()->type()->Is<F32Type>());
+ ASSERT_TRUE(s->Is<Texture>());
+ ASSERT_TRUE(s->Is<StorageTexture>());
+ EXPECT_TRUE(s->As<Texture>()->As<StorageTexture>()->type()->Is<F32>());
}
-TEST_F(StorageTextureTypeTest, U32Type) {
+TEST_F(StorageTextureTest, U32) {
Context ctx;
Module mod;
- Type* s = mod.create<StorageTextureType>(TextureDimension::k2dArray,
- AccessControl::kReadOnly,
- ImageFormat::kRg32Uint);
+ Type* s = mod.create<StorageTexture>(TextureDimension::k2dArray,
+ ast::AccessControl::kReadOnly,
+ ImageFormat::kRg32Uint);
TypeDeterminer td(&ctx, &mod);
ASSERT_TRUE(td.Determine()) << td.error();
- ASSERT_TRUE(s->Is<TextureType>());
- ASSERT_TRUE(s->Is<StorageTextureType>());
- EXPECT_TRUE(s->As<StorageTextureType>()->type()->Is<U32Type>());
+ ASSERT_TRUE(s->Is<Texture>());
+ ASSERT_TRUE(s->Is<StorageTexture>());
+ EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<U32>());
}
-TEST_F(StorageTextureTypeTest, I32Type) {
+TEST_F(StorageTextureTest, I32) {
Context ctx;
Module mod;
- Type* s = mod.create<StorageTextureType>(TextureDimension::k2dArray,
- AccessControl::kReadOnly,
- ImageFormat::kRgba32Sint);
+ Type* s = mod.create<StorageTexture>(TextureDimension::k2dArray,
+ ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Sint);
TypeDeterminer td(&ctx, &mod);
ASSERT_TRUE(td.Determine()) << td.error();
- ASSERT_TRUE(s->Is<TextureType>());
- ASSERT_TRUE(s->Is<StorageTextureType>());
- EXPECT_TRUE(
- s->As<TextureType>()->As<StorageTextureType>()->type()->Is<I32Type>());
+ ASSERT_TRUE(s->Is<Texture>());
+ ASSERT_TRUE(s->Is<StorageTexture>());
+ EXPECT_TRUE(s->As<Texture>()->As<StorageTexture>()->type()->Is<I32>());
}
-TEST_F(StorageTextureTypeTest, MinBufferBindingSize) {
- StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly,
- ImageFormat::kRgba32Sint);
+TEST_F(StorageTextureTest, MinBufferBindingSize) {
+ StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly,
+ ImageFormat::kRgba32Sint);
EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/struct_type.cc b/src/ast/type/struct_type.cc
index 3b107e4..fc8f110 100644
--- a/src/ast/type/struct_type.cc
+++ b/src/ast/type/struct_type.cc
@@ -26,18 +26,18 @@
namespace ast {
namespace type {
-StructType::StructType(const std::string& name, Struct* impl)
+Struct::Struct(const std::string& name, ast::Struct* impl)
: name_(name), struct_(impl) {}
-StructType::StructType(StructType&&) = default;
+Struct::Struct(Struct&&) = default;
-StructType::~StructType() = default;
+Struct::~Struct() = default;
-std::string StructType::type_name() const {
+std::string Struct::type_name() const {
return "__struct_" + name_;
}
-uint64_t StructType::MinBufferBindingSize(MemoryLayout mem_layout) const {
+uint64_t Struct::MinBufferBindingSize(MemoryLayout mem_layout) const {
if (!struct_->members().size()) {
return 0;
}
@@ -61,7 +61,7 @@
return static_cast<uint64_t>(alignment * std::ceil(unaligned / alignment));
}
-uint64_t StructType::BaseAlignment(MemoryLayout mem_layout) const {
+uint64_t Struct::BaseAlignment(MemoryLayout mem_layout) const {
uint64_t max = 0;
for (auto* member : struct_->members()) {
if (member->type()->BaseAlignment(mem_layout) > max) {
diff --git a/src/ast/type/struct_type.h b/src/ast/type/struct_type.h
index 18ed3ba..615468d 100644
--- a/src/ast/type/struct_type.h
+++ b/src/ast/type/struct_type.h
@@ -26,15 +26,15 @@
namespace type {
/// A structure type
-class StructType : public Castable<StructType, Type> {
+class Struct : public Castable<Struct, Type> {
public:
/// Constructor
/// @param name the name of the struct
/// @param impl the struct data
- StructType(const std::string& name, Struct* impl);
+ Struct(const std::string& name, ast::Struct* impl);
/// Move constructor
- StructType(StructType&&);
- ~StructType() override;
+ Struct(Struct&&);
+ ~Struct() override;
/// @returns the struct name
const std::string& name() const { return name_; }
@@ -43,7 +43,7 @@
bool IsBlockDecorated() const { return struct_->IsBlockDecorated(); }
/// @returns the struct name
- Struct* impl() const { return struct_; }
+ ast::Struct* impl() const { return struct_; }
/// @returns the name for the type
std::string type_name() const override;
@@ -60,7 +60,7 @@
private:
std::string name_;
- Struct* struct_ = nullptr;
+ ast::Struct* struct_ = nullptr;
uint64_t LargestMemberBaseAlignment(MemoryLayout mem_layout) const;
};
diff --git a/src/ast/type/struct_type_test.cc b/src/ast/type/struct_type_test.cc
index 1f5587e..1a915a2 100644
--- a/src/ast/type/struct_type_test.cc
+++ b/src/ast/type/struct_type_test.cc
@@ -37,42 +37,42 @@
namespace type {
namespace {
-using StructTypeTest = TestHelper;
+using StructTest = TestHelper;
-TEST_F(StructTypeTest, Creation) {
- auto* impl = create<Struct>();
+TEST_F(StructTest, Creation) {
+ auto* impl = create<ast::Struct>();
auto* ptr = impl;
- StructType s{"S", impl};
+ Struct s{"S", impl};
EXPECT_EQ(s.impl(), ptr);
}
-TEST_F(StructTypeTest, Is) {
- auto* impl = create<Struct>();
- StructType s{"S", impl};
+TEST_F(StructTest, Is) {
+ auto* impl = create<ast::Struct>();
+ Struct s{"S", impl};
Type* ty = &s;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_TRUE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_TRUE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(StructTypeTest, TypeName) {
- auto* impl = create<Struct>();
- StructType s{"my_struct", impl};
+TEST_F(StructTest, TypeName) {
+ auto* impl = create<ast::Struct>();
+ Struct s{"my_struct", impl};
EXPECT_EQ(s.type_name(), "__struct_my_struct");
}
-TEST_F(StructTypeTest, MinBufferBindingSize) {
- U32Type u32;
+TEST_F(StructTest, MinBufferBindingSize) {
+ U32 u32;
StructMemberList members;
{
@@ -87,16 +87,16 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, MinBufferBindingSizeArray) {
- U32Type u32;
- ArrayType arr(&u32, 4);
+TEST_F(StructTest, MinBufferBindingSizeArray) {
+ U32 u32;
+ Array arr(&u32, 4);
{
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
@@ -121,17 +121,17 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(32u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(24u,
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) {
- U32Type u32;
- ArrayType arr(&u32);
+TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) {
+ U32 u32;
+ Array arr(&u32);
{
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
@@ -156,15 +156,15 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(12u,
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, MinBufferBindingSizeVec2) {
- U32Type u32;
- VectorType vec2(&u32, 2);
+TEST_F(StructTest, MinBufferBindingSizeVec2) {
+ U32 u32;
+ Vector vec2(&u32, 2);
StructMemberList members;
{
@@ -174,16 +174,16 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, MinBufferBindingSizeVec3) {
- U32Type u32;
- VectorType vec3(&u32, 3);
+TEST_F(StructTest, MinBufferBindingSizeVec3) {
+ U32 u32;
+ Vector vec3(&u32, 3);
StructMemberList members;
{
@@ -193,17 +193,17 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, MinBufferBindingSizeVec4) {
- U32Type u32;
- VectorType vec4(&u32, 4);
+TEST_F(StructTest, MinBufferBindingSizeVec4) {
+ U32 u32;
+ Vector vec4(&u32, 4);
StructMemberList members;
{
@@ -213,16 +213,16 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, BaseAlignment) {
- U32Type u32;
+TEST_F(StructTest, BaseAlignment) {
+ U32 u32;
StructMemberList members;
{
@@ -237,15 +237,15 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, BaseAlignmentArray) {
- U32Type u32;
- ArrayType arr(&u32, 4);
+TEST_F(StructTest, BaseAlignmentArray) {
+ U32 u32;
+ Array arr(&u32, 4);
{
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
@@ -270,15 +270,15 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) {
- U32Type u32;
- ArrayType arr(&u32);
+TEST_F(StructTest, BaseAlignmentRuntimeArray) {
+ U32 u32;
+ Array arr(&u32);
{
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
@@ -303,14 +303,14 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, BaseAlignmentVec2) {
- U32Type u32;
- VectorType vec2(&u32, 2);
+TEST_F(StructTest, BaseAlignmentVec2) {
+ U32 u32;
+ Vector vec2(&u32, 2);
StructMemberList members;
{
@@ -320,15 +320,15 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, BaseAlignmentVec3) {
- U32Type u32;
- VectorType vec3(&u32, 3);
+TEST_F(StructTest, BaseAlignmentVec3) {
+ U32 u32;
+ Vector vec3(&u32, 3);
StructMemberList members;
{
@@ -338,15 +338,15 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
}
-TEST_F(StructTypeTest, BaseAlignmentVec4) {
- U32Type u32;
- VectorType vec4(&u32, 4);
+TEST_F(StructTest, BaseAlignmentVec4) {
+ U32 u32;
+ Vector vec4(&u32, 4);
StructMemberList members;
{
@@ -356,8 +356,8 @@
}
StructDecorationList decos;
- auto* str = create<Struct>(decos, members);
- StructType struct_type("struct_type", str);
+ auto* str = create<ast::Struct>(decos, members);
+ Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
}
diff --git a/src/ast/type/texture_type.cc b/src/ast/type/texture_type.cc
index 453dcd0..cd81de5 100644
--- a/src/ast/type/texture_type.cc
+++ b/src/ast/type/texture_type.cc
@@ -53,11 +53,11 @@
return out;
}
-TextureType::TextureType(TextureDimension dim) : dim_(dim) {}
+Texture::Texture(TextureDimension dim) : dim_(dim) {}
-TextureType::TextureType(TextureType&&) = default;
+Texture::Texture(Texture&&) = default;
-TextureType::~TextureType() = default;
+Texture::~Texture() = default;
} // namespace type
} // namespace ast
diff --git a/src/ast/type/texture_type.h b/src/ast/type/texture_type.h
index aa8db9f..59c1ccf 100644
--- a/src/ast/type/texture_type.h
+++ b/src/ast/type/texture_type.h
@@ -46,14 +46,14 @@
std::ostream& operator<<(std::ostream& out, TextureDimension dim);
/// A texture type.
-class TextureType : public Castable<TextureType, Type> {
+class Texture : public Castable<Texture, Type> {
public:
/// Constructor
/// @param dim the dimensionality of the texture
- explicit TextureType(TextureDimension dim);
+ explicit Texture(TextureDimension dim);
/// Move constructor
- TextureType(TextureType&&);
- ~TextureType() override;
+ Texture(Texture&&);
+ ~Texture() override;
/// @returns the texture dimension
TextureDimension dim() const { return dim_; }
diff --git a/src/ast/type/type.cc b/src/ast/type/type.cc
index 27d8a49..e1d7b1a 100644
--- a/src/ast/type/type.cc
+++ b/src/ast/type/type.cc
@@ -42,8 +42,8 @@
Type::~Type() = default;
Type* Type::UnwrapPtrIfNeeded() {
- if (Is<PointerType>()) {
- return As<PointerType>()->type();
+ if (Is<Pointer>()) {
+ return As<Pointer>()->type();
}
return this;
}
@@ -51,10 +51,10 @@
Type* Type::UnwrapIfNeeded() {
auto* where = this;
while (true) {
- if (where->Is<AliasType>()) {
- where = where->As<AliasType>()->type();
- } else if (where->Is<AccessControlType>()) {
- where = where->As<AccessControlType>()->type();
+ if (where->Is<Alias>()) {
+ where = where->As<Alias>()->type();
+ } else if (where->Is<AccessControl>()) {
+ where = where->As<AccessControl>()->type();
} else {
break;
}
@@ -75,19 +75,19 @@
}
bool Type::is_scalar() {
- return is_float_scalar() || is_integer_scalar() || Is<BoolType>();
+ return is_float_scalar() || is_integer_scalar() || Is<Bool>();
}
bool Type::is_float_scalar() {
- return Is<F32Type>();
+ return Is<F32>();
}
bool Type::is_float_matrix() {
- return Is<MatrixType>() && As<MatrixType>()->type()->is_float_scalar();
+ return Is<Matrix>() && As<Matrix>()->type()->is_float_scalar();
}
bool Type::is_float_vector() {
- return Is<VectorType>() && As<VectorType>()->type()->is_float_scalar();
+ return Is<Vector>() && As<Vector>()->type()->is_float_scalar();
}
bool Type::is_float_scalar_or_vector() {
@@ -95,25 +95,23 @@
}
bool Type::is_integer_scalar() {
- return Is<U32Type>() || Is<I32Type>();
+ return Is<U32>() || Is<I32>();
}
bool Type::is_unsigned_integer_vector() {
- return Is<VectorType>() && As<VectorType>()->type()->Is<U32Type>();
+ return Is<Vector>() && As<Vector>()->type()->Is<U32>();
}
bool Type::is_signed_integer_vector() {
- return Is<VectorType>() && As<VectorType>()->type()->Is<I32Type>();
+ return Is<Vector>() && As<Vector>()->type()->Is<I32>();
}
bool Type::is_unsigned_scalar_or_vector() {
- return Is<U32Type>() ||
- (Is<VectorType>() && As<VectorType>()->type()->Is<U32Type>());
+ return Is<U32>() || (Is<Vector>() && As<Vector>()->type()->Is<U32>());
}
bool Type::is_signed_scalar_or_vector() {
- return Is<I32Type>() ||
- (Is<VectorType>() && As<VectorType>()->type()->Is<I32Type>());
+ return Is<I32>() || (Is<Vector>() && As<Vector>()->type()->Is<I32>());
}
bool Type::is_integer_scalar_or_vector() {
diff --git a/src/ast/type/u32_type.cc b/src/ast/type/u32_type.cc
index baaffd2..97cf951 100644
--- a/src/ast/type/u32_type.cc
+++ b/src/ast/type/u32_type.cc
@@ -18,21 +18,21 @@
namespace ast {
namespace type {
-U32Type::U32Type() = default;
+U32::U32() = default;
-U32Type::~U32Type() = default;
+U32::~U32() = default;
-U32Type::U32Type(U32Type&&) = default;
+U32::U32(U32&&) = default;
-std::string U32Type::type_name() const {
+std::string U32::type_name() const {
return "__u32";
}
-uint64_t U32Type::MinBufferBindingSize(MemoryLayout) const {
+uint64_t U32::MinBufferBindingSize(MemoryLayout) const {
return 4;
}
-uint64_t U32Type::BaseAlignment(MemoryLayout) const {
+uint64_t U32::BaseAlignment(MemoryLayout) const {
return 4;
}
diff --git a/src/ast/type/u32_type.h b/src/ast/type/u32_type.h
index 35e4b91..9decaa3 100644
--- a/src/ast/type/u32_type.h
+++ b/src/ast/type/u32_type.h
@@ -24,13 +24,13 @@
namespace type {
/// A unsigned int 32 type.
-class U32Type : public Castable<U32Type, Type> {
+class U32 : public Castable<U32, Type> {
public:
/// Constructor
- U32Type();
+ U32();
/// Move constructor
- U32Type(U32Type&&);
- ~U32Type() override;
+ U32(U32&&);
+ ~U32() override;
/// @returns the name for th type
std::string type_name() const override;
diff --git a/src/ast/type/u32_type_test.cc b/src/ast/type/u32_type_test.cc
index 19802b5..bf3a56b 100644
--- a/src/ast/type/u32_type_test.cc
+++ b/src/ast/type/u32_type_test.cc
@@ -32,38 +32,38 @@
namespace type {
namespace {
-using U32TypeTest = TestHelper;
+using U32Test = TestHelper;
-TEST_F(U32TypeTest, Is) {
- U32Type u;
+TEST_F(U32Test, Is) {
+ U32 u;
Type* ty = &u;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_TRUE(ty->Is<U32Type>());
- EXPECT_FALSE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_TRUE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
}
-TEST_F(U32TypeTest, TypeName) {
- U32Type u;
+TEST_F(U32Test, TypeName) {
+ U32 u;
EXPECT_EQ(u.type_name(), "__u32");
}
-TEST_F(U32TypeTest, MinBufferBindingSize) {
- U32Type u;
+TEST_F(U32Test, MinBufferBindingSize) {
+ U32 u;
EXPECT_EQ(4u, u.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(U32TypeTest, BaseAlignment) {
- U32Type u;
+TEST_F(U32Test, BaseAlignment) {
+ U32 u;
EXPECT_EQ(4u, u.BaseAlignment(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/vector_type.cc b/src/ast/type/vector_type.cc
index 14614c3..c2dfaa5 100644
--- a/src/ast/type/vector_type.cc
+++ b/src/ast/type/vector_type.cc
@@ -21,25 +21,24 @@
namespace ast {
namespace type {
-VectorType::VectorType(Type* subtype, uint32_t size)
- : subtype_(subtype), size_(size) {
+Vector::Vector(Type* subtype, uint32_t size) : subtype_(subtype), size_(size) {
assert(size_ > 1);
assert(size_ < 5);
}
-VectorType::VectorType(VectorType&&) = default;
+Vector::Vector(Vector&&) = default;
-VectorType::~VectorType() = default;
+Vector::~Vector() = default;
-std::string VectorType::type_name() const {
+std::string Vector::type_name() const {
return "__vec_" + std::to_string(size_) + subtype_->type_name();
}
-uint64_t VectorType::MinBufferBindingSize(MemoryLayout mem_layout) const {
+uint64_t Vector::MinBufferBindingSize(MemoryLayout mem_layout) const {
return size_ * subtype_->MinBufferBindingSize(mem_layout);
}
-uint64_t VectorType::BaseAlignment(MemoryLayout mem_layout) const {
+uint64_t Vector::BaseAlignment(MemoryLayout mem_layout) const {
if (size_ == 2) {
return 2 * subtype_->BaseAlignment(mem_layout);
} else if (size_ == 3 || size_ == 4) {
diff --git a/src/ast/type/vector_type.h b/src/ast/type/vector_type.h
index c09d75e..2186774 100644
--- a/src/ast/type/vector_type.h
+++ b/src/ast/type/vector_type.h
@@ -24,15 +24,15 @@
namespace type {
/// A vector type.
-class VectorType : public Castable<VectorType, Type> {
+class Vector : public Castable<Vector, Type> {
public:
/// Constructor
/// @param subtype the vector element type
/// @param size the number of elements in the vector
- VectorType(Type* subtype, uint32_t size);
+ Vector(Type* subtype, uint32_t size);
/// Move constructor
- VectorType(VectorType&&);
- ~VectorType() override;
+ Vector(Vector&&);
+ ~Vector() override;
/// @returns the type of the vector elements
Type* type() const { return subtype_; }
diff --git a/src/ast/type/vector_type_test.cc b/src/ast/type/vector_type_test.cc
index 14c88cd..9b885ae 100644
--- a/src/ast/type/vector_type_test.cc
+++ b/src/ast/type/vector_type_test.cc
@@ -31,73 +31,73 @@
namespace type {
namespace {
-using VectorTypeTest = TestHelper;
+using VectorTest = TestHelper;
-TEST_F(VectorTypeTest, Creation) {
- I32Type i32;
- VectorType v{&i32, 2};
+TEST_F(VectorTest, Creation) {
+ I32 i32;
+ Vector v{&i32, 2};
EXPECT_EQ(v.type(), &i32);
EXPECT_EQ(v.size(), 2u);
}
-TEST_F(VectorTypeTest, Is) {
- I32Type i32;
- VectorType v{&i32, 4};
+TEST_F(VectorTest, Is) {
+ I32 i32;
+ Vector v{&i32, 4};
Type* ty = &v;
- EXPECT_FALSE(ty->Is<AccessControlType>());
- EXPECT_FALSE(ty->Is<AliasType>());
- EXPECT_FALSE(ty->Is<ArrayType>());
- EXPECT_FALSE(ty->Is<BoolType>());
- EXPECT_FALSE(ty->Is<F32Type>());
- EXPECT_FALSE(ty->Is<I32Type>());
- EXPECT_FALSE(ty->Is<MatrixType>());
- EXPECT_FALSE(ty->Is<PointerType>());
- EXPECT_FALSE(ty->Is<SamplerType>());
- EXPECT_FALSE(ty->Is<StructType>());
- EXPECT_FALSE(ty->Is<TextureType>());
- EXPECT_FALSE(ty->Is<U32Type>());
- EXPECT_TRUE(ty->Is<VectorType>());
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_TRUE(ty->Is<Vector>());
}
-TEST_F(VectorTypeTest, TypeName) {
- I32Type i32;
- VectorType v{&i32, 3};
+TEST_F(VectorTest, TypeName) {
+ I32 i32;
+ Vector v{&i32, 3};
EXPECT_EQ(v.type_name(), "__vec_3__i32");
}
-TEST_F(VectorTypeTest, MinBufferBindingSizeVec2) {
- I32Type i32;
- VectorType v{&i32, 2};
+TEST_F(VectorTest, MinBufferBindingSizeVec2) {
+ I32 i32;
+ Vector v{&i32, 2};
EXPECT_EQ(8u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(VectorTypeTest, MinBufferBindingSizeVec3) {
- I32Type i32;
- VectorType v{&i32, 3};
+TEST_F(VectorTest, MinBufferBindingSizeVec3) {
+ I32 i32;
+ Vector v{&i32, 3};
EXPECT_EQ(12u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(VectorTypeTest, MinBufferBindingSizeVec4) {
- I32Type i32;
- VectorType v{&i32, 4};
+TEST_F(VectorTest, MinBufferBindingSizeVec4) {
+ I32 i32;
+ Vector v{&i32, 4};
EXPECT_EQ(16u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
-TEST_F(VectorTypeTest, BaseAlignmentVec2) {
- I32Type i32;
- VectorType v{&i32, 2};
+TEST_F(VectorTest, BaseAlignmentVec2) {
+ I32 i32;
+ Vector v{&i32, 2};
EXPECT_EQ(8u, v.BaseAlignment(MemoryLayout::kUniformBuffer));
}
-TEST_F(VectorTypeTest, BaseAlignmentVec3) {
- I32Type i32;
- VectorType v{&i32, 3};
+TEST_F(VectorTest, BaseAlignmentVec3) {
+ I32 i32;
+ Vector v{&i32, 3};
EXPECT_EQ(16u, v.BaseAlignment(MemoryLayout::kUniformBuffer));
}
-TEST_F(VectorTypeTest, BaseAlignmentVec4) {
- I32Type i32;
- VectorType v{&i32, 4};
+TEST_F(VectorTest, BaseAlignmentVec4) {
+ I32 i32;
+ Vector v{&i32, 4};
EXPECT_EQ(16u, v.BaseAlignment(MemoryLayout::kUniformBuffer));
}
diff --git a/src/ast/type/void_type.cc b/src/ast/type/void_type.cc
index ea0ccf6..66fc7c6 100644
--- a/src/ast/type/void_type.cc
+++ b/src/ast/type/void_type.cc
@@ -18,13 +18,13 @@
namespace ast {
namespace type {
-VoidType::VoidType() = default;
+Void::Void() = default;
-VoidType::VoidType(VoidType&&) = default;
+Void::Void(Void&&) = default;
-VoidType::~VoidType() = default;
+Void::~Void() = default;
-std::string VoidType::type_name() const {
+std::string Void::type_name() const {
return "__void";
}
diff --git a/src/ast/type/void_type.h b/src/ast/type/void_type.h
index 5099e8b..16d9193 100644
--- a/src/ast/type/void_type.h
+++ b/src/ast/type/void_type.h
@@ -24,13 +24,13 @@
namespace type {
/// A void type
-class VoidType : public Castable<VoidType, Type> {
+class Void : public Castable<Void, Type> {
public:
/// Constructor
- VoidType();
+ Void();
/// Move constructor
- VoidType(VoidType&&);
- ~VoidType() override;
+ Void(Void&&);
+ ~Void() override;
/// @returns the name for this type
std::string type_name() const override;
diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc
index 517b109..477faf5 100644
--- a/src/ast/type_constructor_expression_test.cc
+++ b/src/ast/type_constructor_expression_test.cc
@@ -30,7 +30,7 @@
using TypeConstructorExpressionTest = TestHelper;
TEST_F(TypeConstructorExpressionTest, Creation) {
- type::F32Type f32;
+ type::F32 f32;
ExpressionList expr;
expr.push_back(create<IdentifierExpression>("expr"));
@@ -41,7 +41,7 @@
}
TEST_F(TypeConstructorExpressionTest, Creation_WithSource) {
- type::F32Type f32;
+ type::F32 f32;
ExpressionList expr;
expr.push_back(create<IdentifierExpression>("expr"));
@@ -57,7 +57,7 @@
}
TEST_F(TypeConstructorExpressionTest, IsValid) {
- type::F32Type f32;
+ type::F32 f32;
ExpressionList expr;
expr.push_back(create<IdentifierExpression>("expr"));
@@ -66,7 +66,7 @@
}
TEST_F(TypeConstructorExpressionTest, IsValid_EmptyValue) {
- type::F32Type f32;
+ type::F32 f32;
ExpressionList expr;
TypeConstructorExpression t(&f32, expr);
@@ -83,7 +83,7 @@
}
TEST_F(TypeConstructorExpressionTest, IsValid_NullValue) {
- type::F32Type f32;
+ type::F32 f32;
ExpressionList expr;
expr.push_back(create<IdentifierExpression>("expr"));
expr.push_back(nullptr);
@@ -93,7 +93,7 @@
}
TEST_F(TypeConstructorExpressionTest, IsValid_InvalidValue) {
- type::F32Type f32;
+ type::F32 f32;
ExpressionList expr;
expr.push_back(create<IdentifierExpression>(""));
@@ -102,8 +102,8 @@
}
TEST_F(TypeConstructorExpressionTest, ToStr) {
- type::F32Type f32;
- type::VectorType vec(&f32, 3);
+ type::F32 f32;
+ type::Vector vec(&f32, 3);
ExpressionList expr;
expr.push_back(create<IdentifierExpression>("expr_1"));
expr.push_back(create<IdentifierExpression>("expr_2"));
diff --git a/src/ast/type_manager_test.cc b/src/ast/type_manager_test.cc
index adced4b..f78a61f 100644
--- a/src/ast/type_manager_test.cc
+++ b/src/ast/type_manager_test.cc
@@ -27,43 +27,43 @@
TEST_F(TypeManagerTest, GetUnregistered) {
TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32Type>());
+ auto* t = tm.Get(std::make_unique<type::I32>());
ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32Type>());
+ EXPECT_TRUE(t->Is<type::I32>());
}
TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32Type>());
+ auto* t = tm.Get(std::make_unique<type::I32>());
ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32Type>());
+ EXPECT_TRUE(t->Is<type::I32>());
- auto* t2 = tm.Get(std::make_unique<type::I32Type>());
+ auto* t2 = tm.Get(std::make_unique<type::I32>());
EXPECT_EQ(t, t2);
}
TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32Type>());
+ auto* t = tm.Get(std::make_unique<type::I32>());
ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32Type>());
+ EXPECT_TRUE(t->Is<type::I32>());
- auto* t2 = tm.Get(std::make_unique<type::U32Type>());
+ auto* t2 = tm.Get(std::make_unique<type::U32>());
ASSERT_NE(t2, nullptr);
EXPECT_NE(t, t2);
- EXPECT_TRUE(t2->Is<type::U32Type>());
+ EXPECT_TRUE(t2->Is<type::U32>());
}
TEST_F(TypeManagerTest, ResetClearsPreviousData) {
TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32Type>());
+ auto* t = tm.Get(std::make_unique<type::I32>());
ASSERT_NE(t, nullptr);
EXPECT_FALSE(tm.types().empty());
tm.Reset();
EXPECT_TRUE(tm.types().empty());
- auto* t2 = tm.Get(std::make_unique<type::I32Type>());
+ auto* t2 = tm.Get(std::make_unique<type::I32>());
ASSERT_NE(t2, nullptr);
}
diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc
index 218c64f..579fdca 100644
--- a/src/ast/uint_literal_test.cc
+++ b/src/ast/uint_literal_test.cc
@@ -28,14 +28,14 @@
using UintLiteralTest = TestHelper;
TEST_F(UintLiteralTest, Value) {
- type::U32Type u32;
+ type::U32 u32;
UintLiteral u{&u32, 47};
ASSERT_TRUE(u.Is<UintLiteral>());
EXPECT_EQ(u.value(), 47u);
}
TEST_F(UintLiteralTest, Is) {
- type::U32Type u32;
+ type::U32 u32;
UintLiteral u{&u32, 42};
Literal* l = &u;
EXPECT_FALSE(l->Is<BoolLiteral>());
@@ -46,7 +46,7 @@
}
TEST_F(UintLiteralTest, ToStr) {
- type::U32Type u32;
+ type::U32 u32;
UintLiteral i{&u32, 42};
EXPECT_EQ(i.to_str(), "42");
diff --git a/src/ast/variable_decl_statement_test.cc b/src/ast/variable_decl_statement_test.cc
index 9b5f907..afd1538 100644
--- a/src/ast/variable_decl_statement_test.cc
+++ b/src/ast/variable_decl_statement_test.cc
@@ -25,7 +25,7 @@
using VariableDeclStatementTest = TestHelper;
TEST_F(VariableDeclStatementTest, Creation) {
- type::F32Type f32;
+ type::F32 f32;
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
VariableDeclStatement stmt(var);
@@ -33,7 +33,7 @@
}
TEST_F(VariableDeclStatementTest, Creation_WithSource) {
- type::F32Type f32;
+ type::F32 f32;
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
VariableDeclStatement stmt(Source{Source::Location{20, 2}}, var);
@@ -48,14 +48,14 @@
}
TEST_F(VariableDeclStatementTest, IsValid) {
- type::F32Type f32;
+ type::F32 f32;
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
VariableDeclStatement stmt(var);
EXPECT_TRUE(stmt.IsValid());
}
TEST_F(VariableDeclStatementTest, IsValid_InvalidVariable) {
- type::F32Type f32;
+ type::F32 f32;
auto* var = create<Variable>("", StorageClass::kNone, &f32);
VariableDeclStatement stmt(var);
EXPECT_FALSE(stmt.IsValid());
@@ -67,7 +67,7 @@
}
TEST_F(VariableDeclStatementTest, ToStr) {
- type::F32Type f32;
+ type::F32 f32;
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
VariableDeclStatement stmt(Source{Source::Location{20, 2}}, var);
diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc
index 0643b84..0b8bf9b 100644
--- a/src/ast/variable_test.cc
+++ b/src/ast/variable_test.cc
@@ -26,7 +26,7 @@
using VariableTest = TestHelper;
TEST_F(VariableTest, Creation) {
- type::I32Type t;
+ type::I32 t;
Variable v("my_var", StorageClass::kFunction, &t);
EXPECT_EQ(v.name(), "my_var");
@@ -40,7 +40,7 @@
TEST_F(VariableTest, CreationWithSource) {
Source s{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}};
- type::F32Type t;
+ type::F32 t;
Variable v(s, "i", StorageClass::kPrivate, &t);
EXPECT_EQ(v.name(), "i");
@@ -59,7 +59,7 @@
v.set_storage_class(StorageClass::kWorkgroup);
v.set_name("a_var");
- type::I32Type t;
+ type::I32 t;
v.set_type(&t);
EXPECT_EQ(v.name(), "a_var");
@@ -72,20 +72,20 @@
}
TEST_F(VariableTest, IsValid) {
- type::I32Type t;
+ type::I32 t;
Variable v{"my_var", StorageClass::kNone, &t};
EXPECT_TRUE(v.IsValid());
}
TEST_F(VariableTest, IsValid_WithConstructor) {
- type::I32Type t;
+ type::I32 t;
Variable v{"my_var", StorageClass::kNone, &t};
v.set_constructor(create<IdentifierExpression>("ident"));
EXPECT_TRUE(v.IsValid());
}
TEST_F(VariableTest, IsValid_MissinName) {
- type::I32Type t;
+ type::I32 t;
Variable v{"", StorageClass::kNone, &t};
EXPECT_FALSE(v.IsValid());
}
@@ -101,14 +101,14 @@
}
TEST_F(VariableTest, IsValid_InvalidConstructor) {
- type::I32Type t;
+ type::I32 t;
Variable v{"my_var", StorageClass::kNone, &t};
v.set_constructor(create<IdentifierExpression>(""));
EXPECT_FALSE(v.IsValid());
}
TEST_F(VariableTest, to_str) {
- type::F32Type t;
+ type::F32 t;
Variable v{"my_var", StorageClass::kFunction, &t};
std::ostringstream out;
v.to_str(out, 2);
diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc
index 596420e..7f18ed4 100644
--- a/src/inspector/inspector.cc
+++ b/src/inspector/inspector.cc
@@ -185,16 +185,16 @@
ast::Variable* var = nullptr;
ast::Function::BindingInfo binding_info;
std::tie(var, binding_info) = ruv;
- if (!var->type()->Is<ast::type::AccessControlType>()) {
+ if (!var->type()->Is<ast::type::AccessControl>()) {
continue;
}
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
- if (!unwrapped_type->Is<ast::type::StructType>()) {
+ if (!unwrapped_type->Is<ast::type::Struct>()) {
continue;
}
- if (!unwrapped_type->As<ast::type::StructType>()->IsBlockDecorated()) {
+ if (!unwrapped_type->As<ast::type::Struct>()->IsBlockDecorated()) {
continue;
}
@@ -307,16 +307,16 @@
ast::Variable* var = nullptr;
ast::Function::BindingInfo binding_info;
std::tie(var, binding_info) = rsv;
- if (!var->type()->Is<ast::type::AccessControlType>()) {
+ if (!var->type()->Is<ast::type::AccessControl>()) {
continue;
}
- auto* ac_type = var->type()->As<ast::type::AccessControlType>();
+ auto* ac_type = var->type()->As<ast::type::AccessControl>();
if (read_only != ac_type->IsReadOnly()) {
continue;
}
- if (!var->type()->UnwrapIfNeeded()->Is<ast::type::StructType>()) {
+ if (!var->type()->UnwrapIfNeeded()->Is<ast::type::Struct>()) {
continue;
}
@@ -353,7 +353,7 @@
entry.binding = binding_info.binding->value();
auto* texture_type =
- var->type()->UnwrapIfNeeded()->As<ast::type::TextureType>();
+ var->type()->UnwrapIfNeeded()->As<ast::type::Texture>();
switch (texture_type->dim()) {
case ast::type::TextureDimension::k1d:
entry.dim = ResourceBinding::TextureDimension::k1d;
@@ -383,28 +383,28 @@
ast::type::Type* base_type = nullptr;
if (multisampled_only) {
- base_type = texture_type->As<ast::type::MultisampledTextureType>()
+ base_type = texture_type->As<ast::type::MultisampledTexture>()
->type()
->UnwrapIfNeeded();
} else {
- base_type = texture_type->As<ast::type::SampledTextureType>()
+ base_type = texture_type->As<ast::type::SampledTexture>()
->type()
->UnwrapIfNeeded();
}
- if (base_type->Is<ast::type::ArrayType>()) {
- base_type = base_type->As<ast::type::ArrayType>()->type();
- } else if (base_type->Is<ast::type::MatrixType>()) {
- base_type = base_type->As<ast::type::MatrixType>()->type();
- } else if (base_type->Is<ast::type::VectorType>()) {
- base_type = base_type->As<ast::type::VectorType>()->type();
+ if (base_type->Is<ast::type::Array>()) {
+ base_type = base_type->As<ast::type::Array>()->type();
+ } else if (base_type->Is<ast::type::Matrix>()) {
+ base_type = base_type->As<ast::type::Matrix>()->type();
+ } else if (base_type->Is<ast::type::Vector>()) {
+ base_type = base_type->As<ast::type::Vector>()->type();
}
- if (base_type->Is<ast::type::F32Type>()) {
+ if (base_type->Is<ast::type::F32>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kFloat;
- } else if (base_type->Is<ast::type::U32Type>()) {
+ } else if (base_type->Is<ast::type::U32>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kUInt;
- } else if (base_type->Is<ast::type::I32Type>()) {
+ } else if (base_type->Is<ast::type::I32>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kSInt;
} else {
entry.sampled_kind = ResourceBinding::SampledKind::kUnknown;
diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc
index eb2a3a0..f463ba3 100644
--- a/src/inspector/inspector_test.cc
+++ b/src/inspector/inspector_test.cc
@@ -244,7 +244,7 @@
/// type and offset of a member of the struct
/// @param is_block whether or not to decorate as a Block
/// @returns a struct type
- std::unique_ptr<ast::type::StructType> MakeStructType(
+ std::unique_ptr<ast::type::Struct> MakeStructType(
const std::string& name,
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info,
bool is_block) {
@@ -269,7 +269,7 @@
auto* str = create<ast::Struct>(decos, members);
- return std::make_unique<ast::type::StructType>(name, str);
+ return std::make_unique<ast::type::Struct>(name, str);
}
/// Generates types appropriate for using in an uniform buffer
@@ -279,13 +279,13 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for an uniform buffer, and the control type wraps the
/// struct.
- std::tuple<std::unique_ptr<ast::type::StructType>,
- std::unique_ptr<ast::type::AccessControlType>>
+ std::tuple<std::unique_ptr<ast::type::Struct>,
+ std::unique_ptr<ast::type::AccessControl>>
MakeUniformBufferTypes(
const std::string& name,
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
auto struct_type = MakeStructType(name, members_info, true);
- auto access_type = std::make_unique<ast::type::AccessControlType>(
+ auto access_type = std::make_unique<ast::type::AccessControl>(
ast::AccessControl::kReadOnly, struct_type.get());
return {std::move(struct_type), std::move(access_type)};
}
@@ -297,13 +297,13 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for a storage buffer, and the control type wraps the
/// struct.
- std::tuple<std::unique_ptr<ast::type::StructType>,
- std::unique_ptr<ast::type::AccessControlType>>
+ std::tuple<std::unique_ptr<ast::type::Struct>,
+ std::unique_ptr<ast::type::AccessControl>>
MakeStorageBufferTypes(
const std::string& name,
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
auto struct_type = MakeStructType(name, members_info, false);
- auto access_type = std::make_unique<ast::type::AccessControlType>(
+ auto access_type = std::make_unique<ast::type::AccessControl>(
ast::AccessControl::kReadWrite, struct_type.get());
return {std::move(struct_type), std::move(access_type)};
}
@@ -315,13 +315,13 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for a read-only storage buffer, and the control type
/// wraps the struct.
- std::tuple<std::unique_ptr<ast::type::StructType>,
- std::unique_ptr<ast::type::AccessControlType>>
+ std::tuple<std::unique_ptr<ast::type::Struct>,
+ std::unique_ptr<ast::type::AccessControl>>
MakeReadOnlyStorageBufferTypes(
const std::string& name,
std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
auto struct_type = MakeStructType(name, members_info, false);
- auto access_type = std::make_unique<ast::type::AccessControlType>(
+ auto access_type = std::make_unique<ast::type::AccessControl>(
ast::AccessControl::kReadOnly, struct_type.get());
return {std::move(struct_type), std::move(access_type)};
}
@@ -429,32 +429,32 @@
ast::StorageClass::kUniformConstant, set, binding);
}
- /// Generates a SampledTextureType appropriate for the params
+ /// Generates a SampledTexture appropriate for the params
/// @param dim the dimensions of the texture
/// @param type the data type of the sampled texture
/// @returns the generated SampleTextureType
- std::unique_ptr<ast::type::SampledTextureType> MakeSampledTextureType(
+ std::unique_ptr<ast::type::SampledTexture> MakeSampledTextureType(
ast::type::TextureDimension dim,
ast::type::Type* type) {
- return std::make_unique<ast::type::SampledTextureType>(dim, type);
+ return std::make_unique<ast::type::SampledTexture>(dim, type);
}
- /// Generates a DepthTextureType appropriate for the params
+ /// Generates a DepthTexture appropriate for the params
/// @param dim the dimensions of the texture
- /// @returns the generated DepthTextureType
- std::unique_ptr<ast::type::DepthTextureType> MakeDepthTextureType(
+ /// @returns the generated DepthTexture
+ std::unique_ptr<ast::type::DepthTexture> MakeDepthTextureType(
ast::type::TextureDimension dim) {
- return std::make_unique<ast::type::DepthTextureType>(dim);
+ return std::make_unique<ast::type::DepthTexture>(dim);
}
- /// Generates a MultisampledTextureType appropriate for the params
+ /// Generates a MultisampledTexture appropriate for the params
/// @param dim the dimensions of the texture
/// @param type the data type of the sampled texture
/// @returns the generated SampleTextureType
- std::unique_ptr<ast::type::MultisampledTextureType>
- MakeMultisampledTextureType(ast::type::TextureDimension dim,
- ast::type::Type* type) {
- return std::make_unique<ast::type::MultisampledTextureType>(dim, type);
+ std::unique_ptr<ast::type::MultisampledTexture> MakeMultisampledTextureType(
+ ast::type::TextureDimension dim,
+ ast::type::Type* type) {
+ return std::make_unique<ast::type::MultisampledTexture>(dim, type);
}
/// Adds a sampled texture variable to the module
@@ -645,31 +645,31 @@
TypeDeterminer* td() { return td_.get(); }
Inspector* inspector() { return inspector_.get(); }
- ast::type::BoolType* bool_type() { return &bool_type_; }
- ast::type::F32Type* f32_type() { return &f32_type_; }
- ast::type::I32Type* i32_type() { return &i32_type_; }
- ast::type::U32Type* u32_type() { return &u32_type_; }
- ast::type::ArrayType* u32_array_type(uint32_t count) {
+ ast::type::Bool* bool_type() { return &bool_type_; }
+ ast::type::F32* f32_type() { return &f32_type_; }
+ ast::type::I32* i32_type() { return &i32_type_; }
+ ast::type::U32* u32_type() { return &u32_type_; }
+ ast::type::Array* u32_array_type(uint32_t count) {
if (array_type_memo_.find(count) == array_type_memo_.end()) {
array_type_memo_[count] =
- std::make_unique<ast::type::ArrayType>(u32_type(), count);
+ std::make_unique<ast::type::Array>(u32_type(), count);
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(4, Source{}));
array_type_memo_[count]->set_decorations(decos);
}
return array_type_memo_[count].get();
}
- ast::type::VectorType* vec_type(ast::type::Type* type, uint32_t count) {
+ ast::type::Vector* vec_type(ast::type::Type* type, uint32_t count) {
if (vector_type_memo_.find(std::tie(type, count)) ==
vector_type_memo_.end()) {
vector_type_memo_[std::tie(type, count)] =
- std::make_unique<ast::type::VectorType>(u32_type(), count);
+ std::make_unique<ast::type::Vector>(u32_type(), count);
}
return vector_type_memo_[std::tie(type, count)].get();
}
- ast::type::VoidType* void_type() { return &void_type_; }
- ast::type::SamplerType* sampler_type() { return &sampler_type_; }
- ast::type::SamplerType* comparison_sampler_type() {
+ ast::type::Void* void_type() { return &void_type_; }
+ ast::type::Sampler* sampler_type() { return &sampler_type_; }
+ ast::type::Sampler* comparison_sampler_type() {
return &comparison_sampler_type_;
}
@@ -688,16 +688,16 @@
std::unique_ptr<TypeDeterminer> td_;
std::unique_ptr<Inspector> inspector_;
- ast::type::BoolType bool_type_;
- ast::type::F32Type f32_type_;
- ast::type::I32Type i32_type_;
- ast::type::U32Type u32_type_;
- ast::type::VoidType void_type_;
- ast::type::SamplerType sampler_type_;
- ast::type::SamplerType comparison_sampler_type_;
- std::map<uint32_t, std::unique_ptr<ast::type::ArrayType>> array_type_memo_;
+ ast::type::Bool bool_type_;
+ ast::type::F32 f32_type_;
+ ast::type::I32 i32_type_;
+ ast::type::U32 u32_type_;
+ ast::type::Void void_type_;
+ ast::type::Sampler sampler_type_;
+ ast::type::Sampler comparison_sampler_type_;
+ std::map<uint32_t, std::unique_ptr<ast::type::Array>> array_type_memo_;
std::map<std::tuple<ast::type::Type*, uint32_t>,
- std::unique_ptr<ast::type::VectorType>>
+ std::unique_ptr<ast::type::Vector>>
vector_type_memo_;
};
@@ -1234,8 +1234,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeUniformBufferTypes("foo_type", {{i32_type(), 0}});
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
@@ -1267,7 +1267,7 @@
ast::StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members);
- auto foo_type = std::make_unique<ast::type::StructType>("foo_type", str);
+ auto foo_type = std::make_unique<ast::type::Struct>("foo_type", str);
AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);
@@ -1288,8 +1288,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeUniformBufferTypes("foo_type", {{i32_type(), 0}});
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
@@ -1315,8 +1315,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes(
"foo_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}});
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
@@ -1342,8 +1342,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
- std::unique_ptr<ast::type::StructType> ub_struct_type;
- std::unique_ptr<ast::type::AccessControlType> ub_control_type;
+ std::unique_ptr<ast::type::Struct> ub_struct_type;
+ std::unique_ptr<ast::type::AccessControl> ub_control_type;
std::tie(ub_struct_type, ub_control_type) = MakeUniformBufferTypes(
"ub_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}});
AddUniformBuffer("ub_foo", ub_control_type.get(), 0, 0);
@@ -1401,8 +1401,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes(
"foo_type", {{i32_type(), 0}, {u32_array_type(4), 4}});
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
@@ -1428,8 +1428,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {{i32_type(), 0}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1455,8 +1455,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
"foo_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1482,8 +1482,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
- std::unique_ptr<ast::type::StructType> sb_struct_type;
- std::unique_ptr<ast::type::AccessControlType> sb_control_type;
+ std::unique_ptr<ast::type::Struct> sb_struct_type;
+ std::unique_ptr<ast::type::AccessControl> sb_control_type;
std::tie(sb_struct_type, sb_control_type) = MakeStorageBufferTypes(
"sb_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}});
AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0);
@@ -1541,8 +1541,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
"foo_type", {{i32_type(), 0}, {u32_array_type(4), 4}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1568,8 +1568,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
"foo_type", {{i32_type(), 0}, {u32_array_type(0), 4}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1595,8 +1595,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {{i32_type(), 0}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1618,8 +1618,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {{i32_type(), 0}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1647,8 +1647,8 @@
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
MultipleStorageBuffers) {
- std::unique_ptr<ast::type::StructType> sb_struct_type;
- std::unique_ptr<ast::type::AccessControlType> sb_control_type;
+ std::unique_ptr<ast::type::Struct> sb_struct_type;
+ std::unique_ptr<ast::type::AccessControl> sb_control_type;
std::tie(sb_struct_type, sb_control_type) = MakeReadOnlyStorageBufferTypes(
"sb_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}});
AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0);
@@ -1707,8 +1707,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
"foo_type", {{i32_type(), 0}, {u32_array_type(4), 4}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1736,8 +1736,8 @@
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
ContainingRuntimeArray) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
"foo_type", {{i32_type(), 0}, {u32_array_type(0), 4}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1764,8 +1764,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
- std::unique_ptr<ast::type::StructType> foo_struct_type;
- std::unique_ptr<ast::type::AccessControlType> foo_control_type;
+ std::unique_ptr<ast::type::Struct> foo_struct_type;
+ std::unique_ptr<ast::type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {{i32_type(), 0}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index 133fac0..a550c6d 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -2013,7 +2013,7 @@
if (!guard_name.empty()) {
// Declare the guard variable just before the "if", initialized to true.
auto* guard_var = create<ast::Variable>(
- guard_name, ast::StorageClass::kFunction, parser_impl_.BoolType());
+ guard_name, ast::StorageClass::kFunction, parser_impl_.Bool());
guard_var->set_constructor(MakeTrue());
auto* guard_decl = create<ast::VariableDeclStatement>(guard_var);
AddStatement(guard_decl);
@@ -2700,8 +2700,8 @@
// So represent a load by a new const definition.
auto expr = MakeExpression(inst.GetSingleWordInOperand(0));
// The load result type is the pointee type of its operand.
- assert(expr.type->Is<ast::type::PointerType>());
- expr.type = expr.type->As<ast::type::PointerType>()->type();
+ assert(expr.type->Is<ast::type::Pointer>());
+ expr.type = expr.type->As<ast::type::Pointer>()->type();
return EmitConstDefOrWriteToHoistedVar(inst, expr);
}
case SpvOpCopyObject: {
@@ -3061,7 +3061,7 @@
type_mgr_->FindPointerToType(pointee_type_id, storage_class);
auto* ast_pointer_type = parser_impl_.ConvertType(pointer_type_id);
assert(ast_pointer_type);
- assert(ast_pointer_type->Is<ast::type::PointerType>());
+ assert(ast_pointer_type->Is<ast::type::Pointer>());
current_expr = TypedExpression{ast_pointer_type, next_expr};
}
return current_expr;
@@ -3080,7 +3080,7 @@
TypedExpression current_expr(MakeOperand(inst, 0));
auto make_index = [this](uint32_t literal) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
return create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(&u32, literal));
};
@@ -3183,13 +3183,13 @@
ast::Expression* FunctionEmitter::MakeTrue() const {
return create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(parser_impl_.BoolType(), true));
+ create<ast::BoolLiteral>(parser_impl_.Bool(), true));
}
ast::Expression* FunctionEmitter::MakeFalse() const {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
return create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(parser_impl_.BoolType(), false));
+ create<ast::BoolLiteral>(parser_impl_.Bool(), false));
}
TypedExpression FunctionEmitter::MakeVectorShuffle(
@@ -3207,8 +3207,8 @@
// Generate an ast::TypeConstructor expression.
// Assume the literal indices are valid, and there is a valid number of them.
- ast::type::VectorType* result_type =
- parser_impl_.ConvertType(inst.type_id())->As<ast::type::VectorType>();
+ ast::type::Vector* result_type =
+ parser_impl_.ConvertType(inst.type_id())->As<ast::type::Vector>();
ast::ExpressionList values;
for (uint32_t i = 2; i < inst.NumInOperands(); ++i) {
const auto index = inst.GetSingleWordInOperand(i);
@@ -3257,9 +3257,9 @@
if (type) {
if (type->AsPointer()) {
const auto* ast_type = parser_impl_.ConvertType(inst.type_id());
- if (ast_type && ast_type->As<ast::type::PointerType>()) {
+ if (ast_type && ast_type->As<ast::type::Pointer>()) {
info->storage_class =
- ast_type->As<ast::type::PointerType>()->storage_class();
+ ast_type->As<ast::type::Pointer>()->storage_class();
}
switch (inst.opcode()) {
case SpvOpUndef:
@@ -3301,8 +3301,8 @@
const auto type_id = def_use_mgr_->GetDef(id)->type_id();
if (type_id) {
auto* ast_type = parser_impl_.ConvertType(type_id);
- if (ast_type && ast_type->Is<ast::type::PointerType>()) {
- return ast_type->As<ast::type::PointerType>()->storage_class();
+ if (ast_type && ast_type->Is<ast::type::Pointer>()) {
+ return ast_type->As<ast::type::Pointer>()->storage_class();
}
}
return ast::StorageClass::kNone;
@@ -3310,13 +3310,13 @@
ast::type::Type* FunctionEmitter::RemapStorageClass(ast::type::Type* type,
uint32_t result_id) {
- if (type->Is<ast::type::PointerType>()) {
+ if (type->Is<ast::type::Pointer>()) {
// Remap an old-style storage buffer pointer to a new-style storage
// buffer pointer.
- const auto* ast_ptr_type = type->As<ast::type::PointerType>();
+ const auto* ast_ptr_type = type->As<ast::type::Pointer>();
const auto sc = GetStorageClassForPointerValue(result_id);
if (ast_ptr_type->storage_class() != sc) {
- return parser_impl_.get_module().create<ast::type::PointerType>(
+ return parser_impl_.get_module().create<ast::type::Pointer>(
ast_ptr_type->type(), sc);
}
}
@@ -3558,7 +3558,7 @@
<< inst.PrettyPrint();
}
- if (result_type->Is<ast::type::VoidType>()) {
+ if (result_type->Is<ast::type::Void>()) {
return nullptr != AddStatementForInstruction(
create<ast::CallStatement>(call_expr), inst);
}
@@ -3600,8 +3600,8 @@
// - you can't select over pointers or pointer vectors, unless you also have
// a VariablePointers* capability, which is not allowed in by WebGPU.
auto* op_ty = operand1.type;
- if (op_ty->Is<ast::type::VectorType>() || op_ty->is_float_scalar() ||
- op_ty->is_integer_scalar() || op_ty->Is<ast::type::BoolType>()) {
+ if (op_ty->Is<ast::type::Vector>() || op_ty->is_float_scalar() ||
+ op_ty->is_integer_scalar() || op_ty->Is<ast::type::Bool>()) {
ast::ExpressionList params;
params.push_back(operand1.expr);
params.push_back(operand2.expr);
@@ -3711,14 +3711,13 @@
auto* lod_operand = MakeOperand(inst, arg_index).expr;
// When sampling from a depth texture, the Lod operand must be an unsigned
// integer.
- if (ast::type::PointerType* type =
- parser_impl_.GetTypeForHandleVar(*image)) {
- if (ast::type::TextureType* texture_type =
- type->type()->As<ast::type::TextureType>()) {
- if (texture_type->Is<ast::type::DepthTextureType>()) {
+ if (ast::type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image)) {
+ if (ast::type::Texture* texture_type =
+ type->type()->As<ast::type::Texture>()) {
+ if (texture_type->Is<ast::type::DepthTexture>()) {
// Convert it to an unsigned integer type.
lod_operand = ast_module_.create<ast::TypeConstructorExpression>(
- ast_module_.create<ast::type::U32Type>(),
+ ast_module_.create<ast::type::U32>(),
ast::ExpressionList{lod_operand});
}
}
@@ -3780,17 +3779,17 @@
if (!raw_coords.type) {
return {};
}
- ast::type::PointerType* type = parser_impl_.GetTypeForHandleVar(*image);
+ ast::type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image);
if (!parser_impl_.success()) {
Fail();
return {};
}
- if (!type || !type->type()->Is<ast::type::TextureType>()) {
+ if (!type || !type->type()->Is<ast::type::Texture>()) {
Fail() << "invalid texture type for " << image->PrettyPrint();
return {};
}
ast::type::TextureDimension dim =
- type->type()->As<ast::type::TextureType>()->dim();
+ type->type()->As<ast::type::Texture>()->dim();
// Number of regular coordinates.
uint32_t num_axes = 0;
bool is_arrayed = false;
@@ -3829,10 +3828,10 @@
assert(num_axes <= 3);
const auto num_coords_required = num_axes + (is_arrayed ? 1 : 0);
uint32_t num_coords_supplied = 0;
- if (raw_coords.type->Is<ast::type::F32Type>()) {
+ if (raw_coords.type->Is<ast::type::F32>()) {
num_coords_supplied = 1;
- } else if (raw_coords.type->Is<ast::type::VectorType>()) {
- num_coords_supplied = raw_coords.type->As<ast::type::VectorType>()->size();
+ } else if (raw_coords.type->Is<ast::type::Vector>()) {
+ num_coords_supplied = raw_coords.type->As<ast::type::Vector>()->size();
}
if (num_coords_supplied == 0) {
Fail() << "bad or unsupported coordinate type for image access: "
@@ -3867,7 +3866,7 @@
Swizzle(num_axes));
// Convert it to an unsigned integer type.
result.push_back(ast_module_.create<ast::TypeConstructorExpression>(
- ast_module_.create<ast::type::U32Type>(),
+ ast_module_.create<ast::type::U32>(),
ast::ExpressionList{array_index}));
} else {
if (num_coords_supplied == num_coords_required) {
diff --git a/src/reader/spirv/function_var_test.cc b/src/reader/spirv/function_var_test.cc
index b3e946d..b4c9461 100644
--- a/src/reader/spirv/function_var_test.cc
+++ b/src/reader/spirv/function_var_test.cc
@@ -441,7 +441,7 @@
)")) << ToString(fe.ast_body());
}
-TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType) {
+TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) {
auto p = parser(test::Assemble(
std::string("OpDecorate %arr2uint ArrayStride 16\n") + Preamble() + R"(
%ptr = OpTypePointer Function %arr2uint
@@ -508,7 +508,7 @@
)")) << ToString(fe.ast_body());
}
-TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType_Null) {
+TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) {
auto p = parser(test::Assemble(
std::string("OpDecorate %arr2uint ArrayStride 16\n") + Preamble() + R"(
%ptr = OpTypePointer Function %arr2uint
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index eb0c8fc..38f5589 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -196,7 +196,7 @@
: Reader(ctx),
spv_binary_(spv_binary),
fail_stream_(&success_, &errors_),
- bool_type_(ast_module_.create<ast::type::BoolType>()),
+ bool_type_(ast_module_.create<ast::type::Bool>()),
namer_(fail_stream_),
enum_converter_(fail_stream_),
tools_context_(kInputEnv) {
@@ -285,7 +285,7 @@
switch (spirv_type->kind()) {
case spvtools::opt::analysis::Type::kVoid:
- return save(ast_module_.create<ast::type::VoidType>());
+ return save(ast_module_.create<ast::type::Void>());
case spvtools::opt::analysis::Type::kBool:
return save(bool_type_);
case spvtools::opt::analysis::Type::kInteger:
@@ -315,7 +315,7 @@
case spvtools::opt::analysis::Type::kImage:
// Fake it for sampler and texture types. These are handled in an
// entirely different way.
- return save(ast_module_.create<ast::type::VoidType>());
+ return save(ast_module_.create<ast::type::Void>());
default:
break;
}
@@ -648,8 +648,8 @@
ast::type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Integer* int_ty) {
if (int_ty->width() == 32) {
- ast::type::Type* signed_ty = ast_module_.create<ast::type::I32Type>();
- ast::type::Type* unsigned_ty = ast_module_.create<ast::type::U32Type>();
+ ast::type::Type* signed_ty = ast_module_.create<ast::type::I32>();
+ ast::type::Type* unsigned_ty = ast_module_.create<ast::type::U32>();
signed_type_for_[unsigned_ty] = signed_ty;
unsigned_type_for_[signed_ty] = unsigned_ty;
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
@@ -661,7 +661,7 @@
ast::type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Float* float_ty) {
if (float_ty->width() == 32) {
- return ast_module_.create<ast::type::F32Type>();
+ return ast_module_.create<ast::type::F32>();
}
Fail() << "unhandled float width: " << float_ty->width();
return nullptr;
@@ -674,16 +674,15 @@
if (ast_elem_ty == nullptr) {
return nullptr;
}
- auto* this_ty =
- ast_module_.create<ast::type::VectorType>(ast_elem_ty, num_elem);
+ auto* this_ty = ast_module_.create<ast::type::Vector>(ast_elem_ty, num_elem);
// Generate the opposite-signedness vector type, if this type is integral.
if (unsigned_type_for_.count(ast_elem_ty)) {
- auto* other_ty = ast_module_.create<ast::type::VectorType>(
+ auto* other_ty = ast_module_.create<ast::type::Vector>(
unsigned_type_for_[ast_elem_ty], num_elem);
signed_type_for_[other_ty] = this_ty;
unsigned_type_for_[this_ty] = other_ty;
} else if (signed_type_for_.count(ast_elem_ty)) {
- auto* other_ty = ast_module_.create<ast::type::VectorType>(
+ auto* other_ty = ast_module_.create<ast::type::Vector>(
signed_type_for_[ast_elem_ty], num_elem);
unsigned_type_for_[other_ty] = this_ty;
signed_type_for_[this_ty] = other_ty;
@@ -701,8 +700,8 @@
if (ast_scalar_ty == nullptr) {
return nullptr;
}
- return ast_module_.create<ast::type::MatrixType>(ast_scalar_ty, num_rows,
- num_columns);
+ return ast_module_.create<ast::type::Matrix>(ast_scalar_ty, num_rows,
+ num_columns);
}
ast::type::Type* ParserImpl::ConvertType(
@@ -711,7 +710,7 @@
if (ast_elem_ty == nullptr) {
return nullptr;
}
- auto ast_type = std::make_unique<ast::type::ArrayType>(ast_elem_ty);
+ auto ast_type = std::make_unique<ast::type::Array>(ast_elem_ty);
if (!ApplyArrayDecorations(rtarr_ty, ast_type.get())) {
return nullptr;
}
@@ -752,7 +751,7 @@
<< num_elem;
return nullptr;
}
- auto ast_type = std::make_unique<ast::type::ArrayType>(
+ auto ast_type = std::make_unique<ast::type::Array>(
ast_elem_ty, static_cast<uint32_t>(num_elem));
if (!ApplyArrayDecorations(arr_ty, ast_type.get())) {
return nullptr;
@@ -765,7 +764,7 @@
bool ParserImpl::ApplyArrayDecorations(
const spvtools::opt::analysis::Type* spv_type,
- ast::type::ArrayType* ast_type) {
+ ast::type::Array* ast_type) {
const auto type_id = type_mgr_->GetId(spv_type);
for (auto& decoration : this->GetDecorationsFor(type_id)) {
if (decoration.size() == 2 && decoration[0] == SpvDecorationArrayStride) {
@@ -886,8 +885,8 @@
namer_.SuggestSanitizedName(type_id, "S");
- auto* result = ast_module_.create<ast::type::StructType>(
- namer_.GetName(type_id), ast_struct);
+ auto* result = ast_module_.create<ast::type::Struct>(namer_.GetName(type_id),
+ ast_struct);
id_to_type_[type_id] = result;
if (num_non_writable_members == members.size()) {
read_only_struct_types_.insert(result);
@@ -927,8 +926,7 @@
ast_storage_class = ast::StorageClass::kStorageBuffer;
remap_buffer_block_type_.insert(type_id);
}
- return ast_module_.create<ast::type::PointerType>(ast_elem_ty,
- ast_storage_class);
+ return ast_module_.create<ast::type::Pointer>(ast_elem_ty, ast_storage_class);
}
bool ParserImpl::RegisterTypes() {
@@ -975,15 +973,15 @@
case SpvOpSpecConstant: {
ast_type = ConvertType(inst.type_id());
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
- if (ast_type->Is<ast::type::I32Type>()) {
+ if (ast_type->Is<ast::type::I32>()) {
ast_expr =
create<ast::ScalarConstructorExpression>(create<ast::SintLiteral>(
ast_type, static_cast<int32_t>(literal_value)));
- } else if (ast_type->Is<ast::type::U32Type>()) {
+ } else if (ast_type->Is<ast::type::U32>()) {
ast_expr =
create<ast::ScalarConstructorExpression>(create<ast::UintLiteral>(
ast_type, static_cast<uint32_t>(literal_value)));
- } else if (ast_type->Is<ast::type::F32Type>()) {
+ } else if (ast_type->Is<ast::type::F32>()) {
float float_value;
// Copy the bits so we can read them as a float.
std::memcpy(&float_value, &literal_value, sizeof(float_value));
@@ -1058,7 +1056,7 @@
}
const auto name = namer_.GetName(type_id);
auto* ast_alias_type =
- ast_module_.create<ast::type::AliasType>(name, ast_underlying_type);
+ ast_module_.create<ast::type::Alias>(name, ast_underlying_type);
// Record this new alias as the AST type for this SPIR-V ID.
id_to_type_[type_id] = ast_alias_type;
ast_module_.AddConstructedType(ast_alias_type);
@@ -1116,15 +1114,15 @@
"SPIR-V type with ID: "
<< var.type_id();
}
- if (!ast_type->Is<ast::type::PointerType>()) {
+ if (!ast_type->Is<ast::type::Pointer>()) {
return Fail() << "variable with ID " << var.result_id()
<< " has non-pointer type " << var.type_id();
}
}
- auto* ast_store_type = ast_type->As<ast::type::PointerType>()->type();
+ auto* ast_store_type = ast_type->As<ast::type::Pointer>()->type();
auto ast_storage_class =
- ast_type->As<ast::type::PointerType>()->storage_class();
+ ast_type->As<ast::type::Pointer>()->storage_class();
auto* ast_var =
MakeVariable(var.result_id(), ast_storage_class, ast_store_type);
if (var.NumInOperands() > 1) {
@@ -1170,7 +1168,7 @@
auto access = read_only_struct_types_.count(type)
? ast::AccessControl::kReadOnly
: ast::AccessControl::kReadWrite;
- type = ast_module_.create<ast::type::AccessControlType>(access, type);
+ type = ast_module_.create<ast::type::AccessControl>(access, type);
}
auto* ast_var = create<ast::Variable>(namer_.Name(id), sc, type);
@@ -1263,22 +1261,22 @@
// So canonicalization should map that way too.
// Currently "null<type>" is missing from the WGSL parser.
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
- if (ast_type->Is<ast::type::U32Type>()) {
+ if (ast_type->Is<ast::type::U32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(ast_type, spirv_const->GetU32()))};
}
- if (ast_type->Is<ast::type::I32Type>()) {
+ if (ast_type->Is<ast::type::I32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(ast_type, spirv_const->GetS32()))};
}
- if (ast_type->Is<ast::type::F32Type>()) {
+ if (ast_type->Is<ast::type::F32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(ast_type, spirv_const->GetFloat()))};
}
- if (ast_type->Is<ast::type::BoolType>()) {
+ if (ast_type->Is<ast::type::Bool>()) {
const bool value = spirv_const->AsNullConstant()
? false
: spirv_const->AsBoolConstant()->value();
@@ -1335,24 +1333,24 @@
auto* original_type = type;
type = type->UnwrapIfNeeded();
- if (type->Is<ast::type::BoolType>()) {
+ if (type->Is<ast::type::Bool>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(type, false));
}
- if (type->Is<ast::type::U32Type>()) {
+ if (type->Is<ast::type::U32>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(type, 0u));
}
- if (type->Is<ast::type::I32Type>()) {
+ if (type->Is<ast::type::I32>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(type, 0));
}
- if (type->Is<ast::type::F32Type>()) {
+ if (type->Is<ast::type::F32>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(type, 0.0f));
}
- if (type->Is<ast::type::VectorType>()) {
- const auto* vec_ty = type->As<ast::type::VectorType>();
+ if (type->Is<ast::type::Vector>()) {
+ const auto* vec_ty = type->As<ast::type::Vector>();
ast::ExpressionList ast_components;
for (size_t i = 0; i < vec_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(vec_ty->type()));
@@ -1360,11 +1358,11 @@
return create<ast::TypeConstructorExpression>(type,
std::move(ast_components));
}
- if (type->Is<ast::type::MatrixType>()) {
- const auto* mat_ty = type->As<ast::type::MatrixType>();
+ if (type->Is<ast::type::Matrix>()) {
+ const auto* mat_ty = type->As<ast::type::Matrix>();
// Matrix components are columns
- auto* column_ty = ast_module_.create<ast::type::VectorType>(mat_ty->type(),
- mat_ty->rows());
+ auto* column_ty =
+ ast_module_.create<ast::type::Vector>(mat_ty->type(), mat_ty->rows());
ast::ExpressionList ast_components;
for (size_t i = 0; i < mat_ty->columns(); ++i) {
ast_components.emplace_back(MakeNullValue(column_ty));
@@ -1372,8 +1370,8 @@
return create<ast::TypeConstructorExpression>(type,
std::move(ast_components));
}
- if (type->Is<ast::type::ArrayType>()) {
- auto* arr_ty = type->As<ast::type::ArrayType>();
+ if (type->Is<ast::type::Array>()) {
+ auto* arr_ty = type->As<ast::type::Array>();
ast::ExpressionList ast_components;
for (size_t i = 0; i < arr_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
@@ -1381,8 +1379,8 @@
return create<ast::TypeConstructorExpression>(original_type,
std::move(ast_components));
}
- if (type->Is<ast::type::StructType>()) {
- auto* struct_ty = type->As<ast::type::StructType>();
+ if (type->Is<ast::type::Struct>()) {
+ auto* struct_ty = type->As<ast::type::Struct>();
ast::ExpressionList ast_components;
for (auto* member : struct_ty->impl()->members()) {
ast_components.emplace_back(MakeNullValue(member->type()));
@@ -1445,14 +1443,14 @@
if (other == nullptr) {
Fail() << "no type provided";
}
- auto* i32 = ast_module_.create<ast::type::I32Type>();
- if (other->Is<ast::type::F32Type>() || other->Is<ast::type::U32Type>() ||
- other->Is<ast::type::I32Type>()) {
+ auto* i32 = ast_module_.create<ast::type::I32>();
+ if (other->Is<ast::type::F32>() || other->Is<ast::type::U32>() ||
+ other->Is<ast::type::I32>()) {
return i32;
}
- auto* vec_ty = other->As<ast::type::VectorType>();
+ auto* vec_ty = other->As<ast::type::Vector>();
if (vec_ty) {
- return ast_module_.create<ast::type::VectorType>(i32, vec_ty->size());
+ return ast_module_.create<ast::type::Vector>(i32, vec_ty->size());
}
Fail() << "required numeric scalar or vector, but got " << other->type_name();
return nullptr;
@@ -1464,14 +1462,14 @@
Fail() << "no type provided";
return nullptr;
}
- auto* u32 = ast_module_.create<ast::type::U32Type>();
- if (other->Is<ast::type::F32Type>() || other->Is<ast::type::U32Type>() ||
- other->Is<ast::type::I32Type>()) {
+ auto* u32 = ast_module_.create<ast::type::U32>();
+ if (other->Is<ast::type::F32>() || other->Is<ast::type::U32>() ||
+ other->Is<ast::type::I32>()) {
return u32;
}
- auto* vec_ty = other->As<ast::type::VectorType>();
+ auto* vec_ty = other->As<ast::type::Vector>();
if (vec_ty) {
- return ast_module_.create<ast::type::VectorType>(u32, vec_ty->size());
+ return ast_module_.create<ast::type::Vector>(u32, vec_ty->size());
}
Fail() << "required numeric scalar or vector, but got " << other->type_name();
return nullptr;
@@ -1603,7 +1601,7 @@
}
}
-ast::type::PointerType* ParserImpl::GetTypeForHandleVar(
+ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
const spvtools::opt::Instruction& var) {
if (!success()) {
return nullptr;
@@ -1726,7 +1724,7 @@
// Construct the Tint handle type.
ast::type::Type* ast_store_type = nullptr;
if (usage.IsSampler()) {
- ast_store_type = ast_module_.create<ast::type::SamplerType>(
+ ast_store_type = ast_module_.create<ast::type::Sampler>(
usage.IsComparisonSampler() ? ast::type::SamplerKind::kComparisonSampler
: ast::type::SamplerKind::kSampler);
} else if (usage.IsTexture()) {
@@ -1757,13 +1755,13 @@
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
// treat that as a depth texture.
if (image_type->depth() || usage.IsDepthTexture()) {
- ast_store_type = ast_module_.create<ast::type::DepthTextureType>(dim);
+ ast_store_type = ast_module_.create<ast::type::DepthTexture>(dim);
} else if (image_type->is_multisampled()) {
// Multisampled textures are never depth textures.
- ast_store_type = ast_module_.create<ast::type::MultisampledTextureType>(
+ ast_store_type = ast_module_.create<ast::type::MultisampledTexture>(
dim, ast_sampled_component_type);
} else {
- ast_store_type = ast_module_.create<ast::type::SampledTextureType>(
+ ast_store_type = ast_module_.create<ast::type::SampledTexture>(
dim, ast_sampled_component_type);
}
} else {
@@ -1774,8 +1772,8 @@
if (format == ast::type::ImageFormat::kNone) {
return nullptr;
}
- ast_store_type = ast_module_.create<ast::type::StorageTextureType>(
- dim, access, format);
+ ast_store_type =
+ ast_module_.create<ast::type::StorageTexture>(dim, access, format);
}
} else {
Fail() << "unsupported: UniformConstant variable is not a recognized "
@@ -1785,7 +1783,7 @@
}
// Form the pointer type.
- auto* result = ast_module_.create<ast::type::PointerType>(
+ auto* result = ast_module_.create<ast::type::Pointer>(
ast_store_type, ast::StorageClass::kUniformConstant);
// Remember it for later.
handle_type_[&var] = result;
diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h
index 11b0052..fbb3e82 100644
--- a/src/reader/spirv/parser_impl.h
+++ b/src/reader/spirv/parser_impl.h
@@ -357,7 +357,7 @@
ast::type::Type* first_operand_type);
/// @returns the registered boolean type.
- ast::type::Type* BoolType() const { return bool_type_; }
+ ast::type::Type* Bool() const { return bool_type_; }
/// Bookkeeping used for tracking the "position" builtin variable.
struct BuiltInPositionInfo {
@@ -433,7 +433,7 @@
/// @param var the OpVariable instruction
/// @returns the Tint AST type for the poiner-to-{sampler|texture} or null on
/// error
- ast::type::PointerType* GetTypeForHandleVar(
+ ast::type::Pointer* GetTypeForHandleVar(
const spvtools::opt::Instruction& var);
/// Returns the SPIR-V instruction with the given ID, or nullptr.
@@ -484,7 +484,7 @@
/// @param ast_type non-null; the AST type to apply decorations to
/// @returns true on success.
bool ApplyArrayDecorations(const spvtools::opt::analysis::Type* spv_type,
- ast::type::ArrayType* ast_type);
+ ast::type::Array* ast_type);
/// Creates a new `ast::Node` owned by the Module. When the Module is
/// destructed, the `ast::Node` will also be destructed.
@@ -592,7 +592,7 @@
// usages implied by usages of the memory-object-declaration.
std::unordered_map<const spvtools::opt::Instruction*, Usage> handle_usage_;
// The inferred pointer type for the given handle variable.
- std::unordered_map<const spvtools::opt::Instruction*, ast::type::PointerType*>
+ std::unordered_map<const spvtools::opt::Instruction*, ast::type::Pointer*>
handle_type_;
};
diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc
index f1f2007..6de6d87 100644
--- a/src/reader/spirv/parser_impl_convert_type_test.cc
+++ b/src/reader/spirv/parser_impl_convert_type_test.cc
@@ -92,7 +92,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<ast::type::VoidType>());
+ EXPECT_TRUE(type->Is<ast::type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -101,7 +101,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(100);
- EXPECT_TRUE(type->Is<ast::type::BoolType>());
+ EXPECT_TRUE(type->Is<ast::type::Bool>());
EXPECT_TRUE(p->error().empty());
}
@@ -110,7 +110,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(2);
- EXPECT_TRUE(type->Is<ast::type::I32Type>());
+ EXPECT_TRUE(type->Is<ast::type::I32>());
EXPECT_TRUE(p->error().empty());
}
@@ -119,7 +119,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::U32Type>());
+ EXPECT_TRUE(type->Is<ast::type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -128,7 +128,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(4);
- EXPECT_TRUE(type->Is<ast::type::F32Type>());
+ EXPECT_TRUE(type->Is<ast::type::F32>());
EXPECT_TRUE(p->error().empty());
}
@@ -172,22 +172,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xf32 = p->ConvertType(20);
- EXPECT_TRUE(v2xf32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v2xf32->As<ast::type::VectorType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(v2xf32->As<ast::type::VectorType>()->size(), 2u);
+ EXPECT_TRUE(v2xf32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v2xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(v2xf32->As<ast::type::Vector>()->size(), 2u);
auto* v3xf32 = p->ConvertType(30);
- EXPECT_TRUE(v3xf32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v3xf32->As<ast::type::VectorType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(v3xf32->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_TRUE(v3xf32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v3xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(v3xf32->As<ast::type::Vector>()->size(), 3u);
auto* v4xf32 = p->ConvertType(40);
- EXPECT_TRUE(v4xf32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v4xf32->As<ast::type::VectorType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(v4xf32->As<ast::type::VectorType>()->size(), 4u);
+ EXPECT_TRUE(v4xf32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v4xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(v4xf32->As<ast::type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -202,22 +199,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xi32 = p->ConvertType(20);
- EXPECT_TRUE(v2xi32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v2xi32->As<ast::type::VectorType>()->type()->Is<ast::type::I32Type>());
- EXPECT_EQ(v2xi32->As<ast::type::VectorType>()->size(), 2u);
+ EXPECT_TRUE(v2xi32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v2xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
+ EXPECT_EQ(v2xi32->As<ast::type::Vector>()->size(), 2u);
auto* v3xi32 = p->ConvertType(30);
- EXPECT_TRUE(v3xi32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v3xi32->As<ast::type::VectorType>()->type()->Is<ast::type::I32Type>());
- EXPECT_EQ(v3xi32->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_TRUE(v3xi32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v3xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
+ EXPECT_EQ(v3xi32->As<ast::type::Vector>()->size(), 3u);
auto* v4xi32 = p->ConvertType(40);
- EXPECT_TRUE(v4xi32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v4xi32->As<ast::type::VectorType>()->type()->Is<ast::type::I32Type>());
- EXPECT_EQ(v4xi32->As<ast::type::VectorType>()->size(), 4u);
+ EXPECT_TRUE(v4xi32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v4xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
+ EXPECT_EQ(v4xi32->As<ast::type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -232,22 +226,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xu32 = p->ConvertType(20);
- EXPECT_TRUE(v2xu32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v2xu32->As<ast::type::VectorType>()->type()->Is<ast::type::U32Type>());
- EXPECT_EQ(v2xu32->As<ast::type::VectorType>()->size(), 2u);
+ EXPECT_TRUE(v2xu32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v2xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
+ EXPECT_EQ(v2xu32->As<ast::type::Vector>()->size(), 2u);
auto* v3xu32 = p->ConvertType(30);
- EXPECT_TRUE(v3xu32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v3xu32->As<ast::type::VectorType>()->type()->Is<ast::type::U32Type>());
- EXPECT_EQ(v3xu32->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_TRUE(v3xu32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v3xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
+ EXPECT_EQ(v3xu32->As<ast::type::Vector>()->size(), 3u);
auto* v4xu32 = p->ConvertType(40);
- EXPECT_TRUE(v4xu32->Is<ast::type::VectorType>());
- EXPECT_TRUE(
- v4xu32->As<ast::type::VectorType>()->type()->Is<ast::type::U32Type>());
- EXPECT_EQ(v4xu32->As<ast::type::VectorType>()->size(), 4u);
+ EXPECT_TRUE(v4xu32->Is<ast::type::Vector>());
+ EXPECT_TRUE(v4xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
+ EXPECT_EQ(v4xu32->As<ast::type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -287,67 +278,58 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* m22 = p->ConvertType(22);
- EXPECT_TRUE(m22->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m22->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m22->As<ast::type::MatrixType>()->rows(), 2u);
- EXPECT_EQ(m22->As<ast::type::MatrixType>()->columns(), 2u);
+ EXPECT_TRUE(m22->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m22->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m22->As<ast::type::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m22->As<ast::type::Matrix>()->columns(), 2u);
auto* m23 = p->ConvertType(23);
- EXPECT_TRUE(m23->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m23->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m23->As<ast::type::MatrixType>()->rows(), 2u);
- EXPECT_EQ(m23->As<ast::type::MatrixType>()->columns(), 3u);
+ EXPECT_TRUE(m23->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m23->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m23->As<ast::type::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m23->As<ast::type::Matrix>()->columns(), 3u);
auto* m24 = p->ConvertType(24);
- EXPECT_TRUE(m24->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m24->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m24->As<ast::type::MatrixType>()->rows(), 2u);
- EXPECT_EQ(m24->As<ast::type::MatrixType>()->columns(), 4u);
+ EXPECT_TRUE(m24->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m24->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m24->As<ast::type::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m24->As<ast::type::Matrix>()->columns(), 4u);
auto* m32 = p->ConvertType(32);
- EXPECT_TRUE(m32->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m32->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m32->As<ast::type::MatrixType>()->rows(), 3u);
- EXPECT_EQ(m32->As<ast::type::MatrixType>()->columns(), 2u);
+ EXPECT_TRUE(m32->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m32->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m32->As<ast::type::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m32->As<ast::type::Matrix>()->columns(), 2u);
auto* m33 = p->ConvertType(33);
- EXPECT_TRUE(m33->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m33->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m33->As<ast::type::MatrixType>()->rows(), 3u);
- EXPECT_EQ(m33->As<ast::type::MatrixType>()->columns(), 3u);
+ EXPECT_TRUE(m33->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m33->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m33->As<ast::type::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m33->As<ast::type::Matrix>()->columns(), 3u);
auto* m34 = p->ConvertType(34);
- EXPECT_TRUE(m34->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m34->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m34->As<ast::type::MatrixType>()->rows(), 3u);
- EXPECT_EQ(m34->As<ast::type::MatrixType>()->columns(), 4u);
+ EXPECT_TRUE(m34->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m34->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m34->As<ast::type::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m34->As<ast::type::Matrix>()->columns(), 4u);
auto* m42 = p->ConvertType(42);
- EXPECT_TRUE(m42->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m42->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m42->As<ast::type::MatrixType>()->rows(), 4u);
- EXPECT_EQ(m42->As<ast::type::MatrixType>()->columns(), 2u);
+ EXPECT_TRUE(m42->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m42->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m42->As<ast::type::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m42->As<ast::type::Matrix>()->columns(), 2u);
auto* m43 = p->ConvertType(43);
- EXPECT_TRUE(m43->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m43->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m43->As<ast::type::MatrixType>()->rows(), 4u);
- EXPECT_EQ(m43->As<ast::type::MatrixType>()->columns(), 3u);
+ EXPECT_TRUE(m43->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m43->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m43->As<ast::type::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m43->As<ast::type::Matrix>()->columns(), 3u);
auto* m44 = p->ConvertType(44);
- EXPECT_TRUE(m44->Is<ast::type::MatrixType>());
- EXPECT_TRUE(
- m44->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(m44->As<ast::type::MatrixType>()->rows(), 4u);
- EXPECT_EQ(m44->As<ast::type::MatrixType>()->columns(), 4u);
+ EXPECT_TRUE(m44->Is<ast::type::Matrix>());
+ EXPECT_TRUE(m44->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(m44->As<ast::type::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m44->As<ast::type::Matrix>()->columns(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -361,8 +343,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::ArrayType>());
- auto* arr_type = type->As<ast::type::ArrayType>();
+ EXPECT_TRUE(type->Is<ast::type::Array>());
+ auto* arr_type = type->As<ast::type::Array>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 0u);
@@ -370,7 +352,7 @@
EXPECT_FALSE(arr_type->has_array_stride());
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
- EXPECT_TRUE(elem_type->Is<ast::type::U32Type>());
+ EXPECT_TRUE(elem_type->Is<ast::type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -397,7 +379,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- auto* arr_type = type->As<ast::type::ArrayType>();
+ auto* arr_type = type->As<ast::type::Array>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->array_stride(), 64u);
@@ -443,8 +425,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::ArrayType>());
- auto* arr_type = type->As<ast::type::ArrayType>();
+ EXPECT_TRUE(type->Is<ast::type::Array>());
+ auto* arr_type = type->As<ast::type::Array>();
EXPECT_FALSE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 42u);
@@ -452,7 +434,7 @@
EXPECT_FALSE(arr_type->has_array_stride());
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
- EXPECT_TRUE(elem_type->Is<ast::type::U32Type>());
+ EXPECT_TRUE(elem_type->Is<ast::type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -531,8 +513,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::ArrayType>());
- auto* arr_type = type->As<ast::type::ArrayType>();
+ EXPECT_TRUE(type->Is<ast::type::Array>());
+ auto* arr_type = type->As<ast::type::Array>();
ASSERT_NE(arr_type, nullptr);
ASSERT_EQ(arr_type->array_stride(), 8u);
EXPECT_TRUE(arr_type->has_array_stride());
@@ -581,9 +563,9 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::StructType>());
+ EXPECT_TRUE(type->Is<ast::type::Struct>());
std::stringstream ss;
- type->As<ast::type::StructType>()->impl()->to_str(ss, 0);
+ type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(ss.str(), Eq(R"(Struct{
StructMember{field0: __u32}
StructMember{field1: __f32}
@@ -602,9 +584,9 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::StructType>());
+ EXPECT_TRUE(type->Is<ast::type::Struct>());
std::stringstream ss;
- type->As<ast::type::StructType>()->impl()->to_str(ss, 0);
+ type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(ss.str(), Eq(R"(Struct{
[[block]]
StructMember{field0: __u32}
@@ -627,9 +609,9 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::StructType>());
+ EXPECT_TRUE(type->Is<ast::type::Struct>());
std::stringstream ss;
- type->As<ast::type::StructType>()->impl()->to_str(ss, 0);
+ type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(ss.str(), Eq(R"(Struct{
StructMember{[[ offset 0 ]] field0: __f32}
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
@@ -676,10 +658,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
EXPECT_TRUE(p->error().empty());
}
@@ -692,10 +674,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput);
EXPECT_TRUE(p->error().empty());
}
@@ -708,10 +690,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform);
EXPECT_TRUE(p->error().empty());
}
@@ -724,10 +706,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup);
EXPECT_TRUE(p->error().empty());
}
@@ -740,10 +722,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant);
EXPECT_TRUE(p->error().empty());
}
@@ -756,10 +738,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorageBuffer);
EXPECT_TRUE(p->error().empty());
}
@@ -772,10 +754,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage);
EXPECT_TRUE(p->error().empty());
}
@@ -788,10 +770,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate);
EXPECT_TRUE(p->error().empty());
}
@@ -804,10 +786,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction);
EXPECT_TRUE(p->error().empty());
}
@@ -823,17 +805,17 @@
auto* type = p->ConvertType(3);
EXPECT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::PointerType>());
+ EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::PointerType>();
+ auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::PointerType>());
+ EXPECT_TRUE(ptr_ty->type()->Is<ast::type::Pointer>());
- auto* ptr_ptr_ty = ptr_ty->type()->As<ast::type::PointerType>();
+ auto* ptr_ptr_ty = ptr_ty->type()->As<ast::type::Pointer>();
EXPECT_NE(ptr_ptr_ty, nullptr);
EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput);
- EXPECT_TRUE(ptr_ptr_ty->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ptr_ptr_ty->type()->Is<ast::type::F32>());
EXPECT_TRUE(p->error().empty());
}
@@ -846,7 +828,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<ast::type::VoidType>());
+ EXPECT_TRUE(type->Is<ast::type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -859,7 +841,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<ast::type::VoidType>());
+ EXPECT_TRUE(type->Is<ast::type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -872,7 +854,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<ast::type::VoidType>());
+ EXPECT_TRUE(type->Is<ast::type::Void>());
EXPECT_TRUE(p->error().empty());
}
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index 60eada7..699bbd2 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -318,7 +318,7 @@
return Failure::kErrored;
auto* type = module_.unique_type(std::move(str.value));
- register_constructed(type->As<ast::type::StructType>()->name(), type);
+ register_constructed(type->As<ast::type::Struct>()->name(), type);
module_.AddConstructedType(type);
return true;
}
@@ -471,8 +471,7 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::SampledTextureType>(dim.value,
- subtype.value);
+ return module_.create<ast::type::SampledTexture>(dim.value, subtype.value);
}
auto ms_dim = multisampled_texture_type();
@@ -483,8 +482,8 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::MultisampledTextureType>(ms_dim.value,
- subtype.value);
+ return module_.create<ast::type::MultisampledTexture>(ms_dim.value,
+ subtype.value);
}
auto storage = storage_texture_type();
@@ -497,7 +496,7 @@
if (format.errored)
return Failure::kErrored;
- return module_.create<ast::type::StorageTextureType>(
+ return module_.create<ast::type::StorageTexture>(
storage->first, storage->second, format.value);
}
@@ -509,11 +508,10 @@
// | SAMPLER_COMPARISON
Maybe<ast::type::Type*> ParserImpl::sampler_type() {
if (match(Token::Type::kSampler))
- return module_.create<ast::type::SamplerType>(
- ast::type::SamplerKind::kSampler);
+ return module_.create<ast::type::Sampler>(ast::type::SamplerKind::kSampler);
if (match(Token::Type::kComparisonSampler))
- return module_.create<ast::type::SamplerType>(
+ return module_.create<ast::type::Sampler>(
ast::type::SamplerKind::kComparisonSampler);
return Failure::kNoMatch;
@@ -642,19 +640,19 @@
// | TEXTURE_DEPTH_CUBE_ARRAY
Maybe<ast::type::Type*> ParserImpl::depth_texture_type() {
if (match(Token::Type::kTextureDepth2d))
- return module_.create<ast::type::DepthTextureType>(
+ return module_.create<ast::type::DepthTexture>(
ast::type::TextureDimension::k2d);
if (match(Token::Type::kTextureDepth2dArray))
- return module_.create<ast::type::DepthTextureType>(
+ return module_.create<ast::type::DepthTexture>(
ast::type::TextureDimension::k2dArray);
if (match(Token::Type::kTextureDepthCube))
- return module_.create<ast::type::DepthTextureType>(
+ return module_.create<ast::type::DepthTexture>(
ast::type::TextureDimension::kCube);
if (match(Token::Type::kTextureDepthCubeArray))
- return module_.create<ast::type::DepthTextureType>(
+ return module_.create<ast::type::DepthTexture>(
ast::type::TextureDimension::kCubeArray);
return Failure::kNoMatch;
@@ -840,7 +838,7 @@
for (auto* deco : access_decos) {
// If we have an access control decoration then we take it and wrap our
// type up with that decoration
- ty = module_.create<ast::type::AccessControlType>(
+ ty = module_.create<ast::type::AccessControl>(
deco->As<ast::AccessDecoration>()->value(), ty);
}
@@ -900,7 +898,7 @@
if (!type.matched)
return add_error(peek(), "invalid type alias");
- auto* alias = module_.create<ast::type::AliasType>(name.value, type.value);
+ auto* alias = module_.create<ast::type::Alias>(name.value, type.value);
register_constructed(name.value, alias);
return alias;
@@ -958,16 +956,16 @@
}
if (match(Token::Type::kBool))
- return module_.create<ast::type::BoolType>();
+ return module_.create<ast::type::Bool>();
if (match(Token::Type::kF32))
- return module_.create<ast::type::F32Type>();
+ return module_.create<ast::type::F32>();
if (match(Token::Type::kI32))
- return module_.create<ast::type::I32Type>();
+ return module_.create<ast::type::I32>();
if (match(Token::Type::kU32))
- return module_.create<ast::type::U32Type>();
+ return module_.create<ast::type::U32>();
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
next(); // Consume the peek
@@ -1025,7 +1023,7 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::PointerType>(subtype.value, sc.value);
+ return module_.create<ast::type::Pointer>(subtype.value, sc.value);
});
}
@@ -1042,7 +1040,7 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::VectorType>(subtype.value, count);
+ return module_.create<ast::type::Vector>(subtype.value, count);
}
Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
@@ -1062,7 +1060,7 @@
size = val.value;
}
- auto ty = std::make_unique<ast::type::ArrayType>(subtype.value, size);
+ auto ty = std::make_unique<ast::type::Array>(subtype.value, size);
ty->set_decorations(std::move(decos));
return module_.unique_type(std::move(ty));
});
@@ -1088,7 +1086,7 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::MatrixType>(subtype.value, rows, columns);
+ return module_.create<ast::type::Matrix>(subtype.value, rows, columns);
}
// storage_class
@@ -1135,7 +1133,7 @@
// struct_decl
// : struct_decoration_decl* STRUCT IDENT struct_body_decl
-Maybe<std::unique_ptr<ast::type::StructType>> ParserImpl::struct_decl(
+Maybe<std::unique_ptr<ast::type::Struct>> ParserImpl::struct_decl(
ast::DecorationList& decos) {
auto t = peek();
auto source = t.source();
@@ -1155,7 +1153,7 @@
if (struct_decos.errored)
return Failure::kErrored;
- return std::make_unique<ast::type::StructType>(
+ return std::make_unique<ast::type::Struct>(
name.value, create<ast::Struct>(source, std::move(struct_decos.value),
std::move(body.value)));
}
@@ -1256,7 +1254,7 @@
// | VOID
Maybe<ast::type::Type*> ParserImpl::function_type_decl() {
if (match(Token::Type::kVoid))
- return module_.create<ast::type::VoidType>();
+ return module_.create<ast::type::Void>();
return type_decl();
}
@@ -2615,19 +2613,19 @@
Maybe<ast::Literal*> ParserImpl::const_literal() {
auto t = peek();
if (match(Token::Type::kTrue)) {
- auto* type = module_.create<ast::type::BoolType>();
+ auto* type = module_.create<ast::type::Bool>();
return create<ast::BoolLiteral>(type, true);
}
if (match(Token::Type::kFalse)) {
- auto* type = module_.create<ast::type::BoolType>();
+ auto* type = module_.create<ast::type::Bool>();
return create<ast::BoolLiteral>(type, false);
}
if (match(Token::Type::kSintLiteral)) {
- auto* type = module_.create<ast::type::I32Type>();
+ auto* type = module_.create<ast::type::I32>();
return create<ast::SintLiteral>(type, t.to_i32());
}
if (match(Token::Type::kUintLiteral)) {
- auto* type = module_.create<ast::type::U32Type>();
+ auto* type = module_.create<ast::type::U32>();
return create<ast::UintLiteral>(type, t.to_u32());
}
if (match(Token::Type::kFloatLiteral)) {
@@ -2636,7 +2634,7 @@
next(); // Consume 'f'
add_error(p.source(), "float literals must not be suffixed with 'f'");
}
- auto* type = module_.create<ast::type::F32Type>();
+ auto* type = module_.create<ast::type::F32>();
return create<ast::FloatLiteral>(type, t.to_f32());
}
return Failure::kNoMatch;
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index 883a713..44f1e2a 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -34,7 +34,6 @@
#include "src/ast/constructor_expression.h"
#include "src/ast/continue_statement.h"
#include "src/ast/else_statement.h"
-#include "src/ast/switch_statement.h"
#include "src/ast/function.h"
#include "src/ast/if_statement.h"
#include "src/ast/literal.h"
@@ -48,6 +47,7 @@
#include "src/ast/struct_decoration.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
+#include "src/ast/switch_statement.h"
#include "src/ast/type/storage_texture_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
@@ -353,7 +353,7 @@
/// `struct_decoration_decl*` provided as |decos|.
/// @returns the struct type or nullptr on error
/// @param decos the list of decorations for the struct declaration.
- Maybe<std::unique_ptr<ast::type::StructType>> struct_decl(
+ Maybe<std::unique_ptr<ast::type::Struct>> struct_decl(
ast::DecorationList& decos);
/// Parses a `struct_body_decl` grammar element, erroring on parse failure.
/// @returns the struct members
diff --git a/src/reader/wgsl/parser_impl_const_expr_test.cc b/src/reader/wgsl/parser_impl_const_expr_test.cc
index cb0c7ee..8dd6068 100644
--- a/src/reader/wgsl/parser_impl_const_expr_test.cc
+++ b/src/reader/wgsl/parser_impl_const_expr_test.cc
@@ -35,8 +35,8 @@
ASSERT_TRUE(e->Is<ast::TypeConstructorExpression>());
auto* t = e->As<ast::TypeConstructorExpression>();
- ASSERT_TRUE(t->type()->Is<ast::type::VectorType>());
- EXPECT_EQ(t->type()->As<ast::type::VectorType>()->size(), 2u);
+ ASSERT_TRUE(t->type()->Is<ast::type::Vector>());
+ EXPECT_EQ(t->type()->As<ast::type::Vector>()->size(), 2u);
ASSERT_EQ(t->values().size(), 2u);
auto& v = t->values();
diff --git a/src/reader/wgsl/parser_impl_depth_texture_type_test.cc b/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
index fd1d93b..5ba850e 100644
--- a/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
+++ b/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
@@ -36,10 +36,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(
- t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->As<ast::type::Texture>()->Is<ast::type::DepthTexture>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -50,10 +49,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(
- t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->As<ast::type::Texture>()->Is<ast::type::DepthTexture>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -64,10 +62,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(
- t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->As<ast::type::Texture>()->Is<ast::type::DepthTexture>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@@ -78,10 +75,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(
- t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->As<ast::type::Texture>()->Is<ast::type::DepthTexture>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_function_decl_test.cc b/src/reader/wgsl/parser_impl_function_decl_test.cc
index 7ba09b3..e7e38ec 100644
--- a/src/reader/wgsl/parser_impl_function_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_function_decl_test.cc
@@ -39,14 +39,14 @@
EXPECT_EQ(f->name(), "main");
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
ASSERT_EQ(f->params().size(), 2u);
EXPECT_EQ(f->params()[0]->name(), "a");
EXPECT_EQ(f->params()[1]->name(), "b");
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
auto* body = f->body();
ASSERT_EQ(body->size(), 1u);
@@ -67,10 +67,10 @@
EXPECT_EQ(f->name(), "main");
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
auto& decorations = f->decorations();
ASSERT_EQ(decorations.size(), 1u);
@@ -105,10 +105,10 @@
EXPECT_EQ(f->name(), "main");
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
auto& decorations = f->decorations();
ASSERT_EQ(decorations.size(), 2u);
@@ -150,10 +150,10 @@
EXPECT_EQ(f->name(), "main");
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
auto& decos = f->decorations();
ASSERT_EQ(decos.size(), 2u);
diff --git a/src/reader/wgsl/parser_impl_function_header_test.cc b/src/reader/wgsl/parser_impl_function_header_test.cc
index 77662bf..e6a9e15 100644
--- a/src/reader/wgsl/parser_impl_function_header_test.cc
+++ b/src/reader/wgsl/parser_impl_function_header_test.cc
@@ -36,7 +36,7 @@
ASSERT_EQ(f->params().size(), 2u);
EXPECT_EQ(f->params()[0]->name(), "a");
EXPECT_EQ(f->params()[1]->name(), "b");
- EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
+ EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
}
TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
diff --git a/src/reader/wgsl/parser_impl_function_type_decl_test.cc b/src/reader/wgsl/parser_impl_function_type_decl_test.cc
index 64b1624..b4160e5 100644
--- a/src/reader/wgsl/parser_impl_function_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_function_type_decl_test.cc
@@ -30,7 +30,7 @@
auto p = parser("void");
auto& mod = p->get_module();
- auto* v = mod.create<ast::type::VoidType>();
+ auto* v = mod.create<ast::type::Void>();
auto e = p->function_type_decl();
EXPECT_TRUE(e.matched);
@@ -43,8 +43,8 @@
auto p = parser("vec2<f32>");
auto& mod = p->get_module();
- auto* f32 = mod.create<ast::type::F32Type>();
- auto* vec2 = mod.create<ast::type::VectorType>(f32, 2);
+ auto* f32 = mod.create<ast::type::F32>();
+ auto* vec2 = mod.create<ast::type::Vector>(f32, 2);
auto e = p->function_type_decl();
EXPECT_TRUE(e.matched);
diff --git a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
index fe26ad1..564b138 100644
--- a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
@@ -35,7 +35,7 @@
EXPECT_TRUE(e->is_const());
EXPECT_EQ(e->name(), "a");
ASSERT_NE(e->type(), nullptr);
- EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->source().range.begin.line, 1u);
EXPECT_EQ(e->source().range.begin.column, 7u);
diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc
index 230c755..d654b06 100644
--- a/src/reader/wgsl/parser_impl_global_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_decl_test.cc
@@ -88,8 +88,8 @@
auto& m = p->get_module();
ASSERT_EQ(m.constructed_types().size(), 1u);
- ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::AliasType>());
- EXPECT_EQ(m.constructed_types()[0]->As<ast::type::AliasType>()->name(), "A");
+ ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Alias>());
+ EXPECT_EQ(m.constructed_types()[0]->As<ast::type::Alias>()->name(), "A");
}
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) {
@@ -103,12 +103,12 @@
auto& m = p->get_module();
ASSERT_EQ(m.constructed_types().size(), 2u);
- ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::StructType>());
- auto* str = m.constructed_types()[0]->As<ast::type::StructType>();
+ ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Struct>());
+ auto* str = m.constructed_types()[0]->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
- ASSERT_TRUE(m.constructed_types()[1]->Is<ast::type::AliasType>());
- auto* alias = m.constructed_types()[1]->As<ast::type::AliasType>();
+ ASSERT_TRUE(m.constructed_types()[1]->Is<ast::type::Alias>());
+ auto* alias = m.constructed_types()[1]->As<ast::type::Alias>();
EXPECT_EQ(alias->name(), "B");
EXPECT_EQ(alias->type(), str);
}
@@ -164,9 +164,9 @@
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<ast::type::StructType>());
+ ASSERT_TRUE(t->Is<ast::type::Struct>());
- auto* str = t->As<ast::type::StructType>();
+ auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->impl()->members().size(), 2u);
}
@@ -183,16 +183,16 @@
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<ast::type::StructType>());
+ ASSERT_TRUE(t->Is<ast::type::Struct>());
- auto* str = t->As<ast::type::StructType>();
+ auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_FALSE(str->IsBlockDecorated());
const auto* ty = str->impl()->members()[0]->type();
- ASSERT_TRUE(ty->Is<ast::type::ArrayType>());
- const auto* arr = ty->As<ast::type::ArrayType>();
+ ASSERT_TRUE(ty->Is<ast::type::Array>());
+ const auto* arr = ty->As<ast::type::Array>();
EXPECT_TRUE(arr->has_array_stride());
EXPECT_EQ(arr->array_stride(), 4u);
}
@@ -207,9 +207,9 @@
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<ast::type::StructType>());
+ ASSERT_TRUE(t->Is<ast::type::Struct>());
- auto* str = t->As<ast::type::StructType>();
+ auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_TRUE(str->IsBlockDecorated());
diff --git a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
index 76f2c29..f095270 100644
--- a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
@@ -37,7 +37,7 @@
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->name(), "a");
- EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -61,7 +61,7 @@
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->name(), "a");
- EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -90,7 +90,7 @@
EXPECT_EQ(e->name(), "a");
ASSERT_NE(e->type(), nullptr);
- EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -124,7 +124,7 @@
EXPECT_EQ(e->name(), "a");
ASSERT_NE(e->type(), nullptr);
- EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
diff --git a/src/reader/wgsl/parser_impl_param_list_test.cc b/src/reader/wgsl/parser_impl_param_list_test.cc
index de27bda..622514d 100644
--- a/src/reader/wgsl/parser_impl_param_list_test.cc
+++ b/src/reader/wgsl/parser_impl_param_list_test.cc
@@ -31,7 +31,7 @@
auto p = parser("a : i32");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32Type>();
+ auto* i32 = mod.create<ast::type::I32>();
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();
@@ -52,9 +52,9 @@
auto p = parser("a : i32, b: f32, c: vec2<f32>");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32Type>();
- auto* f32 = mod.create<ast::type::F32Type>();
- auto* vec2 = mod.create<ast::type::VectorType>(f32, 2);
+ auto* i32 = mod.create<ast::type::I32>();
+ auto* f32 = mod.create<ast::type::F32>();
+ auto* vec2 = mod.create<ast::type::Vector>(f32, 2);
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();
diff --git a/src/reader/wgsl/parser_impl_primary_expression_test.cc b/src/reader/wgsl/parser_impl_primary_expression_test.cc
index 4753c63..8a566af 100644
--- a/src/reader/wgsl/parser_impl_primary_expression_test.cc
+++ b/src/reader/wgsl/parser_impl_primary_expression_test.cc
@@ -194,7 +194,7 @@
auto p = parser("f32(1)");
auto& mod = p->get_module();
- auto* f32 = mod.create<ast::type::F32Type>();
+ auto* f32 = mod.create<ast::type::F32>();
auto e = p->primary_expression();
EXPECT_TRUE(e.matched);
@@ -216,7 +216,7 @@
auto p = parser("bitcast<f32>(1)");
auto& mod = p->get_module();
- auto* f32 = mod.create<ast::type::F32Type>();
+ auto* f32 = mod.create<ast::type::F32>();
auto e = p->primary_expression();
EXPECT_TRUE(e.matched);
diff --git a/src/reader/wgsl/parser_impl_sampler_type_test.cc b/src/reader/wgsl/parser_impl_sampler_type_test.cc
index 5b17627..b4303cd 100644
--- a/src/reader/wgsl/parser_impl_sampler_type_test.cc
+++ b/src/reader/wgsl/parser_impl_sampler_type_test.cc
@@ -37,8 +37,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::SamplerType>());
- EXPECT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
+ ASSERT_TRUE(t->Is<ast::type::Sampler>());
+ EXPECT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
EXPECT_FALSE(p->has_error());
}
@@ -48,8 +48,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::SamplerType>());
- EXPECT_TRUE(t->As<ast::type::SamplerType>()->IsComparison());
+ ASSERT_TRUE(t->Is<ast::type::Sampler>());
+ EXPECT_TRUE(t->As<ast::type::Sampler>()->IsComparison());
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_struct_body_decl_test.cc b/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
index 74c7fdf..8577ecc 100644
--- a/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
@@ -26,7 +26,7 @@
auto p = parser("{a : i32;}");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32Type>();
+ auto* i32 = mod.create<ast::type::I32>();
auto m = p->expect_struct_body_decl();
ASSERT_FALSE(p->has_error());
diff --git a/src/reader/wgsl/parser_impl_struct_member_test.cc b/src/reader/wgsl/parser_impl_struct_member_test.cc
index f4643d3..4223ca3 100644
--- a/src/reader/wgsl/parser_impl_struct_member_test.cc
+++ b/src/reader/wgsl/parser_impl_struct_member_test.cc
@@ -27,7 +27,7 @@
auto p = parser("a : i32;");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32Type>();
+ auto* i32 = mod.create<ast::type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);
@@ -53,7 +53,7 @@
auto p = parser("[[offset(2)]] a : i32;");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32Type>();
+ auto* i32 = mod.create<ast::type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);
@@ -84,7 +84,7 @@
[[offset(4)]] a : i32;)");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32Type>();
+ auto* i32 = mod.create<ast::type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);
diff --git a/src/reader/wgsl/parser_impl_test.cc b/src/reader/wgsl/parser_impl_test.cc
index 475e3c2..44afe10 100644
--- a/src/reader/wgsl/parser_impl_test.cc
+++ b/src/reader/wgsl/parser_impl_test.cc
@@ -57,7 +57,7 @@
TEST_F(ParserImplTest, GetRegisteredType) {
auto p = parser("");
- ast::type::I32Type i32;
+ ast::type::I32 i32;
p->register_constructed("my_alias", &i32);
auto* alias = p->get_constructed("my_alias");
diff --git a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
index 1827766..dc74f29 100644
--- a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
+++ b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
@@ -44,8 +44,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::SamplerType>());
- ASSERT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
+ ASSERT_TRUE(t->Is<ast::type::Sampler>());
+ ASSERT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
@@ -55,8 +55,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::SamplerType>());
- ASSERT_TRUE(t->As<ast::type::SamplerType>()->IsComparison());
+ ASSERT_TRUE(t->Is<ast::type::Sampler>());
+ ASSERT_TRUE(t->As<ast::type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
@@ -66,9 +66,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::DepthTextureType>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -79,11 +79,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
- ASSERT_TRUE(
- t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
+ ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k1d);
}
@@ -94,11 +93,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
- ASSERT_TRUE(
- t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::I32Type>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
+ ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::I32>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -109,11 +107,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
- ASSERT_TRUE(
- t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::U32Type>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
+ ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::U32>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k3d);
}
@@ -165,11 +162,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
- ASSERT_TRUE(
- t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::F32Type>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
+ ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k1d);
}
@@ -180,11 +176,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
- ASSERT_TRUE(
- t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::I32Type>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
+ ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::I32>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -195,11 +190,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
- ASSERT_TRUE(
- t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::U32Type>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
+ ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::U32>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k3d);
}
@@ -250,12 +244,11 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::MultisampledTextureType>());
- ASSERT_TRUE(t->As<ast::type::MultisampledTextureType>()
- ->type()
- ->Is<ast::type::I32Type>());
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::MultisampledTexture>());
+ ASSERT_TRUE(
+ t->As<ast::type::MultisampledTexture>()->type()->Is<ast::type::I32>());
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -307,13 +300,13 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::StorageTextureType>());
- EXPECT_EQ(t->As<ast::type::StorageTextureType>()->image_format(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
+ EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
ast::type::ImageFormat::kR8Unorm);
- EXPECT_EQ(t->As<ast::type::StorageTextureType>()->access(),
+ EXPECT_EQ(t->As<ast::type::StorageTexture>()->access(),
ast::AccessControl::kReadOnly);
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k1d);
}
@@ -325,13 +318,13 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::StorageTextureType>());
- EXPECT_EQ(t->As<ast::type::StorageTextureType>()->image_format(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
+ EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
ast::type::ImageFormat::kR16Float);
- EXPECT_EQ(t->As<ast::type::StorageTextureType>()->access(),
+ EXPECT_EQ(t->As<ast::type::StorageTexture>()->access(),
ast::AccessControl::kWriteOnly);
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -379,13 +372,13 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::StorageTextureType>());
- EXPECT_EQ(t->As<ast::type::StorageTextureType>()->image_format(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
+ EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
ast::type::ImageFormat::kR8Unorm);
- EXPECT_EQ(t->As<ast::type::StorageTextureType>()->access(),
+ EXPECT_EQ(t->As<ast::type::StorageTexture>()->access(),
ast::AccessControl::kReadOnly);
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k1d);
}
@@ -396,13 +389,13 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::StorageTextureType>());
- EXPECT_EQ(t->As<ast::type::StorageTextureType>()->image_format(),
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
+ EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
ast::type::ImageFormat::kR16Float);
- EXPECT_EQ(t->As<ast::type::StorageTextureType>()->access(),
+ EXPECT_EQ(t->As<ast::type::StorageTexture>()->access(),
ast::AccessControl::kWriteOnly);
- EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
+ EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
diff --git a/src/reader/wgsl/parser_impl_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc
index eba0883..52179e1 100644
--- a/src/reader/wgsl/parser_impl_type_alias_test.cc
+++ b/src/reader/wgsl/parser_impl_type_alias_test.cc
@@ -29,21 +29,21 @@
auto p = parser("type a = i32");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32Type>();
+ auto* i32 = mod.create<ast::type::I32>();
auto t = p->type_alias();
EXPECT_FALSE(p->has_error());
EXPECT_FALSE(t.errored);
EXPECT_TRUE(t.matched);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::AliasType>());
- auto* alias = t->As<ast::type::AliasType>();
- ASSERT_TRUE(alias->type()->Is<ast::type::I32Type>());
+ ASSERT_TRUE(t->Is<ast::type::Alias>());
+ auto* alias = t->As<ast::type::Alias>();
+ ASSERT_TRUE(alias->type()->Is<ast::type::I32>());
ASSERT_EQ(alias->type(), i32);
}
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
- ast::type::StructType str("B", {});
+ ast::type::Struct str("B", {});
auto p = parser("type a = B");
p->register_constructed("B", &str);
@@ -53,12 +53,12 @@
EXPECT_FALSE(t.errored);
EXPECT_TRUE(t.matched);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::AliasType>());
- auto* alias = t->As<ast::type::AliasType>();
+ ASSERT_TRUE(t->Is<ast::type::Alias>());
+ auto* alias = t->As<ast::type::Alias>();
EXPECT_EQ(alias->name(), "a");
- ASSERT_TRUE(alias->type()->Is<ast::type::StructType>());
+ ASSERT_TRUE(alias->type()->Is<ast::type::Struct>());
- auto* s = alias->type()->As<ast::type::StructType>();
+ auto* s = alias->type()->As<ast::type::Struct>();
EXPECT_EQ(s->name(), "B");
}
diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc
index e8a85f8..a197168 100644
--- a/src/reader/wgsl/parser_impl_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_type_decl_test.cc
@@ -48,8 +48,8 @@
auto& mod = p->get_module();
- auto* int_type = mod.create<ast::type::I32Type>();
- auto* alias_type = mod.create<ast::type::AliasType>("A", int_type);
+ auto* int_type = mod.create<ast::type::I32>();
+ auto* alias_type = mod.create<ast::type::Alias>("A", int_type);
p->register_constructed("A", alias_type);
@@ -58,9 +58,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, alias_type);
- ASSERT_TRUE(t->Is<ast::type::AliasType>());
+ ASSERT_TRUE(t->Is<ast::type::Alias>());
- auto* alias = t->As<ast::type::AliasType>();
+ auto* alias = t->As<ast::type::Alias>();
EXPECT_EQ(alias->name(), "A");
EXPECT_EQ(alias->type(), int_type);
}
@@ -80,56 +80,56 @@
auto p = parser("bool");
auto& mod = p->get_module();
- auto* bool_type = mod.create<ast::type::BoolType>();
+ auto* bool_type = mod.create<ast::type::Bool>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, bool_type);
- ASSERT_TRUE(t->Is<ast::type::BoolType>());
+ ASSERT_TRUE(t->Is<ast::type::Bool>());
}
TEST_F(ParserImplTest, TypeDecl_F32) {
auto p = parser("f32");
auto& mod = p->get_module();
- auto* float_type = mod.create<ast::type::F32Type>();
+ auto* float_type = mod.create<ast::type::F32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, float_type);
- ASSERT_TRUE(t->Is<ast::type::F32Type>());
+ ASSERT_TRUE(t->Is<ast::type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_I32) {
auto p = parser("i32");
auto& mod = p->get_module();
- auto* int_type = mod.create<ast::type::I32Type>();
+ auto* int_type = mod.create<ast::type::I32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, int_type);
- ASSERT_TRUE(t->Is<ast::type::I32Type>());
+ ASSERT_TRUE(t->Is<ast::type::I32>());
}
TEST_F(ParserImplTest, TypeDecl_U32) {
auto p = parser("u32");
auto& mod = p->get_module();
- auto* uint_type = mod.create<ast::type::U32Type>();
+ auto* uint_type = mod.create<ast::type::U32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, uint_type);
- ASSERT_TRUE(t->Is<ast::type::U32Type>());
+ ASSERT_TRUE(t->Is<ast::type::U32>());
}
struct VecData {
@@ -151,8 +151,8 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- EXPECT_TRUE(t->Is<ast::type::VectorType>());
- EXPECT_EQ(t->As<ast::type::VectorType>()->size(), params.count);
+ EXPECT_TRUE(t->Is<ast::type::Vector>());
+ EXPECT_EQ(t->As<ast::type::Vector>()->size(), params.count);
}
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
VecTest,
@@ -239,10 +239,10 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::PointerType>());
+ ASSERT_TRUE(t->Is<ast::type::Pointer>());
- auto* ptr = t->As<ast::type::PointerType>();
- ASSERT_TRUE(ptr->type()->Is<ast::type::F32Type>());
+ auto* ptr = t->As<ast::type::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<ast::type::F32>());
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
}
@@ -253,15 +253,15 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::PointerType>());
+ ASSERT_TRUE(t->Is<ast::type::Pointer>());
- auto* ptr = t->As<ast::type::PointerType>();
- ASSERT_TRUE(ptr->type()->Is<ast::type::VectorType>());
+ auto* ptr = t->As<ast::type::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<ast::type::Vector>());
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
- auto* vec = ptr->type()->As<ast::type::VectorType>();
+ auto* vec = ptr->type()->As<ast::type::Vector>();
ASSERT_EQ(vec->size(), 2u);
- ASSERT_TRUE(vec->type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(vec->type()->Is<ast::type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
@@ -351,12 +351,12 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::ArrayType>());
+ ASSERT_TRUE(t->Is<ast::type::Array>());
- auto* a = t->As<ast::type::ArrayType>();
+ auto* a = t->As<ast::type::Array>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
- ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(a->type()->Is<ast::type::F32>());
ASSERT_FALSE(a->has_array_stride());
}
@@ -367,12 +367,12 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::ArrayType>());
+ ASSERT_TRUE(t->Is<ast::type::Array>());
- auto* a = t->As<ast::type::ArrayType>();
+ auto* a = t->As<ast::type::Array>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
- ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(a->type()->Is<ast::type::F32>());
ASSERT_TRUE(a->has_array_stride());
EXPECT_EQ(a->array_stride(), 16u);
}
@@ -384,11 +384,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::ArrayType>());
+ ASSERT_TRUE(t->Is<ast::type::Array>());
- auto* a = t->As<ast::type::ArrayType>();
+ auto* a = t->As<ast::type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(a->type()->Is<ast::type::F32>());
ASSERT_TRUE(a->has_array_stride());
EXPECT_EQ(a->array_stride(), 16u);
}
@@ -400,11 +400,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::ArrayType>());
+ ASSERT_TRUE(t->Is<ast::type::Array>());
- auto* a = t->As<ast::type::ArrayType>();
+ auto* a = t->As<ast::type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(a->type()->Is<ast::type::F32>());
auto& decos = a->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -421,11 +421,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::ArrayType>());
+ ASSERT_TRUE(t->Is<ast::type::Array>());
- auto* a = t->As<ast::type::ArrayType>();
+ auto* a = t->As<ast::type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(a->type()->Is<ast::type::F32>());
auto& decos = a->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -524,11 +524,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::ArrayType>());
+ ASSERT_TRUE(t->Is<ast::type::Array>());
- auto* a = t->As<ast::type::ArrayType>();
+ auto* a = t->As<ast::type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(a->type()->Is<ast::type::U32>());
}
TEST_F(ParserImplTest, TypeDecl_Array_BadType) {
@@ -621,8 +621,8 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- EXPECT_TRUE(t->Is<ast::type::MatrixType>());
- auto* mat = t->As<ast::type::MatrixType>();
+ EXPECT_TRUE(t->Is<ast::type::Matrix>());
+ auto* mat = t->As<ast::type::Matrix>();
EXPECT_EQ(mat->rows(), params.rows);
EXPECT_EQ(mat->columns(), params.columns);
}
@@ -739,24 +739,23 @@
auto p = parser("sampler");
auto& mod = p->get_module();
- auto* type =
- mod.create<ast::type::SamplerType>(ast::type::SamplerKind::kSampler);
+ auto* type = mod.create<ast::type::Sampler>(ast::type::SamplerKind::kSampler);
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, type);
- ASSERT_TRUE(t->Is<ast::type::SamplerType>());
- ASSERT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
+ ASSERT_TRUE(t->Is<ast::type::Sampler>());
+ ASSERT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
auto p = parser("texture_sampled_cube<f32>");
auto& mod = p->get_module();
- ast::type::F32Type f32;
- auto* type = mod.create<ast::type::SampledTextureType>(
+ ast::type::F32 f32;
+ auto* type = mod.create<ast::type::SampledTexture>(
ast::type::TextureDimension::kCube, &f32);
auto t = p->type_decl();
@@ -764,18 +763,17 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, type);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
- ASSERT_TRUE(
- t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
+ ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_Texture) {
auto p = parser("texture_cube<f32>");
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto& mod = p->get_module();
- auto* type = mod.create<ast::type::SampledTextureType>(
+ auto* type = mod.create<ast::type::SampledTexture>(
ast::type::TextureDimension::kCube, &f32);
auto t = p->type_decl();
@@ -783,10 +781,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
EXPECT_EQ(t.value, type);
- ASSERT_TRUE(t->Is<ast::type::TextureType>());
- ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
- ASSERT_TRUE(
- t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(t->Is<ast::type::Texture>());
+ ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
+ ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
}
} // namespace
diff --git a/src/reader/wgsl/parser_impl_variable_decl_test.cc b/src/reader/wgsl/parser_impl_variable_decl_test.cc
index fdc17c9..f1a9ea6 100644
--- a/src/reader/wgsl/parser_impl_variable_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_decl_test.cc
@@ -32,7 +32,7 @@
ASSERT_NE(var.value, nullptr);
EXPECT_EQ(var->name(), "my_var");
EXPECT_NE(var->type(), nullptr);
- EXPECT_TRUE(var->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(var->type()->Is<ast::type::F32>());
EXPECT_EQ(var->source().range.begin.line, 1u);
EXPECT_EQ(var->source().range.begin.column, 5u);
@@ -70,7 +70,7 @@
EXPECT_FALSE(p->has_error());
ASSERT_NE(v.value, nullptr);
EXPECT_EQ(v->name(), "my_var");
- EXPECT_TRUE(v->type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(v->type()->Is<ast::type::F32>());
EXPECT_EQ(v->storage_class(), ast::StorageClass::kPrivate);
EXPECT_EQ(v->source().range.begin.line, 1u);
diff --git a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
index da48b88..427a93a 100644
--- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
@@ -34,7 +34,7 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<ast::type::F32Type>());
+ ASSERT_TRUE(decl->type->Is<ast::type::F32>());
ASSERT_EQ(decl->source.range.begin.line, 1u);
ASSERT_EQ(decl->source.range.begin.column, 1u);
@@ -83,7 +83,7 @@
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -94,7 +94,7 @@
decos.push_back(&block_deco);
ast::Struct str(decos, members);
- ast::type::StructType s("S", &str);
+ ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read)]] S");
p->register_constructed("S", &s);
@@ -104,12 +104,12 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<ast::type::AccessControlType>());
- EXPECT_TRUE(decl->type->As<ast::type::AccessControlType>()->IsReadOnly());
+ ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
+ EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadOnly());
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -120,7 +120,7 @@
decos.push_back(&block_deco);
ast::Struct str(decos, members);
- ast::type::StructType s("S", &str);
+ ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read_write)]] S");
p->register_constructed("S", &s);
@@ -130,12 +130,12 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<ast::type::AccessControlType>());
- EXPECT_TRUE(decl->type->As<ast::type::AccessControlType>()->IsReadWrite());
+ ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
+ EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadWrite());
}
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -146,7 +146,7 @@
decos.push_back(&block_deco);
ast::Struct str(decos, members);
- ast::type::StructType s("S", &str);
+ ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read), access(read_write)]] S");
p->register_constructed("S", &s);
@@ -158,7 +158,7 @@
}
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -169,7 +169,7 @@
decos.push_back(&block_deco);
ast::Struct str(decos, members);
- ast::type::StructType s("S", &str);
+ ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
p->register_constructed("S", &s);
@@ -197,7 +197,7 @@
}
TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -208,7 +208,7 @@
decos.push_back(&block_deco);
ast::Struct str(decos, members);
- ast::type::StructType s("S", &str);
+ ast::type::Struct s("S", &str);
auto p = parser("my_var : [[stride(1)]] S");
p->register_constructed("S", &s);
diff --git a/src/transform/bound_array_accessors_transform.cc b/src/transform/bound_array_accessors_transform.cc
index ab5c20d..86d83ee 100644
--- a/src/transform/bound_array_accessors_transform.cc
+++ b/src/transform/bound_array_accessors_transform.cc
@@ -179,17 +179,15 @@
}
auto* ret_type = expr->array()->result_type()->UnwrapAll();
- if (!ret_type->Is<ast::type::ArrayType>() &&
- !ret_type->Is<ast::type::MatrixType>() &&
- !ret_type->Is<ast::type::VectorType>()) {
+ if (!ret_type->Is<ast::type::Array>() && !ret_type->Is<ast::type::Matrix>() &&
+ !ret_type->Is<ast::type::Vector>()) {
return true;
}
- if (ret_type->Is<ast::type::VectorType>() ||
- ret_type->Is<ast::type::ArrayType>()) {
- uint32_t size = ret_type->Is<ast::type::VectorType>()
- ? ret_type->As<ast::type::VectorType>()->size()
- : ret_type->As<ast::type::ArrayType>()->size();
+ if (ret_type->Is<ast::type::Vector>() || ret_type->Is<ast::type::Array>()) {
+ uint32_t size = ret_type->Is<ast::type::Vector>()
+ ? ret_type->As<ast::type::Vector>()->size()
+ : ret_type->As<ast::type::Array>()->size();
if (size == 0) {
error_ = "invalid 0 size for array or vector";
return false;
@@ -201,7 +199,7 @@
} else {
// The row accessor would have been an embedded array accessor and already
// handled, so we just need to do columns here.
- uint32_t size = ret_type->As<ast::type::MatrixType>()->columns();
+ uint32_t size = ret_type->As<ast::type::Matrix>()->columns();
if (!ProcessAccessExpression(expr, size)) {
return false;
}
@@ -234,7 +232,7 @@
return false;
}
} else {
- auto* u32 = mod_->create<ast::type::U32Type>();
+ auto* u32 = mod_->create<ast::type::U32>();
ast::ExpressionList cast_expr;
cast_expr.push_back(expr->idx_expr());
diff --git a/src/transform/bound_array_accessors_transform_test.cc b/src/transform/bound_array_accessors_transform_test.cc
index 7805d8c..8df7a7c 100644
--- a/src/transform/bound_array_accessors_transform_test.cc
+++ b/src/transform/bound_array_accessors_transform_test.cc
@@ -89,7 +89,7 @@
Context ctx_;
ast::Module mod_;
TypeDeterminer td_;
- ast::type::VoidType void_type_;
+ ast::type::Void void_type_;
std::unique_ptr<Manager> manager_;
BoundArrayAccessorsTransform* transform_;
ast::BlockStatement* body_ = nullptr;
@@ -102,10 +102,10 @@
//
// -> const b : ptr<function, i32> = a[min(u32(c), 2)]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::ArrayType ary(&f32, 3);
- ast::type::PointerType ptr_type(&f32, ast::StorageClass::kFunction);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Array ary(&f32, 3);
+ ast::type::Pointer ptr_type(&f32, ast::StorageClass::kFunction);
SetupFunctionAndBody();
DeclareVariable(
@@ -141,7 +141,7 @@
ASSERT_TRUE(idx->params()[0]->Is<ast::ConstructorExpression>());
ASSERT_TRUE(idx->params()[0]->Is<ast::TypeConstructorExpression>());
auto* tc = idx->params()[0]->As<ast::TypeConstructorExpression>();
- EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(tc->type()->Is<ast::type::U32>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@@ -152,7 +152,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) {
@@ -163,10 +163,10 @@
//
// -> var c : f32 = a[min(u32(b[min(u32(i), 4)]), 2)];
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::ArrayType ary3(&f32, 3);
- ast::type::ArrayType ary5(&f32, 5);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Array ary3(&f32, 3);
+ ast::type::Array ary5(&f32, 5);
SetupFunctionAndBody();
DeclareVariable(
@@ -204,7 +204,7 @@
ASSERT_TRUE(idx->params()[0]->Is<ast::ConstructorExpression>());
ASSERT_TRUE(idx->params()[0]->Is<ast::TypeConstructorExpression>());
auto* tc = idx->params()[0]->As<ast::TypeConstructorExpression>();
- EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(tc->type()->Is<ast::type::U32>());
ASSERT_EQ(tc->values().size(), 1u);
auto* sub = tc->values()[0];
@@ -222,7 +222,7 @@
ASSERT_TRUE(sub_idx->params()[0]->Is<ast::ConstructorExpression>());
ASSERT_TRUE(sub_idx->params()[0]->Is<ast::TypeConstructorExpression>());
tc = sub_idx->params()[0]->As<ast::TypeConstructorExpression>();
- EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(tc->type()->Is<ast::type::U32>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], b_access_idx);
@@ -239,7 +239,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) {
@@ -248,9 +248,9 @@
//
// -> var b : f32 = a[1];
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::ArrayType ary(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Array ary(&f32, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -278,7 +278,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) {
@@ -288,9 +288,9 @@
//
// -> var b : f32 = a[min(u32(c + 2 - 3), 2)]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::ArrayType ary(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Array ary(&f32, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -329,7 +329,7 @@
ASSERT_TRUE(idx->params()[0]->Is<ast::ConstructorExpression>());
ASSERT_TRUE(idx->params()[0]->Is<ast::TypeConstructorExpression>());
auto* tc = idx->params()[0]->As<ast::TypeConstructorExpression>();
- EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(tc->type()->Is<ast::type::U32>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@@ -340,7 +340,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) {
@@ -349,9 +349,9 @@
//
// -> var b : f32 = a[0]
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::ArrayType ary(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Array ary(&f32, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -379,7 +379,7 @@
EXPECT_EQ(scalar->literal()->As<ast::SintLiteral>()->value(), 0);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::I32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::I32>());
}
TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) {
@@ -388,9 +388,9 @@
//
// -> var b : f32 = a[2]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::ArrayType ary(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Array ary(&f32, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -418,7 +418,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) {
@@ -427,9 +427,9 @@
//
// -> var b : f32 = a[1]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Vector vec(&f32, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -457,7 +457,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) {
@@ -467,9 +467,9 @@
//
// -> var b : f32 = a[min(u32(c + 2 - 3), 2)]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Vector vec(&f32, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -507,7 +507,7 @@
ASSERT_TRUE(idx->params()[0]->Is<ast::ConstructorExpression>());
ASSERT_TRUE(idx->params()[0]->Is<ast::TypeConstructorExpression>());
auto* tc = idx->params()[0]->As<ast::TypeConstructorExpression>();
- EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(tc->type()->Is<ast::type::U32>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@@ -518,7 +518,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) {
@@ -527,9 +527,9 @@
//
// -> var b : f32 = a[0]
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector vec(&f32, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -557,7 +557,7 @@
EXPECT_EQ(scalar->literal()->As<ast::SintLiteral>()->value(), 0);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::I32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::I32>());
}
TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) {
@@ -566,9 +566,9 @@
//
// -> var b : f32 = a[2]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Vector vec(&f32, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -596,7 +596,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) {
@@ -605,9 +605,9 @@
//
// -> var b : f32 = a[2][1]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Matrix mat(&f32, 2, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -641,7 +641,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
@@ -651,7 +651,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) {
@@ -661,9 +661,9 @@
//
// -> var b : f32 = a[min(u32(c + 2 - 3), 2)][1]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Matrix mat(&f32, 2, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -708,7 +708,7 @@
ASSERT_TRUE(idx->params()[0]->Is<ast::ConstructorExpression>());
ASSERT_TRUE(idx->params()[0]->Is<ast::TypeConstructorExpression>());
auto* tc = idx->params()[0]->As<ast::TypeConstructorExpression>();
- EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(tc->type()->Is<ast::type::U32>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@@ -719,7 +719,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
@@ -729,7 +729,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) {
@@ -739,9 +739,9 @@
//
// -> var b : f32 = a[1][min(u32(c + 2 - 3), 1)]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Matrix mat(&f32, 2, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -794,7 +794,7 @@
ASSERT_TRUE(idx->params()[0]->Is<ast::ConstructorExpression>());
ASSERT_TRUE(idx->params()[0]->Is<ast::TypeConstructorExpression>());
auto* tc = idx->params()[0]->As<ast::TypeConstructorExpression>();
- EXPECT_TRUE(tc->type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(tc->type()->Is<ast::type::U32>());
ASSERT_EQ(tc->values().size(), 1u);
ASSERT_EQ(tc->values()[0], access_idx);
@@ -805,10 +805,10 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 1u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32>());
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) {
@@ -816,9 +816,9 @@
// var b : f32 = a[-1][1]
//
// -> var b : f32 = a[0][1]
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Matrix mat(&f32, 2, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -852,7 +852,7 @@
EXPECT_EQ(scalar->literal()->As<ast::SintLiteral>()->value(), 0);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::I32Type>());
+ ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::I32>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
@@ -862,7 +862,7 @@
EXPECT_EQ(scalar->literal()->As<ast::SintLiteral>()->value(), 1);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::I32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::I32>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) {
@@ -870,9 +870,9 @@
// var b : f32 = a[2][-1]
//
// -> var b : f32 = a[2][0]
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Matrix mat(&f32, 2, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -906,7 +906,7 @@
EXPECT_EQ(scalar->literal()->As<ast::SintLiteral>()->value(), 2);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::I32Type>());
+ ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::I32>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
@@ -916,7 +916,7 @@
EXPECT_EQ(scalar->literal()->As<ast::SintLiteral>()->value(), 0);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::I32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::I32>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) {
@@ -925,9 +925,9 @@
//
// -> var b : f32 = a[2][1]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Matrix mat(&f32, 2, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -961,7 +961,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
@@ -971,7 +971,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) {
@@ -980,9 +980,9 @@
//
// -> var b : f32 = a[2][1]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Matrix mat(&f32, 2, 3);
SetupFunctionAndBody();
DeclareVariable(
@@ -1016,7 +1016,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 2u);
ASSERT_NE(ary->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ary->idx_expr()->result_type()->Is<ast::type::U32>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ConstructorExpression>());
ASSERT_TRUE(ptr->idx_expr()->Is<ast::ScalarConstructorExpression>());
@@ -1026,7 +1026,7 @@
EXPECT_EQ(scalar->literal()->As<ast::UintLiteral>()->value(), 1u);
ASSERT_NE(ptr->idx_expr()->result_type(), nullptr);
- ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32Type>());
+ ASSERT_TRUE(ptr->idx_expr()->result_type()->Is<ast::type::U32>());
}
// TODO(dsinclair): Implement when constant_id exists
diff --git a/src/transform/vertex_pulling_transform.cc b/src/transform/vertex_pulling_transform.cc
index 40cfc4a..21aa053 100644
--- a/src/transform/vertex_pulling_transform.cc
+++ b/src/transform/vertex_pulling_transform.cc
@@ -220,7 +220,7 @@
void VertexPullingTransform::AddVertexStorageBuffers() {
// TODO(idanr): Make this readonly https://github.com/gpuweb/gpuweb/issues/935
// The array inside the struct definition
- auto internal_array = std::make_unique<ast::type::ArrayType>(GetU32Type());
+ auto internal_array = std::make_unique<ast::type::Array>(GetU32Type());
ast::ArrayDecorationList ary_decos;
ary_decos.push_back(create<ast::StrideDecoration>(4u, Source{}));
internal_array->set_decorations(std::move(ary_decos));
@@ -238,7 +238,7 @@
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
- auto* struct_type = mod_->create<ast::type::StructType>(
+ auto* struct_type = mod_->create<ast::type::Struct>(
kStructName, create<ast::Struct>(std::move(decos), std::move(members)));
for (uint32_t i = 0; i < vertex_state_->vertex_buffers.size(); ++i) {
@@ -412,20 +412,19 @@
}
return create<ast::TypeConstructorExpression>(
- mod_->create<ast::type::VectorType>(base_type, count),
- std::move(expr_list));
+ mod_->create<ast::type::Vector>(base_type, count), std::move(expr_list));
}
ast::type::Type* VertexPullingTransform::GetU32Type() {
- return mod_->create<ast::type::U32Type>();
+ return mod_->create<ast::type::U32>();
}
ast::type::Type* VertexPullingTransform::GetI32Type() {
- return mod_->create<ast::type::I32Type>();
+ return mod_->create<ast::type::I32>();
}
ast::type::Type* VertexPullingTransform::GetF32Type() {
- return mod_->create<ast::type::F32Type>();
+ return mod_->create<ast::type::F32>();
}
VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default;
diff --git a/src/transform/vertex_pulling_transform_test.cc b/src/transform/vertex_pulling_transform_test.cc
index 093d7fc..e4657a4 100644
--- a/src/transform/vertex_pulling_transform_test.cc
+++ b/src/transform/vertex_pulling_transform_test.cc
@@ -47,7 +47,7 @@
// Create basic module with an entry point and vertex function
void InitBasicModule() {
auto* func = create<ast::Function>("main", ast::VariableList{},
- mod_->create<ast::type::VoidType>(),
+ mod_->create<ast::type::Void>(),
create<ast::BlockStatement>());
func->add_decoration(
create<ast::StageDecoration>(ast::PipelineStage::kVertex, Source{}));
@@ -125,7 +125,7 @@
TEST_F(VertexPullingTransformTest, Error_EntryPointWrongStage) {
auto* func = create<ast::Function>("main", ast::VariableList{},
- mod()->create<ast::type::VoidType>(),
+ mod()->create<ast::type::Void>(),
create<ast::BlockStatement>());
func->add_decoration(
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
@@ -145,7 +145,7 @@
TEST_F(VertexPullingTransformTest, OneAttribute) {
InitBasicModule();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
AddVertexInputVariable(0, "var_a", &f32);
InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}});
@@ -229,7 +229,7 @@
TEST_F(VertexPullingTransformTest, OneInstancedAttribute) {
InitBasicModule();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
AddVertexInputVariable(0, "var_a", &f32);
InitTransform(
@@ -314,7 +314,7 @@
TEST_F(VertexPullingTransformTest, OneAttributeDifferentOutputSet) {
InitBasicModule();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
AddVertexInputVariable(0, "var_a", &f32);
InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}});
@@ -400,11 +400,11 @@
TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) {
InitBasicModule();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
AddVertexInputVariable(0, "var_a", &f32);
AddVertexInputVariable(1, "var_b", &f32);
- ast::type::I32Type i32;
+ ast::type::I32 i32;
{
auto* vertex_index_var =
create<ast::DecoratedVariable>(create<ast::Variable>(
@@ -564,10 +564,10 @@
TEST_F(VertexPullingTransformTest, TwoAttributesSameBuffer) {
InitBasicModule();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
AddVertexInputVariable(0, "var_a", &f32);
- ast::type::ArrayType vec4_f32{&f32, 4u};
+ ast::type::Array vec4_f32{&f32, 4u};
AddVertexInputVariable(1, "var_b", &vec4_f32);
InitTransform(
@@ -745,14 +745,14 @@
TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
InitBasicModule();
- ast::type::F32Type f32;
- ast::type::ArrayType vec2_f32{&f32, 2u};
+ ast::type::F32 f32;
+ ast::type::Array vec2_f32{&f32, 2u};
AddVertexInputVariable(0, "var_a", &vec2_f32);
- ast::type::ArrayType vec3_f32{&f32, 3u};
+ ast::type::Array vec3_f32{&f32, 3u};
AddVertexInputVariable(1, "var_b", &vec3_f32);
- ast::type::ArrayType vec4_f32{&f32, 4u};
+ ast::type::Array vec4_f32{&f32, 4u};
AddVertexInputVariable(2, "var_c", &vec4_f32);
InitTransform(
diff --git a/src/type_determiner.cc b/src/type_determiner.cc
index b0eaa9a..6679e20 100644
--- a/src/type_determiner.cc
+++ b/src/type_determiner.cc
@@ -88,12 +88,12 @@
bool TypeDeterminer::Determine() {
for (auto& iter : mod_->types()) {
auto& type = iter.second;
- if (!type->Is<ast::type::TextureType>() ||
- !type->Is<ast::type::StorageTextureType>()) {
+ if (!type->Is<ast::type::Texture>() ||
+ !type->Is<ast::type::StorageTexture>()) {
continue;
}
if (!DetermineStorageTextureSubtype(
- type->As<ast::type::StorageTextureType>())) {
+ type->As<ast::type::StorageTexture>())) {
set_error(Source{}, "unable to determine storage texture subtype for: " +
type->type_name());
return false;
@@ -330,13 +330,13 @@
auto* res = expr->array()->result_type();
auto* parent_type = res->UnwrapAll();
ast::type::Type* ret = nullptr;
- if (parent_type->Is<ast::type::ArrayType>()) {
- ret = parent_type->As<ast::type::ArrayType>()->type();
- } else if (parent_type->Is<ast::type::VectorType>()) {
- ret = parent_type->As<ast::type::VectorType>()->type();
- } else if (parent_type->Is<ast::type::MatrixType>()) {
- auto* m = parent_type->As<ast::type::MatrixType>();
- ret = mod_->create<ast::type::VectorType>(m->type(), m->rows());
+ if (parent_type->Is<ast::type::Array>()) {
+ ret = parent_type->As<ast::type::Array>()->type();
+ } else if (parent_type->Is<ast::type::Vector>()) {
+ ret = parent_type->As<ast::type::Vector>()->type();
+ } else if (parent_type->Is<ast::type::Matrix>()) {
+ auto* m = parent_type->As<ast::type::Matrix>();
+ ret = mod_->create<ast::type::Vector>(m->type(), m->rows());
} else {
set_error(expr->source(), "invalid parent type (" +
parent_type->type_name() +
@@ -345,16 +345,15 @@
}
// If we're extracting from a pointer, we return a pointer.
- if (res->Is<ast::type::PointerType>()) {
- ret = mod_->create<ast::type::PointerType>(
- ret, res->As<ast::type::PointerType>()->storage_class());
- } else if (parent_type->Is<ast::type::ArrayType>() &&
- !parent_type->As<ast::type::ArrayType>()->type()->is_scalar()) {
+ if (res->Is<ast::type::Pointer>()) {
+ ret = mod_->create<ast::type::Pointer>(
+ ret, res->As<ast::type::Pointer>()->storage_class());
+ } else if (parent_type->Is<ast::type::Array>() &&
+ !parent_type->As<ast::type::Array>()->type()->is_scalar()) {
// If we extract a non-scalar from an array then we also get a pointer. We
// will generate a Function storage class variable to store this
// into.
- ret =
- mod_->create<ast::type::PointerType>(ret, ast::StorageClass::kFunction);
+ ret = mod_->create<ast::type::Pointer>(ret, ast::StorageClass::kFunction);
}
expr->set_result_type(ret);
@@ -516,11 +515,11 @@
}
if (ident->intrinsic() == ast::Intrinsic::kAny ||
ident->intrinsic() == ast::Intrinsic::kAll) {
- expr->func()->set_result_type(mod_->create<ast::type::BoolType>());
+ expr->func()->set_result_type(mod_->create<ast::type::Bool>());
return true;
}
if (ident->intrinsic() == ast::Intrinsic::kArrayLength) {
- expr->func()->set_result_type(mod_->create<ast::type::U32Type>());
+ expr->func()->set_result_type(mod_->create<ast::type::U32>());
return true;
}
if (ast::intrinsic::IsFloatClassificationIntrinsic(ident->intrinsic())) {
@@ -530,12 +529,12 @@
return false;
}
- auto* bool_type = mod_->create<ast::type::BoolType>();
+ auto* bool_type = mod_->create<ast::type::Bool>();
auto* param_type = expr->params()[0]->result_type()->UnwrapPtrIfNeeded();
- if (param_type->Is<ast::type::VectorType>()) {
- expr->func()->set_result_type(mod_->create<ast::type::VectorType>(
- bool_type, param_type->As<ast::type::VectorType>()->size()));
+ if (param_type->Is<ast::type::Vector>()) {
+ expr->func()->set_result_type(mod_->create<ast::type::Vector>(
+ bool_type, param_type->As<ast::type::Vector>()->size()));
} else {
expr->func()->set_result_type(bool_type);
}
@@ -547,13 +546,13 @@
auto* texture_param = expr->params()[0];
if (!texture_param->result_type()
->UnwrapPtrIfNeeded()
- ->Is<ast::type::TextureType>()) {
+ ->Is<ast::type::Texture>()) {
set_error(expr->source(), "invalid first argument for " + ident->name());
return false;
}
- ast::type::TextureType* texture = texture_param->result_type()
- ->UnwrapPtrIfNeeded()
- ->As<ast::type::TextureType>();
+ ast::type::Texture* texture = texture_param->result_type()
+ ->UnwrapPtrIfNeeded()
+ ->As<ast::type::Texture>();
bool is_array = false;
switch (texture->dim()) {
@@ -658,34 +657,34 @@
ident->set_intrinsic_signature(
std::make_unique<ast::intrinsic::TextureSignature>(param));
- if (texture->Is<ast::type::DepthTextureType>()) {
- expr->func()->set_result_type(mod_->create<ast::type::F32Type>());
+ if (texture->Is<ast::type::DepthTexture>()) {
+ expr->func()->set_result_type(mod_->create<ast::type::F32>());
return true;
}
- if (!texture->Is<ast::type::StorageTextureType>() &&
- !(texture->Is<ast::type::SampledTextureType>() ||
- texture->Is<ast::type::MultisampledTextureType>())) {
+ if (!texture->Is<ast::type::StorageTexture>() &&
+ !(texture->Is<ast::type::SampledTexture>() ||
+ texture->Is<ast::type::MultisampledTexture>())) {
set_error(expr->source(), "invalid texture for " + ident->name());
return false;
}
ast::type::Type* type = nullptr;
- if (texture->Is<ast::type::StorageTextureType>()) {
- type = texture->As<ast::type::StorageTextureType>()->type();
- } else if (texture->Is<ast::type::SampledTextureType>()) {
- type = texture->As<ast::type::SampledTextureType>()->type();
- } else if (texture->Is<ast::type::MultisampledTextureType>()) {
- type = texture->As<ast::type::MultisampledTextureType>()->type();
+ if (texture->Is<ast::type::StorageTexture>()) {
+ type = texture->As<ast::type::StorageTexture>()->type();
+ } else if (texture->Is<ast::type::SampledTexture>()) {
+ type = texture->As<ast::type::SampledTexture>()->type();
+ } else if (texture->Is<ast::type::MultisampledTexture>()) {
+ type = texture->As<ast::type::MultisampledTexture>()->type();
} else {
set_error(expr->source(), "unknown texture type for texture sampling");
return false;
}
- expr->func()->set_result_type(mod_->create<ast::type::VectorType>(type, 4));
+ expr->func()->set_result_type(mod_->create<ast::type::Vector>(type, 4));
return true;
}
if (ident->intrinsic() == ast::Intrinsic::kDot) {
- expr->func()->set_result_type(mod_->create<ast::type::F32Type>());
+ expr->func()->set_result_type(mod_->create<ast::type::F32>());
return true;
}
if (ident->intrinsic() == ast::Intrinsic::kOuterProduct) {
@@ -697,16 +696,16 @@
auto* param0_type = expr->params()[0]->result_type()->UnwrapPtrIfNeeded();
auto* param1_type = expr->params()[1]->result_type()->UnwrapPtrIfNeeded();
- if (!param0_type->Is<ast::type::VectorType>() ||
- !param1_type->Is<ast::type::VectorType>()) {
+ if (!param0_type->Is<ast::type::Vector>() ||
+ !param1_type->Is<ast::type::Vector>()) {
set_error(expr->source(), "invalid parameter type for " + ident->name());
return false;
}
- expr->func()->set_result_type(mod_->create<ast::type::MatrixType>(
- mod_->create<ast::type::F32Type>(),
- param0_type->As<ast::type::VectorType>()->size(),
- param1_type->As<ast::type::VectorType>()->size()));
+ expr->func()->set_result_type(mod_->create<ast::type::Matrix>(
+ mod_->create<ast::type::F32>(),
+ param0_type->As<ast::type::Vector>()->size(),
+ param1_type->As<ast::type::Vector>()->size()));
return true;
}
if (ident->intrinsic() == ast::Intrinsic::kSelect) {
@@ -782,7 +781,7 @@
return false;
}
if (data->vector_size > 0 &&
- result_types.back()->As<ast::type::VectorType>()->size() !=
+ result_types.back()->As<ast::type::Vector>()->size() !=
data->vector_size) {
set_error(expr->source(), "incorrect vector size for " +
ident->name() + ". " + "Requires " +
@@ -792,7 +791,7 @@
}
break;
case IntrinsicDataType::kMatrix:
- if (!result_types.back()->Is<ast::type::MatrixType>()) {
+ if (!result_types.back()->Is<ast::type::Matrix>()) {
set_error(expr->source(), "incorrect type for " + ident->name() +
". Requires matrix value");
return false;
@@ -817,13 +816,13 @@
expr->func()->set_result_type(
result_types[0]->is_float_scalar()
? result_types[0]
- : result_types[0]->As<ast::type::VectorType>()->type());
+ : result_types[0]->As<ast::type::Vector>()->type());
return true;
}
// The determinant returns the component type of the columns
if (ident->intrinsic() == ast::Intrinsic::kDeterminant) {
expr->func()->set_result_type(
- result_types[0]->As<ast::type::MatrixType>()->type());
+ result_types[0]->As<ast::type::Matrix>()->type());
return true;
}
expr->func()->set_result_type(result_types[0]);
@@ -853,11 +852,11 @@
// the pointer around the variable type.
if (var->is_const()) {
expr->set_result_type(var->type());
- } else if (var->type()->Is<ast::type::PointerType>()) {
+ } else if (var->type()->Is<ast::type::Pointer>()) {
expr->set_result_type(var->type());
} else {
- expr->set_result_type(mod_->create<ast::type::PointerType>(
- var->type(), var->storage_class()));
+ expr->set_result_type(
+ mod_->create<ast::type::Pointer>(var->type(), var->storage_class()));
}
set_referenced_from_function_if_needed(var);
@@ -1031,8 +1030,8 @@
auto* data_type = res->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
ast::type::Type* ret = nullptr;
- if (data_type->Is<ast::type::StructType>()) {
- auto* strct = data_type->As<ast::type::StructType>()->impl();
+ if (data_type->Is<ast::type::Struct>()) {
+ auto* strct = data_type->As<ast::type::Struct>()->impl();
auto name = expr->member()->name();
for (auto* member : strct->members()) {
@@ -1048,27 +1047,27 @@
}
// If we're extracting from a pointer, we return a pointer.
- if (res->Is<ast::type::PointerType>()) {
- ret = mod_->create<ast::type::PointerType>(
- ret, res->As<ast::type::PointerType>()->storage_class());
+ if (res->Is<ast::type::Pointer>()) {
+ ret = mod_->create<ast::type::Pointer>(
+ ret, res->As<ast::type::Pointer>()->storage_class());
}
- } else if (data_type->Is<ast::type::VectorType>()) {
- auto* vec = data_type->As<ast::type::VectorType>();
+ } else if (data_type->Is<ast::type::Vector>()) {
+ auto* vec = data_type->As<ast::type::Vector>();
auto size = expr->member()->name().size();
if (size == 1) {
// A single element swizzle is just the type of the vector.
ret = vec->type();
// If we're extracting from a pointer, we return a pointer.
- if (res->Is<ast::type::PointerType>()) {
- ret = mod_->create<ast::type::PointerType>(
- ret, res->As<ast::type::PointerType>()->storage_class());
+ if (res->Is<ast::type::Pointer>()) {
+ ret = mod_->create<ast::type::Pointer>(
+ ret, res->As<ast::type::Pointer>()->storage_class());
}
} else {
// The vector will have a number of components equal to the length of the
// swizzle. This assumes the validator will check that the swizzle
// is correct.
- ret = mod_->create<ast::type::VectorType>(vec->type(), size);
+ ret = mod_->create<ast::type::Vector>(vec->type(), size);
}
} else {
set_error(
@@ -1099,11 +1098,11 @@
if (expr->IsLogicalAnd() || expr->IsLogicalOr() || expr->IsEqual() ||
expr->IsNotEqual() || expr->IsLessThan() || expr->IsGreaterThan() ||
expr->IsLessThanEqual() || expr->IsGreaterThanEqual()) {
- auto* bool_type = mod_->create<ast::type::BoolType>();
+ auto* bool_type = mod_->create<ast::type::Bool>();
auto* param_type = expr->lhs()->result_type()->UnwrapPtrIfNeeded();
- if (param_type->Is<ast::type::VectorType>()) {
- expr->set_result_type(mod_->create<ast::type::VectorType>(
- bool_type, param_type->As<ast::type::VectorType>()->size()));
+ if (param_type->Is<ast::type::Vector>()) {
+ expr->set_result_type(mod_->create<ast::type::Vector>(
+ bool_type, param_type->As<ast::type::Vector>()->size()));
} else {
expr->set_result_type(bool_type);
}
@@ -1115,36 +1114,36 @@
// Note, the ordering here matters. The later checks depend on the prior
// checks having been done.
- if (lhs_type->Is<ast::type::MatrixType>() &&
- rhs_type->Is<ast::type::MatrixType>()) {
- expr->set_result_type(mod_->create<ast::type::MatrixType>(
- lhs_type->As<ast::type::MatrixType>()->type(),
- lhs_type->As<ast::type::MatrixType>()->rows(),
- rhs_type->As<ast::type::MatrixType>()->columns()));
+ if (lhs_type->Is<ast::type::Matrix>() &&
+ rhs_type->Is<ast::type::Matrix>()) {
+ expr->set_result_type(mod_->create<ast::type::Matrix>(
+ lhs_type->As<ast::type::Matrix>()->type(),
+ lhs_type->As<ast::type::Matrix>()->rows(),
+ rhs_type->As<ast::type::Matrix>()->columns()));
- } else if (lhs_type->Is<ast::type::MatrixType>() &&
- rhs_type->Is<ast::type::VectorType>()) {
- auto* mat = lhs_type->As<ast::type::MatrixType>();
+ } else if (lhs_type->Is<ast::type::Matrix>() &&
+ rhs_type->Is<ast::type::Vector>()) {
+ auto* mat = lhs_type->As<ast::type::Matrix>();
expr->set_result_type(
- mod_->create<ast::type::VectorType>(mat->type(), mat->rows()));
- } else if (lhs_type->Is<ast::type::VectorType>() &&
- rhs_type->Is<ast::type::MatrixType>()) {
- auto* mat = rhs_type->As<ast::type::MatrixType>();
+ mod_->create<ast::type::Vector>(mat->type(), mat->rows()));
+ } else if (lhs_type->Is<ast::type::Vector>() &&
+ rhs_type->Is<ast::type::Matrix>()) {
+ auto* mat = rhs_type->As<ast::type::Matrix>();
expr->set_result_type(
- mod_->create<ast::type::VectorType>(mat->type(), mat->columns()));
- } else if (lhs_type->Is<ast::type::MatrixType>()) {
+ mod_->create<ast::type::Vector>(mat->type(), mat->columns()));
+ } else if (lhs_type->Is<ast::type::Matrix>()) {
// matrix * scalar
expr->set_result_type(lhs_type);
- } else if (rhs_type->Is<ast::type::MatrixType>()) {
+ } else if (rhs_type->Is<ast::type::Matrix>()) {
// scalar * matrix
expr->set_result_type(rhs_type);
- } else if (lhs_type->Is<ast::type::VectorType>() &&
- rhs_type->Is<ast::type::VectorType>()) {
+ } else if (lhs_type->Is<ast::type::Vector>() &&
+ rhs_type->Is<ast::type::Vector>()) {
expr->set_result_type(lhs_type);
- } else if (lhs_type->Is<ast::type::VectorType>()) {
+ } else if (lhs_type->Is<ast::type::Vector>()) {
// Vector * scalar
expr->set_result_type(lhs_type);
- } else if (rhs_type->Is<ast::type::VectorType>()) {
+ } else if (rhs_type->Is<ast::type::Vector>()) {
// Scalar * vector
expr->set_result_type(rhs_type);
} else {
@@ -1169,7 +1168,7 @@
}
bool TypeDeterminer::DetermineStorageTextureSubtype(
- ast::type::StorageTextureType* tex) {
+ ast::type::StorageTexture* tex) {
if (tex->type() != nullptr) {
return true;
}
@@ -1184,7 +1183,7 @@
case ast::type::ImageFormat::kRg32Uint:
case ast::type::ImageFormat::kRgba16Uint:
case ast::type::ImageFormat::kRgba32Uint: {
- tex->set_type(mod_->create<ast::type::U32Type>());
+ tex->set_type(mod_->create<ast::type::U32>());
return true;
}
@@ -1197,7 +1196,7 @@
case ast::type::ImageFormat::kRg32Sint:
case ast::type::ImageFormat::kRgba16Sint:
case ast::type::ImageFormat::kRgba32Sint: {
- tex->set_type(mod_->create<ast::type::I32Type>());
+ tex->set_type(mod_->create<ast::type::I32>());
return true;
}
@@ -1218,7 +1217,7 @@
case ast::type::ImageFormat::kRg32Float:
case ast::type::ImageFormat::kRgba16Float:
case ast::type::ImageFormat::kRgba32Float: {
- tex->set_type(mod_->create<ast::type::F32Type>());
+ tex->set_type(mod_->create<ast::type::F32>());
return true;
}
diff --git a/src/type_determiner.h b/src/type_determiner.h
index af279f5..9d2fec9 100644
--- a/src/type_determiner.h
+++ b/src/type_determiner.h
@@ -86,7 +86,7 @@
/// Determines the result type based off a storage texture format
/// @param tex the storage texture
/// @returns false on error
- bool DetermineStorageTextureSubtype(ast::type::StorageTextureType* tex);
+ bool DetermineStorageTextureSubtype(ast::type::StorageTexture* tex);
/// Testing method to set a given variable into the type stack
/// @param var the variable to set
diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc
index 5357c82..e39736c 100644
--- a/src/type_determiner_test.cc
+++ b/src/type_determiner_test.cc
@@ -121,8 +121,8 @@
}
TEST_F(TypeDeterminerTest, Stmt_Assign) {
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -135,13 +135,13 @@
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Case) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -158,13 +158,13 @@
EXPECT_TRUE(td()->DetermineResultType(&cse));
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Block) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -177,13 +177,13 @@
EXPECT_TRUE(td()->DetermineResultType(&block));
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Else) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -201,14 +201,14 @@
ASSERT_NE(stmt.condition()->result_type(), nullptr);
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(stmt.condition()->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(stmt.condition()->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_If) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* else_lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -245,16 +245,16 @@
ASSERT_NE(else_rhs->result_type(), nullptr);
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(stmt.condition()->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(else_lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(else_rhs->result_type()->Is<ast::type::F32Type>());
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(stmt.condition()->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(else_lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(else_rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Loop) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* body_lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -280,14 +280,14 @@
ASSERT_NE(body_rhs->result_type(), nullptr);
ASSERT_NE(continuing_lhs->result_type(), nullptr);
ASSERT_NE(continuing_rhs->result_type(), nullptr);
- EXPECT_TRUE(body_lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(body_rhs->result_type()->Is<ast::type::F32Type>());
- EXPECT_TRUE(continuing_lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(continuing_rhs->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(body_lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(body_rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(continuing_lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(continuing_rhs->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Return) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -296,18 +296,18 @@
EXPECT_TRUE(td()->DetermineResultType(&ret));
ASSERT_NE(cond->result_type(), nullptr);
- EXPECT_TRUE(cond->result_type()->Is<ast::type::I32Type>());
+ EXPECT_TRUE(cond->result_type()->Is<ast::type::I32>());
}
TEST_F(TypeDeterminerTest, Stmt_Return_WithoutValue) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ReturnStatement ret;
EXPECT_TRUE(td()->DetermineResultType(&ret));
}
TEST_F(TypeDeterminerTest, Stmt_Switch) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -332,13 +332,13 @@
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(stmt.condition()->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32Type>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(stmt.condition()->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Call) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableList params;
auto* func = create<ast::Function>("my_func", params, &f32,
@@ -355,13 +355,13 @@
ast::CallStatement call(expr);
EXPECT_TRUE(td()->DetermineResultType(&call));
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(expr->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) {
// fn main() -> void {func(); return; }
// fn func() -> void { return; }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList call_params;
auto* call_expr =
create<ast::CallExpression>(create<ast::IdentifierExpression>(
@@ -385,7 +385,7 @@
}
TEST_F(TypeDeterminerTest, Stmt_VariableDecl) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -395,11 +395,11 @@
EXPECT_TRUE(td()->DetermineResultType(&decl));
ASSERT_NE(init->result_type(), nullptr);
- EXPECT_TRUE(init->result_type()->Is<ast::type::I32Type>());
+ EXPECT_TRUE(init->result_type()->Is<ast::type::I32>());
}
TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -409,7 +409,7 @@
EXPECT_TRUE(td()->Determine());
ASSERT_NE(init->result_type(), nullptr);
- EXPECT_TRUE(init->result_type()->Is<ast::type::I32Type>());
+ EXPECT_TRUE(init->result_type()->Is<ast::type::I32>());
}
TEST_F(TypeDeterminerTest, Expr_Error_Unknown) {
@@ -421,9 +421,9 @@
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 3);
auto* idx = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -438,17 +438,17 @@
idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
- ASSERT_TRUE(acc.result_type()->Is<ast::type::PointerType>());
+ ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
- auto* ptr = acc.result_type()->As<ast::type::PointerType>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32Type>());
+ auto* ptr = acc.result_type()->As<ast::type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 3);
- ast::type::AliasType aary("myarrty", &ary);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 3);
+ ast::type::Alias aary("myarrty", &ary);
auto* idx = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -463,16 +463,16 @@
idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
- ASSERT_TRUE(acc.result_type()->Is<ast::type::PointerType>());
+ ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
- auto* ptr = acc.result_type()->As<ast::type::PointerType>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32Type>());
+ auto* ptr = acc.result_type()->As<ast::type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 3);
auto* idx = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -488,14 +488,14 @@
idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
- EXPECT_TRUE(acc.result_type()->Is<ast::type::F32Type>())
+ EXPECT_TRUE(acc.result_type()->Is<ast::type::F32>())
<< acc.result_type()->type_name();
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 2);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 2);
auto* idx = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -509,17 +509,17 @@
idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
- ASSERT_TRUE(acc.result_type()->Is<ast::type::PointerType>());
+ ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
- auto* ptr = acc.result_type()->As<ast::type::PointerType>();
- ASSERT_TRUE(ptr->type()->Is<ast::type::VectorType>());
- EXPECT_EQ(ptr->type()->As<ast::type::VectorType>()->size(), 3u);
+ auto* ptr = acc.result_type()->As<ast::type::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<ast::type::Vector>());
+ EXPECT_EQ(ptr->type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 2);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 2);
auto* idx1 = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -538,16 +538,16 @@
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
- ASSERT_TRUE(acc.result_type()->Is<ast::type::PointerType>());
+ ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
- auto* ptr = acc.result_type()->As<ast::type::PointerType>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32Type>());
+ auto* ptr = acc.result_type()->As<ast::type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
auto* idx = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@@ -561,14 +561,14 @@
idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
- ASSERT_TRUE(acc.result_type()->Is<ast::type::PointerType>());
+ ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
- auto* ptr = acc.result_type()->As<ast::type::PointerType>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32Type>());
+ auto* ptr = acc.result_type()->As<ast::type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Bitcast) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::BitcastExpression bitcast(&f32,
create<ast::IdentifierExpression>("name"));
@@ -577,11 +577,11 @@
EXPECT_TRUE(td()->DetermineResultType(&bitcast));
ASSERT_NE(bitcast.result_type(), nullptr);
- EXPECT_TRUE(bitcast.result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(bitcast.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Call) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableList params;
auto* func = create<ast::Function>("my_func", params, &f32,
@@ -596,11 +596,11 @@
call_params);
EXPECT_TRUE(td()->DetermineResultType(&call));
ASSERT_NE(call.result_type(), nullptr);
- EXPECT_TRUE(call.result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(call.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Call_WithParams) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableList params;
auto* func = create<ast::Function>("my_func", params, &f32,
@@ -620,11 +620,11 @@
call_params);
EXPECT_TRUE(td()->DetermineResultType(&call));
ASSERT_NE(param->result_type(), nullptr);
- EXPECT_TRUE(param->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(param->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Call_Intrinsic) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// Register the function
EXPECT_TRUE(td()->Determine());
@@ -638,11 +638,11 @@
EXPECT_TRUE(td()->DetermineResultType(&call));
ASSERT_NE(call.result_type(), nullptr);
- EXPECT_TRUE(call.result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(call.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Cast) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>("name"));
@@ -653,21 +653,21 @@
EXPECT_TRUE(td()->DetermineResultType(&cast));
ASSERT_NE(cast.result_type(), nullptr);
- EXPECT_TRUE(cast.result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(cast.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Constructor_Scalar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ScalarConstructorExpression s(create<ast::FloatLiteral>(&f32, 1.0f));
EXPECT_TRUE(td()->DetermineResultType(&s));
ASSERT_NE(s.result_type(), nullptr);
- EXPECT_TRUE(s.result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(s.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Constructor_Type) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -681,16 +681,14 @@
EXPECT_TRUE(td()->DetermineResultType(&tc));
ASSERT_NE(tc.result_type(), nullptr);
- ASSERT_TRUE(tc.result_type()->Is<ast::type::VectorType>());
- EXPECT_TRUE(tc.result_type()
- ->As<ast::type::VectorType>()
- ->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(tc.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ASSERT_TRUE(tc.result_type()->Is<ast::type::Vector>());
+ EXPECT_TRUE(
+ tc.result_type()->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(tc.result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
mod->AddGlobalVariable(var);
@@ -700,15 +698,15 @@
ast::IdentifierExpression ident("my_var");
EXPECT_TRUE(td()->DetermineResultType(&ident));
ASSERT_NE(ident.result_type(), nullptr);
- EXPECT_TRUE(ident.result_type()->Is<ast::type::PointerType>());
+ EXPECT_TRUE(ident.result_type()->Is<ast::type::Pointer>());
EXPECT_TRUE(ident.result_type()
- ->As<ast::type::PointerType>()
+ ->As<ast::type::Pointer>()
->type()
- ->Is<ast::type::F32Type>());
+ ->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
var->set_is_const(true);
mod->AddGlobalVariable(var);
@@ -719,11 +717,11 @@
ast::IdentifierExpression ident("my_var");
EXPECT_TRUE(td()->DetermineResultType(&ident));
ASSERT_NE(ident.result_type(), nullptr);
- EXPECT_TRUE(ident.result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ident.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* my_var = create<ast::IdentifierExpression>("my_var");
@@ -740,11 +738,11 @@
EXPECT_TRUE(td()->DetermineFunction(&f));
ASSERT_NE(my_var->result_type(), nullptr);
- EXPECT_TRUE(my_var->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(my_var->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* my_var = create<ast::IdentifierExpression>("my_var");
@@ -760,16 +758,16 @@
EXPECT_TRUE(td()->DetermineFunction(&f));
ASSERT_NE(my_var->result_type(), nullptr);
- EXPECT_TRUE(my_var->result_type()->Is<ast::type::PointerType>());
+ EXPECT_TRUE(my_var->result_type()->Is<ast::type::Pointer>());
EXPECT_TRUE(my_var->result_type()
- ->As<ast::type::PointerType>()
+ ->As<ast::type::Pointer>()
->type()
- ->Is<ast::type::F32Type>());
+ ->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) {
- ast::type::F32Type f32;
- ast::type::PointerType ptr(&f32, ast::StorageClass::kFunction);
+ ast::type::F32 f32;
+ ast::type::Pointer ptr(&f32, ast::StorageClass::kFunction);
auto* my_var = create<ast::IdentifierExpression>("my_var");
@@ -785,15 +783,15 @@
EXPECT_TRUE(td()->DetermineFunction(&f));
ASSERT_NE(my_var->result_type(), nullptr);
- EXPECT_TRUE(my_var->result_type()->Is<ast::type::PointerType>());
+ EXPECT_TRUE(my_var->result_type()->Is<ast::type::Pointer>());
EXPECT_TRUE(my_var->result_type()
- ->As<ast::type::PointerType>()
+ ->As<ast::type::Pointer>()
->type()
- ->Is<ast::type::F32Type>());
+ ->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_Function) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableList params;
auto* func = create<ast::Function>("my_func", params, &f32,
@@ -806,7 +804,7 @@
ast::IdentifierExpression ident("my_func");
EXPECT_TRUE(td()->DetermineResultType(&ident));
ASSERT_NE(ident.result_type(), nullptr);
- EXPECT_TRUE(ident.result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ident.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) {
@@ -815,7 +813,7 @@
}
TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* in_var =
create<ast::Variable>("in_var", ast::StorageClass::kInput, &f32);
@@ -865,7 +863,7 @@
}
TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* in_var =
create<ast::Variable>("in_var", ast::StorageClass::kInput, &f32);
@@ -924,7 +922,7 @@
}
TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var =
create<ast::Variable>("in_var", ast::StorageClass::kFunction, &f32);
@@ -951,8 +949,8 @@
}
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
@@ -961,7 +959,7 @@
auto* strct = create<ast::Struct>(members);
- ast::type::StructType st("S", strct);
+ ast::type::Struct st("S", strct);
auto* var = create<ast::Variable>("my_struct", ast::StorageClass::kNone, &st);
@@ -976,15 +974,15 @@
ast::MemberAccessorExpression mem(ident, mem_ident);
EXPECT_TRUE(td()->DetermineResultType(&mem));
ASSERT_NE(mem.result_type(), nullptr);
- ASSERT_TRUE(mem.result_type()->Is<ast::type::PointerType>());
+ ASSERT_TRUE(mem.result_type()->Is<ast::type::Pointer>());
- auto* ptr = mem.result_type()->As<ast::type::PointerType>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32Type>());
+ auto* ptr = mem.result_type()->As<ast::type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
@@ -993,8 +991,8 @@
auto* strct = create<ast::Struct>(members);
- auto st = std::make_unique<ast::type::StructType>("alias", strct);
- ast::type::AliasType alias("alias", st.get());
+ auto st = std::make_unique<ast::type::Struct>("alias", strct);
+ ast::type::Alias alias("alias", st.get());
auto* var =
create<ast::Variable>("my_struct", ast::StorageClass::kNone, &alias);
@@ -1010,15 +1008,15 @@
ast::MemberAccessorExpression mem(ident, mem_ident);
EXPECT_TRUE(td()->DetermineResultType(&mem));
ASSERT_NE(mem.result_type(), nullptr);
- ASSERT_TRUE(mem.result_type()->Is<ast::type::PointerType>());
+ ASSERT_TRUE(mem.result_type()->Is<ast::type::Pointer>());
- auto* ptr = mem.result_type()->As<ast::type::PointerType>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32Type>());
+ auto* ptr = mem.result_type()->As<ast::type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* var = create<ast::Variable>("my_vec", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -1032,17 +1030,15 @@
ast::MemberAccessorExpression mem(ident, swizzle);
EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error();
ASSERT_NE(mem.result_type(), nullptr);
- ASSERT_TRUE(mem.result_type()->Is<ast::type::VectorType>());
- EXPECT_TRUE(mem.result_type()
- ->As<ast::type::VectorType>()
- ->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(mem.result_type()->As<ast::type::VectorType>()->size(), 2u);
+ ASSERT_TRUE(mem.result_type()->Is<ast::type::Vector>());
+ EXPECT_TRUE(
+ mem.result_type()->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(mem.result_type()->As<ast::type::Vector>()->size(), 2u);
}
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* var = create<ast::Variable>("my_vec", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -1056,10 +1052,10 @@
ast::MemberAccessorExpression mem(ident, swizzle);
EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error();
ASSERT_NE(mem.result_type(), nullptr);
- ASSERT_TRUE(mem.result_type()->Is<ast::type::PointerType>());
+ ASSERT_TRUE(mem.result_type()->Is<ast::type::Pointer>());
- auto* ptr = mem.result_type()->As<ast::type::PointerType>();
- ASSERT_TRUE(ptr->type()->Is<ast::type::F32Type>());
+ auto* ptr = mem.result_type()->As<ast::type::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) {
@@ -1087,26 +1083,26 @@
// Identifier{yx}
// }
//
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Vector vec4(&f32, 4);
ast::StructMemberDecorationList decos;
ast::StructMemberList b_members;
b_members.push_back(create<ast::StructMember>("foo", &vec4, decos));
auto* strctB = create<ast::Struct>(b_members);
- ast::type::StructType stB("B", strctB);
+ ast::type::Struct stB("B", strctB);
- ast::type::VectorType vecB(&stB, 3);
+ ast::type::Vector vecB(&stB, 3);
ast::StructMemberList a_members;
a_members.push_back(create<ast::StructMember>("mem", &vecB, decos));
auto* strctA = create<ast::Struct>(a_members);
- ast::type::StructType stA("A", strctA);
+ ast::type::Struct stA("A", strctA);
auto* var = create<ast::Variable>("c", ast::StorageClass::kNone, &stA);
mod->AddGlobalVariable(var);
@@ -1130,19 +1126,17 @@
EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error();
ASSERT_NE(mem.result_type(), nullptr);
- ASSERT_TRUE(mem.result_type()->Is<ast::type::VectorType>());
- EXPECT_TRUE(mem.result_type()
- ->As<ast::type::VectorType>()
- ->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(mem.result_type()->As<ast::type::VectorType>()->size(), 2u);
+ ASSERT_TRUE(mem.result_type()->Is<ast::type::Vector>());
+ EXPECT_TRUE(
+ mem.result_type()->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(mem.result_type()->As<ast::type::Vector>()->size(), 2u);
}
using Expr_Binary_BitwiseTest = TypeDeterminerTestWithParam<ast::BinaryOp>;
TEST_P(Expr_Binary_BitwiseTest, Scalar) {
auto op = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &i32);
mod->AddGlobalVariable(var);
@@ -1155,14 +1149,14 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- EXPECT_TRUE(expr.result_type()->Is<ast::type::I32Type>());
+ EXPECT_TRUE(expr.result_type()->Is<ast::type::I32>());
}
TEST_P(Expr_Binary_BitwiseTest, Vector) {
auto op = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec3(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec3(&i32, 3);
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -1175,12 +1169,12 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::I32Type>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ->Is<ast::type::I32>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
Expr_Binary_BitwiseTest,
@@ -1198,7 +1192,7 @@
TEST_P(Expr_Binary_LogicalTest, Scalar) {
auto op = GetParam();
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* var =
create<ast::Variable>("val", ast::StorageClass::kNone, &bool_type);
@@ -1212,14 +1206,14 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- EXPECT_TRUE(expr.result_type()->Is<ast::type::BoolType>());
+ EXPECT_TRUE(expr.result_type()->Is<ast::type::Bool>());
}
TEST_P(Expr_Binary_LogicalTest, Vector) {
auto op = GetParam();
- ast::type::BoolType bool_type;
- ast::type::VectorType vec3(&bool_type, 3);
+ ast::type::Bool bool_type;
+ ast::type::Vector vec3(&bool_type, 3);
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -1232,12 +1226,12 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::BoolType>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ->Is<ast::type::Bool>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
Expr_Binary_LogicalTest,
@@ -1248,7 +1242,7 @@
TEST_P(Expr_Binary_CompareTest, Scalar) {
auto op = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &i32);
mod->AddGlobalVariable(var);
@@ -1261,14 +1255,14 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- EXPECT_TRUE(expr.result_type()->Is<ast::type::BoolType>());
+ EXPECT_TRUE(expr.result_type()->Is<ast::type::Bool>());
}
TEST_P(Expr_Binary_CompareTest, Vector) {
auto op = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec3(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec3(&i32, 3);
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -1281,12 +1275,12 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::BoolType>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ->Is<ast::type::Bool>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
Expr_Binary_CompareTest,
@@ -1298,7 +1292,7 @@
ast::BinaryOp::kGreaterThanEqual));
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &i32);
mod->AddGlobalVariable(var);
@@ -1312,12 +1306,12 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- EXPECT_TRUE(expr.result_type()->Is<ast::type::I32Type>());
+ EXPECT_TRUE(expr.result_type()->Is<ast::type::I32>());
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* scalar =
create<ast::Variable>("scalar", ast::StorageClass::kNone, &f32);
@@ -1335,17 +1329,17 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ->Is<ast::type::F32>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* scalar =
create<ast::Variable>("scalar", ast::StorageClass::kNone, &f32);
@@ -1363,17 +1357,17 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ->Is<ast::type::F32>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* vector =
create<ast::Variable>("vector", ast::StorageClass::kNone, &vec3);
@@ -1388,17 +1382,17 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ->Is<ast::type::F32>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat3x2(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix mat3x2(&f32, 3, 2);
auto* scalar =
create<ast::Variable>("scalar", ast::StorageClass::kNone, &f32);
@@ -1416,17 +1410,17 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::MatrixType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Matrix>());
- auto* mat = expr.result_type()->As<ast::type::MatrixType>();
- EXPECT_TRUE(mat->type()->Is<ast::type::F32Type>());
+ auto* mat = expr.result_type()->As<ast::type::Matrix>();
+ EXPECT_TRUE(mat->type()->Is<ast::type::F32>());
EXPECT_EQ(mat->rows(), 3u);
EXPECT_EQ(mat->columns(), 2u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat3x2(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix mat3x2(&f32, 3, 2);
auto* scalar =
create<ast::Variable>("scalar", ast::StorageClass::kNone, &f32);
@@ -1444,18 +1438,18 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::MatrixType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Matrix>());
- auto* mat = expr.result_type()->As<ast::type::MatrixType>();
- EXPECT_TRUE(mat->type()->Is<ast::type::F32Type>());
+ auto* mat = expr.result_type()->As<ast::type::Matrix>();
+ EXPECT_TRUE(mat->type()->Is<ast::type::F32>());
EXPECT_EQ(mat->rows(), 3u);
EXPECT_EQ(mat->columns(), 2u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 2);
- ast::type::MatrixType mat3x2(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 2);
+ ast::type::Matrix mat3x2(&f32, 3, 2);
auto* vector =
create<ast::Variable>("vector", ast::StorageClass::kNone, &vec3);
@@ -1473,18 +1467,18 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ->Is<ast::type::F32>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::MatrixType mat3x2(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Matrix mat3x2(&f32, 3, 2);
auto* vector =
create<ast::Variable>("vector", ast::StorageClass::kNone, &vec3);
@@ -1502,18 +1496,18 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 2u);
+ ->Is<ast::type::F32>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 2u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat4x3(&f32, 4, 3);
- ast::type::MatrixType mat3x4(&f32, 3, 4);
+ ast::type::F32 f32;
+ ast::type::Matrix mat4x3(&f32, 4, 3);
+ ast::type::Matrix mat3x4(&f32, 3, 4);
auto* matrix1 =
create<ast::Variable>("mat4x3", ast::StorageClass::kNone, &mat4x3);
@@ -1531,10 +1525,10 @@
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::MatrixType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Matrix>());
- auto* mat = expr.result_type()->As<ast::type::MatrixType>();
- EXPECT_TRUE(mat->type()->Is<ast::type::F32Type>());
+ auto* mat = expr.result_type()->As<ast::type::Matrix>();
+ EXPECT_TRUE(mat->type()->Is<ast::type::F32>());
EXPECT_EQ(mat->rows(), 4u);
EXPECT_EQ(mat->columns(), 4u);
}
@@ -1543,7 +1537,7 @@
TEST_P(IntrinsicDerivativeTest, Scalar) {
auto name = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("ident", ast::StorageClass::kNone, &f32);
mod->AddGlobalVariable(var);
@@ -1559,14 +1553,14 @@
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::F32Type>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::F32>());
}
TEST_P(IntrinsicDerivativeTest, Vector) {
auto name = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* var = create<ast::Variable>("ident", ast::StorageClass::kNone, &vec4);
mod->AddGlobalVariable(var);
@@ -1582,19 +1576,19 @@
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 4u);
+ ->Is<ast::type::F32>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 4u);
}
TEST_P(IntrinsicDerivativeTest, MissingParam) {
auto name = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
// Register the global
EXPECT_TRUE(td()->Determine());
@@ -1609,8 +1603,8 @@
TEST_P(IntrinsicDerivativeTest, ToomManyParams) {
auto name = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* var1 = create<ast::Variable>("ident1", ast::StorageClass::kNone, &vec4);
auto* var2 = create<ast::Variable>("ident2", ast::StorageClass::kNone, &vec4);
@@ -1645,8 +1639,8 @@
TEST_P(Intrinsic, Test) {
auto name = GetParam();
- ast::type::BoolType bool_type;
- ast::type::VectorType vec3(&bool_type, 3);
+ ast::type::Bool bool_type;
+ ast::type::Vector vec3(&bool_type, 3);
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -1662,7 +1656,7 @@
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- EXPECT_TRUE(expr.result_type()->Is<ast::type::BoolType>());
+ EXPECT_TRUE(expr.result_type()->Is<ast::type::Bool>());
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
Intrinsic,
@@ -1672,8 +1666,8 @@
TEST_P(Intrinsic_FloatMethod, Vector) {
auto name = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -1689,18 +1683,18 @@
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::BoolType>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ ->Is<ast::type::Bool>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(Intrinsic_FloatMethod, Scalar) {
auto name = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
mod->AddGlobalVariable(var);
@@ -1715,13 +1709,13 @@
EXPECT_TRUE(td()->Determine());
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- EXPECT_TRUE(expr.result_type()->Is<ast::type::BoolType>());
+ EXPECT_TRUE(expr.result_type()->Is<ast::type::Bool>());
}
TEST_P(Intrinsic_FloatMethod, MissingParam) {
auto name = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
mod->AddGlobalVariable(var);
@@ -1739,7 +1733,7 @@
TEST_P(Intrinsic_FloatMethod, TooManyParams) {
auto name = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
mod->AddGlobalVariable(var);
@@ -1761,11 +1755,11 @@
Intrinsic_FloatMethod,
testing::Values("isInf", "isNan", "isFinite", "isNormal"));
-enum class TextureType { kF32, kI32, kU32 };
-inline std::ostream& operator<<(std::ostream& out, TextureType data) {
- if (data == TextureType::kF32) {
+enum class Texture { kF32, kI32, kU32 };
+inline std::ostream& operator<<(std::ostream& out, Texture data) {
+ if (data == Texture::kF32) {
out << "f32";
- } else if (data == TextureType::kI32) {
+ } else if (data == Texture::kI32) {
out << "i32";
} else {
out << "u32";
@@ -1775,7 +1769,7 @@
struct TextureTestParams {
ast::type::TextureDimension dim;
- TextureType type = TextureType::kF32;
+ Texture type = Texture::kF32;
ast::type::ImageFormat format = ast::type::ImageFormat::kR16Float;
};
inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) {
@@ -1790,20 +1784,20 @@
ast::type::TextureDimension dim,
ast::type::Type* type) {
if (dim == ast::type::TextureDimension::k1d) {
- if (type->Is<ast::type::I32Type>()) {
- return std::make_unique<ast::type::I32Type>();
- } else if (type->Is<ast::type::U32Type>()) {
- return std::make_unique<ast::type::U32Type>();
+ if (type->Is<ast::type::I32>()) {
+ return std::make_unique<ast::type::I32>();
+ } else if (type->Is<ast::type::U32>()) {
+ return std::make_unique<ast::type::U32>();
} else {
- return std::make_unique<ast::type::F32Type>();
+ return std::make_unique<ast::type::F32>();
}
} else if (dim == ast::type::TextureDimension::k1dArray ||
dim == ast::type::TextureDimension::k2d) {
- return std::make_unique<ast::type::VectorType>(type, 2);
+ return std::make_unique<ast::type::Vector>(type, 2);
} else if (dim == ast::type::TextureDimension::kCubeArray) {
- return std::make_unique<ast::type::VectorType>(type, 4);
+ return std::make_unique<ast::type::Vector>(type, 4);
} else {
- return std::make_unique<ast::type::VectorType>(type, 3);
+ return std::make_unique<ast::type::Vector>(type, 3);
}
}
@@ -1815,14 +1809,14 @@
call_params->push_back(create<ast::IdentifierExpression>(name));
}
- std::unique_ptr<ast::type::Type> subtype(TextureType type) {
- if (type == TextureType::kF32) {
- return std::make_unique<ast::type::F32Type>();
+ std::unique_ptr<ast::type::Type> subtype(Texture type) {
+ if (type == Texture::kF32) {
+ return std::make_unique<ast::type::F32>();
}
- if (type == TextureType::kI32) {
- return std::make_unique<ast::type::I32Type>();
+ if (type == Texture::kI32) {
+ return std::make_unique<ast::type::I32>();
}
- return std::make_unique<ast::type::U32Type>();
+ return std::make_unique<ast::type::U32>();
}
};
@@ -1832,10 +1826,10 @@
auto type = GetParam().type;
auto format = GetParam().format;
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto coords_type = get_coords_type(dim, &i32);
- ast::type::Type* texture_type = mod->create<ast::type::StorageTextureType>(
+ ast::type::Type* texture_type = mod->create<ast::type::StorageTexture>(
dim, ast::AccessControl::kReadOnly, format);
ast::ExpressionList call_params;
@@ -1851,59 +1845,59 @@
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
- if (type == TextureType::kF32) {
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
+ if (type == Texture::kF32) {
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
- } else if (type == TextureType::kI32) {
+ ->Is<ast::type::F32>());
+ } else if (type == Texture::kI32) {
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::I32Type>());
+ ->Is<ast::type::I32>());
} else {
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::U32Type>());
+ ->Is<ast::type::U32>());
}
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 4u);
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(
TypeDeterminerTest,
Intrinsic_StorageTextureOperation,
testing::Values(
- TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kF32,
+ TextureTestParams{ast::type::TextureDimension::k1d, Texture::kF32,
ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kI32,
+ TextureTestParams{ast::type::TextureDimension::k1d, Texture::kI32,
ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kF32,
+ TextureTestParams{ast::type::TextureDimension::k1d, Texture::kF32,
ast::type::ImageFormat::kR8Unorm},
- TextureTestParams{ast::type::TextureDimension::k1dArray,
- TextureType::kF32, ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k1dArray,
- TextureType::kI32, ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k1dArray,
- TextureType::kF32, ast::type::ImageFormat::kR8Unorm},
- TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kF32,
+ TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kF32,
ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kI32,
+ TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kI32,
ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kF32,
+ TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kF32,
ast::type::ImageFormat::kR8Unorm},
- TextureTestParams{ast::type::TextureDimension::k2dArray,
- TextureType::kF32, ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k2dArray,
- TextureType::kI32, ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k2dArray,
- TextureType::kF32, ast::type::ImageFormat::kR8Unorm},
- TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kF32,
+ TextureTestParams{ast::type::TextureDimension::k2d, Texture::kF32,
ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kI32,
+ TextureTestParams{ast::type::TextureDimension::k2d, Texture::kI32,
ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kF32,
+ TextureTestParams{ast::type::TextureDimension::k2d, Texture::kF32,
+ ast::type::ImageFormat::kR8Unorm},
+ TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kF32,
+ ast::type::ImageFormat::kR16Float},
+ TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kI32,
+ ast::type::ImageFormat::kR16Sint},
+ TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kF32,
+ ast::type::ImageFormat::kR8Unorm},
+ TextureTestParams{ast::type::TextureDimension::k3d, Texture::kF32,
+ ast::type::ImageFormat::kR16Float},
+ TextureTestParams{ast::type::TextureDimension::k3d, Texture::kI32,
+ ast::type::ImageFormat::kR16Sint},
+ TextureTestParams{ast::type::TextureDimension::k3d, Texture::kF32,
ast::type::ImageFormat::kR8Unorm}));
using Intrinsic_SampledTextureOperation = Intrinsic_TextureOperation;
@@ -1911,11 +1905,10 @@
auto dim = GetParam().dim;
auto type = GetParam().type;
- ast::type::I32Type i32;
+ ast::type::I32 i32;
std::unique_ptr<ast::type::Type> s = subtype(type);
auto coords_type = get_coords_type(dim, &i32);
- auto texture_type =
- std::make_unique<ast::type::SampledTextureType>(dim, s.get());
+ auto texture_type = std::make_unique<ast::type::SampledTexture>(dim, s.get());
ast::ExpressionList call_params;
@@ -1930,24 +1923,24 @@
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
- if (type == TextureType::kF32) {
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Vector>());
+ if (type == Texture::kF32) {
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
- } else if (type == TextureType::kI32) {
+ ->Is<ast::type::F32>());
+ } else if (type == Texture::kI32) {
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::I32Type>());
+ ->Is<ast::type::I32>());
} else {
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::U32Type>());
+ ->Is<ast::type::U32>());
}
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 4u);
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(
@@ -1960,8 +1953,8 @@
ast::type::TextureDimension::kCubeArray}));
TEST_F(TypeDeterminerTest, Intrinsic_Dot) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -1977,14 +1970,14 @@
EXPECT_TRUE(td()->Determine());
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- EXPECT_TRUE(expr.result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(expr.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Intrinsic_Select) {
- ast::type::F32Type f32;
- ast::type::BoolType bool_type;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::VectorType bool_vec3(&bool_type, 3);
+ ast::type::F32 f32;
+ ast::type::Bool bool_type;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Vector bool_vec3(&bool_type, 3);
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec3);
auto* bool_var =
@@ -2004,17 +1997,17 @@
EXPECT_TRUE(td()->Determine());
EXPECT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
- EXPECT_TRUE(expr.result_type()->Is<ast::type::VectorType>());
- EXPECT_EQ(expr.result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_TRUE(expr.result_type()->Is<ast::type::Vector>());
+ EXPECT_EQ(expr.result_type()->As<ast::type::Vector>()->size(), 3u);
EXPECT_TRUE(expr.result_type()
- ->As<ast::type::VectorType>()
+ ->As<ast::type::Vector>()
->type()
- ->Is<ast::type::F32Type>());
+ ->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* var = create<ast::Variable>("v", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -2033,8 +2026,8 @@
}
TEST_F(TypeDeterminerTest, Intrinsic_Select_TooManyParams) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* var = create<ast::Variable>("v", ast::StorageClass::kNone, &vec3);
mod->AddGlobalVariable(var);
@@ -2056,9 +2049,9 @@
}
TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::VectorType vec2(&f32, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Vector vec2(&f32, 2);
auto* var1 = create<ast::Variable>("v3", ast::StorageClass::kNone, &vec3);
auto* var2 = create<ast::Variable>("v2", ast::StorageClass::kNone, &vec2);
@@ -2077,18 +2070,18 @@
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
- ASSERT_TRUE(expr.result_type()->Is<ast::type::MatrixType>());
+ ASSERT_TRUE(expr.result_type()->Is<ast::type::Matrix>());
- auto* mat = expr.result_type()->As<ast::type::MatrixType>();
- EXPECT_TRUE(mat->type()->Is<ast::type::F32Type>());
+ auto* mat = expr.result_type()->As<ast::type::Matrix>();
+ EXPECT_TRUE(mat->type()->Is<ast::type::F32>());
EXPECT_EQ(mat->rows(), 3u);
EXPECT_EQ(mat->columns(), 2u);
}
TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooFewParams) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::VectorType vec2(&f32, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Vector vec2(&f32, 2);
auto* var2 = create<ast::Variable>("v2", ast::StorageClass::kNone, &vec2);
mod->AddGlobalVariable(var2);
@@ -2106,9 +2099,9 @@
}
TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooManyParams) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::VectorType vec2(&f32, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Vector vec2(&f32, 2);
auto* var2 = create<ast::Variable>("v2", ast::StorageClass::kNone, &vec2);
mod->AddGlobalVariable(var2);
@@ -2131,9 +2124,9 @@
TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) {
auto op = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Vector vec4(&f32, 4);
auto* var = create<ast::Variable>("ident", ast::StorageClass::kNone, &vec4);
mod->AddGlobalVariable(var);
@@ -2144,12 +2137,10 @@
ast::UnaryOpExpression der(op, create<ast::IdentifierExpression>("ident"));
EXPECT_TRUE(td()->DetermineResultType(&der));
ASSERT_NE(der.result_type(), nullptr);
- ASSERT_TRUE(der.result_type()->Is<ast::type::VectorType>());
- EXPECT_TRUE(der.result_type()
- ->As<ast::type::VectorType>()
- ->type()
- ->Is<ast::type::F32Type>());
- EXPECT_EQ(der.result_type()->As<ast::type::VectorType>()->size(), 4u);
+ ASSERT_TRUE(der.result_type()->Is<ast::type::Vector>());
+ EXPECT_TRUE(
+ der.result_type()->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
+ EXPECT_EQ(der.result_type()->As<ast::type::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
UnaryOpExpressionTest,
@@ -2157,7 +2148,7 @@
ast::UnaryOp::kNot));
TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("var", ast::StorageClass::kNone, &i32);
auto* stmt = create<ast::VariableDeclStatement>(var);
@@ -2173,7 +2164,7 @@
}
TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("var", ast::StorageClass::kNone, &i32);
var->set_is_const(true);
@@ -2190,7 +2181,7 @@
}
TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("var", ast::StorageClass::kWorkgroup, &i32);
auto* stmt = create<ast::VariableDeclStatement>(var);
@@ -2309,7 +2300,7 @@
TEST_P(ImportData_SingleParamTest, Scalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2327,8 +2318,8 @@
TEST_P(ImportData_SingleParamTest, Vector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -2348,13 +2339,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_SingleParamTest, Error_Integer) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2385,7 +2376,7 @@
TEST_P(ImportData_SingleParamTest, Error_MultipleParams) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -2433,7 +2424,7 @@
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Scalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2451,8 +2442,8 @@
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Vector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -2472,13 +2463,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Scalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2490,14 +2481,14 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::I32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::I32>());
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Vector) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec(&i32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -2517,13 +2508,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_signed_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Scalar) {
auto param = GetParam();
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2535,14 +2526,14 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::U32>());
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Vector) {
auto param = GetParam();
- ast::type::U32Type u32;
- ast::type::VectorType vec(&u32, 3);
+ ast::type::U32 u32;
+ ast::type::Vector vec(&u32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -2562,13 +2553,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_Bool) {
auto param = GetParam();
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2599,7 +2590,7 @@
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_MultipleParams) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -2622,7 +2613,7 @@
ast::Intrinsic::kAbs}));
TEST_F(TypeDeterminerTest, ImportData_Length_Scalar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2640,8 +2631,8 @@
}
TEST_F(TypeDeterminerTest, ImportData_Length_FloatVector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -2664,7 +2655,7 @@
}
TEST_F(TypeDeterminerTest, ImportData_Length_Error_Integer) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2691,7 +2682,7 @@
}
TEST_F(TypeDeterminerTest, ImportData_Length_Error_MultipleParams) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -2712,7 +2703,7 @@
TEST_P(ImportData_TwoParamTest, Scalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2732,8 +2723,8 @@
TEST_P(ImportData_TwoParamTest, Vector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -2762,13 +2753,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_TwoParamTest, Error_Integer) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2801,7 +2792,7 @@
TEST_P(ImportData_TwoParamTest, Error_OneParam) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -2817,9 +2808,9 @@
TEST_P(ImportData_TwoParamTest, Error_MismatchedParamCount) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec2(&f32, 2);
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec2(&f32, 2);
+ ast::type::Vector vec3(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -2850,8 +2841,8 @@
TEST_P(ImportData_TwoParamTest, Error_MismatchedParamType) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -2877,7 +2868,7 @@
TEST_P(ImportData_TwoParamTest, Error_TooManyParams) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -2903,7 +2894,7 @@
IntrinsicData{"reflect", ast::Intrinsic::kReflect}));
TEST_F(TypeDeterminerTest, ImportData_Distance_Scalar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2921,8 +2912,8 @@
}
TEST_F(TypeDeterminerTest, ImportData_Distance_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -2950,11 +2941,11 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, ImportData_Distance_Error_Integer) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -2983,7 +2974,7 @@
}
TEST_F(TypeDeterminerTest, ImportData_Distance_Error_OneParam) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -2997,9 +2988,9 @@
}
TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamCount) {
- ast::type::F32Type f32;
- ast::type::VectorType vec2(&f32, 2);
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec2(&f32, 2);
+ ast::type::Vector vec3(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3027,8 +3018,8 @@
}
TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamType) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -3051,7 +3042,7 @@
}
TEST_F(TypeDeterminerTest, ImportData_Distance_Error_TooManyParams) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -3069,8 +3060,8 @@
}
TEST_F(TypeDeterminerTest, ImportData_Cross) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3099,11 +3090,11 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, ImportData_Cross_Error_Scalar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3120,8 +3111,8 @@
}
TEST_F(TypeDeterminerTest, ImportData_Cross_Error_IntType) {
- ast::type::I32Type i32;
- ast::type::VectorType vec(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec(&i32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3162,8 +3153,8 @@
}
TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooFewParams) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3185,8 +3176,8 @@
}
TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooManyParams) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3229,7 +3220,7 @@
TEST_P(ImportData_ThreeParamTest, Scalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3251,8 +3242,8 @@
TEST_P(ImportData_ThreeParamTest, Vector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3290,13 +3281,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_ThreeParamTest, Error_Integer) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3331,7 +3322,7 @@
TEST_P(ImportData_ThreeParamTest, Error_OneParam) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -3347,7 +3338,7 @@
TEST_P(ImportData_ThreeParamTest, Error_TwoParams) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -3365,9 +3356,9 @@
TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamCount) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec2(&f32, 2);
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec2(&f32, 2);
+ ast::type::Vector vec3(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3407,8 +3398,8 @@
TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamType) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -3436,7 +3427,7 @@
TEST_P(ImportData_ThreeParamTest, Error_TooManyParams) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -3469,7 +3460,7 @@
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Scalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3491,8 +3482,8 @@
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Vector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3530,13 +3521,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Scalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3552,14 +3543,14 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::I32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::I32>());
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Vector) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec(&i32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3597,13 +3588,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_signed_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Scalar) {
auto param = GetParam();
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3619,14 +3610,14 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::U32>());
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Vector) {
auto param = GetParam();
- ast::type::U32Type u32;
- ast::type::VectorType vec(&u32, 3);
+ ast::type::U32 u32;
+ ast::type::Vector vec(&u32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3664,13 +3655,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_Bool) {
auto param = GetParam();
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3705,7 +3696,7 @@
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_OneParam) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -3721,7 +3712,7 @@
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TwoParams) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -3739,9 +3730,9 @@
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamCount) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec2(&f32, 2);
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec2(&f32, 2);
+ ast::type::Vector vec3(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -3781,8 +3772,8 @@
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamType) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -3810,7 +3801,7 @@
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TooManyParams) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f)));
@@ -3839,7 +3830,7 @@
TEST_P(ImportData_Int_SingleParamTest, Scalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3857,8 +3848,8 @@
TEST_P(ImportData_Int_SingleParamTest, Vector) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec(&i32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -3878,13 +3869,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_signed_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_Int_SingleParamTest, Error_Float) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3915,7 +3906,7 @@
TEST_P(ImportData_Int_SingleParamTest, Error_MultipleParams) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 1)));
@@ -3944,7 +3935,7 @@
TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Signed) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3958,13 +3949,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::I32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::I32>());
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Unsigned) {
auto param = GetParam();
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3978,13 +3969,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::U32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::U32>());
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Float) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -3998,14 +3989,14 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::F32>());
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Signed) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec(&i32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -4034,14 +4025,14 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_signed_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Unsigned) {
auto param = GetParam();
- ast::type::U32Type u32;
- ast::type::VectorType vec(&u32, 3);
+ ast::type::U32 u32;
+ ast::type::Vector vec(&u32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -4070,14 +4061,14 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Float) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -4106,13 +4097,13 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::VectorType>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_Bool) {
auto param = GetParam();
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -4145,7 +4136,7 @@
TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_OneParam) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 1)));
@@ -4161,9 +4152,9 @@
TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamCount) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec2(&i32, 2);
- ast::type::VectorType vec3(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec2(&i32, 2);
+ ast::type::Vector vec3(&i32, 3);
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
@@ -4194,8 +4185,8 @@
TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamType) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec(&i32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -4221,7 +4212,7 @@
TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_TooManyParams) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 1)));
@@ -4245,8 +4236,8 @@
IntrinsicData{"max", ast::Intrinsic::kMax}));
TEST_F(TypeDeterminerTest, ImportData_GLSL_Determinant) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 3);
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &mat);
mod->AddGlobalVariable(var);
@@ -4263,7 +4254,7 @@
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::F32Type>());
+ EXPECT_TRUE(ident->result_type()->Is<ast::type::F32>());
}
using ImportData_Matrix_OneParam_Test =
@@ -4271,7 +4262,7 @@
TEST_P(ImportData_Matrix_OneParam_Test, Error_Float) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &f32);
mod->AddGlobalVariable(var);
@@ -4306,8 +4297,8 @@
TEST_P(ImportData_Matrix_OneParam_Test, TooManyParams) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 3);
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &mat);
mod->AddGlobalVariable(var);
@@ -4332,7 +4323,7 @@
"determinant", ast::Intrinsic::kDeterminant}));
TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// fn b() {}
// fn c() { b(); }
@@ -4617,17 +4608,17 @@
break;
}
- ast::type::SamplerType sampler_type{param.sampler_kind};
+ ast::type::Sampler sampler_type{param.sampler_kind};
switch (param.texture_kind) {
case ast::intrinsic::test::TextureKind::kRegular:
Var("texture", ast::StorageClass::kNone,
- mod->create<ast::type::SampledTextureType>(param.texture_dimension,
- datatype));
+ mod->create<ast::type::SampledTexture>(param.texture_dimension,
+ datatype));
break;
case ast::intrinsic::test::TextureKind::kDepth:
Var("texture", ast::StorageClass::kNone,
- mod->create<ast::type::DepthTextureType>(param.texture_dimension));
+ mod->create<ast::type::DepthTexture>(param.texture_dimension));
break;
}
@@ -4640,9 +4631,8 @@
switch (param.texture_kind) {
case ast::intrinsic::test::TextureKind::kRegular:
- ASSERT_TRUE(call.result_type()->Is<ast::type::VectorType>());
- EXPECT_EQ(call.result_type()->As<ast::type::VectorType>()->type(),
- datatype);
+ ASSERT_TRUE(call.result_type()->Is<ast::type::Vector>());
+ EXPECT_EQ(call.result_type()->As<ast::type::Vector>()->type(), datatype);
break;
case ast::intrinsic::test::TextureKind::kDepth:
diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc
index 0a54cf9..7e4fef2 100644
--- a/src/validator/validator_control_block_test.cc
+++ b/src/validator/validator_control_block_test.cc
@@ -42,7 +42,7 @@
// switch (a) {
// default: {}
// }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&f32, 3.14f)));
@@ -70,7 +70,7 @@
// switch (a) {
// case 1: {}
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -101,7 +101,7 @@
// case 1: {}
// default: {}
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -143,8 +143,8 @@
// case 1: {}
// default: {}
// }
- ast::type::U32Type u32;
- ast::type::I32Type i32;
+ ast::type::U32 u32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -179,8 +179,8 @@
// case -1: {}
// default: {}
// }
- ast::type::U32Type u32;
- ast::type::I32Type i32;
+ ast::type::U32 u32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &u32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(&u32, 2)));
@@ -215,7 +215,7 @@
// case 2, 2: {}
// default: {}
// }
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &u32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(&u32, 3)));
@@ -256,7 +256,7 @@
// case 0,1,2,10: {}
// default: {}
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -297,7 +297,7 @@
// switch (a) {
// default: { fallthrough; }
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -327,7 +327,7 @@
// default: {}
// case 5: {}
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -358,8 +358,8 @@
// default: {}
// }
- ast::type::U32Type u32;
- ast::type::AliasType my_int{"MyInt", &u32};
+ ast::type::U32 u32;
+ ast::type::Alias my_int{"MyInt", &u32};
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &my_int);
var->set_constructor(create<ast::ScalarConstructorExpression>(
diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc
index 32f111a..4bb5d7c 100644
--- a/src/validator/validator_function_test.cc
+++ b/src/validator/validator_function_test.cc
@@ -38,13 +38,13 @@
TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
// [[stage(vertex)]]
// fn func -> void { var a:i32 = 2; }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
ast::VariableList params;
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* func = create<ast::Function>(Source{Source::Location{12, 34}}, "func",
@@ -61,7 +61,7 @@
VoidFunctionEndWithoutReturnStatementEmptyBody_Pass) {
// [[stage(vertex)]]
// fn func -> void {}
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::VariableList params;
auto* func =
create<ast::Function>(Source{Source::Location{12, 34}}, "func", params,
@@ -77,13 +77,13 @@
TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
// fn func -> int { var a:i32 = 2; }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
ast::VariableList params;
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* func = create<ast::Function>(Source{Source::Location{12, 34}}, "func",
@@ -98,8 +98,8 @@
TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) {
// fn func -> int {}
- ast::type::VoidType void_type;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::I32 i32;
ast::VariableList params;
auto* func =
create<ast::Function>(Source{Source::Location{12, 34}}, "func", params,
@@ -115,7 +115,7 @@
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
// [[stage(vertex)]]
// fn func -> void { return; }
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
@@ -131,8 +131,8 @@
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
// fn func -> void { return 2; }
- ast::type::VoidType void_type;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::I32 i32;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* return_expr = create<ast::ScalarConstructorExpression>(
@@ -153,8 +153,8 @@
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
// fn func -> f32 { return 2; }
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* return_expr = create<ast::ScalarConstructorExpression>(
@@ -176,8 +176,8 @@
TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
// fn func -> i32 { return 2; }
// fn func -> i32 { return 2; }
- ast::type::VoidType void_type;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::I32 i32;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
@@ -206,8 +206,8 @@
TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
// fn func() -> void {func(); return; }
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
+ ast::type::F32 f32;
+ ast::type::Void void_type;
ast::ExpressionList call_params;
auto* call_expr = create<ast::CallExpression>(
Source{Source::Location{12, 34}},
@@ -226,7 +226,7 @@
TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
// fn func() -> i32 {var a: i32 = func(); return 2; }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
ast::ExpressionList call_params;
auto* call_expr = create<ast::CallExpression>(
@@ -251,7 +251,7 @@
TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
// [[stage(vertex)]]
// fn vtx_main() -> i32 { return 0; }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::VariableList params;
auto* return_expr = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 0));
@@ -273,8 +273,8 @@
TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) {
// [[stage(vertex)]]
// fn vtx_func(a : i32) -> void { return; }
- ast::type::I32Type i32;
- ast::type::VoidType void_type;
+ ast::type::I32 i32;
+ ast::type::Void void_type;
ast::VariableList params;
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &i32));
auto* body = create<ast::BlockStatement>();
@@ -296,7 +296,7 @@
// [[stage(fragment)]]
// [[stage(vertex)]]
// fn main() -> void { return; }
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -317,7 +317,7 @@
TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
// [[stage(vertex)]]
// fn vtx_func() -> void { return; }
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -332,7 +332,7 @@
TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) {
// fn vtx_func() -> void { return; }
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc
index 510bcd3..237776b 100644
--- a/src/validator/validator_impl.cc
+++ b/src/validator/validator_impl.cc
@@ -85,11 +85,11 @@
bool ValidatorImpl::ValidateConstructedTypes(
const std::vector<ast::type::Type*>& constructed_types) {
for (auto* const ct : constructed_types) {
- if (ct->Is<ast::type::StructType>()) {
- auto* st = ct->As<ast::type::StructType>();
+ if (ct->Is<ast::type::Struct>()) {
+ auto* st = ct->As<ast::type::Struct>();
for (auto* member : st->impl()->members()) {
- if (member->type()->UnwrapAll()->Is<ast::type::ArrayType>()) {
- auto* r = member->type()->UnwrapAll()->As<ast::type::ArrayType>();
+ if (member->type()->UnwrapAll()->Is<ast::type::Array>()) {
+ auto* r = member->type()->UnwrapAll()->As<ast::type::Array>();
if (r->IsRuntimeArray()) {
if (member != st->impl()->members().back()) {
add_error(member->source(), "v-0015",
@@ -168,7 +168,7 @@
return false;
}
- if (!func->return_type()->Is<ast::type::VoidType>()) {
+ if (!func->return_type()->Is<ast::type::Void>()) {
add_error(
func->source(), "v-0024",
"Entry point function must return void: '" + func->name() + "'");
@@ -207,7 +207,7 @@
}
variable_stack_.pop_scope();
- if (!current_function_->return_type()->Is<ast::type::VoidType>()) {
+ if (!current_function_->return_type()->Is<ast::type::Void>()) {
if (!func->get_last_statement() ||
!func->get_last_statement()->Is<ast::ReturnStatement>()) {
add_error(func->source(), "v-0002",
@@ -223,7 +223,7 @@
// https://github.com/gpuweb/gpuweb/issues/996
ast::type::Type* func_type = current_function_->return_type();
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* ret_type =
ret->has_value() ? ret->value()->result_type()->UnwrapAll() : &void_type;
@@ -265,11 +265,11 @@
return false;
}
variable_stack_.set(name, decl->variable());
- if (decl->variable()->type()->UnwrapAll()->Is<ast::type::ArrayType>()) {
+ if (decl->variable()->type()->UnwrapAll()->Is<ast::type::Array>()) {
if (decl->variable()
->type()
->UnwrapAll()
- ->As<ast::type::ArrayType>()
+ ->As<ast::type::Array>()
->IsRuntimeArray()) {
add_error(decl->source(), "v-0015",
"runtime arrays may only appear as the last "
@@ -317,8 +317,7 @@
}
auto* cond_type = s->condition()->result_type()->UnwrapAll();
- if (!(cond_type->Is<ast::type::I32Type>() ||
- cond_type->Is<ast::type::U32Type>())) {
+ if (!(cond_type->Is<ast::type::I32>() || cond_type->Is<ast::type::U32>())) {
add_error(s->condition()->source(), "v-0025",
"switch statement selector expression must be of a "
"scalar integer type");
@@ -345,11 +344,11 @@
}
auto v =
- static_cast<int32_t>(selector->type()->Is<ast::type::U32Type>()
+ static_cast<int32_t>(selector->type()->Is<ast::type::U32>()
? selector->As<ast::UintLiteral>()->value()
: selector->As<ast::SintLiteral>()->value());
if (selector_set.count(v)) {
- auto v_str = selector->type()->Is<ast::type::U32Type>()
+ auto v_str = selector->type()->Is<ast::type::U32>()
? selector->As<ast::UintLiteral>()->to_str()
: selector->As<ast::SintLiteral>()->to_str();
add_error(case_stmt->source(), "v-0027",
diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc
index 9f0f726..e15a5e0 100644
--- a/src/validator/validator_test.cc
+++ b/src/validator/validator_test.cc
@@ -62,7 +62,7 @@
TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) {
// 1 = my_var;
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 1));
@@ -77,7 +77,7 @@
TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) {
// b = 2;
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lhs =
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "b");
@@ -95,7 +95,7 @@
// {
// b = 2;
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lhs =
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "b");
@@ -114,7 +114,7 @@
TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
// var a :i32 = 2;
// a = 2
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -136,8 +136,8 @@
// var a :i32 = 2;
// a = 2.3;
// }
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -164,7 +164,7 @@
// var a :i32 = 2;
// a = 2
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -190,8 +190,8 @@
// var a :i32 = 2;
// a = 2.3;
// }
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -218,7 +218,7 @@
TEST_F(ValidatorTest, GlobalVariableWithStorageClass_Pass) {
// var<in> gloabl_var: f32;
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* global_var =
create<ast::Variable>(Source{Source::Location{12, 34}}, "global_var",
ast::StorageClass::kInput, &f32);
@@ -229,7 +229,7 @@
TEST_F(ValidatorTest, GlobalVariableNoStorageClass_Fail) {
// var gloabl_var: f32;
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* global_var =
create<ast::Variable>(Source{Source::Location{12, 34}}, "global_var",
ast::StorageClass::kNone, &f32);
@@ -241,7 +241,7 @@
}
TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) {
// const<in> gloabl_var: f32;
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* global_var =
create<ast::Variable>(Source{Source::Location{12, 34}}, "global_var",
ast::StorageClass::kInput, &f32);
@@ -257,7 +257,7 @@
TEST_F(ValidatorTest, GlobalConstNoStorageClass_Pass) {
// const gloabl_var: f32;
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* global_var =
create<ast::Variable>(Source{Source::Location{12, 34}}, "global_var",
ast::StorageClass::kNone, &f32);
@@ -273,7 +273,7 @@
// fn my_func() -> f32 {
// not_global_var = 3.14f;
// }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* global_var =
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
global_var->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -303,8 +303,8 @@
// global_var = 3.14;
// return;
// }
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
+ ast::type::F32 f32;
+ ast::type::Void void_type;
auto* global_var =
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
@@ -336,12 +336,12 @@
// if (true) { var a : f32 = 2.0; }
// a = 3.14;
// }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(&bool_type, true));
auto* body = create<ast::BlockStatement>();
@@ -369,7 +369,7 @@
// var a : f32 = 2.0;
// if (true) { a = 3.14; }
// }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
@@ -379,7 +379,7 @@
auto* rhs = create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 3.14f));
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(&bool_type, true));
auto* body = create<ast::BlockStatement>();
@@ -398,8 +398,8 @@
TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
// var global_var0 : f32 = 0.1;
// var global_var1 : i32 = 0;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* var0 =
create<ast::Variable>("global_var0", ast::StorageClass::kPrivate, &f32);
var0->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -420,8 +420,8 @@
TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
// var global_var : f32 = 0.1;
// var global_var : i32 = 0;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* var0 =
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
var0->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -445,7 +445,7 @@
// const a :i32 = 2;
// a = 2
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -475,8 +475,8 @@
// return 0;
// }
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
auto* global_var =
create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
global_var->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -505,9 +505,9 @@
// var a :i32 = 2;
// var a :f21 = 2.0;
// }
- ast::type::VoidType void_type;
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -537,12 +537,12 @@
// if (true) { var a : f32 = 2.0; }
// var a : f32 = 3.14;
// }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(&bool_type, true));
auto* body = create<ast::BlockStatement>();
@@ -569,7 +569,7 @@
// var a : f32 = 3.14;
// if (true) { var a : f32 = 2.0; }
// }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var_a_float =
create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var_a_float->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -579,7 +579,7 @@
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(&bool_type, true));
auto* body = create<ast::BlockStatement>();
@@ -598,8 +598,8 @@
TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
// func0 { var a : f32 = 2.0; return; }
// func1 { var a : f32 = 3.0; return; }
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
+ ast::type::F32 f32;
+ ast::type::Void void_type;
auto* var0 = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var0->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
@@ -636,7 +636,7 @@
// var a :i32;
// a = 2;
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
td()->RegisterVariableForTesting(var);
diff --git a/src/validator/validator_test_helper.h b/src/validator/validator_test_helper.h
index b4db450..f448d2f 100644
--- a/src/validator/validator_test_helper.h
+++ b/src/validator/validator_test_helper.h
@@ -55,7 +55,7 @@
Context ctx_;
ast::Module mod_;
std::unique_ptr<TypeDeterminer> td_;
- ast::type::VoidType void_type_;
+ ast::type::Void void_type_;
};
} // namespace tint
diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc
index 738776d..f9d6c71 100644
--- a/src/validator/validator_type_test.cc
+++ b/src/validator/validator_type_test.cc
@@ -42,8 +42,8 @@
// rt: array<f32>;
// };
- ast::type::F32Type f32;
- ast::type::ArrayType arr(&f32);
+ ast::type::F32 f32;
+ ast::type::Array arr(&f32);
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@@ -57,7 +57,7 @@
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members);
- ast::type::StructType struct_type("Foo", st);
+ ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type);
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));
@@ -69,8 +69,8 @@
// rt: array<f32>;
// };
- ast::type::F32Type f32;
- ast::type::ArrayType arr(&f32);
+ ast::type::F32 f32;
+ ast::type::Array arr(&f32);
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@@ -83,7 +83,7 @@
}
ast::StructDecorationList decos;
auto* st = create<ast::Struct>(decos, members);
- ast::type::StructType struct_type("Foo", st);
+ ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type);
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
@@ -99,8 +99,8 @@
// vf: f32;
// };
- ast::type::F32Type f32;
- ast::type::ArrayType arr(&f32);
+ ast::type::F32 f32;
+ ast::type::Array arr(&f32);
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@@ -114,7 +114,7 @@
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members);
- ast::type::StructType struct_type("Foo", st);
+ ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type);
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
@@ -131,9 +131,9 @@
// a: u32;
//}
- ast::type::F32Type u32;
- ast::type::ArrayType array(&u32);
- ast::type::AliasType alias{"RTArr", &array};
+ ast::type::F32 u32;
+ ast::type::Array array(&u32);
+ ast::type::Alias alias{"RTArr", &array};
ast::StructMemberList members;
{
@@ -149,7 +149,7 @@
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members);
- ast::type::StructType struct_type("s", st);
+ ast::type::Struct struct_type("s", st);
mod()->AddConstructedType(&struct_type);
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
EXPECT_EQ(v()->error(),
@@ -165,9 +165,9 @@
// b: RTArr;
//}
- ast::type::F32Type u32;
- ast::type::ArrayType array(&u32);
- ast::type::AliasType alias{"RTArr", &array};
+ ast::type::F32 u32;
+ ast::type::Array array(&u32);
+ ast::type::Alias alias{"RTArr", &array};
ast::StructMemberList members;
{
@@ -182,7 +182,7 @@
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members);
- ast::type::StructType struct_type("s", st);
+ ast::type::Struct struct_type("s", st);
mod()->AddConstructedType(&struct_type);
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));
}
@@ -190,12 +190,12 @@
TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
/// [[stage(vertex)]]
// fn func -> void { var a : array<i32>; }
- ast::type::I32Type i32;
- ast::type::ArrayType array(&i32);
+ ast::type::I32 i32;
+ ast::type::Array array(&i32);
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &array);
ast::VariableList params;
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(
Source{Source::Location{12, 34}}, var));
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index 3bbd20b..2979bb9 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -219,12 +219,12 @@
const ast::type::Type* ty) {
make_indent(out);
- if (ty->Is<ast::type::AliasType>()) {
- auto* alias = ty->As<ast::type::AliasType>();
+ if (ty->Is<ast::type::Alias>()) {
+ auto* alias = ty->As<ast::type::Alias>();
// HLSL typedef is for intrinsic types only. For an alias'd struct,
// generate a secondary struct with the new name.
- if (alias->type()->Is<ast::type::StructType>()) {
- if (!EmitStructType(out, alias->type()->As<ast::type::StructType>(),
+ if (alias->type()->Is<ast::type::Struct>()) {
+ if (!EmitStructType(out, alias->type()->As<ast::type::Struct>(),
alias->name())) {
return false;
}
@@ -235,8 +235,8 @@
return false;
}
out << " " << namer_.NameFor(alias->name()) << ";" << std::endl;
- } else if (ty->Is<ast::type::StructType>()) {
- auto* str = ty->As<ast::type::StructType>();
+ } else if (ty->Is<ast::type::Struct>()) {
+ auto* str = ty->As<ast::type::Struct>();
if (!EmitStructType(out, str, str->name())) {
return false;
}
@@ -272,9 +272,9 @@
bool GeneratorImpl::EmitBitcast(std::ostream& pre,
std::ostream& out,
ast::BitcastExpression* expr) {
- if (!expr->type()->Is<ast::type::F32Type>() &&
- !expr->type()->Is<ast::type::I32Type>() &&
- !expr->type()->Is<ast::type::U32Type>()) {
+ if (!expr->type()->Is<ast::type::F32>() &&
+ !expr->type()->Is<ast::type::I32>() &&
+ !expr->type()->Is<ast::type::U32>()) {
error_ = "Unable to do bitcast to type " + expr->type()->type_name();
return false;
}
@@ -379,12 +379,12 @@
// Multiplying by a matrix requires the use of `mul` in order to get the
// type of multiply we desire.
if (expr->op() == ast::BinaryOp::kMultiply &&
- ((lhs_type->Is<ast::type::VectorType>() &&
- rhs_type->Is<ast::type::MatrixType>()) ||
- (lhs_type->Is<ast::type::MatrixType>() &&
- rhs_type->Is<ast::type::VectorType>()) ||
- (lhs_type->Is<ast::type::MatrixType>() &&
- rhs_type->Is<ast::type::MatrixType>()))) {
+ ((lhs_type->Is<ast::type::Vector>() &&
+ rhs_type->Is<ast::type::Matrix>()) ||
+ (lhs_type->Is<ast::type::Matrix>() &&
+ rhs_type->Is<ast::type::Vector>()) ||
+ (lhs_type->Is<ast::type::Matrix>() &&
+ rhs_type->Is<ast::type::Matrix>()))) {
out << "mul(";
if (!EmitExpression(pre, out, expr->lhs())) {
return false;
@@ -618,14 +618,14 @@
// out << "(";
// auto param1_type = params[1]->result_type()->UnwrapPtrIfNeeded();
- // if (!param1_type->Is<ast::type::VectorType>()) {
+ // if (!param1_type->Is<ast::type::Vector>()) {
// error_ = "invalid param type in outer_product got: " +
// param1_type->type_name();
// return false;
// }
// for (uint32_t i = 0; i <
- // param1_type->As<ast::type::VectorType>()->size(); ++i) {
+ // param1_type->As<ast::type::Vector>()->size(); ++i) {
// if (i > 0) {
// out << ", ";
// }
@@ -921,7 +921,7 @@
bool GeneratorImpl::EmitTypeConstructor(std::ostream& pre,
std::ostream& out,
ast::TypeConstructorExpression* expr) {
- if (expr->type()->Is<ast::type::ArrayType>()) {
+ if (expr->type()->Is<ast::type::Array>()) {
out << "{";
} else {
if (!EmitType(out, expr->type(), "")) {
@@ -950,7 +950,7 @@
}
}
- if (expr->type()->Is<ast::type::ArrayType>()) {
+ if (expr->type()->Is<ast::type::Array>()) {
out << "}";
} else {
out << ")";
@@ -1231,7 +1231,7 @@
return false;
}
// Array name is output as part of the type
- if (!v->type()->Is<ast::type::ArrayType>()) {
+ if (!v->type()->Is<ast::type::Array>()) {
out << " " << v->name();
}
}
@@ -1298,8 +1298,8 @@
emitted_globals.insert(var->name());
auto* type = var->type()->UnwrapIfNeeded();
- if (type->Is<ast::type::StructType>()) {
- auto* strct = type->As<ast::type::StructType>();
+ if (type->Is<ast::type::Struct>()) {
+ auto* strct = type->As<ast::type::Struct>();
out << "ConstantBuffer<" << strct->name() << "> " << var->name()
<< " : register(b" << binding->value() << ");" << std::endl;
@@ -1340,11 +1340,11 @@
}
emitted_globals.insert(var->name());
- if (!var->type()->Is<ast::type::AccessControlType>()) {
+ if (!var->type()->Is<ast::type::AccessControl>()) {
error_ = "access control type required for storage buffer";
return false;
}
- auto* ac = var->type()->As<ast::type::AccessControlType>();
+ auto* ac = var->type()->As<ast::type::AccessControl>();
if (ac->IsReadWrite()) {
out << "RW";
@@ -1554,18 +1554,18 @@
}
bool GeneratorImpl::EmitZeroValue(std::ostream& out, ast::type::Type* type) {
- if (type->Is<ast::type::BoolType>()) {
+ if (type->Is<ast::type::Bool>()) {
out << "false";
- } else if (type->Is<ast::type::F32Type>()) {
+ } else if (type->Is<ast::type::F32>()) {
out << "0.0f";
- } else if (type->Is<ast::type::I32Type>()) {
+ } else if (type->Is<ast::type::I32>()) {
out << "0";
- } else if (type->Is<ast::type::U32Type>()) {
+ } else if (type->Is<ast::type::U32>()) {
out << "0u";
- } else if (type->Is<ast::type::VectorType>()) {
- return EmitZeroValue(out, type->As<ast::type::VectorType>()->type());
- } else if (type->Is<ast::type::MatrixType>()) {
- auto* mat = type->As<ast::type::MatrixType>();
+ } else if (type->Is<ast::type::Vector>()) {
+ return EmitZeroValue(out, type->As<ast::type::Vector>()->type());
+ } else if (type->Is<ast::type::Matrix>()) {
+ auto* mat = type->As<ast::type::Matrix>();
for (uint32_t i = 0; i < (mat->rows() * mat->columns()); i++) {
if (i != 0) {
out << ", ";
@@ -1692,8 +1692,8 @@
first = false;
if (auto* mem = expr->As<ast::MemberAccessorExpression>()) {
auto* res_type = mem->structure()->result_type()->UnwrapAll();
- if (res_type->Is<ast::type::StructType>()) {
- auto* str_type = res_type->As<ast::type::StructType>()->impl();
+ if (res_type->Is<ast::type::Struct>()) {
+ auto* str_type = res_type->As<ast::type::Struct>()->impl();
auto* str_member = str_type->get_member(mem->member()->name());
if (!str_member->has_offset_decoration()) {
@@ -1702,7 +1702,7 @@
}
out << str_member->offset();
- } else if (res_type->Is<ast::type::VectorType>()) {
+ } else if (res_type->Is<ast::type::Vector>()) {
// This must be a single element swizzle if we've got a vector at this
// point.
if (mem->member()->name().size() != 1) {
@@ -1728,15 +1728,15 @@
auto* ary_type = ary->array()->result_type()->UnwrapAll();
out << "(";
- if (ary_type->Is<ast::type::ArrayType>()) {
- out << ary_type->As<ast::type::ArrayType>()->array_stride();
- } else if (ary_type->Is<ast::type::VectorType>()) {
+ if (ary_type->Is<ast::type::Array>()) {
+ out << ary_type->As<ast::type::Array>()->array_stride();
+ } else if (ary_type->Is<ast::type::Vector>()) {
// TODO(dsinclair): This is a hack. Our vectors can only be f32, i32
// or u32 which are all 4 bytes. When we get f16 or other types we'll
// have to ask the type for the byte size.
out << "4";
- } else if (ary_type->Is<ast::type::MatrixType>()) {
- auto* mat = ary_type->As<ast::type::MatrixType>();
+ } else if (ary_type->Is<ast::type::Matrix>()) {
+ auto* mat = ary_type->As<ast::type::Matrix>();
if (mat->columns() == 2) {
out << "8";
} else {
@@ -1777,18 +1777,18 @@
bool is_store = rhs != nullptr;
std::string access_method = is_store ? "Store" : "Load";
- if (result_type->Is<ast::type::VectorType>()) {
+ if (result_type->Is<ast::type::Vector>()) {
access_method +=
- std::to_string(result_type->As<ast::type::VectorType>()->size());
- } else if (result_type->Is<ast::type::MatrixType>()) {
+ std::to_string(result_type->As<ast::type::Vector>()->size());
+ } else if (result_type->Is<ast::type::Matrix>()) {
access_method +=
- std::to_string(result_type->As<ast::type::MatrixType>()->rows());
+ std::to_string(result_type->As<ast::type::Matrix>()->rows());
}
// If we aren't storing then we need to put in the outer cast.
if (!is_store) {
if (result_type->is_float_scalar_or_vector() ||
- result_type->Is<ast::type::MatrixType>()) {
+ result_type->Is<ast::type::Matrix>()) {
out << "asfloat(";
} else if (result_type->is_signed_scalar_or_vector()) {
out << "asint(";
@@ -1808,8 +1808,8 @@
return false;
}
- if (result_type->Is<ast::type::MatrixType>()) {
- auto* mat = result_type->As<ast::type::MatrixType>();
+ if (result_type->Is<ast::type::Matrix>()) {
+ auto* mat = result_type->As<ast::type::Matrix>();
// TODO(dsinclair): This is assuming 4 byte elements. Will need to be fixed
// if we get matrixes of f16 or f64.
@@ -1896,8 +1896,7 @@
auto* data_type = structure->result_type()->UnwrapAll();
// If the data is a multi-element swizzle then we will not load the swizzle
// portion through the Load command.
- if (data_type->Is<ast::type::VectorType>() &&
- expr->member()->name().size() > 1) {
+ if (data_type->Is<ast::type::Vector>() && expr->member()->name().size() > 1) {
return false;
}
@@ -2042,24 +2041,24 @@
bool GeneratorImpl::EmitType(std::ostream& out,
ast::type::Type* type,
const std::string& name) {
- if (type->Is<ast::type::AliasType>()) {
- auto* alias = type->As<ast::type::AliasType>();
+ if (type->Is<ast::type::Alias>()) {
+ auto* alias = type->As<ast::type::Alias>();
out << namer_.NameFor(alias->name());
- } else if (type->Is<ast::type::ArrayType>()) {
- auto* ary = type->As<ast::type::ArrayType>();
+ } else if (type->Is<ast::type::Array>()) {
+ auto* ary = type->As<ast::type::Array>();
ast::type::Type* base_type = ary;
std::vector<uint32_t> sizes;
- while (base_type->Is<ast::type::ArrayType>()) {
- if (base_type->As<ast::type::ArrayType>()->IsRuntimeArray()) {
+ while (base_type->Is<ast::type::Array>()) {
+ if (base_type->As<ast::type::Array>()->IsRuntimeArray()) {
// TODO(dsinclair): Support runtime arrays
// https://bugs.chromium.org/p/tint/issues/detail?id=185
error_ = "runtime array not supported yet.";
return false;
} else {
- sizes.push_back(base_type->As<ast::type::ArrayType>()->size());
+ sizes.push_back(base_type->As<ast::type::Array>()->size());
}
- base_type = base_type->As<ast::type::ArrayType>()->type();
+ base_type = base_type->As<ast::type::Array>()->type();
}
if (!EmitType(out, base_type, "")) {
return false;
@@ -2070,35 +2069,35 @@
for (uint32_t size : sizes) {
out << "[" << size << "]";
}
- } else if (type->Is<ast::type::BoolType>()) {
+ } else if (type->Is<ast::type::Bool>()) {
out << "bool";
- } else if (type->Is<ast::type::F32Type>()) {
+ } else if (type->Is<ast::type::F32>()) {
out << "float";
- } else if (type->Is<ast::type::I32Type>()) {
+ } else if (type->Is<ast::type::I32>()) {
out << "int";
- } else if (type->Is<ast::type::MatrixType>()) {
- auto* mat = type->As<ast::type::MatrixType>();
+ } else if (type->Is<ast::type::Matrix>()) {
+ auto* mat = type->As<ast::type::Matrix>();
if (!EmitType(out, mat->type(), "")) {
return false;
}
out << mat->rows() << "x" << mat->columns();
- } else if (type->Is<ast::type::PointerType>()) {
+ } else if (type->Is<ast::type::Pointer>()) {
// TODO(dsinclair): What do we do with pointers in HLSL?
// https://bugs.chromium.org/p/tint/issues/detail?id=183
error_ = "pointers not supported in HLSL";
return false;
- } else if (type->Is<ast::type::SamplerType>()) {
- auto* sampler = type->As<ast::type::SamplerType>();
+ } else if (type->Is<ast::type::Sampler>()) {
+ auto* sampler = type->As<ast::type::Sampler>();
out << "Sampler";
if (sampler->IsComparison()) {
out << "Comparison";
}
out << "State";
- } else if (type->Is<ast::type::StructType>()) {
- out << type->As<ast::type::StructType>()->name();
- } else if (type->Is<ast::type::TextureType>()) {
- auto* tex = type->As<ast::type::TextureType>();
- if (tex->Is<ast::type::StorageTextureType>()) {
+ } else if (type->Is<ast::type::Struct>()) {
+ out << type->As<ast::type::Struct>()->name();
+ } else if (type->Is<ast::type::Texture>()) {
+ auto* tex = type->As<ast::type::Texture>();
+ if (tex->Is<ast::type::StorageTexture>()) {
out << "RW";
}
out << "Texture";
@@ -2130,18 +2129,16 @@
return false;
}
- } else if (type->Is<ast::type::U32Type>()) {
+ } else if (type->Is<ast::type::U32>()) {
out << "uint";
- } else if (type->Is<ast::type::VectorType>()) {
- auto* vec = type->As<ast::type::VectorType>();
+ } else if (type->Is<ast::type::Vector>()) {
+ auto* vec = type->As<ast::type::Vector>();
auto size = vec->size();
- if (vec->type()->Is<ast::type::F32Type>() && size >= 1 && size <= 4) {
+ if (vec->type()->Is<ast::type::F32>() && size >= 1 && size <= 4) {
out << "float" << size;
- } else if (vec->type()->Is<ast::type::I32Type>() && size >= 1 &&
- size <= 4) {
+ } else if (vec->type()->Is<ast::type::I32>() && size >= 1 && size <= 4) {
out << "int" << size;
- } else if (vec->type()->Is<ast::type::U32Type>() && size >= 1 &&
- size <= 4) {
+ } else if (vec->type()->Is<ast::type::U32>() && size >= 1 && size <= 4) {
out << "uint" << size;
} else {
out << "vector<";
@@ -2150,7 +2147,7 @@
}
out << ", " << size << ">";
}
- } else if (type->Is<ast::type::VoidType>()) {
+ } else if (type->Is<ast::type::Void>()) {
out << "void";
} else {
error_ = "unknown type in EmitType";
@@ -2161,7 +2158,7 @@
}
bool GeneratorImpl::EmitStructType(std::ostream& out,
- const ast::type::StructType* str,
+ const ast::type::Struct* str,
const std::string& name) {
// TODO(dsinclair): Block decoration?
// if (str->impl()->decoration() != ast::StructDecoration::kNone) {
@@ -2178,7 +2175,7 @@
return false;
}
// Array member name will be output with the type
- if (!mem->type()->Is<ast::type::ArrayType>()) {
+ if (!mem->type()->Is<ast::type::Array>()) {
out << " " << namer_.NameFor(mem->name());
}
out << ";" << std::endl;
@@ -2241,7 +2238,7 @@
if (!EmitType(out, var->type(), var->name())) {
return false;
}
- if (!var->type()->Is<ast::type::ArrayType>()) {
+ if (!var->type()->Is<ast::type::Array>()) {
out << " " << var->name();
}
out << constructor_out.str() << ";" << std::endl;
@@ -2298,7 +2295,7 @@
if (!EmitType(out, var->type(), var->name())) {
return false;
}
- if (!var->type()->Is<ast::type::ArrayType>()) {
+ if (!var->type()->Is<ast::type::Array>()) {
out << " " << var->name();
}
diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h
index cbfc7cd..44b4dd4 100644
--- a/src/writer/hlsl/generator_impl.h
+++ b/src/writer/hlsl/generator_impl.h
@@ -301,7 +301,7 @@
/// @param name the struct name
/// @returns true if the struct is emitted
bool EmitStructType(std::ostream& out,
- const ast::type::StructType* ty,
+ const ast::type::Struct* ty,
const std::string& name);
/// Handles a unary op expression
/// @param pre the preamble for the expression stream
diff --git a/src/writer/hlsl/generator_impl_alias_type_test.cc b/src/writer/hlsl/generator_impl_alias_type_test.cc
index 4dbe93a..1aa406a 100644
--- a/src/writer/hlsl/generator_impl_alias_type_test.cc
+++ b/src/writer/hlsl/generator_impl_alias_type_test.cc
@@ -26,29 +26,29 @@
namespace hlsl {
namespace {
-using HlslGeneratorImplTest_AliasType = TestHelper;
+using HlslGeneratorImplTest_Alias = TestHelper;
-TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_F32) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("a", &f32);
+TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_F32) {
+ ast::type::F32 f32;
+ ast::type::Alias alias("a", &f32);
ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error();
EXPECT_EQ(result(), R"(typedef float a;
)");
}
-TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_NameCollision) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("float", &f32);
+TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_NameCollision) {
+ ast::type::F32 f32;
+ ast::type::Alias alias("float", &f32);
ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error();
EXPECT_EQ(result(), R"(typedef float float_tint_0;
)");
}
-TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_Struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_Struct) {
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* str = create<ast::Struct>();
str->set_members({
@@ -59,8 +59,8 @@
create<ast::StructMemberOffsetDecoration>(4, Source{})}),
});
- ast::type::StructType s("A", str);
- ast::type::AliasType alias("B", &s);
+ ast::type::Struct s("A", str);
+ ast::type::Alias alias("B", &s);
ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error();
EXPECT_EQ(result(), R"(struct B {
diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc
index b803f8b..53cee1a 100644
--- a/src/writer/hlsl/generator_impl_array_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc
@@ -30,7 +30,7 @@
using HlslGeneratorImplTest_Expression = TestHelper;
TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, 5);
auto* idx = create<ast::ScalarConstructorExpression>(lit);
auto* ary = create<ast::IdentifierExpression>("ary");
diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc
index 3f8d547..18c46f3 100644
--- a/src/writer/hlsl/generator_impl_binary_test.cc
+++ b/src/writer/hlsl/generator_impl_binary_test.cc
@@ -58,7 +58,7 @@
using HlslBinaryTest = TestParamHelper<BinaryData>;
TEST_P(HlslBinaryTest, Emit_f32) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto params = GetParam();
@@ -80,7 +80,7 @@
EXPECT_EQ(result(), params.result);
}
TEST_P(HlslBinaryTest, Emit_u32) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto params = GetParam();
@@ -102,7 +102,7 @@
EXPECT_EQ(result(), params.result);
}
TEST_P(HlslBinaryTest, Emit_i32) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto params = GetParam();
@@ -145,8 +145,8 @@
BinaryData{"(left % right)", ast::BinaryOp::kModulo}));
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
&vec3, ast::ExpressionList{
@@ -171,8 +171,8 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f));
@@ -196,8 +196,8 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
auto* lhs = create<ast::IdentifierExpression>("mat");
@@ -214,8 +214,8 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
auto* lhs = create<ast::ScalarConstructorExpression>(
@@ -232,9 +232,9 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
auto* lhs = create<ast::IdentifierExpression>("mat");
@@ -258,9 +258,9 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
@@ -285,9 +285,9 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
auto* lhs = create<ast::IdentifierExpression>("mat");
@@ -370,7 +370,7 @@
// return 3;
// }
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(
@@ -476,7 +476,7 @@
TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) {
// var a : bool = (b && c) || d;
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* b = create<ast::IdentifierExpression>("b");
auto* c = create<ast::IdentifierExpression>("c");
@@ -505,7 +505,7 @@
TEST_F(HlslGeneratorImplTest_Binary, Bitcast_WithLogical) {
// as<i32>(a && (b || c))
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* a = create<ast::IdentifierExpression>("a");
auto* b = create<ast::IdentifierExpression>("b");
@@ -532,7 +532,7 @@
TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) {
// foo(a && b, c || d, (a || c) && (b || d))
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* func = create<ast::Function>("foo", ast::VariableList{}, &void_type,
create<ast::BlockStatement>());
diff --git a/src/writer/hlsl/generator_impl_bitcast_test.cc b/src/writer/hlsl/generator_impl_bitcast_test.cc
index 1fa7d2e..9d6d214 100644
--- a/src/writer/hlsl/generator_impl_bitcast_test.cc
+++ b/src/writer/hlsl/generator_impl_bitcast_test.cc
@@ -30,7 +30,7 @@
using HlslGeneratorImplTest_Bitcast = TestHelper;
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* id = create<ast::IdentifierExpression>("id");
ast::BitcastExpression bitcast(&f32, id);
@@ -39,7 +39,7 @@
}
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* id = create<ast::IdentifierExpression>("id");
ast::BitcastExpression bitcast(&i32, id);
@@ -48,7 +48,7 @@
}
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* id = create<ast::IdentifierExpression>("id");
ast::BitcastExpression bitcast(&u32, id);
diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc
index 39f20ed..780b253 100644
--- a/src/writer/hlsl/generator_impl_call_test.cc
+++ b/src/writer/hlsl/generator_impl_call_test.cc
@@ -30,7 +30,7 @@
using HlslGeneratorImplTest_Call = TestHelper;
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* id = create<ast::IdentifierExpression>("my_func");
ast::CallExpression call(id, {});
@@ -44,7 +44,7 @@
}
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* id = create<ast::IdentifierExpression>("my_func");
ast::ExpressionList params;
@@ -61,7 +61,7 @@
}
TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* id = create<ast::IdentifierExpression>("my_func");
ast::ExpressionList params;
diff --git a/src/writer/hlsl/generator_impl_case_test.cc b/src/writer/hlsl/generator_impl_case_test.cc
index efff3e9..0efe976 100644
--- a/src/writer/hlsl/generator_impl_case_test.cc
+++ b/src/writer/hlsl/generator_impl_case_test.cc
@@ -31,7 +31,7 @@
using HlslGeneratorImplTest_Case = TestHelper;
TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::BreakStatement>());
@@ -50,7 +50,7 @@
}
TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::CaseSelectorList lit;
lit.push_back(create<ast::SintLiteral>(&i32, 5));
@@ -66,7 +66,7 @@
}
TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::FallthroughStatement>());
@@ -85,7 +85,7 @@
}
TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::BreakStatement>());
diff --git a/src/writer/hlsl/generator_impl_cast_test.cc b/src/writer/hlsl/generator_impl_cast_test.cc
index 8002e27..1fc3c70 100644
--- a/src/writer/hlsl/generator_impl_cast_test.cc
+++ b/src/writer/hlsl/generator_impl_cast_test.cc
@@ -29,7 +29,7 @@
using HlslGeneratorImplTest_Cast = TestHelper;
TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>("id"));
@@ -41,8 +41,8 @@
}
TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>("id"));
diff --git a/src/writer/hlsl/generator_impl_constructor_test.cc b/src/writer/hlsl/generator_impl_constructor_test.cc
index 69c4768..12033c1 100644
--- a/src/writer/hlsl/generator_impl_constructor_test.cc
+++ b/src/writer/hlsl/generator_impl_constructor_test.cc
@@ -36,7 +36,7 @@
using HlslGeneratorImplTest_Constructor = TestHelper;
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* lit = create<ast::BoolLiteral>(&bool_type, false);
ast::ScalarConstructorExpression expr(lit);
@@ -45,7 +45,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, -12345);
ast::ScalarConstructorExpression expr(lit);
@@ -54,7 +54,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(&u32, 56779);
ast::ScalarConstructorExpression expr(lit);
@@ -63,7 +63,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto* lit =
create<ast::FloatLiteral>(&f32, static_cast<float>((1 << 30) - 4));
@@ -74,7 +74,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* lit = create<ast::FloatLiteral>(&f32, -1.2e-5);
ast::ExpressionList values;
@@ -87,7 +87,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) {
- ast::type::BoolType b;
+ ast::type::Bool b;
auto* lit = create<ast::BoolLiteral>(&b, true);
ast::ExpressionList values;
@@ -100,7 +100,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, -12345);
ast::ExpressionList values;
@@ -113,7 +113,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(&u32, 12345);
ast::ExpressionList values;
@@ -126,8 +126,8 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
auto* lit1 = create<ast::FloatLiteral>(&f32, 1.f);
auto* lit2 = create<ast::FloatLiteral>(&f32, 2.f);
@@ -144,8 +144,8 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_Empty) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList values;
ast::TypeConstructorExpression expr(&vec, values);
@@ -155,9 +155,9 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 2); // 3 ROWS, 2 COLUMNS
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 2); // 3 ROWS, 2 COLUMNS
+ ast::type::Vector vec(&f32, 3);
// WGSL matrix is mat2x3 (it flips for AST, sigh). With a type constructor
// of <vec3, vec3>
@@ -191,9 +191,9 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
- ast::type::ArrayType ary(&vec, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
+ ast::type::Array ary(&vec, 3);
ast::ExpressionList ary_values;
diff --git a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc
index d224ccc..fe7b171 100644
--- a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc
+++ b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc
@@ -50,8 +50,8 @@
// int bar : TEXCOORD1;
// };
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -104,8 +104,8 @@
// int bar : TEXCOORD1;
// };
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
@@ -159,8 +159,8 @@
// int bar : TEXCOORD1;
// };
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -214,8 +214,8 @@
// int bar : SV_Target1;
// };
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
@@ -265,8 +265,8 @@
//
// -> Error, not allowed
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -315,8 +315,8 @@
//
// -> Error not allowed
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
@@ -371,9 +371,9 @@
// float depth : SV_Depth;
// };
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::F32 f32;
+ ast::type::Void void_type;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc
index fc81bd5..db623f6 100644
--- a/src/writer/hlsl/generator_impl_function_test.cc
+++ b/src/writer/hlsl/generator_impl_function_test.cc
@@ -55,7 +55,7 @@
using HlslGeneratorImplTest_Function = TestHelper;
TEST_F(HlslGeneratorImplTest_Function, Emit_Function) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -74,7 +74,7 @@
}
TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -93,14 +93,14 @@
}
TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) {
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::VariableList params;
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &f32));
params.push_back(create<ast::Variable>("b", ast::StorageClass::kNone, &i32));
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -119,8 +119,8 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_WithInOutVars) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -169,9 +169,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_WithInOut_Builtins) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
@@ -225,9 +225,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_With_Uniform) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kUniform, &vec4));
@@ -271,9 +271,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_With_UniformStruct) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
ast::StructMemberList members;
members.push_back(create<ast::StructMember>(
@@ -282,7 +282,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Uniforms", str);
+ ast::type::Struct s("Uniforms", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("uniforms", ast::StorageClass::kUniform, &s));
@@ -332,9 +332,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_With_RW_StorageBuffer_Read) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -348,8 +348,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
@@ -391,9 +391,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_With_RO_StorageBuffer_Read) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -407,8 +407,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadOnly, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
@@ -450,9 +450,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_With_StorageBuffer_Store) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -466,8 +466,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
@@ -513,8 +513,8 @@
TEST_F(
HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -597,9 +597,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_Called_By_EntryPoints_NoUsedGlobals) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* depth_var = create<ast::DecoratedVariable>(
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
@@ -662,9 +662,9 @@
TEST_F(
HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
@@ -740,9 +740,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_Called_By_EntryPoint_With_Uniform) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kUniform, &vec4));
@@ -806,10 +806,10 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_Called_By_EntryPoint_With_StorageBuffer) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &vec4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &vec4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
@@ -870,9 +870,9 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoints_WithGlobal_Nested_Return) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* bar_var = create<ast::DecoratedVariable>(
create<ast::Variable>("bar", ast::StorageClass::kOutput, &f32));
@@ -928,7 +928,7 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_WithNameCollision) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* func = create<ast::Function>("GeometryShader", ast::VariableList{},
&void_type, create<ast::BlockStatement>());
@@ -946,7 +946,7 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_Compute) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
@@ -969,7 +969,7 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_EntryPoint_Compute_WithWorkgroup) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
@@ -992,13 +992,13 @@
}
TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 5);
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 5);
ast::VariableList params;
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &ary));
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -1033,8 +1033,8 @@
// return;
// }
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -1046,8 +1046,8 @@
auto* str = create<ast::Struct>(s_decos, members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
auto* data_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &ac));
diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc
index a55c452..237ce11 100644
--- a/src/writer/hlsl/generator_impl_import_test.cc
+++ b/src/writer/hlsl/generator_impl_import_test.cc
@@ -51,7 +51,7 @@
TEST_P(HlslImportData_SingleParamTest, FloatScalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -96,7 +96,7 @@
TEST_P(HlslImportData_SingleIntParamTest, IntScalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -117,7 +117,7 @@
TEST_P(HlslImportData_DualParamTest, FloatScalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -146,8 +146,8 @@
TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList params;
params.push_back(create<ast::TypeConstructorExpression>(
@@ -187,7 +187,7 @@
TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -211,7 +211,7 @@
TEST_P(HlslImportData_TripleParamTest, FloatScalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -244,7 +244,7 @@
TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -266,8 +266,8 @@
testing::Values(HlslImportData{"clamp", "clamp"}));
TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 3);
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &mat);
diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc
index b47a1e3..669d91f 100644
--- a/src/writer/hlsl/generator_impl_intrinsic_test.cc
+++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc
@@ -72,9 +72,9 @@
}
TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_OuterProduct) {
- ast::type::F32Type f32;
- ast::type::VectorType vec2(&f32, 2);
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec2(&f32, 2);
+ ast::type::Vector vec3(&f32, 3);
auto* a = create<ast::Variable>("a", ast::StorageClass::kNone, &vec2);
auto* b = create<ast::Variable>("b", ast::StorageClass::kNone, &vec3);
@@ -105,8 +105,8 @@
}
TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Call) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>("param1"));
diff --git a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
index 19c8612..9da97e1 100644
--- a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
+++ b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
@@ -179,17 +179,17 @@
break;
}
- ast::type::SamplerType sampler_type{param.sampler_kind};
+ ast::type::Sampler sampler_type{param.sampler_kind};
switch (param.texture_kind) {
case ast::intrinsic::test::TextureKind::kRegular:
Var("texture", ast::StorageClass::kNone,
- mod->create<ast::type::SampledTextureType>(param.texture_dimension,
- datatype));
+ mod->create<ast::type::SampledTexture>(param.texture_dimension,
+ datatype));
break;
case ast::intrinsic::test::TextureKind::kDepth:
Var("texture", ast::StorageClass::kNone,
- mod->create<ast::type::DepthTextureType>(param.texture_dimension));
+ mod->create<ast::type::DepthTexture>(param.texture_dimension));
break;
}
diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc
index 4e7bfdd..e180180 100644
--- a/src/writer/hlsl/generator_impl_loop_test.cc
+++ b/src/writer/hlsl/generator_impl_loop_test.cc
@@ -73,7 +73,7 @@
}
TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::DiscardStatement>());
@@ -142,7 +142,7 @@
// }
// }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("lhs", ast::StorageClass::kFunction, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc
index 5c15ab6..145e0c7 100644
--- a/src/writer/hlsl/generator_impl_member_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc
@@ -47,7 +47,7 @@
using HlslGeneratorImplTest_MemberAccessor = TestHelper;
TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::StructMemberList members;
ast::StructMemberDecorationList deco;
@@ -57,7 +57,7 @@
auto* strct = create<ast::Struct>();
strct->set_members(members);
- ast::type::StructType s("Str", strct);
+ ast::type::Struct s("Str", strct);
auto* str_var = create<ast::DecoratedVariable>(
create<ast::Variable>("str", ast::StorageClass::kPrivate, &s));
@@ -86,8 +86,8 @@
// data.b;
//
// -> asfloat(data.Load(4));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -101,7 +101,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -130,8 +130,8 @@
// data.a;
//
// -> asint(data.Load(0));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -145,7 +145,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -176,9 +176,9 @@
// -> float3x2 _tint_tmp = b;
// data.Store3(4 + 0, asuint(_tint_tmp[0]));
// data.Store3(4 + 16, asuint(_tint_tmp[1]));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::MatrixType mat(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Matrix mat(&f32, 3, 2);
auto* str = create<ast::Struct>();
str->set_members({
@@ -192,7 +192,7 @@
create<ast::StructMemberOffsetDecoration>(4, Source{})}),
});
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* b_var = create<ast::Variable>("b", ast::StorageClass::kPrivate, &mat);
@@ -236,9 +236,9 @@
// 0.0f, 0.0f, 0.0f);
// data.Store3(4 + 0, asuint(_tint_tmp[0]);
// data.Store3(4 + 16, asuint(_tint_tmp[1]));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::MatrixType mat(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Matrix mat(&f32, 3, 2);
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -252,7 +252,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -292,9 +292,9 @@
//
// -> asfloat(uint2x3(data.Load2(4 + 0), data.Load2(4 + 8),
// data.Load2(4 + 16)));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Matrix mat(&f32, 2, 3);
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -308,7 +308,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -343,9 +343,9 @@
// data.b.a;
//
// -> asfloat(uint3x2(data.Load3(4 + 0), data.Load3(4 + 16)));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::MatrixType mat(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Matrix mat(&f32, 3, 2);
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -359,7 +359,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -390,9 +390,9 @@
//
// -> asfloat(uint3x3(data.Load3(0), data.Load3(16),
// data.Load3(32)));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::MatrixType mat(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Matrix mat(&f32, 3, 3);
ast::StructMemberList members;
ast::StructMemberDecorationList deco;
@@ -402,7 +402,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -433,9 +433,9 @@
// data.a[2][1];
//
// -> asfloat(data.Load((2 * 16) + (1 * 4) + 16)))
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::MatrixType mat(&f32, 3, 4);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Matrix mat(&f32, 3, 4);
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -449,7 +449,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -484,9 +484,9 @@
// data.a[2];
//
// -> asint(data.Load((2 * 4));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::ArrayType ary(&i32, 5);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Array ary(&i32, 5);
ary.set_decorations({create<ast::StrideDecoration>(4, Source{})});
ast::StructMemberList members;
@@ -497,7 +497,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -529,9 +529,9 @@
// data.a[(2 + 4) - 3];
//
// -> asint(data.Load((4 * ((2 + 4) - 3)));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::ArrayType ary(&i32, 5);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Array ary(&i32, 5);
ary.set_decorations({create<ast::StrideDecoration>(4, Source{})});
ast::StructMemberList members;
@@ -542,7 +542,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -584,8 +584,8 @@
//
// -> data.Store(0, asuint(2.0f));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -599,7 +599,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -633,9 +633,9 @@
//
// -> data.Store((2 * 4), asuint(2.3f));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::ArrayType ary(&i32, 5);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Array ary(&i32, 5);
ary.set_decorations({create<ast::StrideDecoration>(4, Source{})});
ast::StructMemberList members;
@@ -646,7 +646,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -684,8 +684,8 @@
//
// -> data.Store(0, asuint(2));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -699,7 +699,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -734,10 +734,10 @@
//
// -> asfloat(data.Load(16));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType ivec3(&i32, 3);
- ast::type::VectorType fvec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector ivec3(&i32, 3);
+ ast::type::Vector fvec3(&f32, 3);
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -751,7 +751,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -781,10 +781,10 @@
//
// -> data.Store(16, asuint(float3(2.3f, 1.2f, 0.2f)));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType ivec3(&i32, 3);
- ast::type::VectorType fvec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector ivec3(&i32, 3);
+ ast::type::Vector fvec3(&f32, 3);
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -798,7 +798,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
+ ast::type::Struct s("Data", str);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
@@ -846,10 +846,10 @@
//
// -> asfloat(data.Load3(16 + (2 * 32)))
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType ivec3(&i32, 3);
- ast::type::VectorType fvec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector ivec3(&i32, 3);
+ ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>();
data_str->set_members({
@@ -863,9 +863,9 @@
create<ast::StructMemberOffsetDecoration>(16, Source{})}),
});
- ast::type::StructType data("Data", data_str);
+ ast::type::Struct data("Data", data_str);
- ast::type::ArrayType ary(&data, 4);
+ ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
auto* pre_str = create<ast::Struct>();
@@ -876,7 +876,7 @@
create<ast::StructMemberOffsetDecoration>(0, Source{})}),
});
- ast::type::StructType pre_struct("Pre", pre_str);
+ ast::type::Struct pre_struct("Pre", pre_str);
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
@@ -916,10 +916,10 @@
//
// -> asfloat(data.Load3(16 + (2 * 32))).xy
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType ivec3(&i32, 3);
- ast::type::VectorType fvec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector ivec3(&i32, 3);
+ ast::type::Vector fvec3(&f32, 3);
ast::StructMemberList members;
ast::StructMemberDecorationList deco;
@@ -936,9 +936,9 @@
create<ast::StructMemberOffsetDecoration>(16, Source{})}),
});
- ast::type::StructType data("Data", data_str);
+ ast::type::Struct data("Data", data_str);
- ast::type::ArrayType ary(&data, 4);
+ ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
auto* pre_str = create<ast::Struct>();
@@ -947,7 +947,7 @@
ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})});
- ast::type::StructType pre_struct("Pre", pre_str);
+ ast::type::Struct pre_struct("Pre", pre_str);
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
@@ -990,10 +990,10 @@
//
// -> asfloat(data.Load((4 * 1) + 16 + (2 * 32) + 0))
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType ivec3(&i32, 3);
- ast::type::VectorType fvec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector ivec3(&i32, 3);
+ ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>();
data_str->set_members({
@@ -1007,9 +1007,9 @@
create<ast::StructMemberOffsetDecoration>(16, Source{})}),
});
- ast::type::StructType data("Data", data_str);
+ ast::type::Struct data("Data", data_str);
- ast::type::ArrayType ary(&data, 4);
+ ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
auto* pre_str = create<ast::Struct>();
@@ -1018,7 +1018,7 @@
ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})});
- ast::type::StructType pre_struct("Pre", pre_str);
+ ast::type::Struct pre_struct("Pre", pre_str);
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
@@ -1060,10 +1060,10 @@
//
// -> asfloat(data.Load(4 + 16 + (2 * 32)))
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType ivec3(&i32, 3);
- ast::type::VectorType fvec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector ivec3(&i32, 3);
+ ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>();
data_str->set_members({
@@ -1077,9 +1077,9 @@
create<ast::StructMemberOffsetDecoration>(16, Source{})}),
});
- ast::type::StructType data("Data", data_str);
+ ast::type::Struct data("Data", data_str);
- ast::type::ArrayType ary(&data, 4);
+ ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
auto* pre_str = create<ast::Struct>();
@@ -1088,7 +1088,7 @@
ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})});
- ast::type::StructType pre_struct("Pre", pre_str);
+ ast::type::Struct pre_struct("Pre", pre_str);
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
@@ -1131,10 +1131,10 @@
//
// -> data.Store3(16 + (2 * 32), asuint(float3(1.0f, 2.0f, 3.0f)));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType ivec3(&i32, 3);
- ast::type::VectorType fvec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector ivec3(&i32, 3);
+ ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>();
data_str->set_members({
@@ -1148,9 +1148,9 @@
create<ast::StructMemberOffsetDecoration>(16, Source{})}),
});
- ast::type::StructType data("Data", data_str);
+ ast::type::Struct data("Data", data_str);
- ast::type::ArrayType ary(&data, 4);
+ ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
auto* pre_str = create<ast::Struct>();
@@ -1159,7 +1159,7 @@
ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})});
- ast::type::StructType pre_struct("Pre", pre_str);
+ ast::type::Struct pre_struct("Pre", pre_str);
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
@@ -1213,10 +1213,10 @@
//
// -> data.Store((4 * 1) + 16 + (2 * 32) + 0, asuint(1.0f));
- ast::type::F32Type f32;
- ast::type::I32Type i32;
- ast::type::VectorType ivec3(&i32, 3);
- ast::type::VectorType fvec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::I32 i32;
+ ast::type::Vector ivec3(&i32, 3);
+ ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>();
data_str->set_members({
@@ -1230,9 +1230,9 @@
create<ast::StructMemberOffsetDecoration>(16, Source{})}),
});
- ast::type::StructType data("Data", data_str);
+ ast::type::Struct data("Data", data_str);
- ast::type::ArrayType ary(&data, 4);
+ ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
auto* pre_str = create<ast::Struct>();
@@ -1241,7 +1241,7 @@
ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})});
- ast::type::StructType pre_struct("Pre", pre_str);
+ ast::type::Struct pre_struct("Pre", pre_str);
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
diff --git a/src/writer/hlsl/generator_impl_module_constant_test.cc b/src/writer/hlsl/generator_impl_module_constant_test.cc
index 84831d5..2e96034 100644
--- a/src/writer/hlsl/generator_impl_module_constant_test.cc
+++ b/src/writer/hlsl/generator_impl_module_constant_test.cc
@@ -34,8 +34,8 @@
using HlslGeneratorImplTest_ModuleConstant = TestHelper;
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 3);
ast::ExpressionList exprs;
exprs.push_back(create<ast::ScalarConstructorExpression>(
@@ -54,7 +54,7 @@
}
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(23, Source{}));
@@ -76,7 +76,7 @@
}
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(23, Source{}));
diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc
index ab33821..fa5f12d 100644
--- a/src/writer/hlsl/generator_impl_switch_test.cc
+++ b/src/writer/hlsl/generator_impl_switch_test.cc
@@ -35,7 +35,7 @@
def_body->append(create<ast::BreakStatement>());
auto* def = create<ast::CaseStatement>(def_body);
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::CaseSelectorList case_val;
case_val.push_back(create<ast::SintLiteral>(&i32, 5));
diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc
index f2854aa..4f0a14c 100644
--- a/src/writer/hlsl/generator_impl_test.cc
+++ b/src/writer/hlsl/generator_impl_test.cc
@@ -28,7 +28,7 @@
using HlslGeneratorImplTest = TestHelper;
TEST_F(HlslGeneratorImplTest, Generate) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* func = create<ast::Function>("my_func", ast::VariableList{}, &void_type,
create<ast::BlockStatement>());
mod.AddFunction(func);
diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc
index 592a600..e8fcb64 100644
--- a/src/writer/hlsl/generator_impl_type_test.cc
+++ b/src/writer/hlsl/generator_impl_type_test.cc
@@ -44,33 +44,33 @@
using HlslGeneratorImplTest_Type = TestHelper;
TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("alias", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias("alias", &f32);
ASSERT_TRUE(gen.EmitType(out, &alias, "")) << gen.error();
EXPECT_EQ(result(), "alias");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias_NameCollision) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("bool", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias("bool", &f32);
ASSERT_TRUE(gen.EmitType(out, &alias, "")) << gen.error();
EXPECT_EQ(result(), "bool_tint_0");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
ASSERT_TRUE(gen.EmitType(out, &a, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[4]");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
- ast::type::ArrayType c(&a, 5);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
+ ast::type::Array c(&a, 5);
ASSERT_TRUE(gen.EmitType(out, &c, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[5][4]");
@@ -79,44 +79,44 @@
// TODO(dsinclair): Is this possible? What order should it output in?
TEST_F(HlslGeneratorImplTest_Type,
DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
- ast::type::ArrayType c(&a, 5);
- ast::type::ArrayType d(&c);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
+ ast::type::Array c(&a, 5);
+ ast::type::Array d(&c);
ASSERT_TRUE(gen.EmitType(out, &c, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[5][4][1]");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
- ast::type::ArrayType c(&a, 5);
- ast::type::ArrayType d(&c, 6);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
+ ast::type::Array c(&a, 5);
+ ast::type::Array d(&c, 6);
ASSERT_TRUE(gen.EmitType(out, &d, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[6][5][4]");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_NameCollision) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
ASSERT_TRUE(gen.EmitType(out, &a, "bool")) << gen.error();
EXPECT_EQ(result(), "bool bool_tint_0[4]");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
ASSERT_TRUE(gen.EmitType(out, &a, "")) << gen.error();
EXPECT_EQ(result(), "bool[4]");
}
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_RuntimeArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b);
+ ast::type::Bool b;
+ ast::type::Array a(&b);
ASSERT_TRUE(gen.EmitType(out, &a, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[]");
@@ -124,37 +124,37 @@
TEST_F(HlslGeneratorImplTest_Type,
DISABLED_EmitType_RuntimeArray_NameCollision) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b);
+ ast::type::Bool b;
+ ast::type::Array a(&b);
ASSERT_TRUE(gen.EmitType(out, &a, "double")) << gen.error();
EXPECT_EQ(result(), "bool double_tint_0[]");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) {
- ast::type::BoolType b;
+ ast::type::Bool b;
ASSERT_TRUE(gen.EmitType(out, &b, "")) << gen.error();
EXPECT_EQ(result(), "bool");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ASSERT_TRUE(gen.EmitType(out, &f32, "")) << gen.error();
EXPECT_EQ(result(), "float");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ASSERT_TRUE(gen.EmitType(out, &i32, "")) << gen.error();
EXPECT_EQ(result(), "int");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType m(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix m(&f32, 3, 2);
ASSERT_TRUE(gen.EmitType(out, &m, "")) << gen.error();
EXPECT_EQ(result(), "float3x2");
@@ -162,16 +162,16 @@
// TODO(dsinclair): How to annotate as workgroup?
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Pointer) {
- ast::type::F32Type f32;
- ast::type::PointerType p(&f32, ast::StorageClass::kWorkgroup);
+ ast::type::F32 f32;
+ ast::type::Pointer p(&f32, ast::StorageClass::kWorkgroup);
ASSERT_TRUE(gen.EmitType(out, &p, "")) << gen.error();
EXPECT_EQ(result(), "float*");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -184,7 +184,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error();
EXPECT_EQ(result(), R"(struct S {
@@ -195,8 +195,8 @@
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -209,15 +209,15 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), "S");
}
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberDecorationList decos;
decos.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
@@ -234,7 +234,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), R"(struct {
@@ -248,8 +248,8 @@
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(create<ast::StructMember>(
@@ -261,7 +261,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error();
EXPECT_EQ(result(), R"(struct S {
@@ -273,8 +273,8 @@
// TODO(dsinclair): How to translate [[block]]
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -289,7 +289,7 @@
auto* str = create<ast::Struct>(decos, members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitStructType(out, &s, "B")) << gen.error();
EXPECT_EQ(result(), R"(struct B {
@@ -299,36 +299,36 @@
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ASSERT_TRUE(gen.EmitType(out, &u32, "")) << gen.error();
EXPECT_EQ(result(), "uint");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType v(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector v(&f32, 3);
ASSERT_TRUE(gen.EmitType(out, &v, "")) << gen.error();
EXPECT_EQ(result(), "float3");
}
TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) {
- ast::type::VoidType v;
+ ast::type::Void v;
ASSERT_TRUE(gen.EmitType(out, &v, "")) << gen.error();
EXPECT_EQ(result(), "void");
}
TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
- ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
ASSERT_TRUE(gen.EmitType(out, &sampler, "")) << gen.error();
EXPECT_EQ(result(), "SamplerState");
}
TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
- ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler);
ASSERT_TRUE(gen.EmitType(out, &sampler, "")) << gen.error();
EXPECT_EQ(result(), "SamplerComparisonState");
@@ -346,7 +346,7 @@
TEST_P(HlslDepthtexturesTest, Emit) {
auto params = GetParam();
- ast::type::DepthTextureType s(params.dim);
+ ast::type::DepthTexture s(params.dim);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), params.result);
@@ -374,8 +374,8 @@
TEST_P(HlslSampledtexturesTest, Emit) {
auto params = GetParam();
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(params.dim, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(params.dim, &f32);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), params.result);
@@ -396,8 +396,8 @@
"TextureCubeArray"}));
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
- ast::type::F32Type f32;
- ast::type::MultisampledTextureType s(ast::type::TextureDimension::k2d, &f32);
+ ast::type::F32 f32;
+ ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, &f32);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), "Texture2D");
@@ -417,10 +417,10 @@
TEST_P(HlslStoragetexturesTest, Emit) {
auto params = GetParam();
- ast::type::StorageTextureType s(params.dim,
- params.ro ? ast::AccessControl::kReadOnly
- : ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(params.dim,
+ params.ro ? ast::AccessControl::kReadOnly
+ : ast::AccessControl::kWriteOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), params.result);
diff --git a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
index b7da41d..4638cf6 100644
--- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
@@ -33,7 +33,7 @@
using HlslGeneratorImplTest_VariableDecl = TestHelper;
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
ast::VariableDeclStatement stmt(var);
@@ -44,7 +44,7 @@
}
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_is_const(true);
@@ -56,8 +56,8 @@
}
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 5);
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 5);
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &ary);
@@ -70,7 +70,7 @@
TEST_F(HlslGeneratorImplTest_VariableDecl,
Emit_VariableDeclStatement_Function) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kFunction, &f32);
ast::VariableDeclStatement stmt(var);
@@ -81,7 +81,7 @@
}
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
ast::VariableDeclStatement stmt(var);
@@ -95,7 +95,7 @@
Emit_VariableDeclStatement_Initializer_Private) {
auto* ident = create<ast::IdentifierExpression>("initializer");
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(ident);
@@ -107,8 +107,8 @@
TEST_F(HlslGeneratorImplTest_VariableDecl,
Emit_VariableDeclStatement_Initializer_ZeroVec) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList values;
auto* zero_vec = create<ast::TypeConstructorExpression>(&vec, values);
@@ -124,8 +124,8 @@
TEST_F(HlslGeneratorImplTest_VariableDecl,
Emit_VariableDeclStatement_Initializer_ZeroMat) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 2);
ast::ExpressionList values;
auto* zero_mat = create<ast::TypeConstructorExpression>(&mat, values);
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index 4bf9110..76dd997 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -166,55 +166,54 @@
return true;
}
-uint32_t GeneratorImpl::calculate_largest_alignment(
- ast::type::StructType* type) {
- auto* stct = type->As<ast::type::StructType>()->impl();
+uint32_t GeneratorImpl::calculate_largest_alignment(ast::type::Struct* type) {
+ auto* stct = type->As<ast::type::Struct>()->impl();
uint32_t largest_alignment = 0;
for (auto* mem : stct->members()) {
auto align = calculate_alignment_size(mem->type());
if (align == 0) {
return 0;
}
- if (!mem->type()->Is<ast::type::StructType>()) {
+ if (!mem->type()->Is<ast::type::Struct>()) {
largest_alignment = std::max(largest_alignment, align);
} else {
largest_alignment = std::max(
- largest_alignment, calculate_largest_alignment(
- mem->type()->As<ast::type::StructType>()));
+ largest_alignment,
+ calculate_largest_alignment(mem->type()->As<ast::type::Struct>()));
}
}
return largest_alignment;
}
uint32_t GeneratorImpl::calculate_alignment_size(ast::type::Type* type) {
- if (type->Is<ast::type::AliasType>()) {
- return calculate_alignment_size(type->As<ast::type::AliasType>()->type());
+ if (type->Is<ast::type::Alias>()) {
+ return calculate_alignment_size(type->As<ast::type::Alias>()->type());
}
- if (type->Is<ast::type::ArrayType>()) {
- auto* ary = type->As<ast::type::ArrayType>();
+ if (type->Is<ast::type::Array>()) {
+ auto* ary = type->As<ast::type::Array>();
// TODO(dsinclair): Handle array stride and adjust for alignment.
uint32_t type_size = calculate_alignment_size(ary->type());
return ary->size() * type_size;
}
- if (type->Is<ast::type::BoolType>()) {
+ if (type->Is<ast::type::Bool>()) {
return 1;
}
- if (type->Is<ast::type::PointerType>()) {
+ if (type->Is<ast::type::Pointer>()) {
return 0;
}
- if (type->Is<ast::type::F32Type>() || type->Is<ast::type::I32Type>() ||
- type->Is<ast::type::U32Type>()) {
+ if (type->Is<ast::type::F32>() || type->Is<ast::type::I32>() ||
+ type->Is<ast::type::U32>()) {
return 4;
}
- if (type->Is<ast::type::MatrixType>()) {
- auto* mat = type->As<ast::type::MatrixType>();
+ if (type->Is<ast::type::Matrix>()) {
+ auto* mat = type->As<ast::type::Matrix>();
// TODO(dsinclair): Handle MatrixStride
// https://github.com/gpuweb/gpuweb/issues/773
uint32_t type_size = calculate_alignment_size(mat->type());
return mat->rows() * mat->columns() * type_size;
}
- if (type->Is<ast::type::StructType>()) {
- auto* stct = type->As<ast::type::StructType>()->impl();
+ if (type->Is<ast::type::Struct>()) {
+ auto* stct = type->As<ast::type::Struct>()->impl();
uint32_t count = 0;
uint32_t largest_alignment = 0;
// Offset decorations in WGSL must be in increasing order.
@@ -228,12 +227,12 @@
if (align == 0) {
return 0;
}
- if (!mem->type()->Is<ast::type::StructType>()) {
+ if (!mem->type()->Is<ast::type::Struct>()) {
largest_alignment = std::max(largest_alignment, align);
} else {
largest_alignment = std::max(
- largest_alignment, calculate_largest_alignment(
- mem->type()->As<ast::type::StructType>()));
+ largest_alignment,
+ calculate_largest_alignment(mem->type()->As<ast::type::Struct>()));
}
// Round up to the alignment size
@@ -244,8 +243,8 @@
count = adjust_for_alignment(count, largest_alignment);
return count;
}
- if (type->Is<ast::type::VectorType>()) {
- auto* vec = type->As<ast::type::VectorType>();
+ if (type->Is<ast::type::Vector>()) {
+ auto* vec = type->As<ast::type::Vector>();
uint32_t type_size = calculate_alignment_size(vec->type());
if (vec->size() == 2) {
return 2 * type_size;
@@ -258,16 +257,16 @@
bool GeneratorImpl::EmitConstructedType(const ast::type::Type* ty) {
make_indent();
- if (ty->Is<ast::type::AliasType>()) {
- auto* alias = ty->As<ast::type::AliasType>();
+ if (ty->Is<ast::type::Alias>()) {
+ auto* alias = ty->As<ast::type::Alias>();
out_ << "typedef ";
if (!EmitType(alias->type(), "")) {
return false;
}
out_ << " " << namer_.NameFor(alias->name()) << ";" << std::endl;
- } else if (ty->Is<ast::type::StructType>()) {
- if (!EmitStructType(ty->As<ast::type::StructType>())) {
+ } else if (ty->Is<ast::type::Struct>()) {
+ if (!EmitStructType(ty->As<ast::type::Struct>())) {
return false;
}
} else {
@@ -522,14 +521,14 @@
// out_ << "(";
// auto param1_type = params[1]->result_type()->UnwrapPtrIfNeeded();
- // if (!param1_type->Is<ast::type::VectorType>()) {
+ // if (!param1_type->Is<ast::type::Vector>()) {
// error_ = "invalid param type in outer_product got: " +
// param1_type->type_name();
// return false;
// }
// for (uint32_t i = 0; i <
- // param1_type->As<ast::type::VectorType>()->size(); ++i) {
+ // param1_type->As<ast::type::Vector>()->size(); ++i) {
// if (i > 0) {
// out_ << ", ";
// }
@@ -716,7 +715,7 @@
auto dim = params[pidx.texture]
->result_type()
->UnwrapPtrIfNeeded()
- ->As<ast::type::TextureType>()
+ ->As<ast::type::Texture>()
->dim();
switch (dim) {
case ast::type::TextureDimension::k2d:
@@ -798,26 +797,26 @@
out += ident->name();
break;
case ast::Intrinsic::kAbs:
- if (ident->result_type()->Is<ast::type::F32Type>()) {
+ if (ident->result_type()->Is<ast::type::F32>()) {
out += "fabs";
- } else if (ident->result_type()->Is<ast::type::U32Type>() ||
- ident->result_type()->Is<ast::type::I32Type>()) {
+ } else if (ident->result_type()->Is<ast::type::U32>() ||
+ ident->result_type()->Is<ast::type::I32>()) {
out += "abs";
}
break;
case ast::Intrinsic::kMax:
- if (ident->result_type()->Is<ast::type::F32Type>()) {
+ if (ident->result_type()->Is<ast::type::F32>()) {
out += "fmax";
- } else if (ident->result_type()->Is<ast::type::U32Type>() ||
- ident->result_type()->Is<ast::type::I32Type>()) {
+ } else if (ident->result_type()->Is<ast::type::U32>() ||
+ ident->result_type()->Is<ast::type::I32>()) {
out += "max";
}
break;
case ast::Intrinsic::kMin:
- if (ident->result_type()->Is<ast::type::F32Type>()) {
+ if (ident->result_type()->Is<ast::type::F32>()) {
out += "fmin";
- } else if (ident->result_type()->Is<ast::type::U32Type>() ||
- ident->result_type()->Is<ast::type::I32Type>()) {
+ } else if (ident->result_type()->Is<ast::type::U32>() ||
+ ident->result_type()->Is<ast::type::I32>()) {
out += "min";
}
break;
@@ -895,7 +894,7 @@
}
bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) {
- if (expr->type()->Is<ast::type::ArrayType>()) {
+ if (expr->type()->Is<ast::type::Array>()) {
out_ << "{";
} else {
if (!EmitType(expr->type(), "")) {
@@ -924,7 +923,7 @@
}
}
- if (expr->type()->Is<ast::type::ArrayType>()) {
+ if (expr->type()->Is<ast::type::Array>()) {
out_ << "}";
} else {
out_ << ")";
@@ -933,25 +932,25 @@
}
bool GeneratorImpl::EmitZeroValue(ast::type::Type* type) {
- if (type->Is<ast::type::BoolType>()) {
+ if (type->Is<ast::type::Bool>()) {
out_ << "false";
- } else if (type->Is<ast::type::F32Type>()) {
+ } else if (type->Is<ast::type::F32>()) {
out_ << "0.0f";
- } else if (type->Is<ast::type::I32Type>()) {
+ } else if (type->Is<ast::type::I32>()) {
out_ << "0";
- } else if (type->Is<ast::type::U32Type>()) {
+ } else if (type->Is<ast::type::U32>()) {
out_ << "0u";
- } else if (type->Is<ast::type::VectorType>()) {
- return EmitZeroValue(type->As<ast::type::VectorType>()->type());
- } else if (type->Is<ast::type::MatrixType>()) {
- return EmitZeroValue(type->As<ast::type::MatrixType>()->type());
- } else if (type->Is<ast::type::ArrayType>()) {
+ } else if (type->Is<ast::type::Vector>()) {
+ return EmitZeroValue(type->As<ast::type::Vector>()->type());
+ } else if (type->Is<ast::type::Matrix>()) {
+ return EmitZeroValue(type->As<ast::type::Matrix>()->type());
+ } else if (type->Is<ast::type::Array>()) {
out_ << "{";
- if (!EmitZeroValue(type->As<ast::type::ArrayType>()->type())) {
+ if (!EmitZeroValue(type->As<ast::type::Array>()->type())) {
return false;
}
out_ << "}";
- } else if (type->Is<ast::type::StructType>()) {
+ } else if (type->Is<ast::type::Struct>()) {
out_ << "{}";
} else {
error_ = "Invalid type for zero emission: " + type->type_name();
@@ -1287,11 +1286,11 @@
}
first = false;
- if (!var->type()->Is<ast::type::AccessControlType>()) {
+ if (!var->type()->Is<ast::type::AccessControl>()) {
error_ = "invalid type for storage buffer, expected access control";
return false;
}
- auto* ac = var->type()->As<ast::type::AccessControlType>();
+ auto* ac = var->type()->As<ast::type::AccessControl>();
if (ac->IsReadOnly()) {
out_ << "const ";
}
@@ -1313,7 +1312,7 @@
return false;
}
// Array name is output as part of the type
- if (!v->type()->Is<ast::type::ArrayType>()) {
+ if (!v->type()->Is<ast::type::Array>()) {
out_ << " " << v->name();
}
}
@@ -1448,11 +1447,11 @@
auto* binding = data.second.binding;
// auto* set = data.second.set;
- if (!var->type()->Is<ast::type::AccessControlType>()) {
+ if (!var->type()->Is<ast::type::AccessControl>()) {
error_ = "invalid type for storage buffer, expected access control";
return false;
}
- auto* ac = var->type()->As<ast::type::AccessControlType>();
+ auto* ac = var->type()->As<ast::type::AccessControl>();
if (ac->IsReadOnly()) {
out_ << "const ";
}
@@ -1794,21 +1793,21 @@
}
bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) {
- if (type->Is<ast::type::AliasType>()) {
- auto* alias = type->As<ast::type::AliasType>();
+ if (type->Is<ast::type::Alias>()) {
+ auto* alias = type->As<ast::type::Alias>();
out_ << namer_.NameFor(alias->name());
- } else if (type->Is<ast::type::ArrayType>()) {
- auto* ary = type->As<ast::type::ArrayType>();
+ } else if (type->Is<ast::type::Array>()) {
+ auto* ary = type->As<ast::type::Array>();
ast::type::Type* base_type = ary;
std::vector<uint32_t> sizes;
- while (base_type->Is<ast::type::ArrayType>()) {
- if (base_type->As<ast::type::ArrayType>()->IsRuntimeArray()) {
+ while (base_type->Is<ast::type::Array>()) {
+ if (base_type->As<ast::type::Array>()->IsRuntimeArray()) {
sizes.push_back(1);
} else {
- sizes.push_back(base_type->As<ast::type::ArrayType>()->size());
+ sizes.push_back(base_type->As<ast::type::Array>()->size());
}
- base_type = base_type->As<ast::type::ArrayType>()->type();
+ base_type = base_type->As<ast::type::Array>()->type();
}
if (!EmitType(base_type, "")) {
return false;
@@ -1819,35 +1818,35 @@
for (uint32_t size : sizes) {
out_ << "[" << size << "]";
}
- } else if (type->Is<ast::type::BoolType>()) {
+ } else if (type->Is<ast::type::Bool>()) {
out_ << "bool";
- } else if (type->Is<ast::type::F32Type>()) {
+ } else if (type->Is<ast::type::F32>()) {
out_ << "float";
- } else if (type->Is<ast::type::I32Type>()) {
+ } else if (type->Is<ast::type::I32>()) {
out_ << "int";
- } else if (type->Is<ast::type::MatrixType>()) {
- auto* mat = type->As<ast::type::MatrixType>();
+ } else if (type->Is<ast::type::Matrix>()) {
+ auto* mat = type->As<ast::type::Matrix>();
if (!EmitType(mat->type(), "")) {
return false;
}
out_ << mat->columns() << "x" << mat->rows();
- } else if (type->Is<ast::type::PointerType>()) {
- auto* ptr = type->As<ast::type::PointerType>();
+ } else if (type->Is<ast::type::Pointer>()) {
+ auto* ptr = type->As<ast::type::Pointer>();
// TODO(dsinclair): Storage class?
if (!EmitType(ptr->type(), "")) {
return false;
}
out_ << "*";
- } else if (type->Is<ast::type::SamplerType>()) {
+ } else if (type->Is<ast::type::Sampler>()) {
out_ << "sampler";
- } else if (type->Is<ast::type::StructType>()) {
+ } else if (type->Is<ast::type::Struct>()) {
// The struct type emits as just the name. The declaration would be emitted
// as part of emitting the constructed types.
- out_ << type->As<ast::type::StructType>()->name();
- } else if (type->Is<ast::type::TextureType>()) {
- auto* tex = type->As<ast::type::TextureType>();
+ out_ << type->As<ast::type::Struct>()->name();
+ } else if (type->Is<ast::type::Texture>()) {
+ auto* tex = type->As<ast::type::Texture>();
- if (tex->Is<ast::type::DepthTextureType>()) {
+ if (tex->Is<ast::type::DepthTexture>()) {
out_ << "depth";
} else {
out_ << "texture";
@@ -1879,14 +1878,14 @@
error_ = "Invalid texture dimensions";
return false;
}
- if (tex->Is<ast::type::MultisampledTextureType>()) {
+ if (tex->Is<ast::type::MultisampledTexture>()) {
out_ << "_ms";
}
out_ << "<";
- if (tex->Is<ast::type::DepthTextureType>()) {
+ if (tex->Is<ast::type::DepthTexture>()) {
out_ << "float, access::sample";
- } else if (tex->Is<ast::type::StorageTextureType>()) {
- auto* storage = tex->As<ast::type::StorageTextureType>();
+ } else if (tex->Is<ast::type::StorageTexture>()) {
+ auto* storage = tex->As<ast::type::StorageTexture>();
if (!EmitType(storage->type(), "")) {
return false;
}
@@ -1899,14 +1898,13 @@
error_ = "Invalid access control for storage texture";
return false;
}
- } else if (tex->Is<ast::type::MultisampledTextureType>()) {
- if (!EmitType(tex->As<ast::type::MultisampledTextureType>()->type(),
- "")) {
+ } else if (tex->Is<ast::type::MultisampledTexture>()) {
+ if (!EmitType(tex->As<ast::type::MultisampledTexture>()->type(), "")) {
return false;
}
out_ << ", access::sample";
- } else if (tex->Is<ast::type::SampledTextureType>()) {
- if (!EmitType(tex->As<ast::type::SampledTextureType>()->type(), "")) {
+ } else if (tex->Is<ast::type::SampledTexture>()) {
+ if (!EmitType(tex->As<ast::type::SampledTexture>()->type(), "")) {
return false;
}
out_ << ", access::sample";
@@ -1916,15 +1914,15 @@
}
out_ << ">";
- } else if (type->Is<ast::type::U32Type>()) {
+ } else if (type->Is<ast::type::U32>()) {
out_ << "uint";
- } else if (type->Is<ast::type::VectorType>()) {
- auto* vec = type->As<ast::type::VectorType>();
+ } else if (type->Is<ast::type::Vector>()) {
+ auto* vec = type->As<ast::type::Vector>();
if (!EmitType(vec->type(), "")) {
return false;
}
out_ << vec->size();
- } else if (type->Is<ast::type::VoidType>()) {
+ } else if (type->Is<ast::type::Void>()) {
out_ << "void";
} else {
error_ = "unknown type in EmitType: " + type->type_name();
@@ -1934,7 +1932,7 @@
return true;
}
-bool GeneratorImpl::EmitStructType(const ast::type::StructType* str) {
+bool GeneratorImpl::EmitStructType(const ast::type::Struct* str) {
// TODO(dsinclair): Block decoration?
// if (str->impl()->decoration() != ast::StructDecoration::kNone) {
// }
@@ -1972,7 +1970,7 @@
current_offset += size;
// Array member name will be output with the type
- if (!mem->type()->Is<ast::type::ArrayType>()) {
+ if (!mem->type()->Is<ast::type::Array>()) {
out_ << " " << namer_.NameFor(mem->name());
}
out_ << ";" << std::endl;
@@ -2019,7 +2017,7 @@
if (!EmitType(var->type(), var->name())) {
return false;
}
- if (!var->type()->Is<ast::type::ArrayType>()) {
+ if (!var->type()->Is<ast::type::Array>()) {
out_ << " " << var->name();
}
@@ -2060,7 +2058,7 @@
if (!EmitType(var->type(), var->name())) {
return false;
}
- if (!var->type()->Is<ast::type::ArrayType>()) {
+ if (!var->type()->Is<ast::type::Array>()) {
out_ << " " << var->name();
}
diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h
index 2b8a687..a1a4ae9 100644
--- a/src/writer/msl/generator_impl.h
+++ b/src/writer/msl/generator_impl.h
@@ -70,7 +70,7 @@
/// Calculates the largest alignment seen within a struct
/// @param type the struct to calculate
/// @returns the largest alignment value
- uint32_t calculate_largest_alignment(ast::type::StructType* type);
+ uint32_t calculate_largest_alignment(ast::type::Struct* type);
/// Handles generating a constructed
/// @param ty the constructed type to generate
@@ -209,7 +209,7 @@
/// Handles generating a struct declaration
/// @param str the struct to generate
/// @returns true if the struct is emitted
- bool EmitStructType(const ast::type::StructType* str);
+ bool EmitStructType(const ast::type::Struct* str);
/// Handles emitting a type constructor
/// @param expr the type constructor expression
/// @returns true if the constructor is emitted
diff --git a/src/writer/msl/generator_impl_alias_type_test.cc b/src/writer/msl/generator_impl_alias_type_test.cc
index beebfc08..ac4b895 100644
--- a/src/writer/msl/generator_impl_alias_type_test.cc
+++ b/src/writer/msl/generator_impl_alias_type_test.cc
@@ -32,8 +32,8 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitConstructedType_F32) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("a", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias("a", &f32);
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
EXPECT_EQ(gen.result(), R"(typedef float a;
@@ -41,8 +41,8 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructedType_NameCollision) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("float", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias("float", &f32);
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
EXPECT_EQ(gen.result(), R"(typedef float float_tint_0;
@@ -50,8 +50,8 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -64,7 +64,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("a", str);
+ ast::type::Struct s("a", str);
ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error();
EXPECT_EQ(gen.result(), R"(struct a {
@@ -75,8 +75,8 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -89,8 +89,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("b", str);
- ast::type::AliasType alias("a", &s);
+ ast::type::Struct s("b", str);
+ ast::type::Alias alias("a", &s);
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
EXPECT_EQ(gen.result(), R"(typedef b a;
diff --git a/src/writer/msl/generator_impl_array_accessor_test.cc b/src/writer/msl/generator_impl_array_accessor_test.cc
index ee85cb9..a584f80 100644
--- a/src/writer/msl/generator_impl_array_accessor_test.cc
+++ b/src/writer/msl/generator_impl_array_accessor_test.cc
@@ -32,7 +32,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitExpression_ArrayAccessor) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, 5);
auto* idx = create<ast::ScalarConstructorExpression>(lit);
auto* ary = create<ast::IdentifierExpression>("ary");
diff --git a/src/writer/msl/generator_impl_bitcast_test.cc b/src/writer/msl/generator_impl_bitcast_test.cc
index 82fdcab..d6c1546 100644
--- a/src/writer/msl/generator_impl_bitcast_test.cc
+++ b/src/writer/msl/generator_impl_bitcast_test.cc
@@ -30,7 +30,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitExpression_Bitcast) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* id = create<ast::IdentifierExpression>("id");
ast::BitcastExpression bitcast(&f32, id);
diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc
index 2a36938..0041ed7 100644
--- a/src/writer/msl/generator_impl_call_test.cc
+++ b/src/writer/msl/generator_impl_call_test.cc
@@ -32,7 +32,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* id = create<ast::IdentifierExpression>("my_func");
ast::CallExpression call(id, {});
@@ -46,7 +46,7 @@
}
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* id = create<ast::IdentifierExpression>("my_func");
ast::ExpressionList params;
@@ -63,7 +63,7 @@
}
TEST_F(MslGeneratorImplTest, EmitStatement_Call) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* id = create<ast::IdentifierExpression>("my_func");
ast::ExpressionList params;
diff --git a/src/writer/msl/generator_impl_case_test.cc b/src/writer/msl/generator_impl_case_test.cc
index 72d07a9..e8e2244 100644
--- a/src/writer/msl/generator_impl_case_test.cc
+++ b/src/writer/msl/generator_impl_case_test.cc
@@ -33,7 +33,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_Case) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::BreakStatement>());
@@ -52,7 +52,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::CaseSelectorList lit;
lit.push_back(create<ast::SintLiteral>(&i32, 5));
@@ -68,7 +68,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::FallthroughStatement>());
@@ -87,7 +87,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::BreakStatement>());
diff --git a/src/writer/msl/generator_impl_cast_test.cc b/src/writer/msl/generator_impl_cast_test.cc
index 05b4fed..22ebedf 100644
--- a/src/writer/msl/generator_impl_cast_test.cc
+++ b/src/writer/msl/generator_impl_cast_test.cc
@@ -31,7 +31,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Scalar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>("id"));
@@ -43,8 +43,8 @@
}
TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>("id"));
diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc
index e1160b7..223257a 100644
--- a/src/writer/msl/generator_impl_constructor_test.cc
+++ b/src/writer/msl/generator_impl_constructor_test.cc
@@ -38,7 +38,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* lit = create<ast::BoolLiteral>(&bool_type, false);
ast::ScalarConstructorExpression expr(lit);
@@ -47,7 +47,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Int) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, -12345);
ast::ScalarConstructorExpression expr(lit);
@@ -56,7 +56,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(&u32, 56779);
ast::ScalarConstructorExpression expr(lit);
@@ -65,7 +65,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto* lit =
create<ast::FloatLiteral>(&f32, static_cast<float>((1 << 30) - 4));
@@ -76,7 +76,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* lit = create<ast::FloatLiteral>(&f32, -1.2e-5);
ast::ExpressionList values;
@@ -89,7 +89,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Bool) {
- ast::type::BoolType b;
+ ast::type::Bool b;
auto* lit = create<ast::BoolLiteral>(&b, true);
ast::ExpressionList values;
@@ -102,7 +102,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Int) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, -12345);
ast::ExpressionList values;
@@ -115,7 +115,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Uint) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(&u32, 12345);
ast::ExpressionList values;
@@ -128,8 +128,8 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
auto* lit1 = create<ast::FloatLiteral>(&f32, 1.f);
auto* lit2 = create<ast::FloatLiteral>(&f32, 2.f);
@@ -146,8 +146,8 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec_Empty) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList values;
ast::TypeConstructorExpression expr(&vec, values);
@@ -157,9 +157,9 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 2); // 3 ROWS, 2 COLUMNS
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 2); // 3 ROWS, 2 COLUMNS
+ ast::type::Vector vec(&f32, 3);
// WGSL matrix is mat2x3 (it flips for AST, sigh). With a type constructor
// of <vec3, vec3>
@@ -192,9 +192,9 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
- ast::type::ArrayType ary(&vec, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
+ ast::type::Array ary(&vec, 3);
ast::ExpressionList ary_values;
diff --git a/src/writer/msl/generator_impl_function_entry_point_data_test.cc b/src/writer/msl/generator_impl_function_entry_point_data_test.cc
index 492ffc8..d4b3f87 100644
--- a/src/writer/msl/generator_impl_function_entry_point_data_test.cc
+++ b/src/writer/msl/generator_impl_function_entry_point_data_test.cc
@@ -49,8 +49,8 @@
// int bar [[attribute(1)]];
// };
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -101,8 +101,8 @@
// int bar [[user(locn1)]];
// };
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
@@ -153,8 +153,8 @@
// int bar [[user(locn1)]];
// };
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -204,8 +204,8 @@
// int bar [[color(1)]];
// };
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
@@ -253,8 +253,8 @@
//
// -> Error, not allowed
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -301,8 +301,8 @@
//
// -> Error not allowed
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
@@ -354,9 +354,9 @@
// float depth [[depth(any)]];
// };
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::F32 f32;
+ ast::type::Void void_type;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc
index a2b6969..51697e9 100644
--- a/src/writer/msl/generator_impl_function_test.cc
+++ b/src/writer/msl/generator_impl_function_test.cc
@@ -58,7 +58,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_Function) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -79,7 +79,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -100,14 +100,14 @@
}
TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) {
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::VariableList params;
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &f32));
params.push_back(create<ast::Variable>("b", ast::StorageClass::kNone, &i32));
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -127,8 +127,8 @@
}
TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -181,9 +181,9 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_EntryPoint_WithInOut_Builtins) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
@@ -235,9 +235,9 @@
}
TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kUniform, &vec4));
@@ -282,9 +282,9 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_EntryPoint_With_RW_StorageBuffer) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -298,8 +298,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
mod.AddConstructedType(&s);
@@ -350,9 +350,9 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_EntryPoint_With_RO_StorageBuffer) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -366,8 +366,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadOnly, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
mod.AddConstructedType(&s);
@@ -421,8 +421,8 @@
TEST_F(
MslGeneratorImplTest,
Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
auto* foo_var = create<ast::DecoratedVariable>(
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
@@ -508,9 +508,9 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_Called_By_EntryPoints_NoUsedGlobals) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* depth_var = create<ast::DecoratedVariable>(
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
@@ -577,9 +577,9 @@
TEST_F(
MslGeneratorImplTest,
Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
@@ -653,9 +653,9 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_Called_By_EntryPoint_With_Uniform) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::VectorType vec4(&f32, 4);
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::Vector vec4(&f32, 4);
auto* coord_var = create<ast::DecoratedVariable>(
create<ast::Variable>("coord", ast::StorageClass::kUniform, &vec4));
@@ -718,9 +718,9 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_Called_By_EntryPoint_With_RW_StorageBuffer) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -734,8 +734,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
mod.AddConstructedType(&s);
@@ -805,9 +805,9 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_Called_By_EntryPoint_With_RO_StorageBuffer) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -821,8 +821,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadOnly, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
mod.AddConstructedType(&s);
@@ -892,9 +892,9 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_EntryPoints_WithGlobal_Nested_Return) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
auto* bar_var = create<ast::DecoratedVariable>(
create<ast::Variable>("bar", ast::StorageClass::kOutput, &f32));
@@ -953,7 +953,7 @@
TEST_F(MslGeneratorImplTest,
Emit_FunctionDecoration_EntryPoint_WithNameCollision) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* func = create<ast::Function>("main", ast::VariableList{}, &void_type,
create<ast::BlockStatement>());
@@ -972,13 +972,13 @@
}
TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) {
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 5);
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 5);
ast::VariableList params;
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &ary));
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -1016,8 +1016,8 @@
// return;
// }
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -1029,8 +1029,8 @@
auto* str = create<ast::Struct>(s_decos, members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
auto* data_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &ac));
diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc
index ef5428d..c6c1d57 100644
--- a/src/writer/msl/generator_impl_import_test.cc
+++ b/src/writer/msl/generator_impl_import_test.cc
@@ -52,7 +52,7 @@
TEST_P(MslImportData_SingleParamTest, FloatScalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -95,7 +95,7 @@
MslImportData{"trunc", "trunc"}));
TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_IntScalar) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -113,7 +113,7 @@
TEST_P(MslImportData_DualParamTest, FloatScalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -143,8 +143,8 @@
TEST_P(MslImportData_DualParam_VectorTest, FloatVector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList type_params;
@@ -186,7 +186,7 @@
TEST_P(MslImportData_DualParam_Int_Test, IntScalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -210,7 +210,7 @@
TEST_P(MslImportData_TripleParamTest, FloatScalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -241,7 +241,7 @@
TEST_P(MslImportData_TripleParam_Int_Test, IntScalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
@@ -265,8 +265,8 @@
MslImportData{"clamp", "clamp"}));
TEST_F(MslGeneratorImplTest, MslImportData_Determinant) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 3);
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &mat);
diff --git a/src/writer/msl/generator_impl_intrinsic_test.cc b/src/writer/msl/generator_impl_intrinsic_test.cc
index 2bd7dbe..f4d1b76 100644
--- a/src/writer/msl/generator_impl_intrinsic_test.cc
+++ b/src/writer/msl/generator_impl_intrinsic_test.cc
@@ -67,9 +67,9 @@
IntrinsicData{ast::Intrinsic::kSelect, "select"}));
TEST_F(MslGeneratorImplTest, DISABLED_Intrinsic_OuterProduct) {
- ast::type::F32Type f32;
- ast::type::VectorType vec2(&f32, 2);
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec2(&f32, 2);
+ ast::type::Vector vec3(&f32, 3);
auto* a = create<ast::Variable>("a", ast::StorageClass::kNone, &vec2);
auto* b = create<ast::Variable>("b", ast::StorageClass::kNone, &vec3);
@@ -100,8 +100,8 @@
}
TEST_F(MslGeneratorImplTest, Intrinsic_Call) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>("param1"));
diff --git a/src/writer/msl/generator_impl_intrinsic_texture_test.cc b/src/writer/msl/generator_impl_intrinsic_texture_test.cc
index c8079da..f38e3aa 100644
--- a/src/writer/msl/generator_impl_intrinsic_texture_test.cc
+++ b/src/writer/msl/generator_impl_intrinsic_texture_test.cc
@@ -170,17 +170,17 @@
break;
}
- ast::type::SamplerType sampler_type{param.sampler_kind};
+ ast::type::Sampler sampler_type{param.sampler_kind};
switch (param.texture_kind) {
case ast::intrinsic::test::TextureKind::kRegular:
Var("texture", ast::StorageClass::kNone,
- mod->create<ast::type::SampledTextureType>(param.texture_dimension,
- datatype));
+ mod->create<ast::type::SampledTexture>(param.texture_dimension,
+ datatype));
break;
case ast::intrinsic::test::TextureKind::kDepth:
Var("texture", ast::StorageClass::kNone,
- mod->create<ast::type::DepthTextureType>(param.texture_dimension));
+ mod->create<ast::type::DepthTexture>(param.texture_dimension));
break;
}
diff --git a/src/writer/msl/generator_impl_loop_test.cc b/src/writer/msl/generator_impl_loop_test.cc
index 46741e0..bd46e63 100644
--- a/src/writer/msl/generator_impl_loop_test.cc
+++ b/src/writer/msl/generator_impl_loop_test.cc
@@ -77,7 +77,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::DiscardStatement>());
@@ -147,7 +147,7 @@
// }
// }
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("lhs", ast::StorageClass::kFunction, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
diff --git a/src/writer/msl/generator_impl_module_constant_test.cc b/src/writer/msl/generator_impl_module_constant_test.cc
index 6c7b997..ae03c77 100644
--- a/src/writer/msl/generator_impl_module_constant_test.cc
+++ b/src/writer/msl/generator_impl_module_constant_test.cc
@@ -36,8 +36,8 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 3);
ast::ExpressionList exprs;
exprs.push_back(create<ast::ScalarConstructorExpression>(
@@ -56,7 +56,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(23, Source{}));
diff --git a/src/writer/msl/generator_impl_switch_test.cc b/src/writer/msl/generator_impl_switch_test.cc
index 25546b7..88dd603 100644
--- a/src/writer/msl/generator_impl_switch_test.cc
+++ b/src/writer/msl/generator_impl_switch_test.cc
@@ -37,7 +37,7 @@
def_body->append(create<ast::BreakStatement>());
auto* def = create<ast::CaseStatement>(def_body);
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::CaseSelectorList case_val;
case_val.push_back(create<ast::SintLiteral>(&i32, 5));
diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc
index e97b033..15f488a 100644
--- a/src/writer/msl/generator_impl_test.cc
+++ b/src/writer/msl/generator_impl_test.cc
@@ -48,7 +48,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Generate) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* func = create<ast::Function>("my_func", ast::VariableList{}, &void_type,
create<ast::BlockStatement>());
@@ -114,47 +114,47 @@
"thread_position_in_grid"}));
TEST_F(MslGeneratorImplTest, calculate_alignment_size_alias) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("a", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias("a", &f32);
EXPECT_EQ(4u, gen.calculate_alignment_size(&alias));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_array) {
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 4);
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 4);
EXPECT_EQ(4u * 4u, gen.calculate_alignment_size(&ary));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_bool) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
EXPECT_EQ(1u, gen.calculate_alignment_size(&bool_type));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_f32) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
EXPECT_EQ(4u, gen.calculate_alignment_size(&f32));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_i32) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
EXPECT_EQ(4u, gen.calculate_alignment_size(&i32));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_matrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 2);
EXPECT_EQ(4u * 3u * 2u, gen.calculate_alignment_size(&mat));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_pointer) {
- ast::type::BoolType bool_type;
- ast::type::PointerType ptr(&bool_type, ast::StorageClass::kPrivate);
+ ast::type::Bool bool_type;
+ ast::type::Pointer ptr(&bool_type, ast::StorageClass::kPrivate);
EXPECT_EQ(0u, gen.calculate_alignment_size(&ptr));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberDecorationList decos;
decos.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
@@ -171,15 +171,15 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
EXPECT_EQ(132u, gen.calculate_alignment_size(&s));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType fvec(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector fvec(&f32, 3);
ast::StructMemberDecorationList decos;
decos.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
@@ -196,7 +196,7 @@
auto* inner_str = create<ast::Struct>();
inner_str->set_members(members);
- ast::type::StructType inner_s("Inner", inner_str);
+ ast::type::Struct inner_s("Inner", inner_str);
decos.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
members.push_back(create<ast::StructMember>("d", &f32, decos));
@@ -210,13 +210,13 @@
auto* outer_str = create<ast::Struct>();
outer_str->set_members(members);
- ast::type::StructType outer_s("Outer", outer_str);
+ ast::type::Struct outer_s("Outer", outer_str);
EXPECT_EQ(80u, gen.calculate_alignment_size(&outer_s));
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_u32) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
EXPECT_EQ(4u, gen.calculate_alignment_size(&u32));
}
@@ -232,8 +232,8 @@
TEST_P(MslVectorSizeBoolTest, calculate) {
auto param = GetParam();
- ast::type::BoolType bool_type;
- ast::type::VectorType vec(&bool_type, param.elements);
+ ast::type::Bool bool_type;
+ ast::type::Vector vec(&bool_type, param.elements);
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@@ -246,8 +246,8 @@
TEST_P(MslVectorSizeI32Test, calculate) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec(&i32, param.elements);
+ ast::type::I32 i32;
+ ast::type::Vector vec(&i32, param.elements);
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@@ -260,8 +260,8 @@
TEST_P(MslVectorSizeU32Test, calculate) {
auto param = GetParam();
- ast::type::U32Type u32;
- ast::type::VectorType vec(&u32, param.elements);
+ ast::type::U32 u32;
+ ast::type::Vector vec(&u32, param.elements);
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@@ -274,8 +274,8 @@
TEST_P(MslVectorSizeF32Test, calculate) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, param.elements);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, param.elements);
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc
index 49f0399..02340e9 100644
--- a/src/writer/msl/generator_impl_type_test.cc
+++ b/src/writer/msl/generator_impl_type_test.cc
@@ -48,33 +48,33 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitType_Alias) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("alias", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias("alias", &f32);
ASSERT_TRUE(gen.EmitType(&alias, "")) << gen.error();
EXPECT_EQ(gen.result(), "alias");
}
TEST_F(MslGeneratorImplTest, EmitType_Alias_NameCollision) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("bool", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias("bool", &f32);
ASSERT_TRUE(gen.EmitType(&alias, "")) << gen.error();
EXPECT_EQ(gen.result(), "bool_tint_0");
}
TEST_F(MslGeneratorImplTest, EmitType_Array) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
ASSERT_TRUE(gen.EmitType(&a, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[4]");
}
TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
- ast::type::ArrayType c(&a, 5);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
+ ast::type::Array c(&a, 5);
ASSERT_TRUE(gen.EmitType(&c, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[5][4]");
@@ -82,81 +82,81 @@
// TODO(dsinclair): Is this possible? What order should it output in?
TEST_F(MslGeneratorImplTest, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
- ast::type::ArrayType c(&a, 5);
- ast::type::ArrayType d(&c);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
+ ast::type::Array c(&a, 5);
+ ast::type::Array d(&c);
ASSERT_TRUE(gen.EmitType(&c, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[5][4][1]");
}
TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
- ast::type::ArrayType c(&a, 5);
- ast::type::ArrayType d(&c, 6);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
+ ast::type::Array c(&a, 5);
+ ast::type::Array d(&c, 6);
ASSERT_TRUE(gen.EmitType(&d, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[6][5][4]");
}
TEST_F(MslGeneratorImplTest, EmitType_Array_NameCollision) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
ASSERT_TRUE(gen.EmitType(&a, "bool")) << gen.error();
EXPECT_EQ(gen.result(), "bool bool_tint_0[4]");
}
TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
ASSERT_TRUE(gen.EmitType(&a, "")) << gen.error();
EXPECT_EQ(gen.result(), "bool[4]");
}
TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b);
+ ast::type::Bool b;
+ ast::type::Array a(&b);
ASSERT_TRUE(gen.EmitType(&a, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[1]");
}
TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray_NameCollision) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b);
+ ast::type::Bool b;
+ ast::type::Array a(&b);
ASSERT_TRUE(gen.EmitType(&a, "discard_fragment")) << gen.error();
EXPECT_EQ(gen.result(), "bool discard_fragment_tint_0[1]");
}
TEST_F(MslGeneratorImplTest, EmitType_Bool) {
- ast::type::BoolType b;
+ ast::type::Bool b;
ASSERT_TRUE(gen.EmitType(&b, "")) << gen.error();
EXPECT_EQ(gen.result(), "bool");
}
TEST_F(MslGeneratorImplTest, EmitType_F32) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ASSERT_TRUE(gen.EmitType(&f32, "")) << gen.error();
EXPECT_EQ(gen.result(), "float");
}
TEST_F(MslGeneratorImplTest, EmitType_I32) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ASSERT_TRUE(gen.EmitType(&i32, "")) << gen.error();
EXPECT_EQ(gen.result(), "int");
}
TEST_F(MslGeneratorImplTest, EmitType_Matrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType m(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix m(&f32, 3, 2);
ASSERT_TRUE(gen.EmitType(&m, "")) << gen.error();
EXPECT_EQ(gen.result(), "float2x3");
@@ -164,16 +164,16 @@
// TODO(dsinclair): How to annotate as workgroup?
TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Pointer) {
- ast::type::F32Type f32;
- ast::type::PointerType p(&f32, ast::StorageClass::kWorkgroup);
+ ast::type::F32 f32;
+ ast::type::Pointer p(&f32, ast::StorageClass::kWorkgroup);
ASSERT_TRUE(gen.EmitType(&p, "")) << gen.error();
EXPECT_EQ(gen.result(), "float*");
}
TEST_F(MslGeneratorImplTest, EmitType_Struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -186,15 +186,15 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
EXPECT_EQ(gen.result(), "S");
}
TEST_F(MslGeneratorImplTest, EmitType_StructDecl) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -207,7 +207,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
EXPECT_EQ(gen.result(), R"(struct S {
@@ -218,8 +218,8 @@
}
TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
auto* str = create<ast::Struct>();
str->set_members({
@@ -237,7 +237,7 @@
create<ast::StructMemberOffsetDecoration>(128, Source{})}),
});
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
EXPECT_EQ(gen.result(), R"(struct S {
@@ -252,8 +252,8 @@
}
TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(create<ast::StructMember>(
@@ -265,7 +265,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
EXPECT_EQ(gen.result(), R"(struct S {
@@ -277,8 +277,8 @@
// TODO(dsinclair): How to translate [[block]]
TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -292,7 +292,7 @@
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* str = create<ast::Struct>(decos, members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
EXPECT_EQ(gen.result(), R"(struct {
@@ -302,36 +302,36 @@
}
TEST_F(MslGeneratorImplTest, EmitType_U32) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ASSERT_TRUE(gen.EmitType(&u32, "")) << gen.error();
EXPECT_EQ(gen.result(), "uint");
}
TEST_F(MslGeneratorImplTest, EmitType_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType v(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector v(&f32, 3);
ASSERT_TRUE(gen.EmitType(&v, "")) << gen.error();
EXPECT_EQ(gen.result(), "float3");
}
TEST_F(MslGeneratorImplTest, EmitType_Void) {
- ast::type::VoidType v;
+ ast::type::Void v;
ASSERT_TRUE(gen.EmitType(&v, "")) << gen.error();
EXPECT_EQ(gen.result(), "void");
}
TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
- ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
ASSERT_TRUE(gen.EmitType(&sampler, "")) << gen.error();
EXPECT_EQ(gen.result(), "sampler");
}
TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
- ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler);
ASSERT_TRUE(gen.EmitType(&sampler, "")) << gen.error();
EXPECT_EQ(gen.result(), "sampler");
@@ -349,7 +349,7 @@
TEST_P(MslDepthTexturesTest, Emit) {
auto params = GetParam();
- ast::type::DepthTextureType s(params.dim);
+ ast::type::DepthTexture s(params.dim);
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
EXPECT_EQ(gen.result(), params.result);
@@ -379,8 +379,8 @@
TEST_P(MslSampledtexturesTest, Emit) {
auto params = GetParam();
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(params.dim, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(params.dim, &f32);
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
EXPECT_EQ(gen.result(), params.result);
@@ -405,8 +405,8 @@
"texturecube_array<float, access::sample>"}));
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
- ast::type::U32Type u32;
- ast::type::MultisampledTextureType s(ast::type::TextureDimension::k2d, &u32);
+ ast::type::U32 u32;
+ ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, &u32);
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
EXPECT_EQ(gen.result(), "texture2d_ms<uint, access::sample>");
@@ -425,10 +425,10 @@
TEST_P(MslStorageTexturesTest, Emit) {
auto params = GetParam();
- ast::type::StorageTextureType s(params.dim,
- params.ro ? ast::AccessControl::kReadOnly
- : ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(params.dim,
+ params.ro ? ast::AccessControl::kReadOnly
+ : ast::AccessControl::kWriteOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
index f0ec7a0..315dfa5 100644
--- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
@@ -41,7 +41,7 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
ast::VariableDeclStatement stmt(var);
@@ -53,7 +53,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_is_const(true);
@@ -66,8 +66,8 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
- ast::type::F32Type f32;
- ast::type::ArrayType ary(&f32, 5);
+ ast::type::F32 f32;
+ ast::type::Array ary(&f32, 5);
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &ary);
@@ -80,7 +80,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -93,7 +93,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &s);
@@ -107,8 +107,8 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 2);
auto* var = create<ast::Variable>("a", ast::StorageClass::kFunction, &vec);
@@ -121,8 +121,8 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 2, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 2, 3);
auto* var = create<ast::Variable>("a", ast::StorageClass::kFunction, &mat);
ast::VariableDeclStatement stmt(var);
@@ -134,7 +134,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
ast::VariableDeclStatement stmt(var);
@@ -148,7 +148,7 @@
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
auto* ident = create<ast::IdentifierExpression>("initializer");
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(ident);
@@ -160,8 +160,8 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroVec) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList values;
auto* zero_vec = create<ast::TypeConstructorExpression>(&vec, values);
diff --git a/src/writer/pack_coord_arrayidx.cc b/src/writer/pack_coord_arrayidx.cc
index 6fb9b6d..051f0a9 100644
--- a/src/writer/pack_coord_arrayidx.cc
+++ b/src/writer/pack_coord_arrayidx.cc
@@ -30,7 +30,7 @@
if (type_constructor == nullptr) {
return nullptr;
}
- if (!type_constructor->type()->Is<ast::type::VectorType>()) {
+ if (!type_constructor->type()->Is<ast::type::Vector>()) {
return nullptr;
}
return type_constructor;
@@ -44,8 +44,8 @@
std::function<bool(ast::TypeConstructorExpression*)> callback) {
uint32_t packed_size;
ast::type::Type* packed_el_ty; // Currenly must be f32.
- if (coords->result_type()->Is<ast::type::VectorType>()) {
- auto* vec = coords->result_type()->As<ast::type::VectorType>();
+ if (coords->result_type()->Is<ast::type::Vector>()) {
+ auto* vec = coords->result_type()->As<ast::type::Vector>();
packed_size = vec->size() + 1;
packed_el_ty = vec->type();
} else {
@@ -61,7 +61,7 @@
ast::TypeConstructorExpression array_index_cast(packed_el_ty, {array_idx});
array_index_cast.set_result_type(packed_el_ty);
- ast::type::VectorType packed_ty(packed_el_ty, packed_size);
+ ast::type::Vector packed_ty(packed_el_ty, packed_size);
// If the coordinates are already passed in a vector constructor, extract
// the elements into the new vector instead of nesting a vector-in-vector.
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index 08f9eab..1527776 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -151,12 +151,12 @@
/// one or more levels of an arrays inside of |type|.
/// @param type the given type, which must not be null
/// @returns the nested matrix type, or nullptr if none
-ast::type::MatrixType* GetNestedMatrixType(ast::type::Type* type) {
- while (type->Is<ast::type::ArrayType>()) {
- type = type->As<ast::type::ArrayType>()->type();
+ast::type::Matrix* GetNestedMatrixType(ast::type::Type* type) {
+ while (type->Is<ast::type::Array>()) {
+ type = type->As<ast::type::Array>()->type();
}
- return type->Is<ast::type::MatrixType>() ? type->As<ast::type::MatrixType>()
- : nullptr;
+ return type->Is<ast::type::Matrix>() ? type->As<ast::type::Matrix>()
+ : nullptr;
}
uint32_t intrinsic_to_glsl_method(ast::type::Type* type,
@@ -378,7 +378,7 @@
}
uint32_t Builder::GenerateU32Literal(uint32_t val) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ast::SintLiteral lit(&u32, val);
return GenerateLiteralIfNeeded(nullptr, &lit);
}
@@ -634,7 +634,7 @@
auto result = result_op();
auto var_id = result.to_i();
auto sc = ast::StorageClass::kFunction;
- ast::type::PointerType pt(var->type(), sc);
+ ast::type::Pointer pt(var->type(), sc);
auto type_id = GenerateTypeIfNeeded(&pt);
if (type_id == 0) {
return false;
@@ -705,7 +705,7 @@
? ast::StorageClass::kPrivate
: var->storage_class();
- ast::type::PointerType pt(var->type(), sc);
+ ast::type::Pointer pt(var->type(), sc);
auto type_id = GenerateTypeIfNeeded(&pt);
if (type_id == 0) {
return false;
@@ -721,10 +721,10 @@
Operand::Int(ConvertStorageClass(sc))};
if (var->has_constructor()) {
ops.push_back(Operand::Int(init_id));
- } else if (type->Is<ast::type::TextureType>()) {
+ } else if (type->Is<ast::type::Texture>()) {
// Decorate storage texture variables with NonRead/Writeable if needed.
- if (type->Is<ast::type::StorageTextureType>()) {
- switch (type->As<ast::type::StorageTextureType>()->access()) {
+ if (type->Is<ast::type::StorageTexture>()) {
+ switch (type->As<ast::type::StorageTexture>()->access()) {
case ast::AccessControl::kWriteOnly:
push_annot(
spv::Op::OpDecorate,
@@ -739,7 +739,7 @@
break;
}
}
- } else if (!type->Is<ast::type::SamplerType>()) {
+ } else if (!type->Is<ast::type::Sampler>()) {
// Certain cases require us to generate a constructor value.
//
// 1- ConstantId's must be attached to the OpConstant, if we have a
@@ -749,16 +749,16 @@
// then WGSL requires an initializer.
if (var->Is<ast::DecoratedVariable>() &&
var->As<ast::DecoratedVariable>()->HasConstantIdDecoration()) {
- if (type->Is<ast::type::F32Type>()) {
+ if (type->Is<ast::type::F32>()) {
ast::FloatLiteral l(type, 0.0f);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type->Is<ast::type::U32Type>()) {
+ } else if (type->Is<ast::type::U32>()) {
ast::UintLiteral l(type, 0);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type->Is<ast::type::I32Type>()) {
+ } else if (type->Is<ast::type::I32>()) {
ast::SintLiteral l(type, 0);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type->Is<ast::type::BoolType>()) {
+ } else if (type->Is<ast::type::Bool>()) {
ast::BoolLiteral l(type, false);
init_id = GenerateLiteralIfNeeded(var, &l);
} else {
@@ -825,9 +825,9 @@
// If the source is a pointer we access chain into it. We also access chain
// into an array of non-scalar types.
- if (info->source_type->Is<ast::type::PointerType>() ||
- (info->source_type->Is<ast::type::ArrayType>() &&
- !info->source_type->As<ast::type::ArrayType>()->type()->is_scalar())) {
+ if (info->source_type->Is<ast::type::Pointer>() ||
+ (info->source_type->Is<ast::type::Array>() &&
+ !info->source_type->As<ast::type::Array>()->type()->is_scalar())) {
info->access_chain_indices.push_back(idx_id);
info->source_type = expr->result_type();
return true;
@@ -859,15 +859,15 @@
// If the data_type is a structure we're accessing a member, if it's a
// vector we're accessing a swizzle.
- if (data_type->Is<ast::type::StructType>()) {
- if (!info->source_type->Is<ast::type::PointerType>()) {
+ if (data_type->Is<ast::type::Struct>()) {
+ if (!info->source_type->Is<ast::type::Pointer>()) {
error_ =
"Attempting to access a struct member on a non-pointer. Something is "
"wrong";
return false;
}
- auto* strct = data_type->As<ast::type::StructType>()->impl();
+ auto* strct = data_type->As<ast::type::Struct>()->impl();
auto name = expr->member()->name();
uint32_t i = 0;
@@ -887,7 +887,7 @@
return true;
}
- if (!data_type->Is<ast::type::VectorType>()) {
+ if (!data_type->Is<ast::type::Vector>()) {
error_ = "Member accessor without a struct or vector. Something is wrong";
return false;
}
@@ -901,7 +901,7 @@
return false;
}
- if (info->source_type->Is<ast::type::PointerType>()) {
+ if (info->source_type->Is<ast::type::Pointer>()) {
auto idx_id = GenerateU32Literal(val);
if (idx_id == 0) {
return 0;
@@ -1015,10 +1015,10 @@
if (auto* array = accessors[0]->As<ast::ArrayAccessorExpression>()) {
auto* ary_res_type = array->array()->result_type();
- if (!ary_res_type->Is<ast::type::PointerType>() &&
- (ary_res_type->Is<ast::type::ArrayType>() &&
- !ary_res_type->As<ast::type::ArrayType>()->type()->is_scalar())) {
- ast::type::PointerType ptr(ary_res_type, ast::StorageClass::kFunction);
+ if (!ary_res_type->Is<ast::type::Pointer>() &&
+ (ary_res_type->Is<ast::type::Array>() &&
+ !ary_res_type->As<ast::type::Array>()->type()->is_scalar())) {
+ ast::type::Pointer ptr(ary_res_type, ast::StorageClass::kFunction);
auto result_type_id = GenerateTypeIfNeeded(&ptr);
if (result_type_id == 0) {
return 0;
@@ -1093,7 +1093,7 @@
}
uint32_t Builder::GenerateLoadIfNeeded(ast::type::Type* type, uint32_t id) {
- if (!type->Is<ast::type::PointerType>()) {
+ if (!type->Is<ast::type::Pointer>()) {
return id;
}
@@ -1197,7 +1197,7 @@
return false;
}
- if (result_type->Is<ast::type::VectorType>() &&
+ if (result_type->Is<ast::type::Vector>() &&
!e->Is<ast::ScalarConstructorExpression>()) {
return false;
}
@@ -1209,14 +1209,14 @@
auto* sc = e->As<ast::ScalarConstructorExpression>();
ast::type::Type* subtype = result_type->UnwrapAll();
- if (subtype->Is<ast::type::VectorType>()) {
- subtype = subtype->As<ast::type::VectorType>()->type()->UnwrapAll();
- } else if (subtype->Is<ast::type::MatrixType>()) {
- subtype = subtype->As<ast::type::MatrixType>()->type()->UnwrapAll();
- } else if (subtype->Is<ast::type::ArrayType>()) {
- subtype = subtype->As<ast::type::ArrayType>()->type()->UnwrapAll();
- } else if (subtype->Is<ast::type::StructType>()) {
- subtype = subtype->As<ast::type::StructType>()
+ if (subtype->Is<ast::type::Vector>()) {
+ subtype = subtype->As<ast::type::Vector>()->type()->UnwrapAll();
+ } else if (subtype->Is<ast::type::Matrix>()) {
+ subtype = subtype->As<ast::type::Matrix>()->type()->UnwrapAll();
+ } else if (subtype->Is<ast::type::Array>()) {
+ subtype = subtype->As<ast::type::Array>()->type()->UnwrapAll();
+ } else if (subtype->Is<ast::type::Struct>()) {
+ subtype = subtype->As<ast::type::Struct>()
->impl()
->members()[i]
->type()
@@ -1251,14 +1251,14 @@
bool can_cast_or_copy = result_type->is_scalar();
- if (result_type->Is<ast::type::VectorType>() &&
- result_type->As<ast::type::VectorType>()->type()->is_scalar()) {
+ if (result_type->Is<ast::type::Vector>() &&
+ result_type->As<ast::type::Vector>()->type()->is_scalar()) {
auto* value_type = values[0]->result_type()->UnwrapAll();
can_cast_or_copy =
- (value_type->Is<ast::type::VectorType>() &&
- value_type->As<ast::type::VectorType>()->type()->is_scalar() &&
- result_type->As<ast::type::VectorType>()->size() ==
- value_type->As<ast::type::VectorType>()->size());
+ (value_type->Is<ast::type::Vector>() &&
+ value_type->As<ast::type::Vector>()->type()->is_scalar() &&
+ result_type->As<ast::type::Vector>()->size() ==
+ value_type->As<ast::type::Vector>()->size());
}
if (can_cast_or_copy) {
return GenerateCastOrCopyOrPassthrough(result_type, values[0]);
@@ -1272,8 +1272,8 @@
bool result_is_constant_composite = constructor_is_const;
bool result_is_spec_composite = false;
- if (result_type->Is<ast::type::VectorType>()) {
- result_type = result_type->As<ast::type::VectorType>()->type();
+ if (result_type->Is<ast::type::Vector>()) {
+ result_type = result_type->As<ast::type::Vector>()->type();
}
OperandList ops;
@@ -1294,9 +1294,9 @@
// If the result and value types are the same we can just use the object.
// If the result is not a vector then we should have validated that the
// value type is a correctly sized vector so we can just use it directly.
- if (result_type == value_type || result_type->Is<ast::type::MatrixType>() ||
- result_type->Is<ast::type::ArrayType>() ||
- result_type->Is<ast::type::StructType>()) {
+ if (result_type == value_type || result_type->Is<ast::type::Matrix>() ||
+ result_type->Is<ast::type::Array>() ||
+ result_type->Is<ast::type::Struct>()) {
out << "_" << id;
ops.push_back(Operand::Int(id));
@@ -1321,8 +1321,8 @@
//
// For cases 1 and 2, if the type is different we also may need to insert
// a type cast.
- if (value_type->Is<ast::type::VectorType>()) {
- auto* vec = value_type->As<ast::type::VectorType>();
+ if (value_type->Is<ast::type::Vector>()) {
+ auto* vec = value_type->As<ast::type::Vector>();
auto* vec_type = vec->type();
auto value_type_id = GenerateTypeIfNeeded(vec_type);
@@ -1408,40 +1408,38 @@
auto* from_type = from_expr->result_type()->UnwrapPtrIfNeeded();
spv::Op op = spv::Op::OpNop;
- if ((from_type->Is<ast::type::I32Type>() &&
- to_type->Is<ast::type::F32Type>()) ||
+ if ((from_type->Is<ast::type::I32>() && to_type->Is<ast::type::F32>()) ||
(from_type->is_signed_integer_vector() && to_type->is_float_vector())) {
op = spv::Op::OpConvertSToF;
- } else if ((from_type->Is<ast::type::U32Type>() &&
- to_type->Is<ast::type::F32Type>()) ||
+ } else if ((from_type->Is<ast::type::U32>() &&
+ to_type->Is<ast::type::F32>()) ||
(from_type->is_unsigned_integer_vector() &&
to_type->is_float_vector())) {
op = spv::Op::OpConvertUToF;
- } else if ((from_type->Is<ast::type::F32Type>() &&
- to_type->Is<ast::type::I32Type>()) ||
+ } else if ((from_type->Is<ast::type::F32>() &&
+ to_type->Is<ast::type::I32>()) ||
(from_type->is_float_vector() &&
to_type->is_signed_integer_vector())) {
op = spv::Op::OpConvertFToS;
- } else if ((from_type->Is<ast::type::F32Type>() &&
- to_type->Is<ast::type::U32Type>()) ||
+ } else if ((from_type->Is<ast::type::F32>() &&
+ to_type->Is<ast::type::U32>()) ||
(from_type->is_float_vector() &&
to_type->is_unsigned_integer_vector())) {
op = spv::Op::OpConvertFToU;
- } else if ((from_type->Is<ast::type::BoolType>() &&
- to_type->Is<ast::type::BoolType>()) ||
- (from_type->Is<ast::type::U32Type>() &&
- to_type->Is<ast::type::U32Type>()) ||
- (from_type->Is<ast::type::I32Type>() &&
- to_type->Is<ast::type::I32Type>()) ||
- (from_type->Is<ast::type::F32Type>() &&
- to_type->Is<ast::type::F32Type>()) ||
- (from_type->Is<ast::type::VectorType>() &&
- (from_type == to_type))) {
+ } else if ((from_type->Is<ast::type::Bool>() &&
+ to_type->Is<ast::type::Bool>()) ||
+ (from_type->Is<ast::type::U32>() &&
+ to_type->Is<ast::type::U32>()) ||
+ (from_type->Is<ast::type::I32>() &&
+ to_type->Is<ast::type::I32>()) ||
+ (from_type->Is<ast::type::F32>() &&
+ to_type->Is<ast::type::F32>()) ||
+ (from_type->Is<ast::type::Vector>() && (from_type == to_type))) {
return val_id;
- } else if ((from_type->Is<ast::type::I32Type>() &&
- to_type->Is<ast::type::U32Type>()) ||
- (from_type->Is<ast::type::U32Type>() &&
- to_type->Is<ast::type::I32Type>()) ||
+ } else if ((from_type->Is<ast::type::I32>() &&
+ to_type->Is<ast::type::U32>()) ||
+ (from_type->Is<ast::type::U32>() &&
+ to_type->Is<ast::type::I32>()) ||
(from_type->is_signed_integer_vector() &&
to_type->is_unsigned_integer_vector()) ||
(from_type->is_unsigned_integer_vector() &&
@@ -1829,7 +1827,7 @@
error_ = "missing param for runtime array length";
return 0;
} else if (!call->params()[0]->Is<ast::MemberAccessorExpression>()) {
- if (call->params()[0]->result_type()->Is<ast::type::PointerType>()) {
+ if (call->params()[0]->result_type()->Is<ast::type::Pointer>()) {
error_ = "pointer accessors not supported yet";
} else {
error_ = "invalid accessor for runtime array length";
@@ -1844,14 +1842,14 @@
params.push_back(Operand::Int(struct_id));
auto* type = accessor->structure()->result_type()->UnwrapAll();
- if (!type->Is<ast::type::StructType>()) {
+ if (!type->Is<ast::type::Struct>()) {
error_ =
"invalid type (" + type->type_name() + ") for runtime array length";
return 0;
}
// Runtime array must be the last member in the structure
- params.push_back(Operand::Int(uint32_t(
- type->As<ast::type::StructType>()->impl()->members().size() - 1)));
+ params.push_back(Operand::Int(
+ uint32_t(type->As<ast::type::Struct>()->impl()->members().size() - 1)));
push_function_inst(spv::Op::OpArrayLength, params);
return result_id;
@@ -1933,10 +1931,8 @@
ast::CallExpression* call,
spirv::Operand result_type,
spirv::Operand result_id) {
- auto* texture_type = call->params()[0]
- ->result_type()
- ->UnwrapAll()
- ->As<ast::type::TextureType>();
+ auto* texture_type =
+ call->params()[0]->result_type()->UnwrapAll()->As<ast::type::Texture>();
auto* sig = static_cast<const ast::intrinsic::TextureSignature*>(
ident->intrinsic_signature());
@@ -1971,16 +1967,15 @@
spirv_operands.reserve(4); // Enough to fit most parameter lists
if (ident->intrinsic() == ast::Intrinsic::kTextureLoad) {
- op = texture_type->Is<ast::type::StorageTextureType>()
- ? spv::Op::OpImageRead
- : spv::Op::OpImageFetch;
+ op = texture_type->Is<ast::type::StorageTexture>() ? spv::Op::OpImageRead
+ : spv::Op::OpImageFetch;
spirv_params.emplace_back(gen_param(pidx.texture));
spirv_params.emplace_back(gen_param(pidx.coords));
// TODO(dsinclair): Remove the LOD param from textureLoad on storage
// textures when https://github.com/gpuweb/gpuweb/pull/1032 gets merged.
if (pidx.level != kNotUsed) {
- if (texture_type->Is<ast::type::MultisampledTextureType>()) {
+ if (texture_type->Is<ast::type::MultisampledTexture>()) {
spirv_operand_mask |= SpvImageOperandsSampleMask;
} else {
spirv_operand_mask |= SpvImageOperandsLodMask;
@@ -2053,7 +2048,7 @@
spirv_params.emplace_back(gen_param(pidx.depth_ref));
spirv_operand_mask |= SpvImageOperandsLodMask;
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::FloatLiteral float_0(&f32, 0.0);
spirv_operands.emplace_back(
Operand::Int(GenerateLiteralIfNeeded(nullptr, &float_0)));
@@ -2418,8 +2413,8 @@
}
// The alias is a wrapper around the subtype, so emit the subtype
- if (type->Is<ast::type::AliasType>()) {
- return GenerateTypeIfNeeded(type->As<ast::type::AliasType>()->type());
+ if (type->Is<ast::type::Alias>()) {
+ return GenerateTypeIfNeeded(type->As<ast::type::Alias>()->type());
}
auto val = type_name_to_id_.find(type->type_name());
@@ -2430,53 +2425,53 @@
auto result = result_op();
auto id = result.to_i();
- if (type->Is<ast::type::AccessControlType>()) {
- auto* ac = type->As<ast::type::AccessControlType>();
+ if (type->Is<ast::type::AccessControl>()) {
+ auto* ac = type->As<ast::type::AccessControl>();
auto* subtype = ac->type()->UnwrapIfNeeded();
- if (!subtype->Is<ast::type::StructType>()) {
+ if (!subtype->Is<ast::type::Struct>()) {
error_ = "Access control attached to non-struct type.";
return 0;
}
- if (!GenerateStructType(subtype->As<ast::type::StructType>(),
+ if (!GenerateStructType(subtype->As<ast::type::Struct>(),
ac->access_control(), result)) {
return 0;
}
- } else if (type->Is<ast::type::ArrayType>()) {
- if (!GenerateArrayType(type->As<ast::type::ArrayType>(), result)) {
+ } else if (type->Is<ast::type::Array>()) {
+ if (!GenerateArray(type->As<ast::type::Array>(), result)) {
return 0;
}
- } else if (type->Is<ast::type::BoolType>()) {
+ } else if (type->Is<ast::type::Bool>()) {
push_type(spv::Op::OpTypeBool, {result});
- } else if (type->Is<ast::type::F32Type>()) {
+ } else if (type->Is<ast::type::F32>()) {
push_type(spv::Op::OpTypeFloat, {result, Operand::Int(32)});
- } else if (type->Is<ast::type::I32Type>()) {
+ } else if (type->Is<ast::type::I32>()) {
push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(1)});
- } else if (type->Is<ast::type::MatrixType>()) {
- if (!GenerateMatrixType(type->As<ast::type::MatrixType>(), result)) {
+ } else if (type->Is<ast::type::Matrix>()) {
+ if (!GenerateMatrixType(type->As<ast::type::Matrix>(), result)) {
return 0;
}
- } else if (type->Is<ast::type::PointerType>()) {
- if (!GeneratePointerType(type->As<ast::type::PointerType>(), result)) {
+ } else if (type->Is<ast::type::Pointer>()) {
+ if (!GeneratePointerType(type->As<ast::type::Pointer>(), result)) {
return 0;
}
- } else if (type->Is<ast::type::StructType>()) {
- if (!GenerateStructType(type->As<ast::type::StructType>(),
+ } else if (type->Is<ast::type::Struct>()) {
+ if (!GenerateStructType(type->As<ast::type::Struct>(),
ast::AccessControl::kReadWrite, result)) {
return 0;
}
- } else if (type->Is<ast::type::U32Type>()) {
+ } else if (type->Is<ast::type::U32>()) {
push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(0)});
- } else if (type->Is<ast::type::VectorType>()) {
- if (!GenerateVectorType(type->As<ast::type::VectorType>(), result)) {
+ } else if (type->Is<ast::type::Vector>()) {
+ if (!GenerateVectorType(type->As<ast::type::Vector>(), result)) {
return 0;
}
- } else if (type->Is<ast::type::VoidType>()) {
+ } else if (type->Is<ast::type::Void>()) {
push_type(spv::Op::OpTypeVoid, {result});
- } else if (type->Is<ast::type::TextureType>()) {
- if (!GenerateTextureType(type->As<ast::type::TextureType>(), result)) {
+ } else if (type->Is<ast::type::Texture>()) {
+ if (!GenerateTextureType(type->As<ast::type::Texture>(), result)) {
return 0;
}
- } else if (type->Is<ast::type::SamplerType>()) {
+ } else if (type->Is<ast::type::Sampler>()) {
push_type(spv::Op::OpTypeSampler, {result});
// Register both of the sampler type names. In SPIR-V they're the same
@@ -2494,7 +2489,7 @@
}
// TODO(tommek): Cover multisampled textures here when they're included in AST
-bool Builder::GenerateTextureType(ast::type::TextureType* texture,
+bool Builder::GenerateTextureType(ast::type::Texture* texture,
const Operand& result) {
uint32_t array_literal = 0u;
const auto dim = texture->dim();
@@ -2508,10 +2503,10 @@
if (dim == ast::type::TextureDimension::k1dArray ||
dim == ast::type::TextureDimension::k1d) {
dim_literal = SpvDim1D;
- if (texture->Is<ast::type::SampledTextureType>()) {
+ if (texture->Is<ast::type::SampledTexture>()) {
push_capability(SpvCapabilitySampled1D);
} else {
- assert(texture->Is<ast::type::StorageTextureType>());
+ assert(texture->Is<ast::type::StorageTexture>());
push_capability(SpvCapabilityImage1D);
}
}
@@ -2524,47 +2519,47 @@
}
uint32_t ms_literal = 0u;
- if (texture->Is<ast::type::MultisampledTextureType>()) {
+ if (texture->Is<ast::type::MultisampledTexture>()) {
ms_literal = 1u;
}
uint32_t depth_literal = 0u;
- if (texture->Is<ast::type::DepthTextureType>()) {
+ if (texture->Is<ast::type::DepthTexture>()) {
depth_literal = 1u;
}
uint32_t sampled_literal = 2u;
- if (texture->Is<ast::type::MultisampledTextureType>() ||
- texture->Is<ast::type::SampledTextureType>() ||
- texture->Is<ast::type::DepthTextureType>()) {
+ if (texture->Is<ast::type::MultisampledTexture>() ||
+ texture->Is<ast::type::SampledTexture>() ||
+ texture->Is<ast::type::DepthTexture>()) {
sampled_literal = 1u;
}
if (dim == ast::type::TextureDimension::kCubeArray) {
- if (texture->Is<ast::type::SampledTextureType>() ||
- texture->Is<ast::type::DepthTextureType>()) {
+ if (texture->Is<ast::type::SampledTexture>() ||
+ texture->Is<ast::type::DepthTexture>()) {
push_capability(SpvCapabilitySampledCubeArray);
}
}
uint32_t type_id = 0u;
- if (texture->Is<ast::type::DepthTextureType>()) {
- ast::type::F32Type f32;
+ if (texture->Is<ast::type::DepthTexture>()) {
+ ast::type::F32 f32;
type_id = GenerateTypeIfNeeded(&f32);
- } else if (texture->Is<ast::type::SampledTextureType>()) {
+ } else if (texture->Is<ast::type::SampledTexture>()) {
+ type_id =
+ GenerateTypeIfNeeded(texture->As<ast::type::SampledTexture>()->type());
+ } else if (texture->Is<ast::type::MultisampledTexture>()) {
type_id = GenerateTypeIfNeeded(
- texture->As<ast::type::SampledTextureType>()->type());
- } else if (texture->Is<ast::type::MultisampledTextureType>()) {
- type_id = GenerateTypeIfNeeded(
- texture->As<ast::type::MultisampledTextureType>()->type());
- } else if (texture->Is<ast::type::StorageTextureType>()) {
- if (texture->As<ast::type::StorageTextureType>()->access() ==
+ texture->As<ast::type::MultisampledTexture>()->type());
+ } else if (texture->Is<ast::type::StorageTexture>()) {
+ if (texture->As<ast::type::StorageTexture>()->access() ==
ast::AccessControl::kWriteOnly) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
type_id = GenerateTypeIfNeeded(&void_type);
} else {
type_id = GenerateTypeIfNeeded(
- texture->As<ast::type::StorageTextureType>()->type());
+ texture->As<ast::type::StorageTexture>()->type());
}
}
if (type_id == 0u) {
@@ -2572,9 +2567,9 @@
}
uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown;
- if (texture->Is<ast::type::StorageTextureType>()) {
+ if (texture->Is<ast::type::StorageTexture>()) {
format_literal = convert_image_format_to_spv(
- texture->As<ast::type::StorageTextureType>()->image_format());
+ texture->As<ast::type::StorageTexture>()->image_format());
}
push_type(spv::Op::OpTypeImage,
@@ -2586,8 +2581,7 @@
return true;
}
-bool Builder::GenerateArrayType(ast::type::ArrayType* ary,
- const Operand& result) {
+bool Builder::GenerateArray(ast::type::Array* ary, const Operand& result) {
auto elem_type = GenerateTypeIfNeeded(ary->type());
if (elem_type == 0) {
return false;
@@ -2614,9 +2608,9 @@
return true;
}
-bool Builder::GenerateMatrixType(ast::type::MatrixType* mat,
+bool Builder::GenerateMatrixType(ast::type::Matrix* mat,
const Operand& result) {
- ast::type::VectorType col_type(mat->type(), mat->rows());
+ ast::type::Vector col_type(mat->type(), mat->rows());
auto col_type_id = GenerateTypeIfNeeded(&col_type);
if (has_error()) {
return false;
@@ -2627,7 +2621,7 @@
return true;
}
-bool Builder::GeneratePointerType(ast::type::PointerType* ptr,
+bool Builder::GeneratePointerType(ast::type::Pointer* ptr,
const Operand& result) {
auto pointee_id = GenerateTypeIfNeeded(ptr->type());
if (pointee_id == 0) {
@@ -2646,7 +2640,7 @@
return true;
}
-bool Builder::GenerateStructType(ast::type::StructType* struct_type,
+bool Builder::GenerateStructType(ast::type::Struct* struct_type,
ast::AccessControl access_control,
const Operand& result) {
auto struct_id = result.to_i();
@@ -2721,7 +2715,7 @@
push_annot(spv::Op::OpMemberDecorate,
{Operand::Int(struct_id), Operand::Int(idx),
Operand::Int(SpvDecorationColMajor)});
- if (!matrix_type->type()->Is<ast::type::F32Type>()) {
+ if (!matrix_type->type()->Is<ast::type::F32>()) {
error_ = "matrix scalar element type must be f32";
return 0;
}
@@ -2737,7 +2731,7 @@
return GenerateTypeIfNeeded(member->type());
}
-bool Builder::GenerateVectorType(ast::type::VectorType* vec,
+bool Builder::GenerateVectorType(ast::type::Vector* vec,
const Operand& result) {
auto type_id = GenerateTypeIfNeeded(vec->type());
if (has_error()) {
diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h
index d78a9a2..0b32036 100644
--- a/src/writer/spirv/builder.h
+++ b/src/writer/spirv/builder.h
@@ -426,29 +426,28 @@
/// @param texture the texture to generate
/// @param result the result operand
/// @returns true if the texture was successfully generated
- bool GenerateTextureType(ast::type::TextureType* texture,
- const Operand& result);
+ bool GenerateTextureType(ast::type::Texture* texture, const Operand& result);
/// Generates an array type declaration
/// @param ary the array to generate
/// @param result the result operand
/// @returns true if the array was successfully generated
- bool GenerateArrayType(ast::type::ArrayType* ary, const Operand& result);
+ bool GenerateArray(ast::type::Array* ary, const Operand& result);
/// Generates a matrix type declaration
/// @param mat the matrix to generate
/// @param result the result operand
/// @returns true if the matrix was successfully generated
- bool GenerateMatrixType(ast::type::MatrixType* mat, const Operand& result);
+ bool GenerateMatrixType(ast::type::Matrix* mat, const Operand& result);
/// Generates a pointer type declaration
/// @param ptr the pointer type to generate
/// @param result the result operand
/// @returns true if the pointer was successfully generated
- bool GeneratePointerType(ast::type::PointerType* ptr, const Operand& result);
+ bool GeneratePointerType(ast::type::Pointer* ptr, const Operand& result);
/// Generates a vector type declaration
/// @param struct_type the vector to generate
/// @param access_control the access controls to assign to the struct
/// @param result the result operand
/// @returns true if the vector was successfully generated
- bool GenerateStructType(ast::type::StructType* struct_type,
+ bool GenerateStructType(ast::type::Struct* struct_type,
ast::AccessControl access_control,
const Operand& result);
/// Generates a struct member
@@ -467,7 +466,7 @@
/// @param vec the vector to generate
/// @param result the result operand
/// @returns true if the vector was successfully generated
- bool GenerateVectorType(ast::type::VectorType* vec, const Operand& result);
+ bool GenerateVectorType(ast::type::Vector* vec, const Operand& result);
/// Converts AST image format to SPIR-V and pushes an appropriate capability.
/// @param format AST image format type
diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc
index 15c5987..2f22a1d 100644
--- a/src/writer/spirv/builder_accessor_expression_test.cc
+++ b/src/writer/spirv/builder_accessor_expression_test.cc
@@ -47,9 +47,9 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, ArrayAccessor) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// vec3<f32> ary;
// ary[1] -> ptr<f32>
@@ -87,9 +87,9 @@
}
TEST_F(BuilderTest, Accessor_Array_LoadIndex) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// ary : vec3<f32>;
// idx : i32;
@@ -133,9 +133,9 @@
}
TEST_F(BuilderTest, ArrayAccessor_Dynamic) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// vec3<f32> ary;
// ary[1 + 2] -> ptr<f32>
@@ -179,10 +179,10 @@
}
TEST_F(BuilderTest, ArrayAccessor_MultiLevel) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::ArrayType ary4(&vec3, 4);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Array ary4(&vec3, 4);
// ary = array<vec3<f32>, 4>
// ary[3][2];
@@ -226,10 +226,10 @@
}
TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::ArrayType ary4(&vec3, 4);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Array ary4(&vec3, 4);
// var a : array<vec3<f32>, 4>;
// a[2].xy;
@@ -273,7 +273,7 @@
}
TEST_F(BuilderTest, MemberAccessor) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// my_struct {
// a : f32
@@ -288,7 +288,7 @@
members.push_back(create<ast::StructMember>("b", &f32, decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
@@ -320,7 +320,7 @@
}
TEST_F(BuilderTest, MemberAccessor_Nested) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// inner_struct {
// a : f32
@@ -336,14 +336,13 @@
inner_members.push_back(create<ast::StructMember>("a", &f32, decos));
inner_members.push_back(create<ast::StructMember>("b", &f32, decos));
- ast::type::StructType inner_struct("Inner",
- create<ast::Struct>(inner_members));
+ ast::type::Struct inner_struct("Inner", create<ast::Struct>(inner_members));
ast::StructMemberList outer_members;
outer_members.push_back(
create<ast::StructMember>("inner", &inner_struct, decos));
- ast::type::StructType s_type("my_struct", create<ast::Struct>(outer_members));
+ ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members));
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
@@ -379,7 +378,7 @@
}
TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// type Inner = struct {
// a : f32
@@ -396,15 +395,14 @@
inner_members.push_back(create<ast::StructMember>("a", &f32, decos));
inner_members.push_back(create<ast::StructMember>("b", &f32, decos));
- ast::type::StructType inner_struct("Inner",
- create<ast::Struct>(inner_members));
+ ast::type::Struct inner_struct("Inner", create<ast::Struct>(inner_members));
- ast::type::AliasType alias("Inner", &inner_struct);
+ ast::type::Alias alias("Inner", &inner_struct);
ast::StructMemberList outer_members;
outer_members.push_back(create<ast::StructMember>("inner", &alias, decos));
- ast::type::StructType s_type("Outer", create<ast::Struct>(outer_members));
+ ast::type::Struct s_type("Outer", create<ast::Struct>(outer_members));
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
@@ -440,7 +438,7 @@
}
TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// inner_struct {
// a : f32
@@ -457,14 +455,13 @@
inner_members.push_back(create<ast::StructMember>("a", &f32, decos));
inner_members.push_back(create<ast::StructMember>("b", &f32, decos));
- ast::type::StructType inner_struct("Inner",
- create<ast::Struct>(inner_members));
+ ast::type::Struct inner_struct("Inner", create<ast::Struct>(inner_members));
ast::StructMemberList outer_members;
outer_members.push_back(
create<ast::StructMember>("inner", &inner_struct, decos));
- ast::type::StructType s_type("my_struct", create<ast::Struct>(outer_members));
+ ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members));
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
@@ -507,7 +504,7 @@
}
TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// inner_struct {
// a : f32
@@ -524,14 +521,13 @@
inner_members.push_back(create<ast::StructMember>("a", &f32, decos));
inner_members.push_back(create<ast::StructMember>("b", &f32, decos));
- ast::type::StructType inner_struct("Inner",
- create<ast::Struct>(inner_members));
+ ast::type::Struct inner_struct("Inner", create<ast::Struct>(inner_members));
ast::StructMemberList outer_members;
outer_members.push_back(
create<ast::StructMember>("inner", &inner_struct, decos));
- ast::type::StructType s_type("my_struct", create<ast::Struct>(outer_members));
+ ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members));
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
ast::Variable store("store", ast::StorageClass::kFunction, &f32);
@@ -578,8 +574,8 @@
}
TEST_F(BuilderTest, MemberAccessor_Swizzle_Single) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// ident.y
@@ -613,8 +609,8 @@
}
TEST_F(BuilderTest, MemberAccessor_Swizzle_MultipleNames) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// ident.yx
@@ -647,8 +643,8 @@
}
TEST_F(BuilderTest, MemberAccessor_Swizzle_of_Swizzle) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// ident.yxz.xz
@@ -685,8 +681,8 @@
}
TEST_F(BuilderTest, MemberAccessor_Member_of_Swizzle) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// ident.yxz.x
@@ -722,9 +718,9 @@
}
TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// index.yxz[1]
@@ -763,9 +759,9 @@
}
TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// type C = struct {
// baz : vec3<f32>
@@ -783,19 +779,19 @@
auto* s = create<ast::Struct>(
ast::StructMemberList{create<ast::StructMember>("baz", &vec3, decos)});
- ast::type::StructType c_type("C", s);
+ ast::type::Struct c_type("C", s);
s = create<ast::Struct>(
ast::StructMemberList{create<ast::StructMember>("bar", &c_type, decos)});
- ast::type::StructType b_type("B", s);
+ ast::type::Struct b_type("B", s);
- ast::type::ArrayType b_ary_type(&b_type, 3);
+ ast::type::Array b_ary_type(&b_type, 3);
s = create<ast::Struct>(ast::StructMemberList{
create<ast::StructMember>("foo", &b_ary_type, decos)});
- ast::type::StructType a_type("A", s);
+ ast::type::Struct a_type("A", s);
- ast::type::ArrayType a_ary_type(&a_type, 2);
+ ast::type::Array a_ary_type(&a_type, 2);
ast::Variable var("index", ast::StorageClass::kFunction, &a_ary_type);
@@ -859,10 +855,10 @@
// vec2<f32>(0.5, -0.5));
// pos[1]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::VectorType vec(&f32, 2);
- ast::type::ArrayType arr(&vec, 3);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Vector vec(&f32, 2);
+ ast::type::Array arr(&vec, 3);
ast::ExpressionList ary_params;
ary_params.push_back(create<ast::TypeConstructorExpression>(
@@ -935,9 +931,9 @@
// const pos : vec2<f32> = vec2<f32>(0.0, 0.5);
// pos[1]
- ast::type::F32Type f32;
- ast::type::U32Type u32;
- ast::type::VectorType vec(&f32, 2);
+ ast::type::F32 f32;
+ ast::type::U32 u32;
+ ast::type::Vector vec(&f32, 2);
ast::ExpressionList vec_params;
vec_params.push_back(create<ast::ScalarConstructorExpression>(
diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc
index b2a574e..7698c5f 100644
--- a/src/writer/spirv/builder_assign_test.cc
+++ b/src/writer/spirv/builder_assign_test.cc
@@ -43,7 +43,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Assign_Var) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
@@ -76,8 +76,8 @@
}
TEST_F(BuilderTest, Assign_Var_ZeroConstructor) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::Variable v("var", ast::StorageClass::kOutput, &vec);
@@ -110,9 +110,9 @@
}
TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::VectorType vec2(&f32, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Vector vec2(&f32, 2);
auto* first = create<ast::TypeConstructorExpression>(
&vec2, ast::ExpressionList{
@@ -164,8 +164,8 @@
}
TEST_F(BuilderTest, Assign_Var_Complex_Constructor) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -207,7 +207,7 @@
}
TEST_F(BuilderTest, Assign_StructMember) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// my_struct {
// a : f32
@@ -222,7 +222,7 @@
members.push_back(create<ast::StructMember>("b", &f32, decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
ast::Variable v("ident", ast::StorageClass::kFunction, &s_type);
@@ -263,8 +263,8 @@
}
TEST_F(BuilderTest, Assign_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
ast::Variable v("var", ast::StorageClass::kOutput, &vec3);
@@ -308,8 +308,8 @@
}
TEST_F(BuilderTest, Assign_Vector_MemberByName) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// var.y = 1
@@ -352,9 +352,9 @@
}
TEST_F(BuilderTest, Assign_Vector_MemberByIndex) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
// var[1] = 1
diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc
index 3a761c9..bc7463a 100644
--- a/src/writer/spirv/builder_binary_expression_test.cc
+++ b/src/writer/spirv/builder_binary_expression_test.cc
@@ -55,7 +55,7 @@
TEST_P(BinaryArithSignedIntegerTest, Scalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 3));
@@ -79,8 +79,8 @@
TEST_P(BinaryArithSignedIntegerTest, Vector) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec3(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec3(&i32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
&vec3, ast::ExpressionList{
@@ -120,7 +120,7 @@
TEST_P(BinaryArithSignedIntegerTest, Scalar_Loads) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::Variable var("param", ast::StorageClass::kFunction, &i32);
@@ -170,7 +170,7 @@
TEST_P(BinaryArithUnsignedIntegerTest, Scalar) {
auto param = GetParam();
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(&u32, 3));
@@ -194,8 +194,8 @@
TEST_P(BinaryArithUnsignedIntegerTest, Vector) {
auto param = GetParam();
- ast::type::U32Type u32;
- ast::type::VectorType vec3(&u32, 3);
+ ast::type::U32 u32;
+ ast::type::Vector vec3(&u32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
&vec3, ast::ExpressionList{
@@ -251,7 +251,7 @@
TEST_P(BinaryArithFloatTest, Scalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 3.2f));
@@ -275,8 +275,8 @@
TEST_P(BinaryArithFloatTest, Vector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
&vec3, ast::ExpressionList{
@@ -326,7 +326,7 @@
TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) {
auto param = GetParam();
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(&u32, 3));
@@ -352,8 +352,8 @@
TEST_P(BinaryCompareUnsignedIntegerTest, Vector) {
auto param = GetParam();
- ast::type::U32Type u32;
- ast::type::VectorType vec3(&u32, 3);
+ ast::type::U32 u32;
+ ast::type::Vector vec3(&u32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
&vec3, ast::ExpressionList{
@@ -407,7 +407,7 @@
TEST_P(BinaryCompareSignedIntegerTest, Scalar) {
auto param = GetParam();
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 3));
@@ -433,8 +433,8 @@
TEST_P(BinaryCompareSignedIntegerTest, Vector) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::VectorType vec3(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec3(&i32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
&vec3, ast::ExpressionList{
@@ -488,7 +488,7 @@
TEST_P(BinaryCompareFloatTest, Scalar) {
auto param = GetParam();
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 3.2f));
@@ -514,8 +514,8 @@
TEST_P(BinaryCompareFloatTest, Vector) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
&vec3, ast::ExpressionList{
@@ -566,8 +566,8 @@
BinaryData{ast::BinaryOp::kNotEqual, "OpFOrdNotEqual"}));
TEST_F(BuilderTest, Binary_Multiply_VectorScalar) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
&vec3, ast::ExpressionList{
@@ -599,8 +599,8 @@
}
TEST_F(BuilderTest, Binary_Multiply_ScalarVector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.f));
@@ -631,8 +631,8 @@
}
TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
auto* lhs = create<ast::IdentifierExpression>("mat");
@@ -663,8 +663,8 @@
}
TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
auto* lhs = create<ast::ScalarConstructorExpression>(
@@ -695,9 +695,9 @@
}
TEST_F(BuilderTest, Binary_Multiply_MatrixVector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
auto* lhs = create<ast::IdentifierExpression>("mat");
@@ -736,9 +736,9 @@
}
TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
@@ -778,9 +778,9 @@
}
TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::MatrixType mat3(&f32, 3, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Matrix mat3(&f32, 3, 3);
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
auto* lhs = create<ast::IdentifierExpression>("mat");
@@ -810,7 +810,7 @@
}
TEST_F(BuilderTest, Binary_LogicalAnd) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lhs =
create<ast::BinaryExpression>(ast::BinaryOp::kEqual,
@@ -855,7 +855,7 @@
}
TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* a_var =
create<ast::Variable>("a", ast::StorageClass::kFunction, &bool_type);
@@ -904,7 +904,7 @@
}
TEST_F(BuilderTest, Binary_logicalOr_Nested_LogicalAnd) {
- ast::type::BoolType bool_ty;
+ ast::type::Bool bool_ty;
// Test an expression like
// a || (b && c)
@@ -950,7 +950,7 @@
}
TEST_F(BuilderTest, Binary_logicalAnd_Nested_LogicalOr) {
- ast::type::BoolType bool_ty;
+ ast::type::Bool bool_ty;
// Test an expression like
// a && (b || c)
@@ -996,7 +996,7 @@
}
TEST_F(BuilderTest, Binary_LogicalOr) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lhs =
create<ast::BinaryExpression>(ast::BinaryOp::kEqual,
@@ -1041,7 +1041,7 @@
}
TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* a_var =
create<ast::Variable>("a", ast::StorageClass::kFunction, &bool_type);
diff --git a/src/writer/spirv/builder_bitcast_expression_test.cc b/src/writer/spirv/builder_bitcast_expression_test.cc
index 92996ca..9db26dc 100644
--- a/src/writer/spirv/builder_bitcast_expression_test.cc
+++ b/src/writer/spirv/builder_bitcast_expression_test.cc
@@ -33,8 +33,8 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Bitcast) {
- ast::type::U32Type u32;
- ast::type::F32Type f32;
+ ast::type::U32 u32;
+ ast::type::F32 f32;
ast::BitcastExpression bitcast(&u32,
create<ast::ScalarConstructorExpression>(
@@ -55,7 +55,7 @@
}
TEST_F(BuilderTest, Bitcast_DuplicateType) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::BitcastExpression bitcast(&f32,
create<ast::ScalarConstructorExpression>(
diff --git a/src/writer/spirv/builder_block_test.cc b/src/writer/spirv/builder_block_test.cc
index 362536a..bcb5a98 100644
--- a/src/writer/spirv/builder_block_test.cc
+++ b/src/writer/spirv/builder_block_test.cc
@@ -36,7 +36,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Block) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// Note, this test uses shadow variables which aren't allowed in WGSL but
// serves to prove the block code is pushing new scopes as needed.
diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc
index 1fc8aa4..67447cf 100644
--- a/src/writer/spirv/builder_call_test.cc
+++ b/src/writer/spirv/builder_call_test.cc
@@ -40,8 +40,8 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Expression_Call) {
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
+ ast::type::F32 f32;
+ ast::type::Void void_type;
ast::VariableList func_params;
func_params.push_back(
@@ -101,8 +101,8 @@
}
TEST_F(BuilderTest, Statement_Call) {
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
+ ast::type::F32 f32;
+ ast::type::Void void_type;
ast::VariableList func_params;
func_params.push_back(
diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc
index 4ac92c0..bc06bd5 100644
--- a/src/writer/spirv/builder_constructor_expression_test.cc
+++ b/src/writer/spirv/builder_constructor_expression_test.cc
@@ -103,7 +103,7 @@
// type Int = i32
// cast<Int>(2.3f)
- ast::type::AliasType alias("Int", ty.i32);
+ ast::type::Alias alias("Int", ty.i32);
ast::TypeConstructorExpression cast(&alias, ExprList(2.3f));
@@ -947,7 +947,7 @@
create<ast::StructMember>("a", ty.f32, decos),
create<ast::StructMember>("b", ty.vec3<f32>(), decos),
});
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto* t = Construct(&s_type, 2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
@@ -1083,7 +1083,7 @@
auto* s = create<ast::Struct>(ast::StructMemberList{
create<ast::StructMember>("a", ty.f32, decos),
});
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto* t = Construct(&s_type);
@@ -1496,7 +1496,7 @@
create<ast::StructMember>("a", ty.f32, decos),
create<ast::StructMember>("b", ty.vec3<f32>(), decos),
});
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto* t = Construct(&s_type, 2.f, vec3<f32>(2.f, 2.f, 2.f));
@@ -1514,7 +1514,7 @@
create<ast::StructMember>("b", ty.vec3<f32>(), decos),
});
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto* t = Construct(&s_type, 2.f, "a", 2.f);
diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc
index 161966c..e7ad94a 100644
--- a/src/writer/spirv/builder_function_decoration_test.cc
+++ b/src/writer/spirv/builder_function_decoration_test.cc
@@ -40,7 +40,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, FunctionDecoration_Stage) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("main", {}, &void_type, create<ast::BlockStatement>());
func.add_decoration(
@@ -64,7 +64,7 @@
TEST_P(FunctionDecoration_StageTest, Emit) {
auto params = GetParam();
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("main", {}, &void_type, create<ast::BlockStatement>());
func.add_decoration(create<ast::StageDecoration>(params.stage, Source{}));
@@ -89,8 +89,8 @@
SpvExecutionModelGLCompute}));
TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) {
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
+ ast::type::F32 f32;
+ ast::type::Void void_type;
ast::Function func("main", {}, &void_type, create<ast::BlockStatement>());
func.add_decoration(
@@ -132,8 +132,8 @@
}
TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) {
- ast::type::F32Type f32;
- ast::type::VoidType void_type;
+ ast::type::F32 f32;
+ ast::type::Void void_type;
ast::Function func("main", {}, &void_type, create<ast::BlockStatement>());
func.add_decoration(
@@ -195,7 +195,7 @@
}
TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("main", {}, &void_type, create<ast::BlockStatement>());
func.add_decoration(
@@ -208,7 +208,7 @@
}
TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize_Default) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("main", {}, &void_type, create<ast::BlockStatement>());
func.add_decoration(
@@ -221,7 +221,7 @@
}
TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("main", {}, &void_type, create<ast::BlockStatement>());
func.add_decoration(create<ast::WorkgroupDecoration>(2u, 4u, 6u, Source{}));
@@ -235,7 +235,7 @@
}
TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_MultipleFragment) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func1("main1", {}, &void_type, create<ast::BlockStatement>());
func1.add_decoration(
diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc
index 20cbf8a..9e195c2 100644
--- a/src/writer/spirv/builder_function_test.cc
+++ b/src/writer/spirv/builder_function_test.cc
@@ -48,7 +48,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Function_Empty) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("a_func", {}, &void_type, create<ast::BlockStatement>());
ASSERT_TRUE(b.GenerateFunction(&func));
@@ -63,7 +63,7 @@
}
TEST_F(BuilderTest, Function_Terminator_Return) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -82,8 +82,8 @@
}
TEST_F(BuilderTest, Function_Terminator_ReturnValue) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
auto* var_a = create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
td.RegisterVariableForTesting(var_a);
@@ -114,7 +114,7 @@
}
TEST_F(BuilderTest, Function_Terminator_Discard) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::DiscardStatement>());
@@ -133,9 +133,9 @@
}
TEST_F(BuilderTest, Function_WithParams) {
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::VariableList params;
auto* var_a = create<ast::Variable>("a", ast::StorageClass::kFunction, &f32);
@@ -171,7 +171,7 @@
}
TEST_F(BuilderTest, Function_WithBody) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -190,7 +190,7 @@
}
TEST_F(BuilderTest, FunctionType) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("a_func", {}, &void_type, create<ast::BlockStatement>());
ASSERT_TRUE(b.GenerateFunction(&func));
@@ -200,7 +200,7 @@
}
TEST_F(BuilderTest, FunctionType_DeDuplicate) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func1("a_func", {}, &void_type, create<ast::BlockStatement>());
ast::Function func2("b_func", {}, &void_type, create<ast::BlockStatement>());
@@ -228,8 +228,8 @@
// return;
// }
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -241,8 +241,8 @@
auto* str = create<ast::Struct>(s_decos, members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
auto* data_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &ac));
diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc
index dbbdb79..b28e73b 100644
--- a/src/writer/spirv/builder_function_variable_test.cc
+++ b/src/writer/spirv/builder_function_variable_test.cc
@@ -47,7 +47,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, FunctionVar_NoStorageClass) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("var", ast::StorageClass::kNone, &f32);
b.push_function(Function{});
@@ -66,8 +66,8 @@
}
TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -108,8 +108,8 @@
}
TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 2);
auto* rel =
create<ast::BinaryExpression>(ast::BinaryOp::kAdd,
@@ -158,7 +158,7 @@
// var v : f32 = 1.0;
// var v2 : f32 = v; // Should generate the load and store automatically.
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* init = create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.0f));
@@ -203,7 +203,7 @@
// var v : f32 = 1.0;
// const v2 : f32 = v; // Should generate the load
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* init = create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 1.0f));
@@ -243,8 +243,8 @@
}
TEST_F(BuilderTest, FunctionVar_Const) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc
index 9cfbd0f..0b4782c 100644
--- a/src/writer/spirv/builder_global_variable_test.cc
+++ b/src/writer/spirv/builder_global_variable_test.cc
@@ -52,7 +52,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, GlobalVar_NoStorageClass) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("var", ast::StorageClass::kNone, &f32);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
@@ -66,7 +66,7 @@
}
TEST_F(BuilderTest, GlobalVar_WithStorageClass) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
@@ -80,7 +80,7 @@
}
TEST_F(BuilderTest, GlobalVar_WithStorageClass_Input) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("var", ast::StorageClass::kInput, &f32);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
@@ -93,8 +93,8 @@
}
TEST_F(BuilderTest, GlobalVar_WithConstructor) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -128,8 +128,8 @@
}
TEST_F(BuilderTest, GlobalVar_Const) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -162,8 +162,8 @@
}
TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -194,9 +194,9 @@
}
TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
- ast::type::F32Type f32;
- ast::type::VectorType vec3(&f32, 3);
- ast::type::VectorType vec2(&f32, 2);
+ ast::type::F32 f32;
+ ast::type::Vector vec3(&f32, 3);
+ ast::type::Vector vec2(&f32, 2);
auto* first = create<ast::TypeConstructorExpression>(
&vec2, ast::ExpressionList{
@@ -240,7 +240,7 @@
}
TEST_F(BuilderTest, GlobalVar_WithLocation) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* v = create<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
ast::VariableDecorationList decos;
decos.push_back(create<ast::LocationDecoration>(5, Source{}));
@@ -261,7 +261,7 @@
}
TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* v = create<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
ast::VariableDecorationList decos;
decos.push_back(create<ast::BindingDecoration>(2, Source{}));
@@ -284,7 +284,7 @@
}
TEST_F(BuilderTest, GlobalVar_WithBuiltin) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* v = create<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
ast::VariableDecorationList decos;
decos.push_back(
@@ -306,7 +306,7 @@
}
TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(1200, Source{}));
@@ -330,7 +330,7 @@
}
TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(1200, Source{}));
@@ -352,7 +352,7 @@
}
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(0, Source{}));
@@ -376,7 +376,7 @@
}
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(0, Source{}));
@@ -398,7 +398,7 @@
}
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(0, Source{}));
@@ -420,7 +420,7 @@
}
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ast::VariableDecorationList decos;
decos.push_back(create<ast::ConstantIdDecoration>(0, Source{}));
@@ -481,15 +481,15 @@
// };
// var b : [[access(read)]] A
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
members.push_back(create<ast::StructMember>("a", &i32, decos));
members.push_back(create<ast::StructMember>("b", &i32, decos));
- ast::type::StructType A("A", create<ast::Struct>(members));
- ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &A};
+ ast::type::Struct A("A", create<ast::Struct>(members));
+ ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac);
@@ -517,15 +517,15 @@
// type B = A;
// var b : [[access(read)]] B
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
members.push_back(create<ast::StructMember>("a", &i32, decos));
- ast::type::StructType A("A", create<ast::Struct>(members));
- ast::type::AliasType B("B", &A);
- ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &B};
+ ast::type::Struct A("A", create<ast::Struct>(members));
+ ast::type::Alias B("B", &A);
+ ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B};
ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac);
@@ -551,15 +551,15 @@
// type B = [[access(read)]] A;
// var b : B
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
members.push_back(create<ast::StructMember>("a", &i32, decos));
- ast::type::StructType A("A", create<ast::Struct>(members));
- ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &A};
- ast::type::AliasType B("B", &ac);
+ ast::type::Struct A("A", create<ast::Struct>(members));
+ ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
+ ast::type::Alias B("B", &ac);
ast::Variable var("b", ast::StorageClass::kStorageBuffer, &B);
@@ -585,15 +585,15 @@
// var b : [[access(read)]] A
// var c : [[access(read_write)]] A
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
members.push_back(create<ast::StructMember>("a", &i32, decos));
- ast::type::StructType A("A", create<ast::Struct>(members));
- ast::type::AccessControlType read{ast::AccessControl::kReadOnly, &A};
- ast::type::AccessControlType rw{ast::AccessControl::kReadWrite, &A};
+ ast::type::Struct A("A", create<ast::Struct>(members));
+ ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A};
+ ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A};
ast::Variable var_b("b", ast::StorageClass::kStorageBuffer, &read);
ast::Variable var_c("c", ast::StorageClass::kStorageBuffer, &rw);
@@ -622,9 +622,9 @@
TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
// var<uniform_constant> a : texture_storage_ro_2d<r32uint>;
- ast::type::StorageTextureType type(ast::type::TextureDimension::k2d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR32Uint);
+ ast::type::StorageTexture type(ast::type::TextureDimension::k2d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR32Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error();
ast::Variable var_a("a", ast::StorageClass::kUniformConstant, &type);
@@ -642,9 +642,9 @@
TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
// var<uniform_constant> a : texture_storage_wo_2d<r32uint>;
- ast::type::StorageTextureType type(ast::type::TextureDimension::k2d,
- ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kR32Uint);
+ ast::type::StorageTexture type(ast::type::TextureDimension::k2d,
+ ast::AccessControl::kWriteOnly,
+ ast::type::ImageFormat::kR32Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error();
ast::Variable var_a("a", ast::StorageClass::kUniformConstant, &type);
diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc
index 40cd860..7be7907 100644
--- a/src/writer/spirv/builder_ident_expression_test.cc
+++ b/src/writer/spirv/builder_ident_expression_test.cc
@@ -39,8 +39,8 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -77,7 +77,7 @@
}
TEST_F(BuilderTest, IdentifierExpression_GlobalVar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
td.RegisterVariableForTesting(&v);
@@ -98,8 +98,8 @@
}
TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -134,7 +134,7 @@
}
TEST_F(BuilderTest, IdentifierExpression_FunctionVar) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("var", ast::StorageClass::kNone, &f32);
td.RegisterVariableForTesting(&v);
@@ -159,7 +159,7 @@
}
TEST_F(BuilderTest, IdentifierExpression_Load) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::Variable var("var", ast::StorageClass::kPrivate, &i32);
@@ -189,7 +189,7 @@
}
TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::Variable var("var", ast::StorageClass::kNone, &i32);
var.set_constructor(create<ast::ScalarConstructorExpression>(
diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc
index e2303ca..aa503be 100644
--- a/src/writer/spirv/builder_if_test.cc
+++ b/src/writer/spirv/builder_if_test.cc
@@ -42,7 +42,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, If_Empty) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
// if (true) {
// }
@@ -69,8 +69,8 @@
}
TEST_F(BuilderTest, If_WithStatements) {
- ast::type::BoolType bool_type;
- ast::type::I32Type i32;
+ ast::type::Bool bool_type;
+ ast::type::I32 i32;
// if (true) {
// v = 2;
@@ -114,8 +114,8 @@
}
TEST_F(BuilderTest, If_WithElse) {
- ast::type::BoolType bool_type;
- ast::type::I32Type i32;
+ ast::type::Bool bool_type;
+ ast::type::I32 i32;
// if (true) {
// v = 2;
@@ -176,8 +176,8 @@
}
TEST_F(BuilderTest, If_WithElseIf) {
- ast::type::BoolType bool_type;
- ast::type::I32Type i32;
+ ast::type::Bool bool_type;
+ ast::type::I32 i32;
// if (true) {
// v = 2;
@@ -246,8 +246,8 @@
}
TEST_F(BuilderTest, If_WithMultiple) {
- ast::type::BoolType bool_type;
- ast::type::I32Type i32;
+ ast::type::Bool bool_type;
+ ast::type::I32 i32;
// if (true) {
// v = 2;
@@ -349,7 +349,7 @@
}
TEST_F(BuilderTest, If_WithBreak) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
// loop {
// if (true) {
// break;
@@ -395,7 +395,7 @@
}
TEST_F(BuilderTest, If_WithElseBreak) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
// loop {
// if (true) {
// } else {
@@ -448,7 +448,7 @@
}
TEST_F(BuilderTest, If_WithContinue) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
// loop {
// if (true) {
// continue;
@@ -494,7 +494,7 @@
}
TEST_F(BuilderTest, If_WithElseContinue) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
// loop {
// if (true) {
// } else {
@@ -547,7 +547,7 @@
}
TEST_F(BuilderTest, If_WithReturn) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
// if (true) {
// return;
// }
@@ -577,7 +577,7 @@
}
TEST_F(BuilderTest, If_WithReturnValue) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
// if (true) {
// return false;
// }
@@ -614,7 +614,7 @@
// if (a) {
// }
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* var =
create<ast::Variable>("a", ast::StorageClass::kFunction, &bool_type);
td.RegisterVariableForTesting(var);
diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc
index 3b4b401..2f9c33d 100644
--- a/src/writer/spirv/builder_intrinsic_test.cc
+++ b/src/writer/spirv/builder_intrinsic_test.cc
@@ -415,9 +415,9 @@
}
TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Storage_RO_1d) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
@@ -449,9 +449,9 @@
}
TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Storage_RO_2d) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k2d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k2d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
@@ -486,7 +486,7 @@
}
TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Sampled_1d) {
- ast::type::SampledTextureType s(ast::type::TextureDimension::k1d, ty.f32);
+ ast::type::SampledTexture s(ast::type::TextureDimension::k1d, ty.f32);
b.push_function(Function{});
@@ -516,7 +516,7 @@
}
TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Sampled_2d) {
- ast::type::SampledTextureType s(ast::type::TextureDimension::k2d, ty.f32);
+ ast::type::SampledTexture s(ast::type::TextureDimension::k2d, ty.f32);
b.push_function(Function{});
@@ -549,8 +549,7 @@
}
TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Multisampled_2d) {
- ast::type::MultisampledTextureType s(ast::type::TextureDimension::k2d,
- ty.f32);
+ ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, ty.f32);
b.push_function(Function{});
@@ -584,8 +583,8 @@
// This tests that we do not push OpTypeSampledImage and float_0 type twice.
TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
- ast::type::SamplerType s(ast::type::SamplerKind::kComparisonSampler);
- ast::type::DepthTextureType t(ast::type::TextureDimension::k2d);
+ ast::type::Sampler s(ast::type::SamplerKind::kComparisonSampler);
+ ast::type::DepthTexture t(ast::type::TextureDimension::k2d);
b.push_function(Function{});
@@ -1428,7 +1427,7 @@
members.push_back(create<ast::StructMember>("a", ty.array<f32>(), decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
@@ -1467,7 +1466,7 @@
members.push_back(create<ast::StructMember>("a", ty.array<f32>(), decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
auto expr = Call("arrayLength",
@@ -1500,8 +1499,7 @@
// TODO(dsinclair): https://bugs.chromium.org/p/tint/issues/detail?id=266
TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) {
- ast::type::PointerType ptr(ty.array<f32>(),
- ast::StorageClass::kStorageBuffer);
+ ast::type::Pointer ptr(ty.array<f32>(), ast::StorageClass::kStorageBuffer);
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
@@ -1509,7 +1507,7 @@
members.push_back(create<ast::StructMember>("a", ty.array<f32>(), decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
diff --git a/src/writer/spirv/builder_intrinsic_texture_test.cc b/src/writer/spirv/builder_intrinsic_texture_test.cc
index 8f0c970..f5c8c06 100644
--- a/src/writer/spirv/builder_intrinsic_texture_test.cc
+++ b/src/writer/spirv/builder_intrinsic_texture_test.cc
@@ -1525,19 +1525,18 @@
break;
}
- ast::type::SamplerType sampler_type{param.sampler_kind};
+ ast::type::Sampler sampler_type{param.sampler_kind};
ast::Variable* tex = nullptr;
switch (param.texture_kind) {
case ast::intrinsic::test::TextureKind::kRegular:
tex = Var("texture", ast::StorageClass::kNone,
- mod->create<ast::type::SampledTextureType>(
- param.texture_dimension, datatype));
+ mod->create<ast::type::SampledTexture>(param.texture_dimension,
+ datatype));
break;
case ast::intrinsic::test::TextureKind::kDepth:
- tex = Var(
- "texture", ast::StorageClass::kNone,
- mod->create<ast::type::DepthTextureType>(param.texture_dimension));
+ tex = Var("texture", ast::StorageClass::kNone,
+ mod->create<ast::type::DepthTexture>(param.texture_dimension));
break;
}
diff --git a/src/writer/spirv/builder_literal_test.cc b/src/writer/spirv/builder_literal_test.cc
index de94c5f..a50f0ca 100644
--- a/src/writer/spirv/builder_literal_test.cc
+++ b/src/writer/spirv/builder_literal_test.cc
@@ -34,7 +34,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Literal_Bool_True) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::BoolLiteral b_true(&bool_type, true);
auto id = b.GenerateLiteralIfNeeded(nullptr, &b_true);
@@ -47,7 +47,7 @@
}
TEST_F(BuilderTest, Literal_Bool_False) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::BoolLiteral b_false(&bool_type, false);
auto id = b.GenerateLiteralIfNeeded(nullptr, &b_false);
@@ -60,7 +60,7 @@
}
TEST_F(BuilderTest, Literal_Bool_Dedup) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::BoolLiteral b_true(&bool_type, true);
ast::BoolLiteral b_false(&bool_type, false);
@@ -78,7 +78,7 @@
}
TEST_F(BuilderTest, Literal_I32) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::SintLiteral i(&i32, -23);
auto id = b.GenerateLiteralIfNeeded(nullptr, &i);
@@ -91,7 +91,7 @@
}
TEST_F(BuilderTest, Literal_I32_Dedup) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::SintLiteral i1(&i32, -23);
ast::SintLiteral i2(&i32, -23);
@@ -105,7 +105,7 @@
}
TEST_F(BuilderTest, Literal_U32) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ast::UintLiteral i(&u32, 23);
auto id = b.GenerateLiteralIfNeeded(nullptr, &i);
@@ -118,7 +118,7 @@
}
TEST_F(BuilderTest, Literal_U32_Dedup) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ast::UintLiteral i1(&u32, 23);
ast::UintLiteral i2(&u32, 23);
@@ -132,7 +132,7 @@
}
TEST_F(BuilderTest, Literal_F32) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::FloatLiteral i(&f32, 23.245f);
auto id = b.GenerateLiteralIfNeeded(nullptr, &i);
@@ -145,7 +145,7 @@
}
TEST_F(BuilderTest, Literal_F32_Dedup) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::FloatLiteral i1(&f32, 23.245f);
ast::FloatLiteral i2(&f32, 23.245f);
diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc
index ecfe48a..2345a55 100644
--- a/src/writer/spirv/builder_loop_test.cc
+++ b/src/writer/spirv/builder_loop_test.cc
@@ -61,7 +61,7 @@
}
TEST_F(BuilderTest, Loop_WithoutContinuing) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
// loop {
// v = 2;
@@ -104,7 +104,7 @@
}
TEST_F(BuilderTest, Loop_WithContinuing) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
// loop {
// a = 2;
// continuing {
diff --git a/src/writer/spirv/builder_return_test.cc b/src/writer/spirv/builder_return_test.cc
index 738a12a..132a6fd 100644
--- a/src/writer/spirv/builder_return_test.cc
+++ b/src/writer/spirv/builder_return_test.cc
@@ -47,8 +47,8 @@
}
TEST_F(BuilderTest, Return_WithValue) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
@@ -80,7 +80,7 @@
}
TEST_F(BuilderTest, Return_WithValue_GeneratesLoad) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable var("param", ast::StorageClass::kFunction, &f32);
diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc
index b4b110b..25158f3 100644
--- a/src/writer/spirv/builder_switch_test.cc
+++ b/src/writer/spirv/builder_switch_test.cc
@@ -41,7 +41,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Switch_Empty) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
// switch (1) {
// }
@@ -68,7 +68,7 @@
}
TEST_F(BuilderTest, Switch_WithCase) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
// switch(a) {
// case 1:
@@ -147,7 +147,7 @@
}
TEST_F(BuilderTest, Switch_WithDefault) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
// switch(true) {
// default:
@@ -205,7 +205,7 @@
}
TEST_F(BuilderTest, Switch_WithCaseAndDefault) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
// switch(a) {
// case 1:
@@ -296,7 +296,7 @@
}
TEST_F(BuilderTest, Switch_CaseWithFallthrough) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
// switch(a) {
// case 1:
@@ -388,7 +388,7 @@
}
TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
// switch(a) {
// case 1:
@@ -429,8 +429,8 @@
}
TEST_F(BuilderTest, Switch_WithNestedBreak) {
- ast::type::I32Type i32;
- ast::type::BoolType bool_type;
+ ast::type::I32 i32;
+ ast::type::Bool bool_type;
// switch (a) {
// case 1:
diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc
index f72120d..f1c98d4 100644
--- a/src/writer/spirv/builder_type_test.cc
+++ b/src/writer/spirv/builder_type_test.cc
@@ -52,8 +52,8 @@
using BuilderTest_Type = TestHelper;
TEST_F(BuilderTest_Type, GenerateAlias) {
- ast::type::F32Type f32;
- ast::type::AliasType alias_type("my_type", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias_type("my_type", &f32);
auto id = b.GenerateTypeIfNeeded(&alias_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -65,9 +65,9 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedAlias) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
- ast::type::AliasType alias_type("my_type", &f32);
+ ast::type::I32 i32;
+ ast::type::F32 f32;
+ ast::type::Alias alias_type("my_type", &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&alias_type), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -80,8 +80,8 @@
}
TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
- ast::type::I32Type i32;
- ast::type::ArrayType ary(&i32);
+ ast::type::I32 i32;
+ ast::type::Array ary(&i32);
auto id = b.GenerateTypeIfNeeded(&ary);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -93,8 +93,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
- ast::type::I32Type i32;
- ast::type::ArrayType ary(&i32);
+ ast::type::I32 i32;
+ ast::type::Array ary(&i32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
@@ -106,8 +106,8 @@
}
TEST_F(BuilderTest_Type, GenerateArray) {
- ast::type::I32Type i32;
- ast::type::ArrayType ary(&i32, 4);
+ ast::type::I32 i32;
+ ast::type::Array ary(&i32, 4);
auto id = b.GenerateTypeIfNeeded(&ary);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -121,12 +121,12 @@
}
TEST_F(BuilderTest_Type, GenerateArray_WithStride) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(16u, Source{}));
- ast::type::ArrayType ary(&i32, 4);
+ ast::type::Array ary(&i32, 4);
ary.set_decorations(decos);
auto id = b.GenerateTypeIfNeeded(&ary);
@@ -144,8 +144,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedArray) {
- ast::type::I32Type i32;
- ast::type::ArrayType ary(&i32, 4);
+ ast::type::I32 i32;
+ ast::type::Array ary(&i32, 4);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
@@ -159,7 +159,7 @@
}
TEST_F(BuilderTest_Type, GenerateBool) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto id = b.GenerateTypeIfNeeded(&bool_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -171,8 +171,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedBool) {
- ast::type::I32Type i32;
- ast::type::BoolType bool_type;
+ ast::type::I32 i32;
+ ast::type::Bool bool_type;
EXPECT_EQ(b.GenerateTypeIfNeeded(&bool_type), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -183,7 +183,7 @@
}
TEST_F(BuilderTest_Type, GenerateF32) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto id = b.GenerateTypeIfNeeded(&f32);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -195,8 +195,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedF32) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
EXPECT_EQ(b.GenerateTypeIfNeeded(&f32), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -207,7 +207,7 @@
}
TEST_F(BuilderTest_Type, GenerateI32) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto id = b.GenerateTypeIfNeeded(&i32);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -219,8 +219,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedI32) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
EXPECT_EQ(b.GenerateTypeIfNeeded(&i32), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -231,8 +231,8 @@
}
TEST_F(BuilderTest_Type, GenerateMatrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat_type(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix mat_type(&f32, 3, 2);
auto id = b.GenerateTypeIfNeeded(&mat_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -246,8 +246,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) {
- ast::type::I32Type i32;
- ast::type::MatrixType mat_type(&i32, 3, 4);
+ ast::type::I32 i32;
+ ast::type::Matrix mat_type(&i32, 3, 4);
EXPECT_EQ(b.GenerateTypeIfNeeded(&mat_type), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -258,8 +258,8 @@
}
TEST_F(BuilderTest_Type, GeneratePtr) {
- ast::type::I32Type i32;
- ast::type::PointerType ptr(&i32, ast::StorageClass::kOutput);
+ ast::type::I32 i32;
+ ast::type::Pointer ptr(&i32, ast::StorageClass::kOutput);
auto id = b.GenerateTypeIfNeeded(&ptr);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -271,8 +271,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
- ast::type::I32Type i32;
- ast::type::PointerType ptr(&i32, ast::StorageClass::kOutput);
+ ast::type::I32 i32;
+ ast::type::Pointer ptr(&i32, ast::StorageClass::kOutput);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ptr), 1u);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ptr), 1u);
@@ -280,7 +280,7 @@
TEST_F(BuilderTest_Type, GenerateStruct_Empty) {
auto* s = create<ast::Struct>();
- ast::type::StructType s_type("S", s);
+ ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -294,14 +294,14 @@
}
TEST_F(BuilderTest_Type, GenerateStruct) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
members.push_back(create<ast::StructMember>("a", &f32, decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto id = b.GenerateTypeIfNeeded(&s_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -316,7 +316,7 @@
}
TEST_F(BuilderTest_Type, GenerateStruct_Decorated) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::StructMemberDecorationList decos;
ast::StructMemberList members;
@@ -326,7 +326,7 @@
struct_decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* s = create<ast::Struct>(struct_decos, members);
- ast::type::StructType s_type("my_struct", s);
+ ast::type::Struct s_type("my_struct", s);
auto id = b.GenerateTypeIfNeeded(&s_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -343,7 +343,7 @@
}
TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::StructMemberDecorationList a_decos;
a_decos.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
@@ -355,7 +355,7 @@
members.push_back(create<ast::StructMember>("b", &f32, b_decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("S", s);
+ ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -375,10 +375,10 @@
TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) {
// Don't infer layout for matrix when there is no offset.
- ast::type::F32Type f32;
- ast::type::MatrixType glsl_mat2x2(&f32, 2, 2);
- ast::type::MatrixType glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows
- ast::type::MatrixType glsl_mat4x4(&f32, 4, 4);
+ ast::type::F32 f32;
+ ast::type::Matrix glsl_mat2x2(&f32, 2, 2);
+ ast::type::Matrix glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows
+ ast::type::Matrix glsl_mat4x4(&f32, 4, 4);
ast::StructMemberDecorationList empty_a;
ast::StructMemberDecorationList empty_b;
@@ -389,7 +389,7 @@
members.push_back(create<ast::StructMember>("c", &glsl_mat4x4, empty_c));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("S", s);
+ ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -414,10 +414,10 @@
TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) {
// We have to infer layout for matrix when it also has an offset.
- ast::type::F32Type f32;
- ast::type::MatrixType glsl_mat2x2(&f32, 2, 2);
- ast::type::MatrixType glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows
- ast::type::MatrixType glsl_mat4x4(&f32, 4, 4);
+ ast::type::F32 f32;
+ ast::type::Matrix glsl_mat2x2(&f32, 2, 2);
+ ast::type::Matrix glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows
+ ast::type::Matrix glsl_mat4x4(&f32, 4, 4);
ast::StructMemberDecorationList a_decos;
a_decos.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
@@ -432,7 +432,7 @@
members.push_back(create<ast::StructMember>("c", &glsl_mat4x4, c_decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("S", s);
+ ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -468,17 +468,17 @@
// We have to infer layout for matrix when it also has an offset.
// The decoration goes on the struct member, even if the matrix is buried
// in levels of arrays.
- ast::type::F32Type f32;
+ ast::type::F32 f32;
- ast::type::MatrixType glsl_mat2x2(&f32, 2, 2);
- ast::type::ArrayType arr_mat2x2(&glsl_mat2x2, 1); // Singly nested array
+ ast::type::Matrix glsl_mat2x2(&f32, 2, 2);
+ ast::type::Array arr_mat2x2(&glsl_mat2x2, 1); // Singly nested array
- ast::type::MatrixType glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows
- ast::type::ArrayType arr_mat2x3(&glsl_mat2x3, 1);
- ast::type::ArrayType arr_arr_mat2x2(&arr_mat2x3, 1); // Doubly nested array
+ ast::type::Matrix glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows
+ ast::type::Array arr_mat2x3(&glsl_mat2x3, 1);
+ ast::type::Array arr_arr_mat2x2(&arr_mat2x3, 1); // Doubly nested array
- ast::type::MatrixType glsl_mat4x4(&f32, 4, 4);
- ast::type::ArrayType rtarr_mat4x4(&glsl_mat4x4); // Runtime array
+ ast::type::Matrix glsl_mat4x4(&f32, 4, 4);
+ ast::type::Array rtarr_mat4x4(&glsl_mat4x4); // Runtime array
ast::StructMemberDecorationList a_decos;
a_decos.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
@@ -493,7 +493,7 @@
members.push_back(create<ast::StructMember>("c", &glsl_mat4x4, c_decos));
auto* s = create<ast::Struct>(members);
- ast::type::StructType s_type("S", s);
+ ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -526,7 +526,7 @@
}
TEST_F(BuilderTest_Type, GenerateU32) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto id = b.GenerateTypeIfNeeded(&u32);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -538,8 +538,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedU32) {
- ast::type::U32Type u32;
- ast::type::F32Type f32;
+ ast::type::U32 u32;
+ ast::type::F32 f32;
EXPECT_EQ(b.GenerateTypeIfNeeded(&u32), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -550,8 +550,8 @@
}
TEST_F(BuilderTest_Type, GenerateVector) {
- ast::type::F32Type f32;
- ast::type::VectorType vec_type(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec_type(&f32, 3);
auto id = b.GenerateTypeIfNeeded(&vec_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -564,8 +564,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedVector) {
- ast::type::I32Type i32;
- ast::type::VectorType vec_type(&i32, 3);
+ ast::type::I32 i32;
+ ast::type::Vector vec_type(&i32, 3);
EXPECT_EQ(b.GenerateTypeIfNeeded(&vec_type), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -576,7 +576,7 @@
}
TEST_F(BuilderTest_Type, GenerateVoid) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
auto id = b.GenerateTypeIfNeeded(&void_type);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -588,8 +588,8 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedVoid) {
- ast::type::I32Type i32;
- ast::type::VoidType void_type;
+ ast::type::I32 i32;
+ ast::type::Void void_type;
EXPECT_EQ(b.GenerateTypeIfNeeded(&void_type), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -631,7 +631,7 @@
PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction}));
TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
- ast::type::DepthTextureType two_d(ast::type::TextureDimension::k2d);
+ ast::type::DepthTexture two_d(ast::type::TextureDimension::k2d);
auto id_two_d = b.GenerateTypeIfNeeded(&two_d);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -643,8 +643,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
- ast::type::DepthTextureType two_d_array(
- ast::type::TextureDimension::k2dArray);
+ ast::type::DepthTexture two_d_array(ast::type::TextureDimension::k2dArray);
auto id_two_d_array = b.GenerateTypeIfNeeded(&two_d_array);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -656,7 +655,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
- ast::type::DepthTextureType cube(ast::type::TextureDimension::kCube);
+ ast::type::DepthTexture cube(ast::type::TextureDimension::kCube);
auto id_cube = b.GenerateTypeIfNeeded(&cube);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -669,8 +668,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
- ast::type::DepthTextureType cube_array(
- ast::type::TextureDimension::kCubeArray);
+ ast::type::DepthTexture cube_array(ast::type::TextureDimension::kCubeArray);
auto id_cube_array = b.GenerateTypeIfNeeded(&cube_array);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -685,8 +683,8 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
- ast::type::I32Type i32;
- ast::type::MultisampledTextureType ms(ast::type::TextureDimension::k2d, &i32);
+ ast::type::I32 i32;
+ ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, &i32);
EXPECT_EQ(1u, b.GenerateTypeIfNeeded(&ms));
ASSERT_FALSE(b.has_error()) << b.error();
@@ -696,8 +694,8 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
- ast::type::U32Type u32;
- ast::type::MultisampledTextureType ms(ast::type::TextureDimension::k2d, &u32);
+ ast::type::U32 u32;
+ ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, &u32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ms), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -708,8 +706,8 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
- ast::type::F32Type f32;
- ast::type::MultisampledTextureType ms(ast::type::TextureDimension::k2d, &f32);
+ ast::type::F32 f32;
+ ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ms), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -720,8 +718,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
- ast::type::I32Type i32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::k1d, &i32);
+ ast::type::I32 i32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::k1d, &i32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -736,8 +734,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
- ast::type::U32Type u32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::k1d, &u32);
+ ast::type::U32 u32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::k1d, &u32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -752,8 +750,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::k1d, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::k1d, &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -768,8 +766,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1dArray) {
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::k1dArray, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::k1dArray, &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -784,8 +782,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::k2d, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::k2d, &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -796,8 +794,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::k2dArray, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::k2dArray, &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -808,8 +806,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::k3d, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::k3d, &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -820,8 +818,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::kCube, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::kCube, &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -833,9 +831,8 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
- ast::type::F32Type f32;
- ast::type::SampledTextureType s(ast::type::TextureDimension::kCubeArray,
- &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture s(ast::type::TextureDimension::kCubeArray, &f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -849,9 +846,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R16Float) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -867,9 +864,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8SNorm) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR8Snorm);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR8Snorm);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -885,9 +882,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8UNorm) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR8Unorm);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR8Unorm);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -903,9 +900,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8Uint) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR8Uint);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR8Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -916,9 +913,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8Sint) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR8Sint);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR8Sint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -929,9 +926,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_array) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1dArray,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1dArray,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -947,9 +944,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_2d) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k2d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k2d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -960,9 +957,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_2dArray) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k2dArray,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k2dArray,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -973,9 +970,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_3d) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k3d,
- ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k3d,
+ ast::AccessControl::kReadOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -986,9 +983,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_1d) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1d,
- ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
+ ast::AccessControl::kWriteOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -1004,9 +1001,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_1dArray) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k1dArray,
- ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k1dArray,
+ ast::AccessControl::kWriteOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -1022,9 +1019,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_2d) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k2d,
- ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k2d,
+ ast::AccessControl::kWriteOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -1035,9 +1032,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_2dArray) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k2dArray,
- ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k2dArray,
+ ast::AccessControl::kWriteOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -1048,9 +1045,9 @@
}
TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_3d) {
- ast::type::StorageTextureType s(ast::type::TextureDimension::k3d,
- ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kR16Float);
+ ast::type::StorageTexture s(ast::type::TextureDimension::k3d,
+ ast::AccessControl::kWriteOnly,
+ ast::type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -1061,25 +1058,24 @@
}
TEST_F(BuilderTest_Type, Sampler) {
- ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), "%1 = OpTypeSampler\n");
}
TEST_F(BuilderTest_Type, ComparisonSampler) {
- ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler);
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), "%1 = OpTypeSampler\n");
}
TEST_F(BuilderTest_Type, Dedup_Sampler_And_ComparisonSampler) {
- ast::type::SamplerType comp_sampler(
- ast::type::SamplerKind::kComparisonSampler);
+ ast::type::Sampler comp_sampler(ast::type::SamplerKind::kComparisonSampler);
EXPECT_EQ(b.GenerateTypeIfNeeded(&comp_sampler), 1u);
- ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc
index 5795dee..c423293 100644
--- a/src/writer/spirv/builder_unary_op_expression_test.cc
+++ b/src/writer/spirv/builder_unary_op_expression_test.cc
@@ -39,7 +39,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, UnaryOp_Negation_Integer) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::UnaryOpExpression expr(ast::UnaryOp::kNegation,
create<ast::ScalarConstructorExpression>(
@@ -58,7 +58,7 @@
}
TEST_F(BuilderTest, UnaryOp_Negation_Float) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::UnaryOpExpression expr(ast::UnaryOp::kNegation,
create<ast::ScalarConstructorExpression>(
@@ -77,7 +77,7 @@
}
TEST_F(BuilderTest, UnaryOp_Not) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
ast::UnaryOpExpression expr(ast::UnaryOp::kNot,
create<ast::ScalarConstructorExpression>(
@@ -96,8 +96,8 @@
}
TEST_F(BuilderTest, UnaryOp_LoadRequired) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
ast::Variable var("param", ast::StorageClass::kFunction, &vec);
diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc
index d038609..85ac8ba 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -173,15 +173,15 @@
bool GeneratorImpl::EmitConstructedType(const ast::type::Type* ty) {
make_indent();
- if (ty->Is<ast::type::AliasType>()) {
- auto* alias = ty->As<ast::type::AliasType>();
+ if (ty->Is<ast::type::Alias>()) {
+ auto* alias = ty->As<ast::type::Alias>();
out_ << "type " << alias->name() << " = ";
if (!EmitType(alias->type())) {
return false;
}
out_ << ";" << std::endl;
- } else if (ty->Is<ast::type::StructType>()) {
- if (!EmitStructType(ty->As<ast::type::StructType>())) {
+ } else if (ty->Is<ast::type::Struct>()) {
+ if (!EmitStructType(ty->As<ast::type::Struct>())) {
return false;
}
} else {
@@ -399,8 +399,8 @@
}
bool GeneratorImpl::EmitType(ast::type::Type* type) {
- if (type->Is<ast::type::AccessControlType>()) {
- auto* ac = type->As<ast::type::AccessControlType>();
+ if (type->Is<ast::type::AccessControl>()) {
+ auto* ac = type->As<ast::type::AccessControl>();
out_ << "[[access(";
if (ac->IsReadOnly()) {
@@ -415,10 +415,10 @@
if (!EmitType(ac->type())) {
return false;
}
- } else if (type->Is<ast::type::AliasType>()) {
- out_ << type->As<ast::type::AliasType>()->name();
- } else if (type->Is<ast::type::ArrayType>()) {
- auto* ary = type->As<ast::type::ArrayType>();
+ } else if (type->Is<ast::type::Alias>()) {
+ out_ << type->As<ast::type::Alias>()->name();
+ } else if (type->Is<ast::type::Array>()) {
+ auto* ary = type->As<ast::type::Array>();
for (auto* deco : ary->decorations()) {
if (auto* stride = deco->As<ast::StrideDecoration>()) {
@@ -435,51 +435,51 @@
out_ << ", " << ary->size();
out_ << ">";
- } else if (type->Is<ast::type::BoolType>()) {
+ } else if (type->Is<ast::type::Bool>()) {
out_ << "bool";
- } else if (type->Is<ast::type::F32Type>()) {
+ } else if (type->Is<ast::type::F32>()) {
out_ << "f32";
- } else if (type->Is<ast::type::I32Type>()) {
+ } else if (type->Is<ast::type::I32>()) {
out_ << "i32";
- } else if (type->Is<ast::type::MatrixType>()) {
- auto* mat = type->As<ast::type::MatrixType>();
+ } else if (type->Is<ast::type::Matrix>()) {
+ auto* mat = type->As<ast::type::Matrix>();
out_ << "mat" << mat->columns() << "x" << mat->rows() << "<";
if (!EmitType(mat->type())) {
return false;
}
out_ << ">";
- } else if (type->Is<ast::type::PointerType>()) {
- auto* ptr = type->As<ast::type::PointerType>();
+ } else if (type->Is<ast::type::Pointer>()) {
+ auto* ptr = type->As<ast::type::Pointer>();
out_ << "ptr<" << ptr->storage_class() << ", ";
if (!EmitType(ptr->type())) {
return false;
}
out_ << ">";
- } else if (type->Is<ast::type::SamplerType>()) {
- auto* sampler = type->As<ast::type::SamplerType>();
+ } else if (type->Is<ast::type::Sampler>()) {
+ auto* sampler = type->As<ast::type::Sampler>();
out_ << "sampler";
if (sampler->IsComparison()) {
out_ << "_comparison";
}
- } else if (type->Is<ast::type::StructType>()) {
+ } else if (type->Is<ast::type::Struct>()) {
// The struct, as a type, is just the name. We should have already emitted
// the declaration through a call to |EmitStructType| earlier.
- out_ << type->As<ast::type::StructType>()->name();
- } else if (type->Is<ast::type::TextureType>()) {
- auto* texture = type->As<ast::type::TextureType>();
+ out_ << type->As<ast::type::Struct>()->name();
+ } else if (type->Is<ast::type::Texture>()) {
+ auto* texture = type->As<ast::type::Texture>();
out_ << "texture_";
- if (texture->Is<ast::type::DepthTextureType>()) {
+ if (texture->Is<ast::type::DepthTexture>()) {
out_ << "depth_";
- } else if (texture->Is<ast::type::SampledTextureType>()) {
+ } else if (texture->Is<ast::type::SampledTexture>()) {
/* nothing to emit */
- } else if (texture->Is<ast::type::MultisampledTextureType>()) {
+ } else if (texture->Is<ast::type::MultisampledTexture>()) {
out_ << "multisampled_";
- } else if (texture->Is<ast::type::StorageTextureType>()) {
+ } else if (texture->Is<ast::type::StorageTexture>()) {
out_ << "storage_";
- auto* storage = texture->As<ast::type::StorageTextureType>();
+ auto* storage = texture->As<ast::type::StorageTexture>();
if (storage->access() == ast::AccessControl::kReadOnly) {
out_ << "ro_";
} else if (storage->access() == ast::AccessControl::kWriteOnly) {
@@ -520,24 +520,24 @@
return false;
}
- if (texture->Is<ast::type::SampledTextureType>()) {
- auto* sampled = texture->As<ast::type::SampledTextureType>();
+ if (texture->Is<ast::type::SampledTexture>()) {
+ auto* sampled = texture->As<ast::type::SampledTexture>();
out_ << "<";
if (!EmitType(sampled->type())) {
return false;
}
out_ << ">";
- } else if (texture->Is<ast::type::MultisampledTextureType>()) {
- auto* sampled = texture->As<ast::type::MultisampledTextureType>();
+ } else if (texture->Is<ast::type::MultisampledTexture>()) {
+ auto* sampled = texture->As<ast::type::MultisampledTexture>();
out_ << "<";
if (!EmitType(sampled->type())) {
return false;
}
out_ << ">";
- } else if (texture->Is<ast::type::StorageTextureType>()) {
- auto* storage = texture->As<ast::type::StorageTextureType>();
+ } else if (texture->Is<ast::type::StorageTexture>()) {
+ auto* storage = texture->As<ast::type::StorageTexture>();
out_ << "<";
if (!EmitImageFormat(storage->image_format())) {
@@ -546,16 +546,16 @@
out_ << ">";
}
- } else if (type->Is<ast::type::U32Type>()) {
+ } else if (type->Is<ast::type::U32>()) {
out_ << "u32";
- } else if (type->Is<ast::type::VectorType>()) {
- auto* vec = type->As<ast::type::VectorType>();
+ } else if (type->Is<ast::type::Vector>()) {
+ auto* vec = type->As<ast::type::Vector>();
out_ << "vec" << vec->size() << "<";
if (!EmitType(vec->type())) {
return false;
}
out_ << ">";
- } else if (type->Is<ast::type::VoidType>()) {
+ } else if (type->Is<ast::type::Void>()) {
out_ << "void";
} else {
error_ = "unknown type in EmitType: " + type->type_name();
@@ -565,7 +565,7 @@
return true;
}
-bool GeneratorImpl::EmitStructType(const ast::type::StructType* str) {
+bool GeneratorImpl::EmitStructType(const ast::type::Struct* str) {
auto* impl = str->impl();
for (auto* deco : impl->decorations()) {
out_ << "[[";
diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h
index 4680036..3bc921a 100644
--- a/src/writer/wgsl/generator_impl.h
+++ b/src/writer/wgsl/generator_impl.h
@@ -187,7 +187,7 @@
/// Handles generating a struct declaration
/// @param str the struct
/// @returns true if the struct is emitted
- bool EmitStructType(const ast::type::StructType* str);
+ bool EmitStructType(const ast::type::Struct* str);
/// Handles emitting an image format
/// @param fmt the format to generate
/// @returns true if the format is emitted
diff --git a/src/writer/wgsl/generator_impl_alias_type_test.cc b/src/writer/wgsl/generator_impl_alias_type_test.cc
index ce1249e..693c75d 100644
--- a/src/writer/wgsl/generator_impl_alias_type_test.cc
+++ b/src/writer/wgsl/generator_impl_alias_type_test.cc
@@ -30,9 +30,9 @@
using WgslGeneratorImplTest = TestHelper;
-TEST_F(WgslGeneratorImplTest, EmitAliasType_F32) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("a", &f32);
+TEST_F(WgslGeneratorImplTest, EmitAlias_F32) {
+ ast::type::F32 f32;
+ ast::type::Alias alias("a", &f32);
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
EXPECT_EQ(gen.result(), R"(type a = f32;
@@ -40,8 +40,8 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -54,8 +54,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("A", str);
- ast::type::AliasType alias("B", &s);
+ ast::type::Struct s("A", str);
+ ast::type::Alias alias("B", &s);
ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error();
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
@@ -68,9 +68,9 @@
)");
}
-TEST_F(WgslGeneratorImplTest, EmitAliasType_ToStruct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) {
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -83,8 +83,8 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("A", str);
- ast::type::AliasType alias("B", &s);
+ ast::type::Struct s("A", str);
+ ast::type::Alias alias("B", &s);
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
EXPECT_EQ(gen.result(), R"(type B = A;
diff --git a/src/writer/wgsl/generator_impl_array_accessor_test.cc b/src/writer/wgsl/generator_impl_array_accessor_test.cc
index e187612..8678557 100644
--- a/src/writer/wgsl/generator_impl_array_accessor_test.cc
+++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc
@@ -31,7 +31,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitExpression_ArrayAccessor) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, 5);
auto* idx = create<ast::ScalarConstructorExpression>(lit);
auto* ary = create<ast::IdentifierExpression>("ary");
diff --git a/src/writer/wgsl/generator_impl_bitcast_test.cc b/src/writer/wgsl/generator_impl_bitcast_test.cc
index 83ba9e6..2b9d5e8 100644
--- a/src/writer/wgsl/generator_impl_bitcast_test.cc
+++ b/src/writer/wgsl/generator_impl_bitcast_test.cc
@@ -29,7 +29,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitExpression_Bitcast) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* id = create<ast::IdentifierExpression>("id");
ast::BitcastExpression bitcast(&f32, id);
diff --git a/src/writer/wgsl/generator_impl_case_test.cc b/src/writer/wgsl/generator_impl_case_test.cc
index 5b5fc05..b23348f 100644
--- a/src/writer/wgsl/generator_impl_case_test.cc
+++ b/src/writer/wgsl/generator_impl_case_test.cc
@@ -31,7 +31,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, Emit_Case) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::BreakStatement>());
@@ -50,7 +50,7 @@
}
TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::BreakStatement>());
diff --git a/src/writer/wgsl/generator_impl_cast_test.cc b/src/writer/wgsl/generator_impl_cast_test.cc
index c2a86dc..6b0e933 100644
--- a/src/writer/wgsl/generator_impl_cast_test.cc
+++ b/src/writer/wgsl/generator_impl_cast_test.cc
@@ -29,7 +29,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitExpression_Cast) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>("id"));
diff --git a/src/writer/wgsl/generator_impl_constructor_test.cc b/src/writer/wgsl/generator_impl_constructor_test.cc
index 850f5ec..0993355 100644
--- a/src/writer/wgsl/generator_impl_constructor_test.cc
+++ b/src/writer/wgsl/generator_impl_constructor_test.cc
@@ -36,7 +36,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitConstructor_Bool) {
- ast::type::BoolType bool_type;
+ ast::type::Bool bool_type;
auto* lit = create<ast::BoolLiteral>(&bool_type, false);
ast::ScalarConstructorExpression expr(lit);
@@ -45,7 +45,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Int) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, -12345);
ast::ScalarConstructorExpression expr(lit);
@@ -54,7 +54,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(&u32, 56779);
ast::ScalarConstructorExpression expr(lit);
@@ -63,7 +63,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto* lit =
create<ast::FloatLiteral>(&f32, static_cast<float>((1 << 30) - 4));
@@ -74,7 +74,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* lit = create<ast::FloatLiteral>(&f32, -1.2e-5);
ast::ExpressionList values;
@@ -87,7 +87,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Bool) {
- ast::type::BoolType b;
+ ast::type::Bool b;
auto* lit = create<ast::BoolLiteral>(&b, true);
ast::ExpressionList values;
@@ -100,7 +100,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Int) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(&i32, -12345);
ast::ExpressionList values;
@@ -113,7 +113,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Uint) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(&u32, 12345);
ast::ExpressionList values;
@@ -126,8 +126,8 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
auto* lit1 = create<ast::FloatLiteral>(&f32, 1.f);
auto* lit2 = create<ast::FloatLiteral>(&f32, 2.f);
@@ -144,10 +144,10 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) {
- ast::type::F32Type f32;
- ast::type::MatrixType mat(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix mat(&f32, 3, 2);
- ast::type::VectorType vec(&f32, 2);
+ ast::type::Vector vec(&f32, 2);
ast::ExpressionList mat_values;
@@ -172,9 +172,9 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) {
- ast::type::F32Type f32;
- ast::type::VectorType vec(&f32, 3);
- ast::type::ArrayType ary(&vec, 3);
+ ast::type::F32 f32;
+ ast::type::Vector vec(&f32, 3);
+ ast::type::Array ary(&vec, 3);
ast::ExpressionList ary_values;
diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc
index 15815c1..3d337f8 100644
--- a/src/writer/wgsl/generator_impl_function_test.cc
+++ b/src/writer/wgsl/generator_impl_function_test.cc
@@ -47,7 +47,7 @@
body->append(create<ast::DiscardStatement>());
body->append(create<ast::ReturnStatement>());
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("my_func", {}, &void_type, body);
gen.increment_indent();
@@ -65,13 +65,13 @@
body->append(create<ast::DiscardStatement>());
body->append(create<ast::ReturnStatement>());
- ast::type::F32Type f32;
- ast::type::I32Type i32;
+ ast::type::F32 f32;
+ ast::type::I32 i32;
ast::VariableList params;
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &f32));
params.push_back(create<ast::Variable>("b", ast::StorageClass::kNone, &i32));
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("my_func", params, &void_type, body);
gen.increment_indent();
@@ -89,7 +89,7 @@
body->append(create<ast::DiscardStatement>());
body->append(create<ast::ReturnStatement>());
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("my_func", {}, &void_type, body);
func.add_decoration(create<ast::WorkgroupDecoration>(2u, 4u, 6u, Source{}));
@@ -109,7 +109,7 @@
body->append(create<ast::DiscardStatement>());
body->append(create<ast::ReturnStatement>());
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("my_func", {}, &void_type, body);
func.add_decoration(
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
@@ -130,7 +130,7 @@
body->append(create<ast::DiscardStatement>());
body->append(create<ast::ReturnStatement>());
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
ast::Function func("my_func", {}, &void_type, body);
func.add_decoration(
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
@@ -166,8 +166,8 @@
// return;
// }
- ast::type::VoidType void_type;
- ast::type::F32Type f32;
+ ast::type::Void void_type;
+ ast::type::F32 f32;
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@@ -179,8 +179,8 @@
auto* str = create<ast::Struct>(s_decos, members);
- ast::type::StructType s("Data", str);
- ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s);
+ ast::type::Struct s("Data", str);
+ ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
auto* data_var = create<ast::DecoratedVariable>(
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &ac));
diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc
index 06904ee..29f22cc 100644
--- a/src/writer/wgsl/generator_impl_switch_test.cc
+++ b/src/writer/wgsl/generator_impl_switch_test.cc
@@ -36,7 +36,7 @@
def_body->append(create<ast::BreakStatement>());
auto* def = create<ast::CaseStatement>(def_body);
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::CaseSelectorList case_val;
case_val.push_back(create<ast::SintLiteral>(&i32, 5));
diff --git a/src/writer/wgsl/generator_impl_test.cc b/src/writer/wgsl/generator_impl_test.cc
index d9ea548c..a088017 100644
--- a/src/writer/wgsl/generator_impl_test.cc
+++ b/src/writer/wgsl/generator_impl_test.cc
@@ -30,7 +30,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, Generate) {
- ast::type::VoidType void_type;
+ ast::type::Void void_type;
mod.AddFunction(create<ast::Function>("my_func", ast::VariableList{},
&void_type,
diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc
index fd4d81d..202e8fc 100644
--- a/src/writer/wgsl/generator_impl_type_test.cc
+++ b/src/writer/wgsl/generator_impl_type_test.cc
@@ -48,23 +48,23 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitType_Alias) {
- ast::type::F32Type f32;
- ast::type::AliasType alias("alias", &f32);
+ ast::type::F32 f32;
+ ast::type::Alias alias("alias", &f32);
ASSERT_TRUE(gen.EmitType(&alias)) << gen.error();
EXPECT_EQ(gen.result(), "alias");
}
TEST_F(WgslGeneratorImplTest, EmitType_Array) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b, 4);
+ ast::type::Bool b;
+ ast::type::Array a(&b, 4);
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "array<bool, 4>");
}
TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -75,16 +75,16 @@
decos.push_back(&block_deco);
ast::Struct str(decos, members);
- ast::type::StructType s("S", &str);
+ ast::type::Struct s("S", &str);
- ast::type::AccessControlType a(ast::AccessControl::kReadOnly, &s);
+ ast::type::AccessControl a(ast::AccessControl::kReadOnly, &s);
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "[[access(read)]]\nS");
}
TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -95,20 +95,20 @@
decos.push_back(&block_deco);
ast::Struct str(decos, members);
- ast::type::StructType s("S", &str);
+ ast::type::Struct s("S", &str);
- ast::type::AccessControlType a(ast::AccessControl::kReadWrite, &s);
+ ast::type::AccessControl a(ast::AccessControl::kReadWrite, &s);
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "[[access(read_write)]]\nS");
}
TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
- ast::type::BoolType b;
+ ast::type::Bool b;
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(16u, Source{}));
- ast::type::ArrayType a(&b, 4);
+ ast::type::Array a(&b, 4);
a.set_decorations(decos);
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
@@ -116,12 +116,12 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) {
- ast::type::BoolType b;
+ ast::type::Bool b;
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(16u, Source{}));
decos.push_back(create<ast::StrideDecoration>(32u, Source{}));
- ast::type::ArrayType a(&b, 4);
+ ast::type::Array a(&b, 4);
a.set_decorations(decos);
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
@@ -129,53 +129,53 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
- ast::type::BoolType b;
- ast::type::ArrayType a(&b);
+ ast::type::Bool b;
+ ast::type::Array a(&b);
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "array<bool>");
}
TEST_F(WgslGeneratorImplTest, EmitType_Bool) {
- ast::type::BoolType b;
+ ast::type::Bool b;
ASSERT_TRUE(gen.EmitType(&b)) << gen.error();
EXPECT_EQ(gen.result(), "bool");
}
TEST_F(WgslGeneratorImplTest, EmitType_F32) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ASSERT_TRUE(gen.EmitType(&f32)) << gen.error();
EXPECT_EQ(gen.result(), "f32");
}
TEST_F(WgslGeneratorImplTest, EmitType_I32) {
- ast::type::I32Type i32;
+ ast::type::I32 i32;
ASSERT_TRUE(gen.EmitType(&i32)) << gen.error();
EXPECT_EQ(gen.result(), "i32");
}
TEST_F(WgslGeneratorImplTest, EmitType_Matrix) {
- ast::type::F32Type f32;
- ast::type::MatrixType m(&f32, 3, 2);
+ ast::type::F32 f32;
+ ast::type::Matrix m(&f32, 3, 2);
ASSERT_TRUE(gen.EmitType(&m)) << gen.error();
EXPECT_EQ(gen.result(), "mat2x3<f32>");
}
TEST_F(WgslGeneratorImplTest, EmitType_Pointer) {
- ast::type::F32Type f32;
- ast::type::PointerType p(&f32, ast::StorageClass::kWorkgroup);
+ ast::type::F32 f32;
+ ast::type::Pointer p(&f32, ast::StorageClass::kWorkgroup);
ASSERT_TRUE(gen.EmitType(&p)) << gen.error();
EXPECT_EQ(gen.result(), "ptr<workgroup, f32>");
}
TEST_F(WgslGeneratorImplTest, EmitType_Struct) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -188,15 +188,15 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitType(&s)) << gen.error();
EXPECT_EQ(gen.result(), "S");
}
TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -209,7 +209,7 @@
auto* str = create<ast::Struct>();
str->set_members(members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
EXPECT_EQ(gen.result(), R"(struct S {
@@ -221,8 +221,8 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) {
- ast::type::I32Type i32;
- ast::type::F32Type f32;
+ ast::type::I32 i32;
+ ast::type::F32 f32;
ast::StructMemberList members;
members.push_back(
@@ -237,7 +237,7 @@
auto* str = create<ast::Struct>(decos, members);
- ast::type::StructType s("S", str);
+ ast::type::Struct s("S", str);
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
EXPECT_EQ(gen.result(), R"([[block]]
@@ -250,22 +250,22 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_U32) {
- ast::type::U32Type u32;
+ ast::type::U32 u32;
ASSERT_TRUE(gen.EmitType(&u32)) << gen.error();
EXPECT_EQ(gen.result(), "u32");
}
TEST_F(WgslGeneratorImplTest, EmitType_Vector) {
- ast::type::F32Type f32;
- ast::type::VectorType v(&f32, 3);
+ ast::type::F32 f32;
+ ast::type::Vector v(&f32, 3);
ASSERT_TRUE(gen.EmitType(&v)) << gen.error();
EXPECT_EQ(gen.result(), "vec3<f32>");
}
TEST_F(WgslGeneratorImplTest, EmitType_Void) {
- ast::type::VoidType v;
+ ast::type::Void v;
ASSERT_TRUE(gen.EmitType(&v)) << gen.error();
EXPECT_EQ(gen.result(), "void");
@@ -284,7 +284,7 @@
TEST_P(WgslGenerator_DepthTextureTest, EmitType_DepthTexture) {
auto param = GetParam();
- ast::type::DepthTextureType d(param.dim);
+ ast::type::DepthTexture d(param.dim);
ASSERT_TRUE(gen.EmitType(&d)) << gen.error();
EXPECT_EQ(gen.result(), param.name);
@@ -304,8 +304,8 @@
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::SampledTextureType t(param.dim, &f32);
+ ast::type::F32 f32;
+ ast::type::SampledTexture t(param.dim, &f32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<f32>");
@@ -314,8 +314,8 @@
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::SampledTextureType t(param.dim, &i32);
+ ast::type::I32 i32;
+ ast::type::SampledTexture t(param.dim, &i32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<i32>");
@@ -324,8 +324,8 @@
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) {
auto param = GetParam();
- ast::type::U32Type u32;
- ast::type::SampledTextureType t(param.dim, &u32);
+ ast::type::U32 u32;
+ ast::type::SampledTexture t(param.dim, &u32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<u32>");
@@ -347,8 +347,8 @@
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
auto param = GetParam();
- ast::type::F32Type f32;
- ast::type::MultisampledTextureType t(param.dim, &f32);
+ ast::type::F32 f32;
+ ast::type::MultisampledTexture t(param.dim, &f32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<f32>");
@@ -357,8 +357,8 @@
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) {
auto param = GetParam();
- ast::type::I32Type i32;
- ast::type::MultisampledTextureType t(param.dim, &i32);
+ ast::type::I32 i32;
+ ast::type::MultisampledTexture t(param.dim, &i32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<i32>");
@@ -367,8 +367,8 @@
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
auto param = GetParam();
- ast::type::U32Type u32;
- ast::type::MultisampledTextureType t(param.dim, &u32);
+ ast::type::U32 u32;
+ ast::type::MultisampledTexture t(param.dim, &u32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<u32>");
@@ -393,7 +393,7 @@
TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) {
auto param = GetParam();
- ast::type::StorageTextureType t(param.dim, param.access, param.fmt);
+ ast::type::StorageTexture t(param.dim, param.access, param.fmt);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), param.name);
@@ -496,14 +496,14 @@
ImageFormatData{ast::type::ImageFormat::kRgba32Float, "rgba32float"}));
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
- ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
ASSERT_TRUE(gen.EmitType(&sampler)) << gen.error();
EXPECT_EQ(gen.result(), "sampler");
}
TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) {
- ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler);
+ ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler);
ASSERT_TRUE(gen.EmitType(&sampler)) << gen.error();
EXPECT_EQ(gen.result(), "sampler_comparison");
diff --git a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc
index 7d19a1e..375e238 100644
--- a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc
@@ -31,7 +31,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
ast::VariableDeclStatement stmt(var);
@@ -46,7 +46,7 @@
// Variable declarations with Function storage class don't mention their
// storage class. Rely on defaulting.
// https://github.com/gpuweb/gpuweb/issues/654
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kFunction, &f32);
ast::VariableDeclStatement stmt(var);
@@ -58,7 +58,7 @@
}
TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
ast::VariableDeclStatement stmt(var);
diff --git a/src/writer/wgsl/generator_impl_variable_test.cc b/src/writer/wgsl/generator_impl_variable_test.cc
index 23b9adf..d342ba4 100644
--- a/src/writer/wgsl/generator_impl_variable_test.cc
+++ b/src/writer/wgsl/generator_impl_variable_test.cc
@@ -34,7 +34,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitVariable) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("a", ast::StorageClass::kNone, &f32);
ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error();
@@ -43,7 +43,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("a", ast::StorageClass::kInput, &f32);
ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error();
@@ -52,7 +52,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableDecorationList decos;
decos.push_back(create<ast::LocationDecoration>(2, Source{}));
@@ -68,7 +68,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::VariableDecorationList decos;
decos.push_back(
@@ -93,7 +93,7 @@
TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
auto* ident = create<ast::IdentifierExpression>("initializer");
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("a", ast::StorageClass::kNone, &f32);
v.set_constructor(ident);
@@ -105,7 +105,7 @@
TEST_F(WgslGeneratorImplTest, EmitVariable_Const) {
auto* ident = create<ast::IdentifierExpression>("initializer");
- ast::type::F32Type f32;
+ ast::type::F32 f32;
ast::Variable v("a", ast::StorageClass::kNone, &f32);
v.set_constructor(ident);
v.set_is_const(true);