[webkit-changes] [WebKit/WebKit] 250024: [WGSL] Implement local var statement parsing

Dan Glastonbury noreply at github.com
Sat Sep 3 20:06:20 PDT 2022


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

  Changed paths:
    M Source/WebGPU/WGSL/AST/Statement.h
    A Source/WebGPU/WGSL/AST/Statements/VariableStatement.h
    M Source/WebGPU/WGSL/Parser.cpp
    M Source/WebGPU/WGSL/ParserPrivate.h
    M Source/WebGPU/WGSLUnitTests/WGSLParserTests.mm
    M Source/WebGPU/WebGPU.xcodeproj/project.pbxproj

  Log Message:
  -----------
  [WGSL] Implement local var statement parsing
https://bugs.webkit.org/show_bug.cgi?id=244760
rdar://problem/99521231

Reviewed by Myles C. Maxfield.

Make use of existing VariableDecl to implement VariableStatement nodes
representing local variable declaration statements beginning with 'var' keyword.

* Source/WebGPU/WGSL/AST/Statement.h:
Add Variable to Statement::Kind
(WGSL::AST::Statement::isVariable const):
Predicate for new VariableStatement node
* Source/WebGPU/WGSL/Parser.cpp:
(WGSL::Parser<Lexer>::parseVariableDecl):
(WGSL::Parser<Lexer>::parseVariableDeclWithAttributes):
Only global variables can have attributes. Split parsing into parseVariable that
passes an empty list of Attributes for local variable decls and
parseVariableDeclWithAttributes for global variable decls.
(WGSL::Parser<Lexer>::parseStatement):
Handle parsing of variable statements beginning with 'var' keyword.
* Source/WebGPU/WGSLUnitTests/WGSLParserTests.mm:
(-[WGSLParserTests testParsingLocalVariable]):
Simple test of a function with a local variable.
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:
Add VariableStatement.h

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




More information about the webkit-changes mailing list