Changeset 246428 in webkit
- Timestamp:
- Jun 13, 2019 10:45:43 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r246427 r246428 1 2019-06-13 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WHLSL] Remove unnecessary ASSERT()s and clean up visitor lambdas 4 https://bugs.webkit.org/show_bug.cgi?id=198706 5 6 Reviewed by Dean Jackson, Saam Barati, and Robin Morisset. 7 8 Some minor refactoring. 9 10 If the code is going to unconditionally downcast<Foo>(bar), there's no need 11 to guard that with an ASSERT(is<Foo>(bar)) because the downcast() call will 12 do that automatically. 13 14 No new tests because there is no behavior change. 15 16 * Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h: 17 (WebCore::WHLSL::AST::ConstantExpression::visit): 18 (WebCore::WHLSL::AST::ConstantExpression::visit const): 19 * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp: 20 (WebCore::WHLSL::Metal::EntryPointScaffolding::resourceHelperTypes): 21 (WebCore::WHLSL::Metal::EntryPointScaffolding::mangledOutputPath): 22 (WebCore::WHLSL::Metal::EntryPointScaffolding::unpackResourcesAndNamedBuiltIns): 23 * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp: 24 (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit): 25 (WebCore::WHLSL::Metal::FunctionDefinitionWriter::constantExpressionString): 26 * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp: 27 (WebCore::WHLSL::Metal::writeNativeFunction): 28 * Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp: 29 (WebCore::WHLSL::Metal::writeNativeType): 30 * Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp: 31 (WebCore::WHLSL::Metal::find): 32 (WebCore::WHLSL::Metal::TypeNamer::createNameNode): 33 (WebCore::WHLSL::Metal::TypeNamer::insert): 34 (WebCore::WHLSL::Metal::TypeNamer::emitUnnamedTypeDefinition): 35 (WebCore::WHLSL::Metal::TypeNamer::emitNamedTypeDefinition): 36 * Modules/webgpu/WHLSL/WHLSLChecker.cpp: 37 (WebCore::WHLSL::Checker::visit): 38 (WebCore::WHLSL::argumentTypeForAndOverload): 39 * Modules/webgpu/WHLSL/WHLSLInferTypes.cpp: 40 (WebCore::WHLSL::inferTypesForTypeArguments): 41 * Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp: 42 (WebCore::WHLSL::Intrinsics::addFullTexture): 43 (WebCore::WHLSL::Intrinsics::addDepthTexture): 44 * Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp: 45 (WebCore::WHLSL::modify): 46 (WebCore::WHLSL::PropertyResolver::visit): 47 * Modules/webgpu/WHLSL/WHLSLVisitor.cpp: 48 (WebCore::WHLSL::Visitor::visit): 49 1 50 2019-06-12 Myles C. Maxfield <mmaxfield@apple.com> 2 51 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h
r245680 r246428 89 89 } 90 90 91 template <typename T> void visit(T&& t)91 template <typename Visitor> auto visit(const Visitor& visitor) -> decltype(WTF::visit(visitor, std::declval<Variant<IntegerLiteral, UnsignedIntegerLiteral, FloatLiteral, NullLiteral, BooleanLiteral, EnumerationMemberLiteral>&>())) 92 92 { 93 WTF::visit(WTFMove(t), m_variant);93 return WTF::visit(visitor, m_variant); 94 94 } 95 95 96 template <typename T> void visit(T&& t) const96 template <typename Visitor> auto visit(const Visitor& visitor) const -> decltype(WTF::visit(visitor, std::declval<Variant<IntegerLiteral, UnsignedIntegerLiteral, FloatLiteral, NullLiteral, BooleanLiteral, EnumerationMemberLiteral>&>())) 97 97 { 98 WTF::visit(WTFMove(t), m_variant);98 return WTF::visit(visitor, m_variant); 99 99 } 100 100 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp
r246427 r246428 149 149 continue; 150 150 auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; 151 ASSERT(is<AST::ReferenceType>(unnamedType));152 151 auto& referenceType = downcast<AST::ReferenceType>(unnamedType); 153 152 auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); … … 278 277 AST::StructureDefinition* structureDefinition = nullptr; 279 278 auto& unifyNode = m_functionDefinition.type().unifyNode(); 280 ASSERT(is<AST::NamedType>(unifyNode)); 281 auto& namedType = downcast<AST::NamedType>(unifyNode); 282 ASSERT(is<AST::StructureDefinition>(namedType)); 283 structureDefinition = &downcast<AST::StructureDefinition>(namedType); 279 structureDefinition = &downcast<AST::StructureDefinition>(downcast<AST::NamedType>(unifyNode)); 284 280 for (auto& component : path) { 285 281 ASSERT(structureDefinition); … … 318 314 319 315 auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; 320 ASSERT(is<AST::ReferenceType>(unnamedType)); 321 auto& referenceType = downcast<AST::ReferenceType>(unnamedType); 322 auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); 316 auto mangledTypeName = m_typeNamer.mangledNameForType(downcast<AST::ReferenceType>(unnamedType).elementType()); 323 317 324 318 stringBuilder.append(makeString("size_t ", lengthTemporaryName, " = ", variableName, '.', lengthElementName, ".x;\n")); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp
r246273 r246428 398 398 { 399 399 auto& unifyNode = nullLiteral.resolvedType().unifyNode(); 400 ASSERT(is<AST::UnnamedType>(unifyNode));401 400 auto& unnamedType = downcast<AST::UnnamedType>(unifyNode); 402 401 bool isArrayReferenceType = is<AST::ArrayReferenceType>(unnamedType); … … 621 620 String FunctionDefinitionWriter::constantExpressionString(AST::ConstantExpression& constantExpression) 622 621 { 623 String result; 624 constantExpression.visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { 625 result = makeString("", integerLiteral.value()); 626 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { 627 result = makeString("", unsignedIntegerLiteral.value()); 628 }, [&](AST::FloatLiteral& floatLiteral) { 629 result = makeString("", floatLiteral.value()); 630 }, [&](AST::NullLiteral&) { 631 result = "nullptr"_str; 632 }, [&](AST::BooleanLiteral& booleanLiteral) { 633 result = booleanLiteral.value() ? "true"_str : "false"_str; 634 }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) { 622 return constantExpression.visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> String { 623 return makeString("", integerLiteral.value()); 624 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> String { 625 return makeString("", unsignedIntegerLiteral.value()); 626 }, [&](AST::FloatLiteral& floatLiteral) -> String { 627 return makeString("", floatLiteral.value()); 628 }, [&](AST::NullLiteral&) -> String { 629 return "nullptr"_str; 630 }, [&](AST::BooleanLiteral& booleanLiteral) -> String { 631 return booleanLiteral.value() ? "true"_str : "false"_str; 632 }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) -> String { 635 633 ASSERT(enumerationMemberLiteral.enumerationDefinition()); 636 634 ASSERT(enumerationMemberLiteral.enumerationDefinition()); 637 re sult =makeString(m_typeNamer.mangledNameForType(*enumerationMemberLiteral.enumerationDefinition()), '.', m_typeNamer.mangledNameForEnumerationMember(*enumerationMemberLiteral.enumerationMember()));635 return makeString(m_typeNamer.mangledNameForType(*enumerationMemberLiteral.enumerationDefinition()), '.', m_typeNamer.mangledNameForEnumerationMember(*enumerationMemberLiteral.enumerationMember())); 638 636 })); 639 return result;640 637 } 641 638 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp
r246385 r246428 135 135 auto metalParameterName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type()); 136 136 auto& parameterType = nativeFunctionDeclaration.parameters()[0]->type()->unifyNode(); 137 ASSERT(is<AST::UnnamedType>(parameterType));138 137 auto& unnamedParameterType = downcast<AST::UnnamedType>(parameterType); 139 138 if (is<AST::ArrayType>(unnamedParameterType)) { … … 352 351 if (nativeFunctionDeclaration.name() == "InterlockedCompareExchange") { 353 352 ASSERT(nativeFunctionDeclaration.parameters().size() == 4); 354 ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()));355 353 auto& firstArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()); 356 354 auto firstArgumentAddressSpace = firstArgumentPointer.addressSpace(); … … 358 356 auto secondArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); 359 357 auto thirdArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[2]->type()); 360 ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[3]->type()));361 358 auto& fourthArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[3]->type()); 362 359 auto fourthArgumentAddressSpace = fourthArgumentPointer.addressSpace(); … … 370 367 371 368 ASSERT(nativeFunctionDeclaration.parameters().size() == 3); 372 ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()));373 369 auto& firstArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()); 374 370 auto firstArgumentAddressSpace = firstArgumentPointer.addressSpace(); 375 371 auto firstArgumentPointee = typeNamer.mangledNameForType(firstArgumentPointer.elementType()); 376 372 auto secondArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); 377 ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[2]->type()));378 373 auto& thirdArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[2]->type()); 379 374 auto thirdArgumentAddressSpace = thirdArgumentPointer.addressSpace(); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp
r245680 r246428 72 72 auto& typeReference = WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); 73 73 auto& unifyNode = typeReference->unifyNode(); 74 ASSERT(is<AST::NamedType>(unifyNode));75 74 auto& namedType = downcast<AST::NamedType>(unifyNode); 76 ASSERT(is<AST::NativeTypeDeclaration>(namedType));77 75 auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType); 78 76 auto prefix = ([&]() -> String { … … 117 115 auto& typeReference = WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); 118 116 auto& unifyNode = typeReference->unifyNode(); 119 ASSERT(is<AST::NamedType>(unifyNode));120 117 auto& namedType = downcast<AST::NamedType>(unifyNode); 121 ASSERT(is<AST::NativeTypeDeclaration>(namedType));122 118 auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType); 123 119 auto prefix = ([&]() -> String { -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp
r245680 r246428 202 202 if (is<AST::ArrayReferenceType>(unnamedType)) 203 203 return find(downcast<AST::ArrayReferenceType>(unnamedType).elementType(), types).children(); 204 ASSERT(is<AST::ArrayType>(unnamedType));205 204 return find(downcast<AST::ArrayType>(unnamedType).type(), types).children(); 206 205 })(); … … 307 306 return makeUniqueRef<ArrayReferenceTypeNameNode>(parent, generateNextTypeName(), arrayReferenceType.addressSpace()); 308 307 } 309 ASSERT(is<AST::ArrayType>(unnamedType));310 308 auto& arrayType = downcast<AST::ArrayType>(unnamedType); 311 309 return makeUniqueRef<ArrayTypeNameNode>(parent, generateNextTypeName(), arrayType.numElements()); … … 328 326 parent = &item; 329 327 } else { 330 ASSERT(is<AST::ArrayType>(unnamedType));331 328 auto& item = types[insert(downcast<AST::ArrayType>(unnamedType).type(), types)]; 332 329 vectorToInsertInto = &item->children(); … … 400 397 stringBuilder.append("};\n"); 401 398 } else { 402 ASSERT(is<ArrayTypeNameNode>(baseTypeNameNode));403 399 auto& arrayType = downcast<ArrayTypeNameNode>(baseTypeNameNode); 404 400 ASSERT(baseTypeNameNode.parent()); … … 419 415 auto& enumerationDefinition = downcast<AST::EnumerationDefinition>(namedType); 420 416 auto& baseType = enumerationDefinition.type().unifyNode(); 421 ASSERT(is<AST::NamedType>(baseType));422 417 stringBuilder.append(makeString("enum class ", mangledNameForType(enumerationDefinition), " : ", mangledNameForType(downcast<AST::NamedType>(baseType)), " {\n")); 423 418 for (auto& enumerationMember : enumerationDefinition.enumerationMembers()) … … 433 428 stringBuilder.append("};\n"); 434 429 } else { 435 ASSERT(is<AST::TypeDefinition>(namedType));436 430 auto& typeDefinition = downcast<AST::TypeDefinition>(namedType); 437 431 stringBuilder.append(makeString("typedef ", mangledNameForType(typeDefinition.type()), ' ', mangledNameForType(typeDefinition), ";\n")); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp
r246394 r246428 657 657 658 658 auto matchAndCommitMember = [&](AST::EnumerationMember& member) -> bool { 659 bool success = false; 660 member.value()->visit(WTF::makeVisitor([&](AST::Expression& value) { 659 return member.value()->visit(WTF::makeVisitor([&](AST::Expression& value) -> bool { 661 660 auto valueInfo = recurseAndGetInfo(value); 662 661 if (!valueInfo) 663 return ;664 success =static_cast<bool>(matchAndCommit(valueInfo->resolvingType, *baseType));662 return false; 663 return static_cast<bool>(matchAndCommit(valueInfo->resolvingType, *baseType)); 665 664 })); 666 return success;667 665 }; 668 666 … … 680 678 for (auto& member : enumerationMembers) { 681 679 if (member.get().value()) { 682 int64_t value; 683 member.get().value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { 684 value = integerLiteral.valueForSelectedType(); 685 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { 686 value = unsignedIntegerLiteral.valueForSelectedType(); 687 }, [&](auto&) { 680 auto value = member.get().value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { 681 return integerLiteral.valueForSelectedType(); 682 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { 683 return unsignedIntegerLiteral.valueForSelectedType(); 684 }, [&](auto&) -> int64_t { 688 685 ASSERT_NOT_REACHED(); 686 return 0; 689 687 })); 690 688 nextValue = baseType->successor()(value); … … 707 705 708 706 auto getValue = [&](AST::EnumerationMember& member) -> int64_t { 709 int64_t value;710 707 ASSERT(member.value()); 711 member.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral){712 value =integerLiteral.value();713 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) {714 value =unsignedIntegerLiteral.value();715 }, [&](auto&) {708 auto value = member.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { 709 return integerLiteral.value(); 710 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { 711 return unsignedIntegerLiteral.value(); 712 }, [&](auto&) -> int64_t { 716 713 ASSERT_NOT_REACHED(); 714 return 0; 717 715 })); 718 716 return value; … … 978 976 } 979 977 980 ASSERT(is<AST::UnnamedType>(unifyNode));981 978 auto& unnamedType = downcast<AST::UnnamedType>(unifyNode); 982 979 … … 1306 1303 continue; 1307 1304 } 1308 bool success; 1309 switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { 1310 success = static_cast<bool>(matchAndCommit(*valueType, integerLiteral.type())); 1311 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { 1312 success = static_cast<bool>(matchAndCommit(*valueType, unsignedIntegerLiteral.type())); 1313 }, [&](AST::FloatLiteral& floatLiteral) { 1314 success = static_cast<bool>(matchAndCommit(*valueType, floatLiteral.type())); 1315 }, [&](AST::NullLiteral& nullLiteral) { 1316 success = static_cast<bool>(matchAndCommit(*valueType, nullLiteral.type())); 1317 }, [&](AST::BooleanLiteral&) { 1318 success = matches(*valueType, m_intrinsics.boolType()); 1319 }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) { 1305 auto success = switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> bool { 1306 return static_cast<bool>(matchAndCommit(*valueType, integerLiteral.type())); 1307 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> bool { 1308 return static_cast<bool>(matchAndCommit(*valueType, unsignedIntegerLiteral.type())); 1309 }, [&](AST::FloatLiteral& floatLiteral) -> bool { 1310 return static_cast<bool>(matchAndCommit(*valueType, floatLiteral.type())); 1311 }, [&](AST::NullLiteral& nullLiteral) -> bool { 1312 return static_cast<bool>(matchAndCommit(*valueType, nullLiteral.type())); 1313 }, [&](AST::BooleanLiteral&) -> bool { 1314 return matches(*valueType, m_intrinsics.boolType()); 1315 }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) -> bool { 1320 1316 ASSERT(enumerationMemberLiteral.enumerationDefinition()); 1321 success =matches(*valueType, *enumerationMemberLiteral.enumerationDefinition());1317 return matches(*valueType, *enumerationMemberLiteral.enumerationDefinition()); 1322 1318 })); 1323 1319 if (!success) { … … 1340 1336 } 1341 1337 1342 bool success = true;1343 firstCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& firstIntegerLiteral){1344 secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) {1345 success = firstIntegerLiteral.value() != secondIntegerLiteral.value();1346 }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) {1347 success = static_cast<int64_t>(firstIntegerLiteral.value()) != static_cast<int64_t>(secondUnsignedIntegerLiteral.value());1348 }, [](auto&) {1338 auto success = firstCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& firstIntegerLiteral) -> bool { 1339 return secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) -> bool { 1340 return firstIntegerLiteral.value() != secondIntegerLiteral.value(); 1341 }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) -> bool { 1342 return static_cast<int64_t>(firstIntegerLiteral.value()) != static_cast<int64_t>(secondUnsignedIntegerLiteral.value()); 1343 }, [](auto&) -> bool { 1344 return true; 1349 1345 })); 1350 }, [&](AST::UnsignedIntegerLiteral& firstUnsignedIntegerLiteral) { 1351 secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) { 1352 success = static_cast<int64_t>(firstUnsignedIntegerLiteral.value()) != static_cast<int64_t>(secondIntegerLiteral.value()); 1353 }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) { 1354 success = firstUnsignedIntegerLiteral.value() != secondUnsignedIntegerLiteral.value(); 1355 }, [](auto&) { 1346 }, [&](AST::UnsignedIntegerLiteral& firstUnsignedIntegerLiteral) -> bool { 1347 return secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& secondIntegerLiteral) -> bool { 1348 return static_cast<int64_t>(firstUnsignedIntegerLiteral.value()) != static_cast<int64_t>(secondIntegerLiteral.value()); 1349 }, [&](AST::UnsignedIntegerLiteral& secondUnsignedIntegerLiteral) -> bool { 1350 return firstUnsignedIntegerLiteral.value() != secondUnsignedIntegerLiteral.value(); 1351 }, [](auto&) -> bool { 1352 return true; 1356 1353 })); 1357 }, [&](AST::EnumerationMemberLiteral& firstEnumerationMemberLiteral) { 1358 secondCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral&) { 1359 }, [&](AST::EnumerationMemberLiteral& secondEnumerationMemberLiteral) { 1354 }, [&](AST::EnumerationMemberLiteral& firstEnumerationMemberLiteral) -> bool { 1355 return secondCase.value()->visit(WTF::makeVisitor([&](AST::EnumerationMemberLiteral& secondEnumerationMemberLiteral) -> bool { 1360 1356 ASSERT(firstEnumerationMemberLiteral.enumerationMember()); 1361 1357 ASSERT(secondEnumerationMemberLiteral.enumerationMember()); 1362 success = firstEnumerationMemberLiteral.enumerationMember() != secondEnumerationMemberLiteral.enumerationMember(); 1363 }, [](auto&) { 1358 return firstEnumerationMemberLiteral.enumerationMember() != secondEnumerationMemberLiteral.enumerationMember(); 1359 }, [](auto&) -> bool { 1360 return true; 1364 1361 })); 1365 }, [](auto&) { 1362 }, [](auto&) -> bool { 1363 return true; 1366 1364 })); 1365 if (!success) { 1366 setError(); 1367 return; 1368 } 1367 1369 } 1368 1370 } … … 1373 1375 bool zeroValueExists; 1374 1376 for (auto& switchCase : switchStatement.switchCases()) { 1375 int64_t value; 1376 switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { 1377 value = integerLiteral.valueForSelectedType(); 1378 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { 1379 value = unsignedIntegerLiteral.valueForSelectedType(); 1380 }, [](auto&) { 1377 auto value = switchCase.value()->visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) -> int64_t { 1378 return integerLiteral.valueForSelectedType(); 1379 }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) -> int64_t { 1380 return unsignedIntegerLiteral.valueForSelectedType(); 1381 }, [](auto&) -> int64_t { 1381 1382 ASSERT_NOT_REACHED(); 1383 return 0; 1382 1384 })); 1383 1385 if (!value) … … 1406 1408 } 1407 1409 } else { 1408 ASSERT(is<AST::EnumerationDefinition>(*valueType));1409 1410 HashSet<AST::EnumerationMember*> values; 1410 1411 for (auto& switchCase : switchStatement.switchCases()) { -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp
r246273 r246428 189 189 } 190 190 191 ASSERT(is<AST::NativeTypeDeclaration>(possibleType));192 191 auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(possibleType); 193 192 if (nativeTypeDeclaration.typeArguments().size() != typeArguments.size()) -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp
r243091 r246428 348 348 bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType) 349 349 { 350 unsigned textureTypeIndex = WTF_ARRAY_LENGTH(m_textureTypeNames); 351 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_textureTypeNames); ++i) { 352 if (nativeTypeDeclaration.name() == m_textureTypeNames[i]) 353 textureTypeIndex = i; 354 } 350 auto textureTypeIndex = std::find(m_textureTypeNames, m_textureTypeNames + WTF_ARRAY_LENGTH(m_textureTypeNames), nativeTypeDeclaration.name()) - m_textureTypeNames; 355 351 if (textureTypeIndex == WTF_ARRAY_LENGTH(m_textureTypeNames)) 356 352 return false; … … 378 374 } 379 375 380 boolIntrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType)381 { 382 AST::NativeTypeDeclaration** texture ;376 void Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType) 377 { 378 AST::NativeTypeDeclaration** texture = nullptr; 383 379 if (nativeTypeDeclaration.name() == "TextureDepth2D") 384 380 texture = m_textureDepth2D; … … 389 385 else if (nativeTypeDeclaration.name() == "RWTextureDepth2DArray") 390 386 texture = m_rwTextureDepth2DArray; 391 else if (nativeTypeDeclaration.name() == "TextureDepthCube") 387 else { 388 ASSERT(nativeTypeDeclaration.name() == "TextureDepthCube"); 392 389 texture = m_textureDepthCube; 393 else394 ASSERT_NOT_REACHED();395 unsigned innerTypeIndex = WTF_ARRAY_LENGTH(m_depthTextureInnerTypes);396 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_depthTextureInnerTypes); ++i) {397 if (innerType.name() == m_depthTextureInnerTypes[i])398 innerTypeIndex = i;399 390 } 391 auto innerTypeIndex = std::find(m_depthTextureInnerTypes, m_depthTextureInnerTypes + WTF_ARRAY_LENGTH(m_depthTextureInnerTypes), innerType.name()) - m_depthTextureInnerTypes; 400 392 ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)); 401 393 nativeTypeDeclaration.setIsTexture(); 402 394 texture[innerTypeIndex] = &nativeTypeDeclaration; 403 return true;404 395 } 405 396 … … 414 405 return; 415 406 } 416 if (addDepthTexture(nativeTypeDeclaration, innerType))417 407 addDepthTexture(nativeTypeDeclaration, innerType); 408 m_textureSet.add(&nativeTypeDeclaration); 418 409 } 419 410 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h
r243091 r246428 232 232 bool addMatrix(AST::NativeTypeDeclaration&); 233 233 bool addFullTexture(AST::NativeTypeDeclaration&, AST::TypeReference&); 234 booladdDepthTexture(AST::NativeTypeDeclaration&, AST::TypeReference&);234 void addDepthTexture(AST::NativeTypeDeclaration&, AST::TypeReference&); 235 235 void addTexture(AST::NativeTypeDeclaration&); 236 236 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp
r246427 r246428 307 307 break; 308 308 ASSERT(!iterator->base().typeAnnotation().isRightValue()); 309 ASSERT(is<AST::PropertyAccessExpression>(iterator->base()));310 309 iterator = &downcast<AST::PropertyAccessExpression>(iterator->base()); 311 310 } … … 520 519 } 521 520 ASSERT(!assignmentExpression.left().typeAnnotation().isRightValue()); 522 ASSERT(is<AST::PropertyAccessExpression>(assignmentExpression.left()));523 521 524 522 auto type = assignmentExpression.right().resolvedType().clone(); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp
r246121 r246428 60 60 else if (is<AST::ArrayReferenceType>(unnamedType)) 61 61 checkErrorAndVisit(downcast<AST::ArrayReferenceType>(unnamedType)); 62 else { 63 ASSERT(is<AST::ArrayType>(unnamedType)); 62 else 64 63 checkErrorAndVisit(downcast<AST::ArrayType>(unnamedType)); 65 }66 64 } 67 65 … … 74 72 else if (is<AST::EnumerationDefinition>(namedType)) 75 73 checkErrorAndVisit(downcast<AST::EnumerationDefinition>(namedType)); 76 else { 77 ASSERT(is<AST::NativeTypeDeclaration>(namedType)); 74 else 78 75 checkErrorAndVisit(downcast<AST::NativeTypeDeclaration>(namedType)); 79 }80 76 } 81 77 … … 337 333 else if (is<AST::VariableDeclarationsStatement>(statement)) 338 334 checkErrorAndVisit(downcast<AST::VariableDeclarationsStatement>(statement)); 339 else { 340 ASSERT(is<AST::WhileLoop>(statement)); 335 else 341 336 checkErrorAndVisit(downcast<AST::WhileLoop>(statement)); 342 }343 337 } 344 338 … … 397 391 else if (is<AST::EnumerationMemberLiteral>(expression)) 398 392 checkErrorAndVisit(downcast<AST::EnumerationMemberLiteral>(expression)); 399 else { 400 ASSERT(is<AST::VariableReference>(expression)); 393 else 401 394 checkErrorAndVisit(downcast<AST::VariableReference>(expression)); 402 }403 395 } 404 396
Note: See TracChangeset
for help on using the changeset viewer.