Changeset 246428 in webkit


Ignore:
Timestamp:
Jun 13, 2019 10:45:43 PM (5 years ago)
Author:
mmaxfield@apple.com
Message:

[WHLSL] Remove unnecessary ASSERT()s and clean up visitor lambdas
https://bugs.webkit.org/show_bug.cgi?id=198706

Reviewed by Dean Jackson, Saam Barati, and Robin Morisset.

Some minor refactoring.

If the code is going to unconditionally downcast<Foo>(bar), there's no need
to guard that with an ASSERT(is<Foo>(bar)) because the downcast() call will
do that automatically.

No new tests because there is no behavior change.

  • Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h:

(WebCore::WHLSL::AST::ConstantExpression::visit):
(WebCore::WHLSL::AST::ConstantExpression::visit const):

  • Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp:

(WebCore::WHLSL::Metal::EntryPointScaffolding::resourceHelperTypes):
(WebCore::WHLSL::Metal::EntryPointScaffolding::mangledOutputPath):
(WebCore::WHLSL::Metal::EntryPointScaffolding::unpackResourcesAndNamedBuiltIns):

  • Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:

(WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit):
(WebCore::WHLSL::Metal::FunctionDefinitionWriter::constantExpressionString):

  • Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:

(WebCore::WHLSL::Metal::writeNativeFunction):

  • Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp:

(WebCore::WHLSL::Metal::writeNativeType):

  • Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp:

(WebCore::WHLSL::Metal::find):
(WebCore::WHLSL::Metal::TypeNamer::createNameNode):
(WebCore::WHLSL::Metal::TypeNamer::insert):
(WebCore::WHLSL::Metal::TypeNamer::emitUnnamedTypeDefinition):
(WebCore::WHLSL::Metal::TypeNamer::emitNamedTypeDefinition):

  • Modules/webgpu/WHLSL/WHLSLChecker.cpp:

(WebCore::WHLSL::Checker::visit):
(WebCore::WHLSL::argumentTypeForAndOverload):

  • Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:

(WebCore::WHLSL::inferTypesForTypeArguments):

  • Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp:

(WebCore::WHLSL::Intrinsics::addFullTexture):
(WebCore::WHLSL::Intrinsics::addDepthTexture):

  • Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:

(WebCore::WHLSL::modify):
(WebCore::WHLSL::PropertyResolver::visit):

  • Modules/webgpu/WHLSL/WHLSLVisitor.cpp:

(WebCore::WHLSL::Visitor::visit):

Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r246427 r246428  
     12019-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
    1502019-06-12  Myles C. Maxfield  <mmaxfield@apple.com>
    251
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h

    r245680 r246428  
    8989    }
    9090
    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>&>()))
    9292    {
    93         WTF::visit(WTFMove(t), m_variant);
     93        return WTF::visit(visitor, m_variant);
    9494    }
    9595
    96     template<typename T> void visit(T&& t) const
     96    template <typename Visitor> auto visit(const Visitor& visitor) const -> decltype(WTF::visit(visitor, std::declval<Variant<IntegerLiteral, UnsignedIntegerLiteral, FloatLiteral, NullLiteral, BooleanLiteral, EnumerationMemberLiteral>&>()))
    9797    {
    98         WTF::visit(WTFMove(t), m_variant);
     98        return WTF::visit(visitor, m_variant);
    9999    }
    100100
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp

    r246427 r246428  
    149149                continue;
    150150            auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType;
    151             ASSERT(is<AST::ReferenceType>(unnamedType));
    152151            auto& referenceType = downcast<AST::ReferenceType>(unnamedType);
    153152            auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType());
     
    278277    AST::StructureDefinition* structureDefinition = nullptr;
    279278    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));
    284280    for (auto& component : path) {
    285281        ASSERT(structureDefinition);
     
    318314
    319315                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());
    323317
    324318                stringBuilder.append(makeString("size_t ", lengthTemporaryName, " = ", variableName, '.', lengthElementName, ".x;\n"));
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp

    r246273 r246428  
    398398{
    399399    auto& unifyNode = nullLiteral.resolvedType().unifyNode();
    400     ASSERT(is<AST::UnnamedType>(unifyNode));
    401400    auto& unnamedType = downcast<AST::UnnamedType>(unifyNode);
    402401    bool isArrayReferenceType = is<AST::ArrayReferenceType>(unnamedType);
     
    621620String FunctionDefinitionWriter::constantExpressionString(AST::ConstantExpression& constantExpression)
    622621{
    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 {
    635633        ASSERT(enumerationMemberLiteral.enumerationDefinition());
    636634        ASSERT(enumerationMemberLiteral.enumerationDefinition());
    637         result = makeString(m_typeNamer.mangledNameForType(*enumerationMemberLiteral.enumerationDefinition()), '.', m_typeNamer.mangledNameForEnumerationMember(*enumerationMemberLiteral.enumerationMember()));
     635        return makeString(m_typeNamer.mangledNameForType(*enumerationMemberLiteral.enumerationDefinition()), '.', m_typeNamer.mangledNameForEnumerationMember(*enumerationMemberLiteral.enumerationMember()));
    638636    }));
    639     return result;
    640637}
    641638
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp

    r246385 r246428  
    135135        auto metalParameterName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type());
    136136        auto& parameterType = nativeFunctionDeclaration.parameters()[0]->type()->unifyNode();
    137         ASSERT(is<AST::UnnamedType>(parameterType));
    138137        auto& unnamedParameterType = downcast<AST::UnnamedType>(parameterType);
    139138        if (is<AST::ArrayType>(unnamedParameterType)) {
     
    352351        if (nativeFunctionDeclaration.name() == "InterlockedCompareExchange") {
    353352            ASSERT(nativeFunctionDeclaration.parameters().size() == 4);
    354             ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()));
    355353            auto& firstArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type());
    356354            auto firstArgumentAddressSpace = firstArgumentPointer.addressSpace();
     
    358356            auto secondArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type());
    359357            auto thirdArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[2]->type());
    360             ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[3]->type()));
    361358            auto& fourthArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[3]->type());
    362359            auto fourthArgumentAddressSpace = fourthArgumentPointer.addressSpace();
     
    370367
    371368        ASSERT(nativeFunctionDeclaration.parameters().size() == 3);
    372         ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type()));
    373369        auto& firstArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[0]->type());
    374370        auto firstArgumentAddressSpace = firstArgumentPointer.addressSpace();
    375371        auto firstArgumentPointee = typeNamer.mangledNameForType(firstArgumentPointer.elementType());
    376372        auto secondArgument = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type());
    377         ASSERT(is<AST::PointerType>(*nativeFunctionDeclaration.parameters()[2]->type()));
    378373        auto& thirdArgumentPointer = downcast<AST::PointerType>(*nativeFunctionDeclaration.parameters()[2]->type());
    379374        auto thirdArgumentAddressSpace = thirdArgumentPointer.addressSpace();
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp

    r245680 r246428  
    7272        auto& typeReference = WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]);
    7373        auto& unifyNode = typeReference->unifyNode();
    74         ASSERT(is<AST::NamedType>(unifyNode));
    7574        auto& namedType = downcast<AST::NamedType>(unifyNode);
    76         ASSERT(is<AST::NativeTypeDeclaration>(namedType));
    7775        auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType);
    7876        auto prefix = ([&]() -> String {
     
    117115        auto& typeReference = WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]);
    118116        auto& unifyNode = typeReference->unifyNode();
    119         ASSERT(is<AST::NamedType>(unifyNode));
    120117        auto& namedType = downcast<AST::NamedType>(unifyNode);
    121         ASSERT(is<AST::NativeTypeDeclaration>(namedType));
    122118        auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType);
    123119        auto prefix = ([&]() -> String {
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp

    r245680 r246428  
    202202        if (is<AST::ArrayReferenceType>(unnamedType))
    203203            return find(downcast<AST::ArrayReferenceType>(unnamedType).elementType(), types).children();
    204         ASSERT(is<AST::ArrayType>(unnamedType));
    205204        return find(downcast<AST::ArrayType>(unnamedType).type(), types).children();
    206205    })();
     
    307306        return makeUniqueRef<ArrayReferenceTypeNameNode>(parent, generateNextTypeName(), arrayReferenceType.addressSpace());
    308307    }
    309     ASSERT(is<AST::ArrayType>(unnamedType));
    310308    auto& arrayType = downcast<AST::ArrayType>(unnamedType);
    311309    return makeUniqueRef<ArrayTypeNameNode>(parent, generateNextTypeName(), arrayType.numElements());
     
    328326        parent = &item;
    329327    } else {
    330         ASSERT(is<AST::ArrayType>(unnamedType));
    331328        auto& item = types[insert(downcast<AST::ArrayType>(unnamedType).type(), types)];
    332329        vectorToInsertInto = &item->children();
     
    400397        stringBuilder.append("};\n");
    401398    } else {
    402         ASSERT(is<ArrayTypeNameNode>(baseTypeNameNode));
    403399        auto& arrayType = downcast<ArrayTypeNameNode>(baseTypeNameNode);
    404400        ASSERT(baseTypeNameNode.parent());
     
    419415        auto& enumerationDefinition = downcast<AST::EnumerationDefinition>(namedType);
    420416        auto& baseType = enumerationDefinition.type().unifyNode();
    421         ASSERT(is<AST::NamedType>(baseType));
    422417        stringBuilder.append(makeString("enum class ", mangledNameForType(enumerationDefinition), " : ", mangledNameForType(downcast<AST::NamedType>(baseType)), " {\n"));
    423418        for (auto& enumerationMember : enumerationDefinition.enumerationMembers())
     
    433428        stringBuilder.append("};\n");
    434429    } else {
    435         ASSERT(is<AST::TypeDefinition>(namedType));
    436430        auto& typeDefinition = downcast<AST::TypeDefinition>(namedType);
    437431        stringBuilder.append(makeString("typedef ", mangledNameForType(typeDefinition.type()), ' ', mangledNameForType(typeDefinition), ";\n"));
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp

    r246394 r246428  
    657657
    658658    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 {
    661660            auto valueInfo = recurseAndGetInfo(value);
    662661            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));
    665664        }));
    666         return success;
    667665    };
    668666
     
    680678    for (auto& member : enumerationMembers) {
    681679        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 {
    688685                ASSERT_NOT_REACHED();
     686                return 0;
    689687            }));
    690688            nextValue = baseType->successor()(value);
     
    707705
    708706    auto getValue = [&](AST::EnumerationMember& member) -> int64_t {
    709         int64_t value;
    710707        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 {
    716713            ASSERT_NOT_REACHED();
     714            return 0;
    717715        }));
    718716        return value;
     
    978976    }
    979977
    980     ASSERT(is<AST::UnnamedType>(unifyNode));
    981978    auto& unnamedType = downcast<AST::UnnamedType>(unifyNode);
    982979
     
    13061303            continue;
    13071304        }
    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 {
    13201316            ASSERT(enumerationMemberLiteral.enumerationDefinition());
    1321             success = matches(*valueType, *enumerationMemberLiteral.enumerationDefinition());
     1317            return matches(*valueType, *enumerationMemberLiteral.enumerationDefinition());
    13221318        }));
    13231319        if (!success) {
     
    13401336            }
    13411337
    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;
    13491345                }));
    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;
    13561353                }));
    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 {
    13601356                    ASSERT(firstEnumerationMemberLiteral.enumerationMember());
    13611357                    ASSERT(secondEnumerationMemberLiteral.enumerationMember());
    1362                     success = firstEnumerationMemberLiteral.enumerationMember() != secondEnumerationMemberLiteral.enumerationMember();
    1363                 }, [](auto&) {
     1358                    return firstEnumerationMemberLiteral.enumerationMember() != secondEnumerationMemberLiteral.enumerationMember();
     1359                }, [](auto&) -> bool {
     1360                    return true;
    13641361                }));
    1365             }, [](auto&) {
     1362            }, [](auto&) -> bool {
     1363                return true;
    13661364            }));
     1365            if (!success) {
     1366                setError();
     1367                return;
     1368            }
    13671369        }
    13681370    }
     
    13731375            bool zeroValueExists;
    13741376            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 {
    13811382                    ASSERT_NOT_REACHED();
     1383                    return 0;
    13821384                }));
    13831385                if (!value)
     
    14061408            }
    14071409        } else {
    1408             ASSERT(is<AST::EnumerationDefinition>(*valueType));
    14091410            HashSet<AST::EnumerationMember*> values;
    14101411            for (auto& switchCase : switchStatement.switchCases()) {
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp

    r246273 r246428  
    189189    }
    190190
    191     ASSERT(is<AST::NativeTypeDeclaration>(possibleType));
    192191    auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(possibleType);
    193192    if (nativeTypeDeclaration.typeArguments().size() != typeArguments.size())
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp

    r243091 r246428  
    348348bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType)
    349349{
    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;
    355351    if (textureTypeIndex == WTF_ARRAY_LENGTH(m_textureTypeNames))
    356352        return false;
     
    378374}
    379375
    380 bool Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType)
    381 {
    382     AST::NativeTypeDeclaration** texture;
     376void Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType)
     377{
     378    AST::NativeTypeDeclaration** texture = nullptr;
    383379    if (nativeTypeDeclaration.name() == "TextureDepth2D")
    384380        texture = m_textureDepth2D;
     
    389385    else if (nativeTypeDeclaration.name() == "RWTextureDepth2DArray")
    390386        texture = m_rwTextureDepth2DArray;
    391     else if (nativeTypeDeclaration.name() == "TextureDepthCube")
     387    else {
     388        ASSERT(nativeTypeDeclaration.name() == "TextureDepthCube");
    392389        texture = m_textureDepthCube;
    393     else
    394         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;
    399390    }
     391    auto innerTypeIndex = std::find(m_depthTextureInnerTypes, m_depthTextureInnerTypes + WTF_ARRAY_LENGTH(m_depthTextureInnerTypes), innerType.name()) - m_depthTextureInnerTypes;
    400392    ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_depthTextureInnerTypes));
    401393    nativeTypeDeclaration.setIsTexture();
    402394    texture[innerTypeIndex] = &nativeTypeDeclaration;
    403     return true;
    404395}
    405396
     
    414405        return;
    415406    }
    416     if (addDepthTexture(nativeTypeDeclaration, innerType))
    417         m_textureSet.add(&nativeTypeDeclaration);
     407    addDepthTexture(nativeTypeDeclaration, innerType);
     408    m_textureSet.add(&nativeTypeDeclaration);
    418409}
    419410
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h

    r243091 r246428  
    232232    bool addMatrix(AST::NativeTypeDeclaration&);
    233233    bool addFullTexture(AST::NativeTypeDeclaration&, AST::TypeReference&);
    234     bool addDepthTexture(AST::NativeTypeDeclaration&, AST::TypeReference&);
     234    void addDepthTexture(AST::NativeTypeDeclaration&, AST::TypeReference&);
    235235    void addTexture(AST::NativeTypeDeclaration&);
    236236
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp

    r246427 r246428  
    307307            break;
    308308        ASSERT(!iterator->base().typeAnnotation().isRightValue());
    309         ASSERT(is<AST::PropertyAccessExpression>(iterator->base()));
    310309        iterator = &downcast<AST::PropertyAccessExpression>(iterator->base());
    311310    }
     
    520519    }
    521520    ASSERT(!assignmentExpression.left().typeAnnotation().isRightValue());
    522     ASSERT(is<AST::PropertyAccessExpression>(assignmentExpression.left()));
    523521
    524522    auto type = assignmentExpression.right().resolvedType().clone();
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp

    r246121 r246428  
    6060    else if (is<AST::ArrayReferenceType>(unnamedType))
    6161        checkErrorAndVisit(downcast<AST::ArrayReferenceType>(unnamedType));
    62     else {
    63         ASSERT(is<AST::ArrayType>(unnamedType));
     62    else
    6463        checkErrorAndVisit(downcast<AST::ArrayType>(unnamedType));
    65     }
    6664}
    6765
     
    7472    else if (is<AST::EnumerationDefinition>(namedType))
    7573        checkErrorAndVisit(downcast<AST::EnumerationDefinition>(namedType));
    76     else {
    77         ASSERT(is<AST::NativeTypeDeclaration>(namedType));
     74    else
    7875        checkErrorAndVisit(downcast<AST::NativeTypeDeclaration>(namedType));
    79     }
    8076}
    8177
     
    337333    else if (is<AST::VariableDeclarationsStatement>(statement))
    338334        checkErrorAndVisit(downcast<AST::VariableDeclarationsStatement>(statement));
    339     else {
    340         ASSERT(is<AST::WhileLoop>(statement));
     335    else
    341336        checkErrorAndVisit(downcast<AST::WhileLoop>(statement));
    342     }
    343337}
    344338
     
    397391    else if (is<AST::EnumerationMemberLiteral>(expression))
    398392        checkErrorAndVisit(downcast<AST::EnumerationMemberLiteral>(expression));
    399     else {
    400         ASSERT(is<AST::VariableReference>(expression));
     393    else
    401394        checkErrorAndVisit(downcast<AST::VariableReference>(expression));
    402     }
    403395}
    404396
Note: See TracChangeset for help on using the changeset viewer.