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>
This commit is contained in:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent 03ae9a397f
commit f1b0e1ee57
202 changed files with 3909 additions and 3998 deletions

View File

@@ -2013,7 +2013,7 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) {
if (!guard_name.empty()) {
// Declare the guard variable just before the "if", initialized to true.
auto* guard_var = create<ast::Variable>(
guard_name, ast::StorageClass::kFunction, parser_impl_.BoolType());
guard_name, ast::StorageClass::kFunction, parser_impl_.Bool());
guard_var->set_constructor(MakeTrue());
auto* guard_decl = create<ast::VariableDeclStatement>(guard_var);
AddStatement(guard_decl);
@@ -2700,8 +2700,8 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) {
// So represent a load by a new const definition.
auto expr = MakeExpression(inst.GetSingleWordInOperand(0));
// The load result type is the pointee type of its operand.
assert(expr.type->Is<ast::type::PointerType>());
expr.type = expr.type->As<ast::type::PointerType>()->type();
assert(expr.type->Is<ast::type::Pointer>());
expr.type = expr.type->As<ast::type::Pointer>()->type();
return EmitConstDefOrWriteToHoistedVar(inst, expr);
}
case SpvOpCopyObject: {
@@ -3061,7 +3061,7 @@ TypedExpression FunctionEmitter::MakeAccessChain(
type_mgr_->FindPointerToType(pointee_type_id, storage_class);
auto* ast_pointer_type = parser_impl_.ConvertType(pointer_type_id);
assert(ast_pointer_type);
assert(ast_pointer_type->Is<ast::type::PointerType>());
assert(ast_pointer_type->Is<ast::type::Pointer>());
current_expr = TypedExpression{ast_pointer_type, next_expr};
}
return current_expr;
@@ -3080,7 +3080,7 @@ TypedExpression FunctionEmitter::MakeCompositeExtract(
TypedExpression current_expr(MakeOperand(inst, 0));
auto make_index = [this](uint32_t literal) {
ast::type::U32Type u32;
ast::type::U32 u32;
return create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(&u32, literal));
};
@@ -3183,13 +3183,13 @@ TypedExpression FunctionEmitter::MakeCompositeExtract(
ast::Expression* FunctionEmitter::MakeTrue() const {
return create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(parser_impl_.BoolType(), true));
create<ast::BoolLiteral>(parser_impl_.Bool(), true));
}
ast::Expression* FunctionEmitter::MakeFalse() const {
ast::type::BoolType bool_type;
ast::type::Bool bool_type;
return create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(parser_impl_.BoolType(), false));
create<ast::BoolLiteral>(parser_impl_.Bool(), false));
}
TypedExpression FunctionEmitter::MakeVectorShuffle(
@@ -3207,8 +3207,8 @@ TypedExpression FunctionEmitter::MakeVectorShuffle(
// Generate an ast::TypeConstructor expression.
// Assume the literal indices are valid, and there is a valid number of them.
ast::type::VectorType* result_type =
parser_impl_.ConvertType(inst.type_id())->As<ast::type::VectorType>();
ast::type::Vector* result_type =
parser_impl_.ConvertType(inst.type_id())->As<ast::type::Vector>();
ast::ExpressionList values;
for (uint32_t i = 2; i < inst.NumInOperands(); ++i) {
const auto index = inst.GetSingleWordInOperand(i);
@@ -3257,9 +3257,9 @@ bool FunctionEmitter::RegisterLocallyDefinedValues() {
if (type) {
if (type->AsPointer()) {
const auto* ast_type = parser_impl_.ConvertType(inst.type_id());
if (ast_type && ast_type->As<ast::type::PointerType>()) {
if (ast_type && ast_type->As<ast::type::Pointer>()) {
info->storage_class =
ast_type->As<ast::type::PointerType>()->storage_class();
ast_type->As<ast::type::Pointer>()->storage_class();
}
switch (inst.opcode()) {
case SpvOpUndef:
@@ -3301,8 +3301,8 @@ ast::StorageClass FunctionEmitter::GetStorageClassForPointerValue(uint32_t id) {
const auto type_id = def_use_mgr_->GetDef(id)->type_id();
if (type_id) {
auto* ast_type = parser_impl_.ConvertType(type_id);
if (ast_type && ast_type->Is<ast::type::PointerType>()) {
return ast_type->As<ast::type::PointerType>()->storage_class();
if (ast_type && ast_type->Is<ast::type::Pointer>()) {
return ast_type->As<ast::type::Pointer>()->storage_class();
}
}
return ast::StorageClass::kNone;
@@ -3310,13 +3310,13 @@ ast::StorageClass FunctionEmitter::GetStorageClassForPointerValue(uint32_t id) {
ast::type::Type* FunctionEmitter::RemapStorageClass(ast::type::Type* type,
uint32_t result_id) {
if (type->Is<ast::type::PointerType>()) {
if (type->Is<ast::type::Pointer>()) {
// Remap an old-style storage buffer pointer to a new-style storage
// buffer pointer.
const auto* ast_ptr_type = type->As<ast::type::PointerType>();
const auto* ast_ptr_type = type->As<ast::type::Pointer>();
const auto sc = GetStorageClassForPointerValue(result_id);
if (ast_ptr_type->storage_class() != sc) {
return parser_impl_.get_module().create<ast::type::PointerType>(
return parser_impl_.get_module().create<ast::type::Pointer>(
ast_ptr_type->type(), sc);
}
}
@@ -3558,7 +3558,7 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) {
<< inst.PrettyPrint();
}
if (result_type->Is<ast::type::VoidType>()) {
if (result_type->Is<ast::type::Void>()) {
return nullptr != AddStatementForInstruction(
create<ast::CallStatement>(call_expr), inst);
}
@@ -3600,8 +3600,8 @@ TypedExpression FunctionEmitter::MakeSimpleSelect(
// - you can't select over pointers or pointer vectors, unless you also have
// a VariablePointers* capability, which is not allowed in by WebGPU.
auto* op_ty = operand1.type;
if (op_ty->Is<ast::type::VectorType>() || op_ty->is_float_scalar() ||
op_ty->is_integer_scalar() || op_ty->Is<ast::type::BoolType>()) {
if (op_ty->Is<ast::type::Vector>() || op_ty->is_float_scalar() ||
op_ty->is_integer_scalar() || op_ty->Is<ast::type::Bool>()) {
ast::ExpressionList params;
params.push_back(operand1.expr);
params.push_back(operand2.expr);
@@ -3711,14 +3711,13 @@ bool FunctionEmitter::EmitSampledImageAccess(
auto* lod_operand = MakeOperand(inst, arg_index).expr;
// When sampling from a depth texture, the Lod operand must be an unsigned
// integer.
if (ast::type::PointerType* type =
parser_impl_.GetTypeForHandleVar(*image)) {
if (ast::type::TextureType* texture_type =
type->type()->As<ast::type::TextureType>()) {
if (texture_type->Is<ast::type::DepthTextureType>()) {
if (ast::type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image)) {
if (ast::type::Texture* texture_type =
type->type()->As<ast::type::Texture>()) {
if (texture_type->Is<ast::type::DepthTexture>()) {
// Convert it to an unsigned integer type.
lod_operand = ast_module_.create<ast::TypeConstructorExpression>(
ast_module_.create<ast::type::U32Type>(),
ast_module_.create<ast::type::U32>(),
ast::ExpressionList{lod_operand});
}
}
@@ -3780,17 +3779,17 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
if (!raw_coords.type) {
return {};
}
ast::type::PointerType* type = parser_impl_.GetTypeForHandleVar(*image);
ast::type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image);
if (!parser_impl_.success()) {
Fail();
return {};
}
if (!type || !type->type()->Is<ast::type::TextureType>()) {
if (!type || !type->type()->Is<ast::type::Texture>()) {
Fail() << "invalid texture type for " << image->PrettyPrint();
return {};
}
ast::type::TextureDimension dim =
type->type()->As<ast::type::TextureType>()->dim();
type->type()->As<ast::type::Texture>()->dim();
// Number of regular coordinates.
uint32_t num_axes = 0;
bool is_arrayed = false;
@@ -3829,10 +3828,10 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
assert(num_axes <= 3);
const auto num_coords_required = num_axes + (is_arrayed ? 1 : 0);
uint32_t num_coords_supplied = 0;
if (raw_coords.type->Is<ast::type::F32Type>()) {
if (raw_coords.type->Is<ast::type::F32>()) {
num_coords_supplied = 1;
} else if (raw_coords.type->Is<ast::type::VectorType>()) {
num_coords_supplied = raw_coords.type->As<ast::type::VectorType>()->size();
} else if (raw_coords.type->Is<ast::type::Vector>()) {
num_coords_supplied = raw_coords.type->As<ast::type::Vector>()->size();
}
if (num_coords_supplied == 0) {
Fail() << "bad or unsupported coordinate type for image access: "
@@ -3867,7 +3866,7 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
Swizzle(num_axes));
// Convert it to an unsigned integer type.
result.push_back(ast_module_.create<ast::TypeConstructorExpression>(
ast_module_.create<ast::type::U32Type>(),
ast_module_.create<ast::type::U32>(),
ast::ExpressionList{array_index}));
} else {
if (num_coords_supplied == num_coords_required) {

View File

@@ -441,7 +441,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
)")) << ToString(fe.ast_body());
}
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType) {
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) {
auto p = parser(test::Assemble(
std::string("OpDecorate %arr2uint ArrayStride 16\n") + Preamble() + R"(
%ptr = OpTypePointer Function %arr2uint
@@ -508,7 +508,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
)")) << ToString(fe.ast_body());
}
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType_Null) {
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) {
auto p = parser(test::Assemble(
std::string("OpDecorate %arr2uint ArrayStride 16\n") + Preamble() + R"(
%ptr = OpTypePointer Function %arr2uint

View File

@@ -196,7 +196,7 @@ ParserImpl::ParserImpl(Context* ctx, const std::vector<uint32_t>& spv_binary)
: Reader(ctx),
spv_binary_(spv_binary),
fail_stream_(&success_, &errors_),
bool_type_(ast_module_.create<ast::type::BoolType>()),
bool_type_(ast_module_.create<ast::type::Bool>()),
namer_(fail_stream_),
enum_converter_(fail_stream_),
tools_context_(kInputEnv) {
@@ -285,7 +285,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
switch (spirv_type->kind()) {
case spvtools::opt::analysis::Type::kVoid:
return save(ast_module_.create<ast::type::VoidType>());
return save(ast_module_.create<ast::type::Void>());
case spvtools::opt::analysis::Type::kBool:
return save(bool_type_);
case spvtools::opt::analysis::Type::kInteger:
@@ -315,7 +315,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
case spvtools::opt::analysis::Type::kImage:
// Fake it for sampler and texture types. These are handled in an
// entirely different way.
return save(ast_module_.create<ast::type::VoidType>());
return save(ast_module_.create<ast::type::Void>());
default:
break;
}
@@ -648,8 +648,8 @@ bool ParserImpl::RegisterEntryPoints() {
ast::type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Integer* int_ty) {
if (int_ty->width() == 32) {
ast::type::Type* signed_ty = ast_module_.create<ast::type::I32Type>();
ast::type::Type* unsigned_ty = ast_module_.create<ast::type::U32Type>();
ast::type::Type* signed_ty = ast_module_.create<ast::type::I32>();
ast::type::Type* unsigned_ty = ast_module_.create<ast::type::U32>();
signed_type_for_[unsigned_ty] = signed_ty;
unsigned_type_for_[signed_ty] = unsigned_ty;
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
@@ -661,7 +661,7 @@ ast::type::Type* ParserImpl::ConvertType(
ast::type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Float* float_ty) {
if (float_ty->width() == 32) {
return ast_module_.create<ast::type::F32Type>();
return ast_module_.create<ast::type::F32>();
}
Fail() << "unhandled float width: " << float_ty->width();
return nullptr;
@@ -674,16 +674,15 @@ ast::type::Type* ParserImpl::ConvertType(
if (ast_elem_ty == nullptr) {
return nullptr;
}
auto* this_ty =
ast_module_.create<ast::type::VectorType>(ast_elem_ty, num_elem);
auto* this_ty = ast_module_.create<ast::type::Vector>(ast_elem_ty, num_elem);
// Generate the opposite-signedness vector type, if this type is integral.
if (unsigned_type_for_.count(ast_elem_ty)) {
auto* other_ty = ast_module_.create<ast::type::VectorType>(
auto* other_ty = ast_module_.create<ast::type::Vector>(
unsigned_type_for_[ast_elem_ty], num_elem);
signed_type_for_[other_ty] = this_ty;
unsigned_type_for_[this_ty] = other_ty;
} else if (signed_type_for_.count(ast_elem_ty)) {
auto* other_ty = ast_module_.create<ast::type::VectorType>(
auto* other_ty = ast_module_.create<ast::type::Vector>(
signed_type_for_[ast_elem_ty], num_elem);
unsigned_type_for_[other_ty] = this_ty;
signed_type_for_[this_ty] = other_ty;
@@ -701,8 +700,8 @@ ast::type::Type* ParserImpl::ConvertType(
if (ast_scalar_ty == nullptr) {
return nullptr;
}
return ast_module_.create<ast::type::MatrixType>(ast_scalar_ty, num_rows,
num_columns);
return ast_module_.create<ast::type::Matrix>(ast_scalar_ty, num_rows,
num_columns);
}
ast::type::Type* ParserImpl::ConvertType(
@@ -711,7 +710,7 @@ ast::type::Type* ParserImpl::ConvertType(
if (ast_elem_ty == nullptr) {
return nullptr;
}
auto ast_type = std::make_unique<ast::type::ArrayType>(ast_elem_ty);
auto ast_type = std::make_unique<ast::type::Array>(ast_elem_ty);
if (!ApplyArrayDecorations(rtarr_ty, ast_type.get())) {
return nullptr;
}
@@ -752,7 +751,7 @@ ast::type::Type* ParserImpl::ConvertType(
<< num_elem;
return nullptr;
}
auto ast_type = std::make_unique<ast::type::ArrayType>(
auto ast_type = std::make_unique<ast::type::Array>(
ast_elem_ty, static_cast<uint32_t>(num_elem));
if (!ApplyArrayDecorations(arr_ty, ast_type.get())) {
return nullptr;
@@ -765,7 +764,7 @@ ast::type::Type* ParserImpl::ConvertType(
bool ParserImpl::ApplyArrayDecorations(
const spvtools::opt::analysis::Type* spv_type,
ast::type::ArrayType* ast_type) {
ast::type::Array* ast_type) {
const auto type_id = type_mgr_->GetId(spv_type);
for (auto& decoration : this->GetDecorationsFor(type_id)) {
if (decoration.size() == 2 && decoration[0] == SpvDecorationArrayStride) {
@@ -886,8 +885,8 @@ ast::type::Type* ParserImpl::ConvertType(
namer_.SuggestSanitizedName(type_id, "S");
auto* result = ast_module_.create<ast::type::StructType>(
namer_.GetName(type_id), ast_struct);
auto* result = ast_module_.create<ast::type::Struct>(namer_.GetName(type_id),
ast_struct);
id_to_type_[type_id] = result;
if (num_non_writable_members == members.size()) {
read_only_struct_types_.insert(result);
@@ -927,8 +926,7 @@ ast::type::Type* ParserImpl::ConvertType(
ast_storage_class = ast::StorageClass::kStorageBuffer;
remap_buffer_block_type_.insert(type_id);
}
return ast_module_.create<ast::type::PointerType>(ast_elem_ty,
ast_storage_class);
return ast_module_.create<ast::type::Pointer>(ast_elem_ty, ast_storage_class);
}
bool ParserImpl::RegisterTypes() {
@@ -975,15 +973,15 @@ bool ParserImpl::EmitScalarSpecConstants() {
case SpvOpSpecConstant: {
ast_type = ConvertType(inst.type_id());
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
if (ast_type->Is<ast::type::I32Type>()) {
if (ast_type->Is<ast::type::I32>()) {
ast_expr =
create<ast::ScalarConstructorExpression>(create<ast::SintLiteral>(
ast_type, static_cast<int32_t>(literal_value)));
} else if (ast_type->Is<ast::type::U32Type>()) {
} else if (ast_type->Is<ast::type::U32>()) {
ast_expr =
create<ast::ScalarConstructorExpression>(create<ast::UintLiteral>(
ast_type, static_cast<uint32_t>(literal_value)));
} else if (ast_type->Is<ast::type::F32Type>()) {
} else if (ast_type->Is<ast::type::F32>()) {
float float_value;
// Copy the bits so we can read them as a float.
std::memcpy(&float_value, &literal_value, sizeof(float_value));
@@ -1058,7 +1056,7 @@ void ParserImpl::MaybeGenerateAlias(uint32_t type_id,
}
const auto name = namer_.GetName(type_id);
auto* ast_alias_type =
ast_module_.create<ast::type::AliasType>(name, ast_underlying_type);
ast_module_.create<ast::type::Alias>(name, ast_underlying_type);
// Record this new alias as the AST type for this SPIR-V ID.
id_to_type_[type_id] = ast_alias_type;
ast_module_.AddConstructedType(ast_alias_type);
@@ -1116,15 +1114,15 @@ bool ParserImpl::EmitModuleScopeVariables() {
"SPIR-V type with ID: "
<< var.type_id();
}
if (!ast_type->Is<ast::type::PointerType>()) {
if (!ast_type->Is<ast::type::Pointer>()) {
return Fail() << "variable with ID " << var.result_id()
<< " has non-pointer type " << var.type_id();
}
}
auto* ast_store_type = ast_type->As<ast::type::PointerType>()->type();
auto* ast_store_type = ast_type->As<ast::type::Pointer>()->type();
auto ast_storage_class =
ast_type->As<ast::type::PointerType>()->storage_class();
ast_type->As<ast::type::Pointer>()->storage_class();
auto* ast_var =
MakeVariable(var.result_id(), ast_storage_class, ast_store_type);
if (var.NumInOperands() > 1) {
@@ -1170,7 +1168,7 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id,
auto access = read_only_struct_types_.count(type)
? ast::AccessControl::kReadOnly
: ast::AccessControl::kReadWrite;
type = ast_module_.create<ast::type::AccessControlType>(access, type);
type = ast_module_.create<ast::type::AccessControl>(access, type);
}
auto* ast_var = create<ast::Variable>(namer_.Name(id), sc, type);
@@ -1263,22 +1261,22 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
// So canonicalization should map that way too.
// Currently "null<type>" is missing from the WGSL parser.
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
if (ast_type->Is<ast::type::U32Type>()) {
if (ast_type->Is<ast::type::U32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(ast_type, spirv_const->GetU32()))};
}
if (ast_type->Is<ast::type::I32Type>()) {
if (ast_type->Is<ast::type::I32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(ast_type, spirv_const->GetS32()))};
}
if (ast_type->Is<ast::type::F32Type>()) {
if (ast_type->Is<ast::type::F32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(ast_type, spirv_const->GetFloat()))};
}
if (ast_type->Is<ast::type::BoolType>()) {
if (ast_type->Is<ast::type::Bool>()) {
const bool value = spirv_const->AsNullConstant()
? false
: spirv_const->AsBoolConstant()->value();
@@ -1335,24 +1333,24 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
auto* original_type = type;
type = type->UnwrapIfNeeded();
if (type->Is<ast::type::BoolType>()) {
if (type->Is<ast::type::Bool>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(type, false));
}
if (type->Is<ast::type::U32Type>()) {
if (type->Is<ast::type::U32>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(type, 0u));
}
if (type->Is<ast::type::I32Type>()) {
if (type->Is<ast::type::I32>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(type, 0));
}
if (type->Is<ast::type::F32Type>()) {
if (type->Is<ast::type::F32>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(type, 0.0f));
}
if (type->Is<ast::type::VectorType>()) {
const auto* vec_ty = type->As<ast::type::VectorType>();
if (type->Is<ast::type::Vector>()) {
const auto* vec_ty = type->As<ast::type::Vector>();
ast::ExpressionList ast_components;
for (size_t i = 0; i < vec_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(vec_ty->type()));
@@ -1360,11 +1358,11 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
return create<ast::TypeConstructorExpression>(type,
std::move(ast_components));
}
if (type->Is<ast::type::MatrixType>()) {
const auto* mat_ty = type->As<ast::type::MatrixType>();
if (type->Is<ast::type::Matrix>()) {
const auto* mat_ty = type->As<ast::type::Matrix>();
// Matrix components are columns
auto* column_ty = ast_module_.create<ast::type::VectorType>(mat_ty->type(),
mat_ty->rows());
auto* column_ty =
ast_module_.create<ast::type::Vector>(mat_ty->type(), mat_ty->rows());
ast::ExpressionList ast_components;
for (size_t i = 0; i < mat_ty->columns(); ++i) {
ast_components.emplace_back(MakeNullValue(column_ty));
@@ -1372,8 +1370,8 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
return create<ast::TypeConstructorExpression>(type,
std::move(ast_components));
}
if (type->Is<ast::type::ArrayType>()) {
auto* arr_ty = type->As<ast::type::ArrayType>();
if (type->Is<ast::type::Array>()) {
auto* arr_ty = type->As<ast::type::Array>();
ast::ExpressionList ast_components;
for (size_t i = 0; i < arr_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
@@ -1381,8 +1379,8 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
return create<ast::TypeConstructorExpression>(original_type,
std::move(ast_components));
}
if (type->Is<ast::type::StructType>()) {
auto* struct_ty = type->As<ast::type::StructType>();
if (type->Is<ast::type::Struct>()) {
auto* struct_ty = type->As<ast::type::Struct>();
ast::ExpressionList ast_components;
for (auto* member : struct_ty->impl()->members()) {
ast_components.emplace_back(MakeNullValue(member->type()));
@@ -1445,14 +1443,14 @@ ast::type::Type* ParserImpl::GetSignedIntMatchingShape(ast::type::Type* other) {
if (other == nullptr) {
Fail() << "no type provided";
}
auto* i32 = ast_module_.create<ast::type::I32Type>();
if (other->Is<ast::type::F32Type>() || other->Is<ast::type::U32Type>() ||
other->Is<ast::type::I32Type>()) {
auto* i32 = ast_module_.create<ast::type::I32>();
if (other->Is<ast::type::F32>() || other->Is<ast::type::U32>() ||
other->Is<ast::type::I32>()) {
return i32;
}
auto* vec_ty = other->As<ast::type::VectorType>();
auto* vec_ty = other->As<ast::type::Vector>();
if (vec_ty) {
return ast_module_.create<ast::type::VectorType>(i32, vec_ty->size());
return ast_module_.create<ast::type::Vector>(i32, vec_ty->size());
}
Fail() << "required numeric scalar or vector, but got " << other->type_name();
return nullptr;
@@ -1464,14 +1462,14 @@ ast::type::Type* ParserImpl::GetUnsignedIntMatchingShape(
Fail() << "no type provided";
return nullptr;
}
auto* u32 = ast_module_.create<ast::type::U32Type>();
if (other->Is<ast::type::F32Type>() || other->Is<ast::type::U32Type>() ||
other->Is<ast::type::I32Type>()) {
auto* u32 = ast_module_.create<ast::type::U32>();
if (other->Is<ast::type::F32>() || other->Is<ast::type::U32>() ||
other->Is<ast::type::I32>()) {
return u32;
}
auto* vec_ty = other->As<ast::type::VectorType>();
auto* vec_ty = other->As<ast::type::Vector>();
if (vec_ty) {
return ast_module_.create<ast::type::VectorType>(u32, vec_ty->size());
return ast_module_.create<ast::type::Vector>(u32, vec_ty->size());
}
Fail() << "required numeric scalar or vector, but got " << other->type_name();
return nullptr;
@@ -1603,7 +1601,7 @@ ParserImpl::GetMemoryObjectDeclarationForHandle(uint32_t id,
}
}
ast::type::PointerType* ParserImpl::GetTypeForHandleVar(
ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
const spvtools::opt::Instruction& var) {
if (!success()) {
return nullptr;
@@ -1726,7 +1724,7 @@ ast::type::PointerType* ParserImpl::GetTypeForHandleVar(
// Construct the Tint handle type.
ast::type::Type* ast_store_type = nullptr;
if (usage.IsSampler()) {
ast_store_type = ast_module_.create<ast::type::SamplerType>(
ast_store_type = ast_module_.create<ast::type::Sampler>(
usage.IsComparisonSampler() ? ast::type::SamplerKind::kComparisonSampler
: ast::type::SamplerKind::kSampler);
} else if (usage.IsTexture()) {
@@ -1757,13 +1755,13 @@ ast::type::PointerType* ParserImpl::GetTypeForHandleVar(
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
// treat that as a depth texture.
if (image_type->depth() || usage.IsDepthTexture()) {
ast_store_type = ast_module_.create<ast::type::DepthTextureType>(dim);
ast_store_type = ast_module_.create<ast::type::DepthTexture>(dim);
} else if (image_type->is_multisampled()) {
// Multisampled textures are never depth textures.
ast_store_type = ast_module_.create<ast::type::MultisampledTextureType>(
ast_store_type = ast_module_.create<ast::type::MultisampledTexture>(
dim, ast_sampled_component_type);
} else {
ast_store_type = ast_module_.create<ast::type::SampledTextureType>(
ast_store_type = ast_module_.create<ast::type::SampledTexture>(
dim, ast_sampled_component_type);
}
} else {
@@ -1774,8 +1772,8 @@ ast::type::PointerType* ParserImpl::GetTypeForHandleVar(
if (format == ast::type::ImageFormat::kNone) {
return nullptr;
}
ast_store_type = ast_module_.create<ast::type::StorageTextureType>(
dim, access, format);
ast_store_type =
ast_module_.create<ast::type::StorageTexture>(dim, access, format);
}
} else {
Fail() << "unsupported: UniformConstant variable is not a recognized "
@@ -1785,7 +1783,7 @@ ast::type::PointerType* ParserImpl::GetTypeForHandleVar(
}
// Form the pointer type.
auto* result = ast_module_.create<ast::type::PointerType>(
auto* result = ast_module_.create<ast::type::Pointer>(
ast_store_type, ast::StorageClass::kUniformConstant);
// Remember it for later.
handle_type_[&var] = result;

View File

@@ -357,7 +357,7 @@ class ParserImpl : Reader {
ast::type::Type* first_operand_type);
/// @returns the registered boolean type.
ast::type::Type* BoolType() const { return bool_type_; }
ast::type::Type* Bool() const { return bool_type_; }
/// Bookkeeping used for tracking the "position" builtin variable.
struct BuiltInPositionInfo {
@@ -433,7 +433,7 @@ class ParserImpl : Reader {
/// @param var the OpVariable instruction
/// @returns the Tint AST type for the poiner-to-{sampler|texture} or null on
/// error
ast::type::PointerType* GetTypeForHandleVar(
ast::type::Pointer* GetTypeForHandleVar(
const spvtools::opt::Instruction& var);
/// Returns the SPIR-V instruction with the given ID, or nullptr.
@@ -484,7 +484,7 @@ class ParserImpl : Reader {
/// @param ast_type non-null; the AST type to apply decorations to
/// @returns true on success.
bool ApplyArrayDecorations(const spvtools::opt::analysis::Type* spv_type,
ast::type::ArrayType* ast_type);
ast::type::Array* ast_type);
/// Creates a new `ast::Node` owned by the Module. When the Module is
/// destructed, the `ast::Node` will also be destructed.
@@ -592,7 +592,7 @@ class ParserImpl : Reader {
// usages implied by usages of the memory-object-declaration.
std::unordered_map<const spvtools::opt::Instruction*, Usage> handle_usage_;
// The inferred pointer type for the given handle variable.
std::unordered_map<const spvtools::opt::Instruction*, ast::type::PointerType*>
std::unordered_map<const spvtools::opt::Instruction*, ast::type::Pointer*>
handle_type_;
};

View File

@@ -92,7 +92,7 @@ TEST_F(SpvParserTest, ConvertType_Void) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
EXPECT_TRUE(type->Is<ast::type::VoidType>());
EXPECT_TRUE(type->Is<ast::type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -101,7 +101,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(100);
EXPECT_TRUE(type->Is<ast::type::BoolType>());
EXPECT_TRUE(type->Is<ast::type::Bool>());
EXPECT_TRUE(p->error().empty());
}
@@ -110,7 +110,7 @@ TEST_F(SpvParserTest, ConvertType_I32) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(2);
EXPECT_TRUE(type->Is<ast::type::I32Type>());
EXPECT_TRUE(type->Is<ast::type::I32>());
EXPECT_TRUE(p->error().empty());
}
@@ -119,7 +119,7 @@ TEST_F(SpvParserTest, ConvertType_U32) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::U32Type>());
EXPECT_TRUE(type->Is<ast::type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -128,7 +128,7 @@ TEST_F(SpvParserTest, ConvertType_F32) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(4);
EXPECT_TRUE(type->Is<ast::type::F32Type>());
EXPECT_TRUE(type->Is<ast::type::F32>());
EXPECT_TRUE(p->error().empty());
}
@@ -172,22 +172,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) {
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xf32 = p->ConvertType(20);
EXPECT_TRUE(v2xf32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v2xf32->As<ast::type::VectorType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(v2xf32->As<ast::type::VectorType>()->size(), 2u);
EXPECT_TRUE(v2xf32->Is<ast::type::Vector>());
EXPECT_TRUE(v2xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
EXPECT_EQ(v2xf32->As<ast::type::Vector>()->size(), 2u);
auto* v3xf32 = p->ConvertType(30);
EXPECT_TRUE(v3xf32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v3xf32->As<ast::type::VectorType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(v3xf32->As<ast::type::VectorType>()->size(), 3u);
EXPECT_TRUE(v3xf32->Is<ast::type::Vector>());
EXPECT_TRUE(v3xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
EXPECT_EQ(v3xf32->As<ast::type::Vector>()->size(), 3u);
auto* v4xf32 = p->ConvertType(40);
EXPECT_TRUE(v4xf32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v4xf32->As<ast::type::VectorType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(v4xf32->As<ast::type::VectorType>()->size(), 4u);
EXPECT_TRUE(v4xf32->Is<ast::type::Vector>());
EXPECT_TRUE(v4xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
EXPECT_EQ(v4xf32->As<ast::type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -202,22 +199,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) {
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xi32 = p->ConvertType(20);
EXPECT_TRUE(v2xi32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v2xi32->As<ast::type::VectorType>()->type()->Is<ast::type::I32Type>());
EXPECT_EQ(v2xi32->As<ast::type::VectorType>()->size(), 2u);
EXPECT_TRUE(v2xi32->Is<ast::type::Vector>());
EXPECT_TRUE(v2xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
EXPECT_EQ(v2xi32->As<ast::type::Vector>()->size(), 2u);
auto* v3xi32 = p->ConvertType(30);
EXPECT_TRUE(v3xi32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v3xi32->As<ast::type::VectorType>()->type()->Is<ast::type::I32Type>());
EXPECT_EQ(v3xi32->As<ast::type::VectorType>()->size(), 3u);
EXPECT_TRUE(v3xi32->Is<ast::type::Vector>());
EXPECT_TRUE(v3xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
EXPECT_EQ(v3xi32->As<ast::type::Vector>()->size(), 3u);
auto* v4xi32 = p->ConvertType(40);
EXPECT_TRUE(v4xi32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v4xi32->As<ast::type::VectorType>()->type()->Is<ast::type::I32Type>());
EXPECT_EQ(v4xi32->As<ast::type::VectorType>()->size(), 4u);
EXPECT_TRUE(v4xi32->Is<ast::type::Vector>());
EXPECT_TRUE(v4xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
EXPECT_EQ(v4xi32->As<ast::type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -232,22 +226,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) {
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xu32 = p->ConvertType(20);
EXPECT_TRUE(v2xu32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v2xu32->As<ast::type::VectorType>()->type()->Is<ast::type::U32Type>());
EXPECT_EQ(v2xu32->As<ast::type::VectorType>()->size(), 2u);
EXPECT_TRUE(v2xu32->Is<ast::type::Vector>());
EXPECT_TRUE(v2xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
EXPECT_EQ(v2xu32->As<ast::type::Vector>()->size(), 2u);
auto* v3xu32 = p->ConvertType(30);
EXPECT_TRUE(v3xu32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v3xu32->As<ast::type::VectorType>()->type()->Is<ast::type::U32Type>());
EXPECT_EQ(v3xu32->As<ast::type::VectorType>()->size(), 3u);
EXPECT_TRUE(v3xu32->Is<ast::type::Vector>());
EXPECT_TRUE(v3xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
EXPECT_EQ(v3xu32->As<ast::type::Vector>()->size(), 3u);
auto* v4xu32 = p->ConvertType(40);
EXPECT_TRUE(v4xu32->Is<ast::type::VectorType>());
EXPECT_TRUE(
v4xu32->As<ast::type::VectorType>()->type()->Is<ast::type::U32Type>());
EXPECT_EQ(v4xu32->As<ast::type::VectorType>()->size(), 4u);
EXPECT_TRUE(v4xu32->Is<ast::type::Vector>());
EXPECT_TRUE(v4xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
EXPECT_EQ(v4xu32->As<ast::type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -287,67 +278,58 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) {
EXPECT_TRUE(p->BuildInternalModule());
auto* m22 = p->ConvertType(22);
EXPECT_TRUE(m22->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m22->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m22->As<ast::type::MatrixType>()->rows(), 2u);
EXPECT_EQ(m22->As<ast::type::MatrixType>()->columns(), 2u);
EXPECT_TRUE(m22->Is<ast::type::Matrix>());
EXPECT_TRUE(m22->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m22->As<ast::type::Matrix>()->rows(), 2u);
EXPECT_EQ(m22->As<ast::type::Matrix>()->columns(), 2u);
auto* m23 = p->ConvertType(23);
EXPECT_TRUE(m23->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m23->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m23->As<ast::type::MatrixType>()->rows(), 2u);
EXPECT_EQ(m23->As<ast::type::MatrixType>()->columns(), 3u);
EXPECT_TRUE(m23->Is<ast::type::Matrix>());
EXPECT_TRUE(m23->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m23->As<ast::type::Matrix>()->rows(), 2u);
EXPECT_EQ(m23->As<ast::type::Matrix>()->columns(), 3u);
auto* m24 = p->ConvertType(24);
EXPECT_TRUE(m24->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m24->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m24->As<ast::type::MatrixType>()->rows(), 2u);
EXPECT_EQ(m24->As<ast::type::MatrixType>()->columns(), 4u);
EXPECT_TRUE(m24->Is<ast::type::Matrix>());
EXPECT_TRUE(m24->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m24->As<ast::type::Matrix>()->rows(), 2u);
EXPECT_EQ(m24->As<ast::type::Matrix>()->columns(), 4u);
auto* m32 = p->ConvertType(32);
EXPECT_TRUE(m32->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m32->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m32->As<ast::type::MatrixType>()->rows(), 3u);
EXPECT_EQ(m32->As<ast::type::MatrixType>()->columns(), 2u);
EXPECT_TRUE(m32->Is<ast::type::Matrix>());
EXPECT_TRUE(m32->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m32->As<ast::type::Matrix>()->rows(), 3u);
EXPECT_EQ(m32->As<ast::type::Matrix>()->columns(), 2u);
auto* m33 = p->ConvertType(33);
EXPECT_TRUE(m33->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m33->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m33->As<ast::type::MatrixType>()->rows(), 3u);
EXPECT_EQ(m33->As<ast::type::MatrixType>()->columns(), 3u);
EXPECT_TRUE(m33->Is<ast::type::Matrix>());
EXPECT_TRUE(m33->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m33->As<ast::type::Matrix>()->rows(), 3u);
EXPECT_EQ(m33->As<ast::type::Matrix>()->columns(), 3u);
auto* m34 = p->ConvertType(34);
EXPECT_TRUE(m34->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m34->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m34->As<ast::type::MatrixType>()->rows(), 3u);
EXPECT_EQ(m34->As<ast::type::MatrixType>()->columns(), 4u);
EXPECT_TRUE(m34->Is<ast::type::Matrix>());
EXPECT_TRUE(m34->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m34->As<ast::type::Matrix>()->rows(), 3u);
EXPECT_EQ(m34->As<ast::type::Matrix>()->columns(), 4u);
auto* m42 = p->ConvertType(42);
EXPECT_TRUE(m42->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m42->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m42->As<ast::type::MatrixType>()->rows(), 4u);
EXPECT_EQ(m42->As<ast::type::MatrixType>()->columns(), 2u);
EXPECT_TRUE(m42->Is<ast::type::Matrix>());
EXPECT_TRUE(m42->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m42->As<ast::type::Matrix>()->rows(), 4u);
EXPECT_EQ(m42->As<ast::type::Matrix>()->columns(), 2u);
auto* m43 = p->ConvertType(43);
EXPECT_TRUE(m43->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m43->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m43->As<ast::type::MatrixType>()->rows(), 4u);
EXPECT_EQ(m43->As<ast::type::MatrixType>()->columns(), 3u);
EXPECT_TRUE(m43->Is<ast::type::Matrix>());
EXPECT_TRUE(m43->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m43->As<ast::type::Matrix>()->rows(), 4u);
EXPECT_EQ(m43->As<ast::type::Matrix>()->columns(), 3u);
auto* m44 = p->ConvertType(44);
EXPECT_TRUE(m44->Is<ast::type::MatrixType>());
EXPECT_TRUE(
m44->As<ast::type::MatrixType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(m44->As<ast::type::MatrixType>()->rows(), 4u);
EXPECT_EQ(m44->As<ast::type::MatrixType>()->columns(), 4u);
EXPECT_TRUE(m44->Is<ast::type::Matrix>());
EXPECT_TRUE(m44->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
EXPECT_EQ(m44->As<ast::type::Matrix>()->rows(), 4u);
EXPECT_EQ(m44->As<ast::type::Matrix>()->columns(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -361,8 +343,8 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<ast::type::ArrayType>());
auto* arr_type = type->As<ast::type::ArrayType>();
EXPECT_TRUE(type->Is<ast::type::Array>());
auto* arr_type = type->As<ast::type::Array>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 0u);
@@ -370,7 +352,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
EXPECT_FALSE(arr_type->has_array_stride());
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
EXPECT_TRUE(elem_type->Is<ast::type::U32Type>());
EXPECT_TRUE(elem_type->Is<ast::type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -397,7 +379,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
auto* arr_type = type->As<ast::type::ArrayType>();
auto* arr_type = type->As<ast::type::Array>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->array_stride(), 64u);
@@ -443,8 +425,8 @@ TEST_F(SpvParserTest, ConvertType_Array) {
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<ast::type::ArrayType>());
auto* arr_type = type->As<ast::type::ArrayType>();
EXPECT_TRUE(type->Is<ast::type::Array>());
auto* arr_type = type->As<ast::type::Array>();
EXPECT_FALSE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 42u);
@@ -452,7 +434,7 @@ TEST_F(SpvParserTest, ConvertType_Array) {
EXPECT_FALSE(arr_type->has_array_stride());
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
EXPECT_TRUE(elem_type->Is<ast::type::U32Type>());
EXPECT_TRUE(elem_type->Is<ast::type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -531,8 +513,8 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) {
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<ast::type::ArrayType>());
auto* arr_type = type->As<ast::type::ArrayType>();
EXPECT_TRUE(type->Is<ast::type::Array>());
auto* arr_type = type->As<ast::type::Array>();
ASSERT_NE(arr_type, nullptr);
ASSERT_EQ(arr_type->array_stride(), 8u);
EXPECT_TRUE(arr_type->has_array_stride());
@@ -581,9 +563,9 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<ast::type::StructType>());
EXPECT_TRUE(type->Is<ast::type::Struct>());
std::stringstream ss;
type->As<ast::type::StructType>()->impl()->to_str(ss, 0);
type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(ss.str(), Eq(R"(Struct{
StructMember{field0: __u32}
StructMember{field1: __f32}
@@ -602,9 +584,9 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<ast::type::StructType>());
EXPECT_TRUE(type->Is<ast::type::Struct>());
std::stringstream ss;
type->As<ast::type::StructType>()->impl()->to_str(ss, 0);
type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(ss.str(), Eq(R"(Struct{
[[block]]
StructMember{field0: __u32}
@@ -627,9 +609,9 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
EXPECT_TRUE(type->Is<ast::type::StructType>());
EXPECT_TRUE(type->Is<ast::type::Struct>());
std::stringstream ss;
type->As<ast::type::StructType>()->impl()->to_str(ss, 0);
type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(ss.str(), Eq(R"(Struct{
StructMember{[[ offset 0 ]] field0: __f32}
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
@@ -676,10 +658,10 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
EXPECT_TRUE(p->error().empty());
}
@@ -692,10 +674,10 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput);
EXPECT_TRUE(p->error().empty());
}
@@ -708,10 +690,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform);
EXPECT_TRUE(p->error().empty());
}
@@ -724,10 +706,10 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup);
EXPECT_TRUE(p->error().empty());
}
@@ -740,10 +722,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant);
EXPECT_TRUE(p->error().empty());
}
@@ -756,10 +738,10 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorageBuffer);
EXPECT_TRUE(p->error().empty());
}
@@ -772,10 +754,10 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage);
EXPECT_TRUE(p->error().empty());
}
@@ -788,10 +770,10 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate);
EXPECT_TRUE(p->error().empty());
}
@@ -804,10 +786,10 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
auto* ptr_ty = type->As<ast::type::PointerType>();
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction);
EXPECT_TRUE(p->error().empty());
}
@@ -823,17 +805,17 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) {
auto* type = p->ConvertType(3);
EXPECT_NE(type, nullptr);
EXPECT_TRUE(type->Is<ast::type::PointerType>());
EXPECT_TRUE(type->Is<ast::type::Pointer>());
auto* ptr_ty = type->As<ast::type::PointerType>();
auto* ptr_ty = type->As<ast::type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::PointerType>());
EXPECT_TRUE(ptr_ty->type()->Is<ast::type::Pointer>());
auto* ptr_ptr_ty = ptr_ty->type()->As<ast::type::PointerType>();
auto* ptr_ptr_ty = ptr_ty->type()->As<ast::type::Pointer>();
EXPECT_NE(ptr_ptr_ty, nullptr);
EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput);
EXPECT_TRUE(ptr_ptr_ty->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(ptr_ptr_ty->type()->Is<ast::type::F32>());
EXPECT_TRUE(p->error().empty());
}
@@ -846,7 +828,7 @@ TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
EXPECT_TRUE(type->Is<ast::type::VoidType>());
EXPECT_TRUE(type->Is<ast::type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -859,7 +841,7 @@ TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
EXPECT_TRUE(type->Is<ast::type::VoidType>());
EXPECT_TRUE(type->Is<ast::type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -872,7 +854,7 @@ TEST_F(SpvParserTest, ConvertType_SampledImage_PretendVoid) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
EXPECT_TRUE(type->Is<ast::type::VoidType>());
EXPECT_TRUE(type->Is<ast::type::Void>());
EXPECT_TRUE(p->error().empty());
}

View File

@@ -318,7 +318,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
return Failure::kErrored;
auto* type = module_.unique_type(std::move(str.value));
register_constructed(type->As<ast::type::StructType>()->name(), type);
register_constructed(type->As<ast::type::Struct>()->name(), type);
module_.AddConstructedType(type);
return true;
}
@@ -471,8 +471,7 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
if (subtype.errored)
return Failure::kErrored;
return module_.create<ast::type::SampledTextureType>(dim.value,
subtype.value);
return module_.create<ast::type::SampledTexture>(dim.value, subtype.value);
}
auto ms_dim = multisampled_texture_type();
@@ -483,8 +482,8 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
if (subtype.errored)
return Failure::kErrored;
return module_.create<ast::type::MultisampledTextureType>(ms_dim.value,
subtype.value);
return module_.create<ast::type::MultisampledTexture>(ms_dim.value,
subtype.value);
}
auto storage = storage_texture_type();
@@ -497,7 +496,7 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
if (format.errored)
return Failure::kErrored;
return module_.create<ast::type::StorageTextureType>(
return module_.create<ast::type::StorageTexture>(
storage->first, storage->second, format.value);
}
@@ -509,11 +508,10 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
// | SAMPLER_COMPARISON
Maybe<ast::type::Type*> ParserImpl::sampler_type() {
if (match(Token::Type::kSampler))
return module_.create<ast::type::SamplerType>(
ast::type::SamplerKind::kSampler);
return module_.create<ast::type::Sampler>(ast::type::SamplerKind::kSampler);
if (match(Token::Type::kComparisonSampler))
return module_.create<ast::type::SamplerType>(
return module_.create<ast::type::Sampler>(
ast::type::SamplerKind::kComparisonSampler);
return Failure::kNoMatch;
@@ -642,19 +640,19 @@ ParserImpl::storage_texture_type() {
// | TEXTURE_DEPTH_CUBE_ARRAY
Maybe<ast::type::Type*> ParserImpl::depth_texture_type() {
if (match(Token::Type::kTextureDepth2d))
return module_.create<ast::type::DepthTextureType>(
return module_.create<ast::type::DepthTexture>(
ast::type::TextureDimension::k2d);
if (match(Token::Type::kTextureDepth2dArray))
return module_.create<ast::type::DepthTextureType>(
return module_.create<ast::type::DepthTexture>(
ast::type::TextureDimension::k2dArray);
if (match(Token::Type::kTextureDepthCube))
return module_.create<ast::type::DepthTextureType>(
return module_.create<ast::type::DepthTexture>(
ast::type::TextureDimension::kCube);
if (match(Token::Type::kTextureDepthCubeArray))
return module_.create<ast::type::DepthTextureType>(
return module_.create<ast::type::DepthTexture>(
ast::type::TextureDimension::kCubeArray);
return Failure::kNoMatch;
@@ -840,7 +838,7 @@ Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_variable_ident_decl(
for (auto* deco : access_decos) {
// If we have an access control decoration then we take it and wrap our
// type up with that decoration
ty = module_.create<ast::type::AccessControlType>(
ty = module_.create<ast::type::AccessControl>(
deco->As<ast::AccessDecoration>()->value(), ty);
}
@@ -900,7 +898,7 @@ Maybe<ast::type::Type*> ParserImpl::type_alias() {
if (!type.matched)
return add_error(peek(), "invalid type alias");
auto* alias = module_.create<ast::type::AliasType>(name.value, type.value);
auto* alias = module_.create<ast::type::Alias>(name.value, type.value);
register_constructed(name.value, alias);
return alias;
@@ -958,16 +956,16 @@ Maybe<ast::type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
}
if (match(Token::Type::kBool))
return module_.create<ast::type::BoolType>();
return module_.create<ast::type::Bool>();
if (match(Token::Type::kF32))
return module_.create<ast::type::F32Type>();
return module_.create<ast::type::F32>();
if (match(Token::Type::kI32))
return module_.create<ast::type::I32Type>();
return module_.create<ast::type::I32>();
if (match(Token::Type::kU32))
return module_.create<ast::type::U32Type>();
return module_.create<ast::type::U32>();
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
next(); // Consume the peek
@@ -1025,7 +1023,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_pointer() {
if (subtype.errored)
return Failure::kErrored;
return module_.create<ast::type::PointerType>(subtype.value, sc.value);
return module_.create<ast::type::Pointer>(subtype.value, sc.value);
});
}
@@ -1042,7 +1040,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
if (subtype.errored)
return Failure::kErrored;
return module_.create<ast::type::VectorType>(subtype.value, count);
return module_.create<ast::type::Vector>(subtype.value, count);
}
Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
@@ -1062,7 +1060,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
size = val.value;
}
auto ty = std::make_unique<ast::type::ArrayType>(subtype.value, size);
auto ty = std::make_unique<ast::type::Array>(subtype.value, size);
ty->set_decorations(std::move(decos));
return module_.unique_type(std::move(ty));
});
@@ -1088,7 +1086,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
if (subtype.errored)
return Failure::kErrored;
return module_.create<ast::type::MatrixType>(subtype.value, rows, columns);
return module_.create<ast::type::Matrix>(subtype.value, rows, columns);
}
// storage_class
@@ -1135,7 +1133,7 @@ Expect<ast::StorageClass> ParserImpl::expect_storage_class(
// struct_decl
// : struct_decoration_decl* STRUCT IDENT struct_body_decl
Maybe<std::unique_ptr<ast::type::StructType>> ParserImpl::struct_decl(
Maybe<std::unique_ptr<ast::type::Struct>> ParserImpl::struct_decl(
ast::DecorationList& decos) {
auto t = peek();
auto source = t.source();
@@ -1155,7 +1153,7 @@ Maybe<std::unique_ptr<ast::type::StructType>> ParserImpl::struct_decl(
if (struct_decos.errored)
return Failure::kErrored;
return std::make_unique<ast::type::StructType>(
return std::make_unique<ast::type::Struct>(
name.value, create<ast::Struct>(source, std::move(struct_decos.value),
std::move(body.value)));
}
@@ -1256,7 +1254,7 @@ Maybe<ast::Function*> ParserImpl::function_decl(ast::DecorationList& decos) {
// | VOID
Maybe<ast::type::Type*> ParserImpl::function_type_decl() {
if (match(Token::Type::kVoid))
return module_.create<ast::type::VoidType>();
return module_.create<ast::type::Void>();
return type_decl();
}
@@ -2615,19 +2613,19 @@ Maybe<ast::AssignmentStatement*> ParserImpl::assignment_stmt() {
Maybe<ast::Literal*> ParserImpl::const_literal() {
auto t = peek();
if (match(Token::Type::kTrue)) {
auto* type = module_.create<ast::type::BoolType>();
auto* type = module_.create<ast::type::Bool>();
return create<ast::BoolLiteral>(type, true);
}
if (match(Token::Type::kFalse)) {
auto* type = module_.create<ast::type::BoolType>();
auto* type = module_.create<ast::type::Bool>();
return create<ast::BoolLiteral>(type, false);
}
if (match(Token::Type::kSintLiteral)) {
auto* type = module_.create<ast::type::I32Type>();
auto* type = module_.create<ast::type::I32>();
return create<ast::SintLiteral>(type, t.to_i32());
}
if (match(Token::Type::kUintLiteral)) {
auto* type = module_.create<ast::type::U32Type>();
auto* type = module_.create<ast::type::U32>();
return create<ast::UintLiteral>(type, t.to_u32());
}
if (match(Token::Type::kFloatLiteral)) {
@@ -2636,7 +2634,7 @@ Maybe<ast::Literal*> ParserImpl::const_literal() {
next(); // Consume 'f'
add_error(p.source(), "float literals must not be suffixed with 'f'");
}
auto* type = module_.create<ast::type::F32Type>();
auto* type = module_.create<ast::type::F32>();
return create<ast::FloatLiteral>(type, t.to_f32());
}
return Failure::kNoMatch;

View File

@@ -34,7 +34,6 @@
#include "src/ast/constructor_expression.h"
#include "src/ast/continue_statement.h"
#include "src/ast/else_statement.h"
#include "src/ast/switch_statement.h"
#include "src/ast/function.h"
#include "src/ast/if_statement.h"
#include "src/ast/literal.h"
@@ -48,6 +47,7 @@
#include "src/ast/struct_decoration.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/switch_statement.h"
#include "src/ast/type/storage_texture_type.h"
#include "src/ast/type/struct_type.h"
#include "src/ast/type/texture_type.h"
@@ -353,7 +353,7 @@ class ParserImpl {
/// `struct_decoration_decl*` provided as |decos|.
/// @returns the struct type or nullptr on error
/// @param decos the list of decorations for the struct declaration.
Maybe<std::unique_ptr<ast::type::StructType>> struct_decl(
Maybe<std::unique_ptr<ast::type::Struct>> struct_decl(
ast::DecorationList& decos);
/// Parses a `struct_body_decl` grammar element, erroring on parse failure.
/// @returns the struct members

View File

@@ -35,8 +35,8 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl) {
ASSERT_TRUE(e->Is<ast::TypeConstructorExpression>());
auto* t = e->As<ast::TypeConstructorExpression>();
ASSERT_TRUE(t->type()->Is<ast::type::VectorType>());
EXPECT_EQ(t->type()->As<ast::type::VectorType>()->size(), 2u);
ASSERT_TRUE(t->type()->Is<ast::type::Vector>());
EXPECT_EQ(t->type()->As<ast::type::Vector>()->size(), 2u);
ASSERT_EQ(t->values().size(), 2u);
auto& v = t->values();

View File

@@ -36,10 +36,9 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(
t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->As<ast::type::Texture>()->Is<ast::type::DepthTexture>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -50,10 +49,9 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(
t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->As<ast::type::Texture>()->Is<ast::type::DepthTexture>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -64,10 +62,9 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(
t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->As<ast::type::Texture>()->Is<ast::type::DepthTexture>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@@ -78,10 +75,9 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(
t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->As<ast::type::Texture>()->Is<ast::type::DepthTexture>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}

View File

@@ -39,14 +39,14 @@ TEST_F(ParserImplTest, FunctionDecl) {
EXPECT_EQ(f->name(), "main");
ASSERT_NE(f->return_type(), nullptr);
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
ASSERT_EQ(f->params().size(), 2u);
EXPECT_EQ(f->params()[0]->name(), "a");
EXPECT_EQ(f->params()[1]->name(), "b");
ASSERT_NE(f->return_type(), nullptr);
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
auto* body = f->body();
ASSERT_EQ(body->size(), 1u);
@@ -67,10 +67,10 @@ TEST_F(ParserImplTest, FunctionDecl_DecorationList) {
EXPECT_EQ(f->name(), "main");
ASSERT_NE(f->return_type(), nullptr);
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
auto& decorations = f->decorations();
ASSERT_EQ(decorations.size(), 1u);
@@ -105,10 +105,10 @@ fn main() -> void { return; })");
EXPECT_EQ(f->name(), "main");
ASSERT_NE(f->return_type(), nullptr);
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
auto& decorations = f->decorations();
ASSERT_EQ(decorations.size(), 2u);
@@ -150,10 +150,10 @@ fn main() -> void { return; })");
EXPECT_EQ(f->name(), "main");
ASSERT_NE(f->return_type(), nullptr);
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
auto& decos = f->decorations();
ASSERT_EQ(decos.size(), 2u);

View File

@@ -36,7 +36,7 @@ TEST_F(ParserImplTest, FunctionHeader) {
ASSERT_EQ(f->params().size(), 2u);
EXPECT_EQ(f->params()[0]->name(), "a");
EXPECT_EQ(f->params()[1]->name(), "b");
EXPECT_TRUE(f->return_type()->Is<ast::type::VoidType>());
EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
}
TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {

View File

@@ -30,7 +30,7 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Void) {
auto p = parser("void");
auto& mod = p->get_module();
auto* v = mod.create<ast::type::VoidType>();
auto* v = mod.create<ast::type::Void>();
auto e = p->function_type_decl();
EXPECT_TRUE(e.matched);
@@ -43,8 +43,8 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Type) {
auto p = parser("vec2<f32>");
auto& mod = p->get_module();
auto* f32 = mod.create<ast::type::F32Type>();
auto* vec2 = mod.create<ast::type::VectorType>(f32, 2);
auto* f32 = mod.create<ast::type::F32>();
auto* vec2 = mod.create<ast::type::Vector>(f32, 2);
auto e = p->function_type_decl();
EXPECT_TRUE(e.matched);

View File

@@ -35,7 +35,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl) {
EXPECT_TRUE(e->is_const());
EXPECT_EQ(e->name(), "a");
ASSERT_NE(e->type(), nullptr);
EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->source().range.begin.line, 1u);
EXPECT_EQ(e->source().range.begin.column, 7u);

View File

@@ -88,8 +88,8 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias) {
auto& m = p->get_module();
ASSERT_EQ(m.constructed_types().size(), 1u);
ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::AliasType>());
EXPECT_EQ(m.constructed_types()[0]->As<ast::type::AliasType>()->name(), "A");
ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Alias>());
EXPECT_EQ(m.constructed_types()[0]->As<ast::type::Alias>()->name(), "A");
}
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) {
@@ -103,12 +103,12 @@ type B = A;)");
auto& m = p->get_module();
ASSERT_EQ(m.constructed_types().size(), 2u);
ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::StructType>());
auto* str = m.constructed_types()[0]->As<ast::type::StructType>();
ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Struct>());
auto* str = m.constructed_types()[0]->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
ASSERT_TRUE(m.constructed_types()[1]->Is<ast::type::AliasType>());
auto* alias = m.constructed_types()[1]->As<ast::type::AliasType>();
ASSERT_TRUE(m.constructed_types()[1]->Is<ast::type::Alias>());
auto* alias = m.constructed_types()[1]->As<ast::type::Alias>();
EXPECT_EQ(alias->name(), "B");
EXPECT_EQ(alias->type(), str);
}
@@ -164,9 +164,9 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) {
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<ast::type::StructType>());
ASSERT_TRUE(t->Is<ast::type::Struct>());
auto* str = t->As<ast::type::StructType>();
auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->impl()->members().size(), 2u);
}
@@ -183,16 +183,16 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<ast::type::StructType>());
ASSERT_TRUE(t->Is<ast::type::Struct>());
auto* str = t->As<ast::type::StructType>();
auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_FALSE(str->IsBlockDecorated());
const auto* ty = str->impl()->members()[0]->type();
ASSERT_TRUE(ty->Is<ast::type::ArrayType>());
const auto* arr = ty->As<ast::type::ArrayType>();
ASSERT_TRUE(ty->Is<ast::type::Array>());
const auto* arr = ty->As<ast::type::Array>();
EXPECT_TRUE(arr->has_array_stride());
EXPECT_EQ(arr->array_stride(), 4u);
}
@@ -207,9 +207,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<ast::type::StructType>());
ASSERT_TRUE(t->Is<ast::type::Struct>());
auto* str = t->As<ast::type::StructType>();
auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_TRUE(str->IsBlockDecorated());

View File

@@ -37,7 +37,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->name(), "a");
EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -61,7 +61,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->name(), "a");
EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -90,7 +90,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
EXPECT_EQ(e->name(), "a");
ASSERT_NE(e->type(), nullptr);
EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -124,7 +124,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
EXPECT_EQ(e->name(), "a");
ASSERT_NE(e->type(), nullptr);
EXPECT_TRUE(e->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(e->type()->Is<ast::type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);

View File

@@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ParamList_Single) {
auto p = parser("a : i32");
auto& mod = p->get_module();
auto* i32 = mod.create<ast::type::I32Type>();
auto* i32 = mod.create<ast::type::I32>();
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();
@@ -52,9 +52,9 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
auto p = parser("a : i32, b: f32, c: vec2<f32>");
auto& mod = p->get_module();
auto* i32 = mod.create<ast::type::I32Type>();
auto* f32 = mod.create<ast::type::F32Type>();
auto* vec2 = mod.create<ast::type::VectorType>(f32, 2);
auto* i32 = mod.create<ast::type::I32>();
auto* f32 = mod.create<ast::type::F32>();
auto* vec2 = mod.create<ast::type::Vector>(f32, 2);
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();

View File

@@ -194,7 +194,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) {
auto p = parser("f32(1)");
auto& mod = p->get_module();
auto* f32 = mod.create<ast::type::F32Type>();
auto* f32 = mod.create<ast::type::F32>();
auto e = p->primary_expression();
EXPECT_TRUE(e.matched);
@@ -216,7 +216,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast) {
auto p = parser("bitcast<f32>(1)");
auto& mod = p->get_module();
auto* f32 = mod.create<ast::type::F32Type>();
auto* f32 = mod.create<ast::type::F32>();
auto e = p->primary_expression();
EXPECT_TRUE(e.matched);

View File

@@ -37,8 +37,8 @@ TEST_F(ParserImplTest, SamplerType_Sampler) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
EXPECT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
ASSERT_TRUE(t->Is<ast::type::Sampler>());
EXPECT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
EXPECT_FALSE(p->has_error());
}
@@ -48,8 +48,8 @@ TEST_F(ParserImplTest, SamplerType_ComparisonSampler) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
EXPECT_TRUE(t->As<ast::type::SamplerType>()->IsComparison());
ASSERT_TRUE(t->Is<ast::type::Sampler>());
EXPECT_TRUE(t->As<ast::type::Sampler>()->IsComparison());
EXPECT_FALSE(p->has_error());
}

View File

@@ -26,7 +26,7 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses) {
auto p = parser("{a : i32;}");
auto& mod = p->get_module();
auto* i32 = mod.create<ast::type::I32Type>();
auto* i32 = mod.create<ast::type::I32>();
auto m = p->expect_struct_body_decl();
ASSERT_FALSE(p->has_error());

View File

@@ -27,7 +27,7 @@ TEST_F(ParserImplTest, StructMember_Parses) {
auto p = parser("a : i32;");
auto& mod = p->get_module();
auto* i32 = mod.create<ast::type::I32Type>();
auto* i32 = mod.create<ast::type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);
@@ -53,7 +53,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithDecoration) {
auto p = parser("[[offset(2)]] a : i32;");
auto& mod = p->get_module();
auto* i32 = mod.create<ast::type::I32Type>();
auto* i32 = mod.create<ast::type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);
@@ -84,7 +84,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleDecorations) {
[[offset(4)]] a : i32;)");
auto& mod = p->get_module();
auto* i32 = mod.create<ast::type::I32Type>();
auto* i32 = mod.create<ast::type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);

View File

@@ -57,7 +57,7 @@ fn main() -> { # missing return type
TEST_F(ParserImplTest, GetRegisteredType) {
auto p = parser("");
ast::type::I32Type i32;
ast::type::I32 i32;
p->register_constructed("my_alias", &i32);
auto* alias = p->get_constructed("my_alias");

View File

@@ -44,8 +44,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
ASSERT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
ASSERT_TRUE(t->Is<ast::type::Sampler>());
ASSERT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
@@ -55,8 +55,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
ASSERT_TRUE(t->As<ast::type::SamplerType>()->IsComparison());
ASSERT_TRUE(t->Is<ast::type::Sampler>());
ASSERT_TRUE(t->As<ast::type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
@@ -66,9 +66,9 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -79,11 +79,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
ASSERT_TRUE(
t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k1d);
}
@@ -94,11 +93,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
ASSERT_TRUE(
t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::I32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::I32>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -109,11 +107,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
ASSERT_TRUE(
t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::U32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::U32>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k3d);
}
@@ -165,11 +162,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
ASSERT_TRUE(
t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::F32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k1d);
}
@@ -180,11 +176,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
ASSERT_TRUE(
t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::I32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::I32>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -195,11 +190,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
ASSERT_TRUE(
t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::U32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::U32>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k3d);
}
@@ -250,12 +244,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::MultisampledTextureType>());
ASSERT_TRUE(t->As<ast::type::MultisampledTextureType>()
->type()
->Is<ast::type::I32Type>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::MultisampledTexture>());
ASSERT_TRUE(
t->As<ast::type::MultisampledTexture>()->type()->Is<ast::type::I32>());
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -307,13 +300,13 @@ TEST_F(ParserImplTest,
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::StorageTextureType>());
EXPECT_EQ(t->As<ast::type::StorageTextureType>()->image_format(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
ast::type::ImageFormat::kR8Unorm);
EXPECT_EQ(t->As<ast::type::StorageTextureType>()->access(),
EXPECT_EQ(t->As<ast::type::StorageTexture>()->access(),
ast::AccessControl::kReadOnly);
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k1d);
}
@@ -325,13 +318,13 @@ TEST_F(ParserImplTest,
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::StorageTextureType>());
EXPECT_EQ(t->As<ast::type::StorageTextureType>()->image_format(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
ast::type::ImageFormat::kR16Float);
EXPECT_EQ(t->As<ast::type::StorageTextureType>()->access(),
EXPECT_EQ(t->As<ast::type::StorageTexture>()->access(),
ast::AccessControl::kWriteOnly);
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}
@@ -379,13 +372,13 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::StorageTextureType>());
EXPECT_EQ(t->As<ast::type::StorageTextureType>()->image_format(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
ast::type::ImageFormat::kR8Unorm);
EXPECT_EQ(t->As<ast::type::StorageTextureType>()->access(),
EXPECT_EQ(t->As<ast::type::StorageTexture>()->access(),
ast::AccessControl::kReadOnly);
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k1d);
}
@@ -396,13 +389,13 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::StorageTextureType>());
EXPECT_EQ(t->As<ast::type::StorageTextureType>()->image_format(),
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
ast::type::ImageFormat::kR16Float);
EXPECT_EQ(t->As<ast::type::StorageTextureType>()->access(),
EXPECT_EQ(t->As<ast::type::StorageTexture>()->access(),
ast::AccessControl::kWriteOnly);
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
ast::type::TextureDimension::k2d);
}

View File

@@ -29,21 +29,21 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) {
auto p = parser("type a = i32");
auto& mod = p->get_module();
auto* i32 = mod.create<ast::type::I32Type>();
auto* i32 = mod.create<ast::type::I32>();
auto t = p->type_alias();
EXPECT_FALSE(p->has_error());
EXPECT_FALSE(t.errored);
EXPECT_TRUE(t.matched);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::AliasType>());
auto* alias = t->As<ast::type::AliasType>();
ASSERT_TRUE(alias->type()->Is<ast::type::I32Type>());
ASSERT_TRUE(t->Is<ast::type::Alias>());
auto* alias = t->As<ast::type::Alias>();
ASSERT_TRUE(alias->type()->Is<ast::type::I32>());
ASSERT_EQ(alias->type(), i32);
}
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
ast::type::StructType str("B", {});
ast::type::Struct str("B", {});
auto p = parser("type a = B");
p->register_constructed("B", &str);
@@ -53,12 +53,12 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
EXPECT_FALSE(t.errored);
EXPECT_TRUE(t.matched);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::AliasType>());
auto* alias = t->As<ast::type::AliasType>();
ASSERT_TRUE(t->Is<ast::type::Alias>());
auto* alias = t->As<ast::type::Alias>();
EXPECT_EQ(alias->name(), "a");
ASSERT_TRUE(alias->type()->Is<ast::type::StructType>());
ASSERT_TRUE(alias->type()->Is<ast::type::Struct>());
auto* s = alias->type()->As<ast::type::StructType>();
auto* s = alias->type()->As<ast::type::Struct>();
EXPECT_EQ(s->name(), "B");
}

View File

@@ -48,8 +48,8 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) {
auto& mod = p->get_module();
auto* int_type = mod.create<ast::type::I32Type>();
auto* alias_type = mod.create<ast::type::AliasType>("A", int_type);
auto* int_type = mod.create<ast::type::I32>();
auto* alias_type = mod.create<ast::type::Alias>("A", int_type);
p->register_constructed("A", alias_type);
@@ -58,9 +58,9 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, alias_type);
ASSERT_TRUE(t->Is<ast::type::AliasType>());
ASSERT_TRUE(t->Is<ast::type::Alias>());
auto* alias = t->As<ast::type::AliasType>();
auto* alias = t->As<ast::type::Alias>();
EXPECT_EQ(alias->name(), "A");
EXPECT_EQ(alias->type(), int_type);
}
@@ -80,56 +80,56 @@ TEST_F(ParserImplTest, TypeDecl_Bool) {
auto p = parser("bool");
auto& mod = p->get_module();
auto* bool_type = mod.create<ast::type::BoolType>();
auto* bool_type = mod.create<ast::type::Bool>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, bool_type);
ASSERT_TRUE(t->Is<ast::type::BoolType>());
ASSERT_TRUE(t->Is<ast::type::Bool>());
}
TEST_F(ParserImplTest, TypeDecl_F32) {
auto p = parser("f32");
auto& mod = p->get_module();
auto* float_type = mod.create<ast::type::F32Type>();
auto* float_type = mod.create<ast::type::F32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, float_type);
ASSERT_TRUE(t->Is<ast::type::F32Type>());
ASSERT_TRUE(t->Is<ast::type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_I32) {
auto p = parser("i32");
auto& mod = p->get_module();
auto* int_type = mod.create<ast::type::I32Type>();
auto* int_type = mod.create<ast::type::I32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, int_type);
ASSERT_TRUE(t->Is<ast::type::I32Type>());
ASSERT_TRUE(t->Is<ast::type::I32>());
}
TEST_F(ParserImplTest, TypeDecl_U32) {
auto p = parser("u32");
auto& mod = p->get_module();
auto* uint_type = mod.create<ast::type::U32Type>();
auto* uint_type = mod.create<ast::type::U32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, uint_type);
ASSERT_TRUE(t->Is<ast::type::U32Type>());
ASSERT_TRUE(t->Is<ast::type::U32>());
}
struct VecData {
@@ -151,8 +151,8 @@ TEST_P(VecTest, Parse) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
EXPECT_TRUE(t->Is<ast::type::VectorType>());
EXPECT_EQ(t->As<ast::type::VectorType>()->size(), params.count);
EXPECT_TRUE(t->Is<ast::type::Vector>());
EXPECT_EQ(t->As<ast::type::Vector>()->size(), params.count);
}
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
VecTest,
@@ -239,10 +239,10 @@ TEST_F(ParserImplTest, TypeDecl_Ptr) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
ASSERT_TRUE(t->Is<ast::type::PointerType>());
ASSERT_TRUE(t->Is<ast::type::Pointer>());
auto* ptr = t->As<ast::type::PointerType>();
ASSERT_TRUE(ptr->type()->Is<ast::type::F32Type>());
auto* ptr = t->As<ast::type::Pointer>();
ASSERT_TRUE(ptr->type()->Is<ast::type::F32>());
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
}
@@ -253,15 +253,15 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_ToVec) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
ASSERT_TRUE(t->Is<ast::type::PointerType>());
ASSERT_TRUE(t->Is<ast::type::Pointer>());
auto* ptr = t->As<ast::type::PointerType>();
ASSERT_TRUE(ptr->type()->Is<ast::type::VectorType>());
auto* ptr = t->As<ast::type::Pointer>();
ASSERT_TRUE(ptr->type()->Is<ast::type::Vector>());
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
auto* vec = ptr->type()->As<ast::type::VectorType>();
auto* vec = ptr->type()->As<ast::type::Vector>();
ASSERT_EQ(vec->size(), 2u);
ASSERT_TRUE(vec->type()->Is<ast::type::F32Type>());
ASSERT_TRUE(vec->type()->Is<ast::type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
@@ -351,12 +351,12 @@ TEST_F(ParserImplTest, TypeDecl_Array) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
ASSERT_TRUE(t->Is<ast::type::ArrayType>());
ASSERT_TRUE(t->Is<ast::type::Array>());
auto* a = t->As<ast::type::ArrayType>();
auto* a = t->As<ast::type::Array>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
ASSERT_FALSE(a->has_array_stride());
}
@@ -367,12 +367,12 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
ASSERT_TRUE(t->Is<ast::type::ArrayType>());
ASSERT_TRUE(t->Is<ast::type::Array>());
auto* a = t->As<ast::type::ArrayType>();
auto* a = t->As<ast::type::Array>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
ASSERT_TRUE(a->has_array_stride());
EXPECT_EQ(a->array_stride(), 16u);
}
@@ -384,11 +384,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
ASSERT_TRUE(t->Is<ast::type::ArrayType>());
ASSERT_TRUE(t->Is<ast::type::Array>());
auto* a = t->As<ast::type::ArrayType>();
auto* a = t->As<ast::type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
ASSERT_TRUE(a->has_array_stride());
EXPECT_EQ(a->array_stride(), 16u);
}
@@ -400,11 +400,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
ASSERT_TRUE(t->Is<ast::type::ArrayType>());
ASSERT_TRUE(t->Is<ast::type::Array>());
auto* a = t->As<ast::type::ArrayType>();
auto* a = t->As<ast::type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
auto& decos = a->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -421,11 +421,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
ASSERT_TRUE(t->Is<ast::type::ArrayType>());
ASSERT_TRUE(t->Is<ast::type::Array>());
auto* a = t->As<ast::type::ArrayType>();
auto* a = t->As<ast::type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->Is<ast::type::F32Type>());
ASSERT_TRUE(a->type()->Is<ast::type::F32>());
auto& decos = a->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -524,11 +524,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
ASSERT_TRUE(t->Is<ast::type::ArrayType>());
ASSERT_TRUE(t->Is<ast::type::Array>());
auto* a = t->As<ast::type::ArrayType>();
auto* a = t->As<ast::type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->Is<ast::type::U32Type>());
ASSERT_TRUE(a->type()->Is<ast::type::U32>());
}
TEST_F(ParserImplTest, TypeDecl_Array_BadType) {
@@ -621,8 +621,8 @@ TEST_P(MatrixTest, Parse) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
EXPECT_TRUE(t->Is<ast::type::MatrixType>());
auto* mat = t->As<ast::type::MatrixType>();
EXPECT_TRUE(t->Is<ast::type::Matrix>());
auto* mat = t->As<ast::type::Matrix>();
EXPECT_EQ(mat->rows(), params.rows);
EXPECT_EQ(mat->columns(), params.columns);
}
@@ -739,24 +739,23 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
auto p = parser("sampler");
auto& mod = p->get_module();
auto* type =
mod.create<ast::type::SamplerType>(ast::type::SamplerKind::kSampler);
auto* type = mod.create<ast::type::Sampler>(ast::type::SamplerKind::kSampler);
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, type);
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
ASSERT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
ASSERT_TRUE(t->Is<ast::type::Sampler>());
ASSERT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
auto p = parser("texture_sampled_cube<f32>");
auto& mod = p->get_module();
ast::type::F32Type f32;
auto* type = mod.create<ast::type::SampledTextureType>(
ast::type::F32 f32;
auto* type = mod.create<ast::type::SampledTexture>(
ast::type::TextureDimension::kCube, &f32);
auto t = p->type_decl();
@@ -764,18 +763,17 @@ TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, type);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
ASSERT_TRUE(
t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::F32Type>());
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_Texture) {
auto p = parser("texture_cube<f32>");
ast::type::F32Type f32;
ast::type::F32 f32;
auto& mod = p->get_module();
auto* type = mod.create<ast::type::SampledTextureType>(
auto* type = mod.create<ast::type::SampledTexture>(
ast::type::TextureDimension::kCube, &f32);
auto t = p->type_decl();
@@ -783,10 +781,9 @@ TEST_F(ParserImplTest, TypeDecl_Texture) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
EXPECT_EQ(t.value, type);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->Is<ast::type::SampledTextureType>());
ASSERT_TRUE(
t->As<ast::type::SampledTextureType>()->type()->Is<ast::type::F32Type>());
ASSERT_TRUE(t->Is<ast::type::Texture>());
ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
}
} // namespace

View File

@@ -32,7 +32,7 @@ TEST_F(ParserImplTest, VariableDecl_Parses) {
ASSERT_NE(var.value, nullptr);
EXPECT_EQ(var->name(), "my_var");
EXPECT_NE(var->type(), nullptr);
EXPECT_TRUE(var->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(var->type()->Is<ast::type::F32>());
EXPECT_EQ(var->source().range.begin.line, 1u);
EXPECT_EQ(var->source().range.begin.column, 5u);
@@ -70,7 +70,7 @@ TEST_F(ParserImplTest, VariableDecl_WithStorageClass) {
EXPECT_FALSE(p->has_error());
ASSERT_NE(v.value, nullptr);
EXPECT_EQ(v->name(), "my_var");
EXPECT_TRUE(v->type()->Is<ast::type::F32Type>());
EXPECT_TRUE(v->type()->Is<ast::type::F32>());
EXPECT_EQ(v->storage_class(), ast::StorageClass::kPrivate);
EXPECT_EQ(v->source().range.begin.line, 1u);

View File

@@ -34,7 +34,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_Parses) {
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
ASSERT_TRUE(decl->type->Is<ast::type::F32Type>());
ASSERT_TRUE(decl->type->Is<ast::type::F32>());
ASSERT_EQ(decl->source.range.begin.line, 1u);
ASSERT_EQ(decl->source.range.begin.column, 1u);
@@ -83,7 +83,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_InvalidType) {
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
ast::type::I32Type i32;
ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -94,7 +94,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::type::StructType s("S", &str);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read)]] S");
p->register_constructed("S", &s);
@@ -104,12 +104,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
ASSERT_TRUE(decl->type->Is<ast::type::AccessControlType>());
EXPECT_TRUE(decl->type->As<ast::type::AccessControlType>()->IsReadOnly());
ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadOnly());
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
ast::type::I32Type i32;
ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -120,7 +120,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::type::StructType s("S", &str);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read_write)]] S");
p->register_constructed("S", &s);
@@ -130,12 +130,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
ASSERT_TRUE(decl->type->Is<ast::type::AccessControlType>());
EXPECT_TRUE(decl->type->As<ast::type::AccessControlType>()->IsReadWrite());
ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadWrite());
}
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
ast::type::I32Type i32;
ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -146,7 +146,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::type::StructType s("S", &str);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read), access(read_write)]] S");
p->register_constructed("S", &s);
@@ -158,7 +158,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
}
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
ast::type::I32Type i32;
ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -169,7 +169,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::type::StructType s("S", &str);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
p->register_constructed("S", &s);
@@ -197,7 +197,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_AccessDecoIllegalValue) {
}
TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
ast::type::I32Type i32;
ast::type::I32 i32;
ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{});
ast::StructMemberList members;
@@ -208,7 +208,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
decos.push_back(&block_deco);
ast::Struct str(decos, members);
ast::type::StructType s("S", &str);
ast::type::Struct s("S", &str);
auto p = parser("my_var : [[stride(1)]] S");
p->register_constructed("S", &s);