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);