Bug 193430

Summary: [WHLSL] Add the literal type checker
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: New BugsAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, fpizlo, jonlee, justin_fan, rmorisset, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch dino: review+

Description Myles C. Maxfield 2019-01-14 20:45:55 PST
[WHLSL] Add the literal type checker
Comment 1 Myles C. Maxfield 2019-01-14 20:47:29 PST
Created attachment 359126 [details]
Patch
Comment 2 Myles C. Maxfield 2019-01-14 20:53:14 PST
Comment on attachment 359126 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=359126&action=review

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:104
> +    virtual void visit(AST::FloatLiteralType& floatLiteralType)
> +    {
> +        auto* nativeTypeDeclaration = getNativeTypeDeclaration(floatLiteralType);
> +        if (!nativeTypeDeclaration) {
> +            setError();
> +            return;
> +        }
> +        if (!nativeTypeDeclaration->canRepresentInteger()(floatLiteralType.value())) {
> +            setError();
> +            return;
> +        }
> +    }
> +
> +    virtual void visit(AST::IntegerLiteralType& integerLiteralType)
> +    {
> +        auto* nativeTypeDeclaration = getNativeTypeDeclaration(integerLiteralType);
> +        if (!nativeTypeDeclaration) {
> +            setError();
> +            return;
> +        }
> +        if (!nativeTypeDeclaration->canRepresentInteger()(integerLiteralType.value())) {
> +            setError();
> +            return;
> +        }
> +    }
> +
> +    virtual void visit(AST::UnsignedIntegerLiteralType& unsignedIntegerLiteralType)
> +    {
> +        auto* nativeTypeDeclaration = getNativeTypeDeclaration(unsignedIntegerLiteralType);
> +        if (!nativeTypeDeclaration) {
> +            setError();
> +            return;
> +        }
> +        if (!nativeTypeDeclaration->canRepresentInteger()(unsignedIntegerLiteralType.value())) {
> +            setError();
> +            return;
> +        }
> +    }
> +
> +    virtual void visit(AST::NullLiteralType& nullLiteralType)
> +    {
> +        if (!nullLiteralType.resolvedType())
> +            setError();
> +    }

These can be private.
Comment 3 Myles C. Maxfield 2019-01-14 20:55:08 PST
Comment on attachment 359126 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=359126&action=review

>> Source/WebCore/Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:104
>> +    }
> 
> These can be private.

Also be marked as override instead of virtual.
Comment 4 Myles C. Maxfield 2019-01-15 16:03:35 PST
Created attachment 359216 [details]
Patch
Comment 5 Myles C. Maxfield 2019-01-15 19:10:08 PST
Created attachment 359245 [details]
Patch
Comment 6 Saam Barati 2019-01-16 08:36:51 PST
Comment on attachment 359245 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=359245&action=review

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:67
> +        ASSERT(nativeTypeDeclaration->canRepresentInteger()(floatLiteralType.value()));

This doesn’t look correct to me but I haven’t looked in detail. Shouldn’t this be something like canRepresentFloat?

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:100
> +}

// namespace ..
Comment 7 Dean Jackson 2019-01-16 12:30:10 PST
Comment on attachment 359245 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=359245&action=review

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:60
> +    LiteralTypeChecker() = default;
> +
> +    virtual ~LiteralTypeChecker() = default;

Not needed.
Comment 8 Myles C. Maxfield 2019-01-16 16:31:27 PST
Committed r240095: <https://trac.webkit.org/changeset/240095>
Comment 9 Radar WebKit Bug Importer 2019-01-16 16:32:38 PST
<rdar://problem/47334356>