Bug 193430 - [WHLSL] Add the literal type checker
Summary: [WHLSL] Add the literal type checker
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-01-14 20:45 PST by Myles C. Maxfield
Modified: 2019-01-16 16:32 PST (History)
7 users (show)

See Also:


Attachments
Patch (12.67 KB, patch)
2019-01-14 20:47 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (13.21 KB, patch)
2019-01-15 16:03 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (19.83 KB, patch)
2019-01-15 19:10 PST, Myles C. Maxfield
dino: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>