[webkit-changes] [WebKit/WebKit] 09f41c: [WGSL] Make number parsing conform to the spec

Tadeu Zagallo noreply at github.com
Wed Oct 25 13:17:23 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 09f41c245383b69d1a6bc8fb1c2ceec14ccc8282
      https://github.com/WebKit/WebKit/commit/09f41c245383b69d1a6bc8fb1c2ceec14ccc8282
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-10-25 (Wed, 25 Oct 2023)

  Changed paths:
    M Source/WebGPU/WGSL/ConstantValue.h
    M Source/WebGPU/WGSL/Lexer.cpp
    M Source/WebGPU/WGSL/Lexer.h
    M Source/WebGPU/WGSL/TypeCheck.cpp
    M Source/WebGPU/WebGPU/ShaderModule.h
    M Source/WebGPU/WebGPU/ShaderModule.mm

  Log Message:
  -----------
  [WGSL] Make number parsing conform to the spec
https://bugs.webkit.org/show_bug.cgi?id=263675
rdar://117486209

Reviewed by Mike Wyrzykowski.

Refactor how we lex numbers to unify the code and add support for hexadecimal
float literals. Some of decimal float CTS tests were also failing, so a refactor
seemed appropriate. Additionally, this patch also handles the constant narrowing
during type conversion, since that code is shared with the promoting done via
literal suffixes. With these two changes, (nearly) all number parsing CTS tests
now pass, the only exception being tests that use f16. The new version of the
lexer/parser uses a hand-written state machine derived from the grammar, so I
left the comment in there hoping it helps understand what is going on when going
back to this code.

* Source/WebGPU/WGSL/ConstantValue.h:
(WGSL::ConstantValue::isArray const):
(WGSL::convertInteger):
(WGSL::convertFloat):
* Source/WebGPU/WGSL/Lexer.cpp:
(WGSL::Lexer<T>::nextToken):
(WGSL::Lexer<T>::lexNumber):
(WGSL::Lexer<T>::parseDecimalInteger): Deleted.
(WGSL::Lexer<T>::parseDecimalFloatExponent): Deleted.
(WGSL::Lexer<T>::parseIntegerLiteralSuffix): Deleted.
* Source/WebGPU/WGSL/Lexer.h:
(WGSL::Lexer::isIdentifierContinue):
(WGSL::Lexer::readDecimal): Deleted.
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::visitVariable):
(WGSL::TypeChecker::convertValue):
* Source/WebGPU/WebGPU/ShaderModule.h:
(WebGPU::ShaderModule::createInvalid):
* Source/WebGPU/WebGPU/ShaderModule.mm:
(WebGPU::Device::createShaderModule):
(WebGPU::ShaderModule::ShaderModule):
(WebGPU::m_device): Deleted.

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




More information about the webkit-changes mailing list