[webkit-changes] [WebKit/WebKit] d22295: [WGSL] Implement parsing for array types and calla...

Dan Glastonbury noreply at github.com
Mon Sep 19 15:49:36 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d22295da2d69385297114b3985dbc255bdacadab
      https://github.com/WebKit/WebKit/commit/d22295da2d69385297114b3985dbc255bdacadab
  Author: Dan Glastonbury <djg at apple.com>
  Date:   2022-09-19 (Mon, 19 Sep 2022)

  Changed paths:
    M Source/WebGPU/WGSL/AST/TypeDecl.h
    M Source/WebGPU/WGSL/Parser.cpp
    M Source/WebGPU/WGSL/ParserPrivate.h
    M Source/WebGPU/WGSLUnitTests/WGSLParserTests.mm

  Log Message:
  -----------
  [WGSL] Implement parsing for array types and callable array constructors.
https://bugs.webkit.org/show_bug.cgi?id=244792
rdar://99557526

Reviewed by Myles Maxfield.

* Source/WebGPU/WGSL/AST/TypeDecl.h:
(WGSL::AST::TypeDecl::isArray const):
Add kind and predicate for array types.
* Source/WebGPU/WGSL/Parser.cpp:
(WGSL::Parser<Lexer>::parseTypeDecl):
Begin parsing of an array type declaration. Defers to parseArrayType to do
actual parsing.
(WGSL::Parser<Lexer>::parseArrayType):
Parse an array type consisting of 'array' ('<' TypeDecl (','
AdditionExpression)? '>')?
This is different to the WGSL spec as this recursive descent parser can't handle
the grammar factored as AdditiveExpression | BitwiseExpression. Making the
element TypeDecl optional allows the code to parse array in
CallableExpression. Validity of array TypeDecls that require element TypeDecl
will be handled when type-checking the AST.
(WGSL::Parser<Lexer>::parsePrimaryExpression):
Accept array type as a CallableExpression.
* Source/WebGPU/WGSL/ParserPrivate.h:
Add prototype for parsing array type
* Source/WebGPU/WGSLUnitTests/WGSLParserTests.mm:
- Test the parsing of a WebGPU example triangle vertex & fragment shader that
contains ArrayType, ArrayAccess and CallableExpression of array.
- Add some macros to help alleviate the repeative AST matching patterns.

Canonical link: https://commits.webkit.org/254650@main




More information about the webkit-changes mailing list