[WHLSL] Add the literal type checker
Created attachment 359126 [details] Patch
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 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.
Created attachment 359216 [details] Patch
Created attachment 359245 [details] Patch
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 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.
Committed r240095: <https://trac.webkit.org/changeset/240095>
<rdar://problem/47334356>