WebKit Bugzilla
Attachment 357035 Details for
Bug 192355
: [WHLSL] Add a handwritten parser
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
bug-192355-20181210223926.patch (text/plain), 198.39 KB, created by
Myles C. Maxfield
on 2018-12-10 22:39:27 PST
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-12-10 22:39:27 PST
Size:
198.39 KB
patch
obsolete
>Subversion Revision: 239068 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b322b31e5c30f2b930c6524d46a5d4f67975acc5..fd19778af369cc7b237e65601b3bcac5b1183f56 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,77 @@ >+2018-12-10 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Add a handwritten parser >+ https://bugs.webkit.org/show_bug.cgi?id=192355 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * Modules/webgpu/WHLSL/WHLSLASTEnumDef.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTEnumDef.h: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTFuncDef.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTFuncDef.h: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.h: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.h: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTStructDef.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTStructDef.h: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTType.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTType.h: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTTypeDef.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTTypeDef.h: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTVariableDecl.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLASTVariableDecl.h: Added. >+ * Modules/webgpu/WHLSL/WHLSLLexer.cpp: Added. >+ (WebCore::WHLSL::Lexer::consumeTokenFromStream): >+ (WebCore::WHLSL::Lexer::skipWhitespaceAndComments): >+ (WebCore::WHLSL::isWhitespace): >+ (WebCore::WHLSL::isNewline): >+ (WebCore::WHLSL::Lexer::skipWhitespace): >+ (WebCore::WHLSL::Lexer::skipLineComment): >+ (WebCore::WHLSL::Lexer::skipLongComment): >+ (WebCore::WHLSL::Lexer::coreDecimalIntLiteral const): >+ (WebCore::WHLSL::Lexer::decimalIntLiteral const): >+ (WebCore::WHLSL::Lexer::decimalUintLiteral const): >+ (WebCore::WHLSL::isHexadecimalCharacter): >+ (WebCore::WHLSL::Lexer::coreHexadecimalIntLiteral const): >+ (WebCore::WHLSL::Lexer::hexadecimalIntLiteral const): >+ (WebCore::WHLSL::Lexer::hexadecimalUintLiteral const): >+ (WebCore::WHLSL::Lexer::intLiteral const): >+ (WebCore::WHLSL::Lexer::digit const): >+ (WebCore::WHLSL::Lexer::digitStar const): >+ (WebCore::WHLSL::Lexer::character const): >+ (WebCore::WHLSL::Lexer::coreFloatLiteralType1 const): >+ (WebCore::WHLSL::Lexer::coreFloatLiteral const): >+ (WebCore::WHLSL::Lexer::floatLiteral const): >+ (WebCore::WHLSL::Lexer::qualifier const): >+ (WebCore::WHLSL::Lexer::semantic const): >+ (WebCore::WHLSL::Lexer::numthreads const): >+ (WebCore::WHLSL::Lexer::validIdentifier const): >+ (WebCore::WHLSL::Lexer::identifier const): >+ (WebCore::WHLSL::Lexer::operatorName const): >+ * Modules/webgpu/WHLSL/WHLSLLexer.h: Added. >+ (WebCore::WHLSL::Lexer::Lexer): >+ (WebCore::WHLSL::Lexer::consumeToken): >+ (WebCore::WHLSL::Lexer::unconsumeToken): >+ (WebCore::WHLSL::Lexer::state const): >+ (WebCore::WHLSL::Lexer::setState): >+ (WebCore::WHLSL::Lexer::isFullyConsumed const): >+ (WebCore::WHLSL::Lexer::string const): >+ (WebCore::WHLSL::Lexer::anyCharacter const): >+ * Modules/webgpu/WHLSL/WHLSLParser.cpp: Added. >+ (WebCore::WHLSL::Parser::Parser): >+ (WebCore::WHLSL::Parser::parse): >+ (WebCore::WHLSL::Parser::parseType): >+ * Modules/webgpu/WHLSL/WHLSLParser.h: Added. >+ (WebCore::WHLSL::Parser::backtrackingScope): >+ (WebCore::WHLSL::Parser::testScope): >+ * Modules/webgpu/WHLSL/WHLSLProgram.cpp: Added. >+ * Modules/webgpu/WHLSL/WHLSLProgram.h: Added. >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ > 2018-12-10 Don Olmstead <don.olmstead@sony.com> > > Move ENABLE_RESOURCE_LOAD_STATISTICS to FeatureDefines.xcconfig >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayReferenceType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayReferenceType.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..718a233a0d05d3516a5000a7d339396ffe77fbe7 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayReferenceType.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTArrayReferenceType.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayReferenceType.h >new file mode 100644 >index 0000000000000000000000000000000000000000..a6a7324482d18da1912bd62310eeb259a7b8d8b4 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayReferenceType.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTReferenceType.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class ArrayReferenceType : public ReferenceType { >+public: >+ ArrayReferenceType(Lexer::Token&& origin, String&& addressSpace, std::unique_ptr<Type>&& elementType) >+ : ReferenceType(WTFMove(origin), WTFMove(addressSpace), WTFMove(elementType)) >+ { >+ } >+ >+ virtual ~ArrayReferenceType() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayType.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..a003551b8a4a06c380cfb6ba41469143d413a0b9 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayType.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTArrayType.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayType.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayType.h >new file mode 100644 >index 0000000000000000000000000000000000000000..b856007fc8c2279db73dee98f8c98a378a56efce >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayType.h >@@ -0,0 +1,68 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTType.h" >+#include "WHLSLASTTypeArgument.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class ArrayType : public Type { >+public: >+ ArrayType(Lexer::Token&& origin, std::unique_ptr<Type>&& elementType, unsigned numElements) >+ : m_origin(WTFMove(origin)) >+ , m_elementType(WTFMove(elementType)) >+ , m_numElements(numElements) >+ { >+ } >+ >+ virtual ~ArrayType() >+ { >+ } >+ >+ unsigned numElements() const { return m_numElements; } >+ >+private: >+ Lexer::Token m_origin; >+ std::unique_ptr<Type> m_elementType; >+ unsigned m_numElements; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseSemantic.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..7675146e6aba24171f19190107498691913d2d09 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseSemantic.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTSemantic.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseSemantic.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0c5b6028334c7f7edd6c04696e77bab91970570a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseSemantic.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class BaseSemantic : public Node { >+public: >+ BaseSemantic(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~BaseSemantic() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBuiltInSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBuiltInSemantic.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d6a091d4cae5273dd7df5b4451d575ff5e130c39 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBuiltInSemantic.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTBuiltInSemantic.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBuiltInSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBuiltInSemantic.h >new file mode 100644 >index 0000000000000000000000000000000000000000..92977a4ed7bfccb7ce577d4f4553d3613555f42a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBuiltInSemantic.h >@@ -0,0 +1,82 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTBaseSemantic.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class BuiltInSemantic : public BaseSemantic { >+public: >+ enum class Variable { >+ SVInstanceID, >+ SVVertexID, >+ PSize, >+ SVPosition, >+ SVIsFrontFace, >+ SVSampleIndex, >+ SVInnerCoverage, >+ SVTarget, >+ SVDepth, >+ SVCoverage, >+ SVDispatchThreadID, >+ SVGroupID, >+ SVGroupIndex, >+ SVGroupThreadID >+ }; >+ >+ BuiltInSemantic(Lexer::Token&& origin, Variable variable, std::optional<unsigned>&& targetIndex = std::nullopt) >+ : BaseSemantic(WTFMove(origin)) >+ , m_variable(variable) >+ , m_targetIndex(WTFMove(targetIndex)) >+ { >+ } >+ >+ virtual ~BuiltInSemantic() >+ { >+ } >+ >+ Variable variable() const { return m_variable; } >+ >+private: >+ Variable m_variable; >+ std::optional<unsigned> m_targetIndex; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstExpr.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstExpr.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..bf7160f64fcd2475a3e6dd7c61eb57f345f2bb8e >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstExpr.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTConstExpr.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstExpr.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstExpr.h >new file mode 100644 >index 0000000000000000000000000000000000000000..e66a988c21ced40a9939e67e9215c0cb42d8f20f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstExpr.h >@@ -0,0 +1,89 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+// FIXME: Represent this better >+class ConstExpr : public Node { >+public: >+ static ConstExpr createWithLiteral(Lexer::Token&& token) >+ { >+ ConstExpr result; >+ result.first = WTFMove(token); >+ result.type = Type::Literal; >+ return result; >+ } >+ >+ static ConstExpr createWithIdentifier(Lexer::Token&& token) >+ { >+ ConstExpr result; >+ result.first = WTFMove(token); >+ result.type = Type::Identifier; >+ return result; >+ } >+ >+ static ConstExpr createWithIdentifierDotIdentifier(Lexer::Token&& token1, Lexer::Token&& token2) >+ { >+ ConstExpr result; >+ result.first = WTFMove(token1); >+ result.second = WTFMove(token2); >+ result.type = Type::Identifier; >+ return result; >+ } >+ >+ virtual ~ConstExpr() >+ { >+ } >+ >+private: >+ // "origin" is the same as "first". >+ Lexer::Token first; >+ Lexer::Token second; >+ >+ enum class Type { >+ Literal, >+ Identifier, >+ IdentifierDotIdentifier >+ } type; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumDef.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumDef.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..623cb0768d2dea4c1c588a757d286750cea98f5e >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumDef.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTEnumDef.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumDef.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumDef.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7fc37eb8bca8c5b0a1b9dbc4e52315fae1c4d3b5 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumDef.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class EnumDef : public Node { >+public: >+ EnumDef(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~EnumDef() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumMember.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumMember.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..8416e1cf5b75c13f7c7626f303280e711fd2558f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumMember.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTEnumMember.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumMember.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumMember.h >new file mode 100644 >index 0000000000000000000000000000000000000000..3224396769da1f2d4f15612b7261c9870257f8ec >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumMember.h >@@ -0,0 +1,67 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTConstExpr.h" >+#include "WHLSLASTNode.h" >+#include "WHLSLLexer.h" >+#include <wtf/Optional.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class EnumMember : public Node { >+public: >+ EnumMember(Lexer::Token&& origin, String&& name, std::optional<ConstExpr>&& value = std::nullopt) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_value(WTFMove(value)) >+ { >+ } >+ >+ virtual ~EnumMember() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ std::optional<ConstExpr> m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumType.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e40b72770d6bf6ab71cc1379ce69c7dd2956893b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumType.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTEnumType.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumType.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumType.h >new file mode 100644 >index 0000000000000000000000000000000000000000..dfa3eb8923f4078f857dee1ac2a26e3940f84722 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumType.h >@@ -0,0 +1,71 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTEnumMember.h" >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class EnumType : public Type { >+public: >+ EnumType(Lexer::Token&& origin, String&& name, std::unique_ptr<Type>&& type, Vector<EnumMember> members) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_type(WTFMove(type)) >+ , m_members(WTFMove(members)) >+ { >+ } >+ >+ virtual ~EnumType() >+ { >+ } >+ >+ EnumType(EnumType&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ std::unique_ptr<Type> m_type; >+ Vector<EnumMember> m_members; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTField.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTField.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..8642d4d5c025e56879a8f1a25914a906467cfd4f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTField.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTField.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTField.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTField.h >new file mode 100644 >index 0000000000000000000000000000000000000000..3245aa1b564a2d7cf1c5dd6e4d067c5fa44ee60a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTField.h >@@ -0,0 +1,73 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+#include "WHLSLASTQualifier.h" >+#include "WHLSLASTSemantic.h" >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Field : public Node { >+public: >+ Field(Lexer::Token&& origin, Vector<Qualifier>&& qualifiers, std::unique_ptr<Type>&& type, String&& name, std::optional<Semantic> semantic) >+ : m_origin(WTFMove(origin)) >+ , m_qualifiers(WTFMove(qualifiers)) >+ , m_type(WTFMove(type)) >+ , m_name(WTFMove(name)) >+ , m_semantic(WTFMove(semantic)) >+ { >+ } >+ >+ virtual ~Field() >+ { >+ } >+ >+ Field(Field&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+ Vector<Qualifier> m_qualifiers; >+ std::unique_ptr<Type> m_type; >+ String m_name; >+ std::optional<Semantic> m_semantic; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFuncDef.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFuncDef.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2d63c430306fe8b91c4b20253edbac5ee667fa2f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFuncDef.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTFuncDef.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFuncDef.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFuncDef.h >new file mode 100644 >index 0000000000000000000000000000000000000000..5829cee040db8738a14a8294e9dea0f0f663964f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFuncDef.h >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class FuncDef : public Node { >+public: >+ virtual ~FuncDef() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..5c42c74d4603492c8460bff075c6fc45b3e2c537 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTNativeFuncDecl.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.h >new file mode 100644 >index 0000000000000000000000000000000000000000..266da1c0883cdc6f92798a723620b6ed750211af >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.h >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class NativeFuncDecl { >+public: >+ virtual ~NativeFuncDecl() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..72b74ad26e6520b2aa300b8fbd3d32e215c85e81 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTNativeTypeDecl.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0b49e72a1b43842919a00d3b010755102b4cd796 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class NativeTypeDecl { >+public: >+ NativeTypeDecl(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~NativeTypeDecl() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNode.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNode.h >new file mode 100644 >index 0000000000000000000000000000000000000000..6f2be43faccb8f6ce3ef97e51fe12a913f9b24f6 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNode.h >@@ -0,0 +1,51 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Node { >+public: >+ virtual ~Node() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPointerType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPointerType.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2ebe12fc18504fecffb0d37f2566dea64d664336 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPointerType.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTPointerType.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPointerType.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPointerType.h >new file mode 100644 >index 0000000000000000000000000000000000000000..141882f8ff314140d568daf536d218fdeb2a53e7 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPointerType.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTReferenceType.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class PointerType : public ReferenceType { >+public: >+ PointerType(Lexer::Token&& origin, String&& addressSpace, std::unique_ptr<Type> elementType) >+ : ReferenceType(WTFMove(origin), WTFMove(addressSpace), WTFMove(elementType)) >+ { >+ } >+ >+ virtual ~PointerType() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTQualifier.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTQualifier.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ada01742aa1bb59df719fa91a171067364e88f34 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTQualifier.h >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+enum class Qualifier { >+ Nointerpolation, >+ Noperspective, >+ Uniform, >+ Centroid, >+ Sample >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReferenceType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReferenceType.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e609f7e8293ff7dec7c818bae46cdecc4f30710b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReferenceType.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTReferenceType.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReferenceType.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c5befea17e62a42aa426afcfcb997f6d5df52440 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReferenceType.h >@@ -0,0 +1,65 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class ReferenceType : public Type { >+public: >+ ReferenceType(Lexer::Token&& origin, String&& addressSpace, std::unique_ptr<Type>&& elementType) >+ : m_origin(WTFMove(origin)) >+ , m_addressSpace(WTFMove(addressSpace)) >+ , m_elementType(WTFMove(elementType)) >+ { >+ } >+ >+ virtual ~ReferenceType() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+ String m_addressSpace; >+ std::unique_ptr<Type> m_elementType; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f578e10b74d803fab572f4d33a3214fccf98f059 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTResourceSemantic.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8bbcc08bbc66f636ec257db8dc6add739a0f4bb9 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.h >@@ -0,0 +1,76 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTBaseSemantic.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class ResourceSemantic : public BaseSemantic { >+public: >+ enum class Mode { >+ U, >+ T, >+ B, >+ S >+ }; >+ >+ ResourceSemantic(Lexer::Token&& origin, Mode mode, unsigned index, unsigned space) >+ : BaseSemantic(WTFMove(origin)) >+ , m_mode(mode) >+ , m_index(index) >+ , m_space(space) >+ { >+ } >+ >+ virtual ~ResourceSemantic() >+ { >+ } >+ >+ Mode mode() const { return m_mode; } >+ unsigned index() const { return m_index; } >+ unsigned space() const { return m_space; } >+ >+private: >+ Mode m_mode; >+ unsigned m_index; >+ unsigned m_space; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSemantic.h >new file mode 100644 >index 0000000000000000000000000000000000000000..67c0f9ca97c9fe9afde465e7ed42a9c75b27e59e >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSemantic.h >@@ -0,0 +1,50 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTBuiltInSemantic.h" >+#include "WHLSLASTResourceSemantic.h" >+#include "WHLSLASTSpecializationConstantSemantic.h" >+#include "WHLSLASTStageInOutSemantic.h" >+#include <wtf/Variant.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+typedef Variant<BuiltInSemantic, ResourceSemantic, SpecializationConstantSemantic, StageInOutSemantic> Semantic; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSpecializationConstantSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSpecializationConstantSemantic.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..78e7d2fa5975aa410d7463cfdea8343ba8725cbc >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSpecializationConstantSemantic.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTSpecializationConstantSemantic.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSpecializationConstantSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSpecializationConstantSemantic.h >new file mode 100644 >index 0000000000000000000000000000000000000000..954c9e1d71ae4321fa2e399fba7de42162946c9a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSpecializationConstantSemantic.h >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTBaseSemantic.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class SpecializationConstantSemantic : public BaseSemantic { >+public: >+ SpecializationConstantSemantic(Lexer::Token&& origin) >+ : BaseSemantic(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~SpecializationConstantSemantic() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStageInOutSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStageInOutSemantic.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..9a2e73b19da8cfe6534ee81769a6e941bad5b657 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStageInOutSemantic.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTStageInOutSemantic.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStageInOutSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStageInOutSemantic.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0c6571a8ebe8d45401b3e9b17bad434258d0eb25 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStageInOutSemantic.h >@@ -0,0 +1,63 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTBaseSemantic.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class StageInOutSemantic : public BaseSemantic { >+public: >+ StageInOutSemantic(Lexer::Token&& origin, unsigned index) >+ : BaseSemantic(WTFMove(origin)) >+ , m_index(index) >+ { >+ } >+ >+ virtual ~StageInOutSemantic() >+ { >+ } >+ >+ unsigned index() const { return m_index; } >+ >+private: >+ unsigned m_index; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructDef.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructDef.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d88b1a19e6ddfaf59f45a835dd52d28d5ee90a53 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructDef.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTStructDef.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructDef.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructDef.h >new file mode 100644 >index 0000000000000000000000000000000000000000..cdd1769c69565eac5714e4575e5ba1faeb468e3c >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructDef.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class StructDef { >+public: >+ StructDef(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~StructDef() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructType.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..400a43dcf1bf701a806001c3e51f8d03219a1e0b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructType.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTStructType.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructType.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructType.h >new file mode 100644 >index 0000000000000000000000000000000000000000..bf10128ae2e2319c90b1fc4418bf3deb83322865 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructType.h >@@ -0,0 +1,69 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTField.h" >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class StructType : public Type { >+public: >+ StructType(Lexer::Token&& origin, String&& name, Vector<Field>&& fields) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_fields(WTFMove(fields)) >+ { >+ } >+ >+ virtual ~StructType() >+ { >+ } >+ >+ StructType(StructType&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ Vector<Field> m_fields; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTType.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..0aa193f91d9886816e7d04c271ac71f50a71dc09 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTType.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTType.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTType.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTType.h >new file mode 100644 >index 0000000000000000000000000000000000000000..e16885959b15782e9ef618699478cbb77fff8213 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTType.h >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Type : public Node { >+public: >+ virtual ~Type() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeArgument.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeArgument.h >new file mode 100644 >index 0000000000000000000000000000000000000000..05cc2deefbcd43c6f1738f6aaa77172de173648c >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeArgument.h >@@ -0,0 +1,51 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTConstExpr.h" >+#include "WHLSLLexer.h" >+#include <wtf/Variant.h> >+#include <wtf/Vector.h> >+#include <wtf/text/StringView.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+typedef Variant<ConstExpr, Lexer::Token> TypeArgument; >+typedef Vector<TypeArgument> TypeArguments; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDef.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDef.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..b1e7bfc7440a5a9405bcfca2a83a07a89688d528 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDef.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTTypeDef.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDef.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDef.h >new file mode 100644 >index 0000000000000000000000000000000000000000..aea052419bd051cdee33e6d313741a3fd8375e8c >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDef.h >@@ -0,0 +1,68 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class TypeDef : public Type { >+public: >+ TypeDef(Lexer::Token&& origin, String&& name, std::unique_ptr<AST::Type>&& type) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_type(WTFMove(type)) >+ { >+ } >+ >+ TypeDef(TypeDef&&) = default; >+ >+ virtual ~TypeDef() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ std::unique_ptr<AST::Type> m_type; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeRef.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeRef.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..51cb9ab98f9289e1cac6c7c0065b60d49e9b4c59 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeRef.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTTypeRef.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeRef.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeRef.h >new file mode 100644 >index 0000000000000000000000000000000000000000..a98b836cf7f5aa8403f86dc999ca1144913f5aaa >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeRef.h >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTType.h" >+#include "WHLSLASTTypeArgument.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class TypeRef : public Type { >+public: >+ TypeRef(Lexer::Token&& origin, String&& name, Vector<TypeArgument>&& typeArguments) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_typeArguments(WTFMove(typeArguments)) >+ { >+ } >+ >+ virtual ~TypeRef() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ Vector<TypeArgument> m_typeArguments; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDecl.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDecl.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..57d10ca2697c0f8bc853f99575f96582871422c4 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDecl.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLASTVariableDecl.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDecl.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDecl.h >new file mode 100644 >index 0000000000000000000000000000000000000000..a3c7547d19442dd970c02e56e0501ffaa807e750 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDecl.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTNode.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class VariableDecl : public Node { >+public: >+ VariableDecl(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~VariableDecl() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..a88f6c137e87520c997913e1a1254b98051a2015 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp >@@ -0,0 +1,590 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+auto Lexer::consumeTokenFromStream() -> std::optional<Token> >+{ >+ auto prepare = [&](unsigned newOffset, Token::Type type) -> std::optional<Token> { >+ auto offset = m_offset; >+ m_offset = newOffset; >+ skipWhitespaceAndComments(); >+ return {{ m_stringView.substring(offset, m_offset - offset), type }}; >+ }; >+ >+ if (auto newOffset = intLiteral(m_offset)) >+ return prepare(*newOffset, Token::Type::IntLiteral); >+ if (auto newOffset = floatLiteral(m_offset)) >+ return prepare(*newOffset, Token::Type::FloatLiteral); >+ if (auto newOffset = string("struct", m_offset)) >+ return prepare(*newOffset, Token::Type::Struct); >+ if (auto newOffset = string("typedef", m_offset)) >+ return prepare(*newOffset, Token::Type::Typedef); >+ if (auto newOffset = string("enum", m_offset)) >+ return prepare(*newOffset, Token::Type::Enum); >+ if (auto newOffset = string("operator", m_offset)) >+ return prepare(*newOffset, Token::Type::Operator); >+ if (auto newOffset = string("if", m_offset)) >+ return prepare(*newOffset, Token::Type::If); >+ if (auto newOffset = string("else", m_offset)) >+ return prepare(*newOffset, Token::Type::Else); >+ if (auto newOffset = string("continue", m_offset)) >+ return prepare(*newOffset, Token::Type::Continue); >+ if (auto newOffset = string("break", m_offset)) >+ return prepare(*newOffset, Token::Type::Break); >+ if (auto newOffset = string("switch", m_offset)) >+ return prepare(*newOffset, Token::Type::Switch); >+ if (auto newOffset = string("case", m_offset)) >+ return prepare(*newOffset, Token::Type::Case); >+ if (auto newOffset = string("default", m_offset)) >+ return prepare(*newOffset, Token::Type::Default); >+ if (auto newOffset = string("fallthrough", m_offset)) >+ return prepare(*newOffset, Token::Type::Fallthrough); >+ if (auto newOffset = string("for", m_offset)) >+ return prepare(*newOffset, Token::Type::For); >+ if (auto newOffset = string("while", m_offset)) >+ return prepare(*newOffset, Token::Type::While); >+ if (auto newOffset = string("do", m_offset)) >+ return prepare(*newOffset, Token::Type::Do); >+ if (auto newOffset = string("return", m_offset)) >+ return prepare(*newOffset, Token::Type::Return); >+ if (auto newOffset = string("trap", m_offset)) >+ return prepare(*newOffset, Token::Type::Trap); >+ if (auto newOffset = string("null", m_offset)) >+ return prepare(*newOffset, Token::Type::Null); >+ if (auto newOffset = string("true", m_offset)) >+ return prepare(*newOffset, Token::Type::True); >+ if (auto newOffset = string("false", m_offset)) >+ return prepare(*newOffset, Token::Type::False); >+ if (auto newOffset = string("constant", m_offset)) >+ return prepare(*newOffset, Token::Type::Constant); >+ if (auto newOffset = string("device", m_offset)) >+ return prepare(*newOffset, Token::Type::Device); >+ if (auto newOffset = string("threadgroup", m_offset)) >+ return prepare(*newOffset, Token::Type::Threadgroup); >+ if (auto newOffset = string("thread", m_offset)) >+ return prepare(*newOffset, Token::Type::Thread); >+ if (auto newOffset = string("space", m_offset)) >+ return prepare(*newOffset, Token::Type::Space); >+ if (auto newOffset = string("vertex", m_offset)) >+ return prepare(*newOffset, Token::Type::Vertex); >+ if (auto newOffset = string("fragment", m_offset)) >+ return prepare(*newOffset, Token::Type::Fragment); >+ if (auto newOffset = string("compute", m_offset)) >+ return prepare(*newOffset, Token::Type::Compute); >+ if (auto newOffset = string("numthreads", m_offset)) >+ return prepare(*newOffset, Token::Type::Numthreads); >+ if (auto newOffset = string("SV_InstanceID", m_offset)) >+ return prepare(*newOffset, Token::Type::SVInstanceID); >+ if (auto newOffset = string("SV_VertexID", m_offset)) >+ return prepare(*newOffset, Token::Type::SVVertexID); >+ if (auto newOffset = string("PSIZE", m_offset)) >+ return prepare(*newOffset, Token::Type::PSize); >+ if (auto newOffset = string("SV_Position", m_offset)) >+ return prepare(*newOffset, Token::Type::SVPosition); >+ if (auto newOffset = string("SV_IsFrontFace", m_offset)) >+ return prepare(*newOffset, Token::Type::SVIsFrontFace); >+ if (auto newOffset = string("SV_SampleIndex", m_offset)) >+ return prepare(*newOffset, Token::Type::SVSampleIndex); >+ if (auto newOffset = string("SV_InnerCoverage", m_offset)) >+ return prepare(*newOffset, Token::Type::SVInnerCoverage); >+ if (auto newOffset = string("SV_Target", m_offset)) >+ return prepare(*newOffset, Token::Type::SVTarget); >+ if (auto newOffset = string("SV_Depth", m_offset)) >+ return prepare(*newOffset, Token::Type::SVDepth); >+ if (auto newOffset = string("SV_Coverage", m_offset)) >+ return prepare(*newOffset, Token::Type::SVCoverage); >+ if (auto newOffset = string("SV_DispatchThreadID", m_offset)) >+ return prepare(*newOffset, Token::Type::SVDispatchThreadID); >+ if (auto newOffset = string("SV_GroupID", m_offset)) >+ return prepare(*newOffset, Token::Type::SVGroupID); >+ if (auto newOffset = string("SV_GroupIndex", m_offset)) >+ return prepare(*newOffset, Token::Type::SVGroupIndex); >+ if (auto newOffset = string("SV_GroupThreadID", m_offset)) >+ return prepare(*newOffset, Token::Type::SVGroupThreadID); >+ if (auto newOffset = string("attribute", m_offset)) >+ return prepare(*newOffset, Token::Type::Attribute); >+ if (auto newOffset = string("register", m_offset)) >+ return prepare(*newOffset, Token::Type::Register); >+ if (auto newOffset = string("specialized", m_offset)) >+ return prepare(*newOffset, Token::Type::Specialized); >+ if (auto newOffset = string("native", m_offset)) >+ return prepare(*newOffset, Token::Type::Native); >+ if (auto newOffset = string("restricted", m_offset)) >+ return prepare(*newOffset, Token::Type::Restricted); >+ if (auto newOffset = string("_", m_offset)) >+ return prepare(*newOffset, Token::Type::Underscore); >+ if (auto newOffset = string("auto", m_offset)) >+ return prepare(*newOffset, Token::Type::Auto); >+ if (auto newOffset = string("protocol", m_offset)) >+ return prepare(*newOffset, Token::Type::Protocol); >+ if (auto newOffset = string("const", m_offset)) >+ return prepare(*newOffset, Token::Type::Const); >+ if (auto newOffset = string("static", m_offset)) >+ return prepare(*newOffset, Token::Type::Static); >+ if (auto newOffset = qualifier(m_offset)) >+ return prepare(*newOffset, Token::Type::Qualifier); >+ if (auto newOffset = identifier(m_offset)) >+ return prepare(*newOffset, Token::Type::Identifier); >+ if (auto newOffset = operatorName(m_offset)) >+ return prepare(*newOffset, Token::Type::OperatorName); >+ if (auto newOffset = string("=", m_offset)) >+ return prepare(*newOffset, Token::Type::EqualsSign); >+ if (auto newOffset = string(";", m_offset)) >+ return prepare(*newOffset, Token::Type::Semicolon); >+ if (auto newOffset = string("{", m_offset)) >+ return prepare(*newOffset, Token::Type::LeftCurlyBracket); >+ if (auto newOffset = string("}", m_offset)) >+ return prepare(*newOffset, Token::Type::RightCurlyBracket); >+ if (auto newOffset = string(":", m_offset)) >+ return prepare(*newOffset, Token::Type::Colon); >+ if (auto newOffset = string(",", m_offset)) >+ return prepare(*newOffset, Token::Type::Comma); >+ if (auto newOffset = string("(", m_offset)) >+ return prepare(*newOffset, Token::Type::LeftParenthesis); >+ if (auto newOffset = string(")", m_offset)) >+ return prepare(*newOffset, Token::Type::RightParenthesis); >+ if (auto newOffset = string("[]", m_offset)) >+ return prepare(*newOffset, Token::Type::SquareBracketPair); >+ if (auto newOffset = string("[", m_offset)) >+ return prepare(*newOffset, Token::Type::LeftSquareBracket); >+ if (auto newOffset = string("]", m_offset)) >+ return prepare(*newOffset, Token::Type::RightSquareBracket); >+ if (auto newOffset = string("*", m_offset)) >+ return prepare(*newOffset, Token::Type::Star); >+ if (auto newOffset = string("<", m_offset)) >+ return prepare(*newOffset, Token::Type::LessThanSign); >+ if (auto newOffset = string(">", m_offset)) >+ return prepare(*newOffset, Token::Type::GreaterThanSign); >+ if (auto newOffset = string(".", m_offset)) >+ return prepare(*newOffset, Token::Type::FullStop); >+ if (auto newOffset = string("+=", m_offset)) >+ return prepare(*newOffset, Token::Type::PlusEquals); >+ if (auto newOffset = string("-=", m_offset)) >+ return prepare(*newOffset, Token::Type::MinusEquals); >+ if (auto newOffset = string("*=", m_offset)) >+ return prepare(*newOffset, Token::Type::TimesEquals); >+ if (auto newOffset = string("/=", m_offset)) >+ return prepare(*newOffset, Token::Type::DivideEquals); >+ if (auto newOffset = string("%=", m_offset)) >+ return prepare(*newOffset, Token::Type::ModEquals); >+ if (auto newOffset = string("^=", m_offset)) >+ return prepare(*newOffset, Token::Type::XorEquals); >+ if (auto newOffset = string("&=", m_offset)) >+ return prepare(*newOffset, Token::Type::AndEquals); >+ if (auto newOffset = string("|=", m_offset)) >+ return prepare(*newOffset, Token::Type::OrEquals); >+ if (auto newOffset = string(">>=", m_offset)) >+ return prepare(*newOffset, Token::Type::RightShiftEquals); >+ if (auto newOffset = string("<<=", m_offset)) >+ return prepare(*newOffset, Token::Type::LeftShiftEquals); >+ if (auto newOffset = string("++", m_offset)) >+ return prepare(*newOffset, Token::Type::PlusPlus); >+ if (auto newOffset = string("--", m_offset)) >+ return prepare(*newOffset, Token::Type::MinusMinus); >+ if (auto newOffset = string("->", m_offset)) >+ return prepare(*newOffset, Token::Type::Arrow); >+ if (auto newOffset = string("?", m_offset)) >+ return prepare(*newOffset, Token::Type::QuestionMark); >+ if (auto newOffset = string("||", m_offset)) >+ return prepare(*newOffset, Token::Type::OrOr); >+ if (auto newOffset = string("&&", m_offset)) >+ return prepare(*newOffset, Token::Type::AndAnd); >+ if (auto newOffset = string("|", m_offset)) >+ return prepare(*newOffset, Token::Type::Or); >+ if (auto newOffset = string("^", m_offset)) >+ return prepare(*newOffset, Token::Type::Xor); >+ if (auto newOffset = string("&", m_offset)) >+ return prepare(*newOffset, Token::Type::And); >+ if (auto newOffset = string("<=", m_offset)) >+ return prepare(*newOffset, Token::Type::LessThanOrEqualTo); >+ if (auto newOffset = string(">=", m_offset)) >+ return prepare(*newOffset, Token::Type::GreaterThanOrEqualTo); >+ if (auto newOffset = string("==", m_offset)) >+ return prepare(*newOffset, Token::Type::EqualComparison); >+ if (auto newOffset = string("!=", m_offset)) >+ return prepare(*newOffset, Token::Type::NotEqual); >+ if (auto newOffset = string(">>", m_offset)) >+ return prepare(*newOffset, Token::Type::RightShift); >+ if (auto newOffset = string("<<", m_offset)) >+ return prepare(*newOffset, Token::Type::LeftShift); >+ if (auto newOffset = string("+", m_offset)) >+ return prepare(*newOffset, Token::Type::Plus); >+ if (auto newOffset = string("-", m_offset)) >+ return prepare(*newOffset, Token::Type::Minus); >+ if (auto newOffset = string("*", m_offset)) >+ return prepare(*newOffset, Token::Type::Times); >+ if (auto newOffset = string("/", m_offset)) >+ return prepare(*newOffset, Token::Type::Divide); >+ if (auto newOffset = string("%", m_offset)) >+ return prepare(*newOffset, Token::Type::Mod); >+ if (auto newOffset = string("~", m_offset)) >+ return prepare(*newOffset, Token::Type::Tilde); >+ if (auto newOffset = string("!", m_offset)) >+ return prepare(*newOffset, Token::Type::ExclamationPoint); >+ if (auto newOffset = string("@", m_offset)) >+ return prepare(*newOffset, Token::Type::At); >+ >+ skipWhitespaceAndComments(); >+ return std::nullopt; >+} >+ >+void Lexer::skipWhitespaceAndComments() >+{ >+ unsigned savedOffset; >+ do { >+ savedOffset = m_offset; >+ skipWhitespace(); >+ skipLineComment(); >+ skipLongComment(); >+ } while (savedOffset != m_offset); >+} >+ >+static inline bool isWhitespace(UChar codeUnit) >+{ >+ switch (codeUnit) { >+ case ' ': >+ case '\t': >+ case '\r': >+ case '\n': >+ return true; >+ default: >+ return false; >+ } >+} >+ >+static inline bool isNewline(UChar codeUnit) >+{ >+ switch (codeUnit) { >+ case '\r': >+ case '\n': >+ return true; >+ default: >+ return false; >+ } >+} >+ >+// We can take advantage of two properties of Unicode: >+// 1. The consitutent UTF-16 code units for all non-BMP code points are surrogates, >+// which means we'll never see a false match. If we see a BMP code unit, we >+// really have a BMP code point. >+// 2. Everything we're looking for is in BMP >+ >+void Lexer::skipWhitespace() >+{ >+ for ( ; m_offset < m_stringView.length() && isWhitespace(m_stringView[m_offset]); ++m_offset) { } >+} >+ >+void Lexer::skipLineComment() >+{ >+ if (m_offset + 1 >= m_stringView.length() || m_stringView[m_offset] != '/' || m_stringView[m_offset + 1] != '/') >+ return; >+ >+ m_offset += 2; >+ for ( ; m_offset < m_stringView.length() && !isNewline(m_stringView[m_offset]); ++m_offset) { } >+} >+ >+void Lexer::skipLongComment() >+{ >+ if (m_offset + 1 >= m_stringView.length() || m_stringView[m_offset] != '/' || m_stringView[m_offset + 1] != '*') >+ return; >+ >+ m_offset += 2; >+ do { >+ for ( ; m_offset < m_stringView.length() && m_stringView[m_offset] != '*'; ++m_offset) { } >+ if (m_offset < m_stringView.length()) >+ ++m_offset; >+ if (m_offset < m_stringView.length() && m_stringView[m_offset] == '/') { >+ ++m_offset; >+ break; >+ } >+ } while (m_offset < m_stringView.length()); >+} >+ >+// Regular expression are unnecessary; we shouldn't need to compile them. >+ >+std::optional<unsigned> Lexer::coreDecimalIntLiteral(unsigned offset) const >+{ >+ if (offset >= m_stringView.length()) >+ return std::nullopt; >+ if (m_stringView[offset] == '0') >+ return offset + 1; >+ if (m_stringView[offset] >= '1' && m_stringView[offset] <= '9') { >+ ++offset; >+ for ( ; offset < m_stringView.length() && m_stringView[offset] >= '0' && m_stringView[offset] <= '9'; ++offset) { >+ } >+ return offset; >+ } >+ return std::nullopt; >+} >+ >+std::optional<unsigned> Lexer::decimalIntLiteral(unsigned offset) const >+{ >+ if (offset < m_stringView.length() && m_stringView[offset] == '-') >+ ++offset; >+ return coreDecimalIntLiteral(offset); >+} >+ >+std::optional<unsigned> Lexer::decimalUintLiteral(unsigned offset) const >+{ >+ auto result = coreDecimalIntLiteral(offset); >+ if (!result) >+ return std::nullopt; >+ if (*result < m_stringView.length() && m_stringView[*result] == 'u') >+ return *result + 1; >+ return std::nullopt; >+} >+ >+static inline bool isHexadecimalCharacter(UChar character) >+{ >+ return (character >= '0' && character <= '9') >+ || (character >= 'a' && character <= 'f') >+ || (character >= 'A' && character <= 'F'); >+} >+ >+std::optional<unsigned> Lexer::coreHexadecimalIntLiteral(unsigned offset) const >+{ >+ if (offset + 1 >= m_stringView.length() || m_stringView[offset] != '0' || m_stringView[offset + 1] != 'x') >+ return std::nullopt; >+ >+ offset += 2; >+ if (offset >= m_stringView.length() || !isHexadecimalCharacter(m_stringView[offset])) >+ return std::nullopt; >+ ++offset; >+ for ( ; offset < m_stringView.length() && isHexadecimalCharacter(m_stringView[offset]); ++offset) { >+ } >+ return offset; >+} >+ >+std::optional<unsigned> Lexer::hexadecimalIntLiteral(unsigned offset) const >+{ >+ if (offset < m_stringView.length() && m_stringView[offset] == '-') >+ ++offset; >+ return coreHexadecimalIntLiteral(offset); >+} >+ >+std::optional<unsigned> Lexer::hexadecimalUintLiteral(unsigned offset) const >+{ >+ auto result = coreHexadecimalIntLiteral(offset); >+ if (!result) >+ return std::nullopt; >+ if (*result < m_stringView.length() && m_stringView[*result] == 'u') >+ return *result + 1; >+ return std::nullopt; >+} >+ >+std::optional<unsigned> Lexer::intLiteral(unsigned offset) const >+{ >+ if (auto result = decimalIntLiteral(offset)) >+ return result; >+ if (auto result = decimalUintLiteral(offset)) >+ return result; >+ if (auto result = hexadecimalIntLiteral(offset)) >+ return result; >+ if (auto result = hexadecimalUintLiteral(offset)) >+ return result; >+ return std::nullopt; >+} >+ >+std::optional<unsigned> Lexer::digit(unsigned offset) const >+{ >+ if (offset < m_stringView.length() && m_stringView[offset] >= '0' && m_stringView[offset] <= '9') >+ return offset + 1; >+ return std::nullopt; >+} >+ >+unsigned Lexer::digitStar(unsigned offset) const >+{ >+ while (true) { >+ auto result = digit(offset); >+ if (!result) >+ return offset; >+ offset = *result; >+ } >+} >+ >+std::optional<unsigned> Lexer::character(char character, unsigned offset) const >+{ >+ if (offset < m_stringView.length() && m_stringView[offset] == character) >+ return offset + 1; >+ return std::nullopt; >+} >+ >+std::optional<unsigned> Lexer::coreFloatLiteralType1(unsigned offset) const >+{ >+ auto result = digit(offset); >+ if (!result) >+ return std::nullopt; >+ auto result2 = digitStar(*result); >+ auto result3 = character('.', result2); >+ if (!result3) >+ return std::nullopt; >+ return digitStar(*result3); >+} >+ >+std::optional<unsigned> Lexer::coreFloatLiteral(unsigned offset) const >+{ >+ if (auto type1 = coreFloatLiteralType1(offset)) >+ return type1; >+ auto result = digitStar(offset); >+ auto result2 = character('.', result); >+ if (!result2) >+ return std::nullopt; >+ auto result3 = digit(*result2); >+ if (!result3) >+ return std::nullopt; >+ return digitStar(*result3); >+} >+ >+std::optional<unsigned> Lexer::floatLiteral(unsigned offset) const >+{ >+ if (offset < m_stringView.length() && m_stringView[offset] == '-') >+ ++offset; >+ auto result = coreFloatLiteral(offset); >+ if (!result) >+ return std::nullopt; >+ offset = *result; >+ if (offset < m_stringView.length() && (m_stringView[offset] == 'f' || m_stringView[offset] == 'd')) >+ ++offset; >+ return offset; >+} >+ >+std::optional<unsigned> Lexer::qualifier(unsigned offset) const >+{ >+ if (auto result = string("nointerpolation", offset)) >+ return result; >+ if (auto result = string("noperspective", offset)) >+ return result; >+ if (auto result = string("uniform", offset)) >+ return result; >+ if (auto result = string("centroid", offset)) >+ return result; >+ if (auto result = string("sample", offset)) >+ return result; >+ return std::nullopt; >+} >+ >+std::optional<unsigned> Lexer::validIdentifier(unsigned offset) const >+{ >+ if (offset >= m_stringView.length() >+ || !((m_stringView[offset] >= 'a' && m_stringView[offset] <= 'z') >+ || (m_stringView[offset] >= 'A' && m_stringView[offset] <= 'Z') >+ || (m_stringView[offset] == '_'))) >+ return std::nullopt; >+ ++offset; >+ while (true) { >+ if (offset >= m_stringView.length() >+ || !((m_stringView[offset] >= 'a' && m_stringView[offset] <= 'z') >+ || (m_stringView[offset] >= 'A' && m_stringView[offset] <= 'Z') >+ || (m_stringView[offset] >= '0' && m_stringView[offset] <= '9') >+ || (m_stringView[offset] == '_'))) >+ return offset; >+ ++offset; >+ } >+} >+ >+std::optional<unsigned> Lexer::identifier(unsigned offset) const >+{ >+ return validIdentifier(offset); >+} >+ >+std::optional<unsigned> Lexer::operatorName(unsigned offset) const >+{ >+ if (auto result = string("operator&.", offset)) >+ return validIdentifier(*result); >+ if (auto result = string("operator.", offset)) { >+ if ((result = validIdentifier(*result))) { >+ if (auto result2 = character('=', *result)) >+ return result2; >+ return *result; >+ } >+ } >+ if (auto result = string("operator", offset)) { >+ if (auto result2 = string(">>", *result)) >+ return result2; >+ if (auto result2 = string("<<", *result)) >+ return result2; >+ if (auto result2 = string("++", *result)) >+ return result2; >+ if (auto result2 = string("--", *result)) >+ return result2; >+ if (auto result2 = string("+", *result)) >+ return result2; >+ if (auto result2 = string("-", *result)) >+ return result2; >+ if (auto result2 = string("*", *result)) >+ return result2; >+ if (auto result2 = string("/", *result)) >+ return result2; >+ if (auto result2 = string("%", *result)) >+ return result2; >+ if (auto result2 = string("&&", *result)) >+ return result2; >+ if (auto result2 = string("||", *result)) >+ return result2; >+ if (auto result2 = string("&[]", *result)) >+ return result2; >+ if (auto result2 = string("&", *result)) >+ return result2; >+ if (auto result2 = string("^", *result)) >+ return result2; >+ if (auto result2 = string("|", *result)) >+ return result2; >+ if (auto result2 = string(">=", *result)) >+ return result2; >+ if (auto result2 = string("<=", *result)) >+ return result2; >+ if (auto result2 = string("==", *result)) >+ return result2; >+ if (auto result2 = string("<", *result)) >+ return result2; >+ if (auto result2 = string(">", *result)) >+ return result2; >+ if (auto result2 = string("!", *result)) >+ return result2; >+ if (auto result2 = string("~", *result)) >+ return result2; >+ if (auto result2 = string("[]=", *result)) >+ return result2; >+ if (auto result2 = string("[]", *result)) >+ return result2; >+ } >+ return std::nullopt; >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c6b26d7b12db24ea91bc18bbd26bb9f106f35c08 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h >@@ -0,0 +1,260 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include <wtf/Optional.h> >+#include <wtf/Vector.h> >+#include <wtf/text/StringView.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class Lexer { >+public: >+ Lexer(StringView stringView) >+ : m_stringView(stringView) >+ { >+ skipWhitespaceAndComments(); >+ } >+ >+ struct Token { >+ StringView stringView; >+ enum class Type { >+ IntLiteral, >+ FloatLiteral, >+ Struct, >+ Typedef, >+ Enum, >+ Operator, >+ If, >+ Else, >+ Continue, >+ Break, >+ Switch, >+ Case, >+ Default, >+ Fallthrough, >+ For, >+ While, >+ Do, >+ Return, >+ Trap, >+ Null, >+ True, >+ False, >+ Constant, >+ Device, >+ Threadgroup, >+ Thread, >+ Space, >+ Vertex, >+ Fragment, >+ Compute, >+ Numthreads, >+ SVInstanceID, >+ SVVertexID, >+ PSize, >+ SVPosition, >+ SVIsFrontFace, >+ SVSampleIndex, >+ SVInnerCoverage, >+ SVTarget, >+ SVDepth, >+ SVCoverage, >+ SVDispatchThreadID, >+ SVGroupID, >+ SVGroupIndex, >+ SVGroupThreadID, >+ Attribute, >+ Register, >+ Specialized, >+ Native, >+ Restricted, >+ Underscore, >+ Auto, >+ Protocol, >+ Const, >+ Static, >+ Qualifier, >+ Identifier, >+ OperatorName, >+ EqualsSign, >+ Semicolon, >+ LeftCurlyBracket, >+ RightCurlyBracket, >+ Colon, >+ Comma, >+ LeftParenthesis, >+ RightParenthesis, >+ SquareBracketPair, >+ LeftSquareBracket, >+ RightSquareBracket, >+ Star, >+ LessThanSign, >+ GreaterThanSign, >+ FullStop, >+ PlusEquals, >+ MinusEquals, >+ TimesEquals, >+ DivideEquals, >+ ModEquals, >+ XorEquals, >+ AndEquals, >+ OrEquals, >+ RightShiftEquals, >+ LeftShiftEquals, >+ PlusPlus, >+ MinusMinus, >+ Arrow, >+ QuestionMark, >+ OrOr, >+ AndAnd, >+ Or, >+ Xor, >+ And, >+ LessThanOrEqualTo, >+ GreaterThanOrEqualTo, >+ EqualComparison, >+ NotEqual, >+ RightShift, >+ LeftShift, >+ Plus, >+ Minus, >+ Times, >+ Divide, >+ Mod, >+ Tilde, >+ ExclamationPoint, >+ At, >+ } type; >+ }; >+ >+ std::optional<Token> consumeToken() >+ { >+ if (!m_stack.isEmpty()) >+ return m_stack.takeLast(); >+ return consumeTokenFromStream(); >+ } >+ >+ void unconsumeToken(Token&& token) >+ { >+ m_stack.append(WTFMove(token)); >+ } >+ >+ struct State { >+ Vector<Token> stack; >+ unsigned offset; >+ }; >+ >+ State state() const >+ { >+ return { m_stack, m_offset }; >+ } >+ >+ void setState(const State& state) >+ { >+ m_stack = state.stack; >+ m_offset = state.offset; >+ } >+ >+ void setState(State&& state) >+ { >+ m_stack = WTFMove(state.stack); >+ m_offset = WTFMove(state.offset); >+ } >+ >+ bool isFullyConsumed() const >+ { >+ return m_offset == m_stringView.length(); >+ } >+ >+private: >+ std::optional<Token> consumeTokenFromStream(); >+ >+ void skipWhitespaceAndComments(); >+ void skipWhitespace(); >+ void skipLineComment(); >+ void skipLongComment(); >+ >+ std::optional<unsigned> coreDecimalIntLiteral(unsigned) const; >+ std::optional<unsigned> decimalIntLiteral(unsigned) const; >+ std::optional<unsigned> decimalUintLiteral(unsigned) const; >+ std::optional<unsigned> coreHexadecimalIntLiteral(unsigned) const; >+ std::optional<unsigned> hexadecimalIntLiteral(unsigned) const; >+ std::optional<unsigned> hexadecimalUintLiteral(unsigned) const; >+ std::optional<unsigned> intLiteral(unsigned) const; >+ std::optional<unsigned> digit(unsigned) const; >+ unsigned digitStar(unsigned) const; >+ std::optional<unsigned> character(char, unsigned) const; >+ template<unsigned length> std::optional<unsigned> anyCharacter(const char (&string)[length], unsigned) const; >+ std::optional<unsigned> coreFloatLiteralType1(unsigned) const; >+ std::optional<unsigned> coreFloatLiteral(unsigned) const; >+ std::optional<unsigned> floatLiteral(unsigned) const; >+ template<unsigned length> std::optional<unsigned> string(const char (&string)[length], unsigned) const; >+ std::optional<unsigned> qualifier(unsigned) const; >+ std::optional<unsigned> builtInSemantic(unsigned) const; >+ std::optional<unsigned> resourceSemantic(unsigned) const; >+ std::optional<unsigned> specializationConstantSemantic(unsigned) const; >+ std::optional<unsigned> stageInOutSemantic(unsigned) const; >+ std::optional<unsigned> numthreads(unsigned) const; >+ std::optional<unsigned> validIdentifier(unsigned) const; >+ std::optional<unsigned> identifier(unsigned) const; >+ std::optional<unsigned> operatorName(unsigned) const; >+ >+ const StringView m_stringView; >+ Vector<Token> m_stack; >+ unsigned m_offset { 0 }; >+}; >+ >+template<unsigned length> std::optional<unsigned> Lexer::string(const char (&string)[length], unsigned offset) const >+{ >+ for (unsigned i = 0; i < length - 1; ++i) { >+ if (i >= m_stringView.length() || m_stringView[i] != string[i]) >+ return std::nullopt; >+ } >+ return offset + length - 1; >+} >+ >+template<unsigned length> std::optional<unsigned> Lexer::anyCharacter(const char (&string)[length], unsigned offset) const >+{ >+ if (offset >= m_stringView.length()) >+ return std::nullopt; >+ for (unsigned i = 0; i < length - 1; ++i) { >+ if (m_stringView[offset] == string[i]) >+ return offset + 1; >+ } >+ return std::nullopt; >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..770d7377d358dc5f0277e0339cabdfaaae6910e0 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >@@ -0,0 +1,776 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLParser.h" >+#include "WHLSLASTPointerType.h" >+#include "WHLSLASTArrayReferenceType.h" >+#include "WHLSLASTArrayType.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+Parser::Parser(StringView stringView) >+ : m_lexer(stringView) >+{ >+} >+ >+std::optional<Program> Parser::parse() >+{ >+ Program result; >+ while (!m_lexer.isFullyConsumed()) { >+ if (peekType(Lexer::Token::Type::Semicolon)) { >+ m_lexer.consumeToken(); >+ continue; >+ } >+ >+ auto typeDef = backtrackingScope<std::optional<AST::TypeDef>>([&]() -> std::optional<AST::TypeDef> { >+ return parseTypeDef(); >+ }); >+ if (typeDef) { >+ result.append(WTFMove(*typeDef)); >+ continue; >+ } >+ >+ auto structDef = backtrackingScope<std::optional<AST::StructType>>([&]() -> std::optional<AST::StructType> { >+ return parseStructDef(); >+ }); >+ if (structDef) { >+ result.append(WTFMove(*structDef)); >+ continue; >+ } >+ >+ auto enumDef = backtrackingScope<std::optional<AST::EnumType>>([&]() -> std::optional<AST::EnumType> { >+ return parseEnumDef(); >+ }); >+ if (enumDef) { >+ result.append(WTFMove(*enumDef)); >+ continue; >+ } >+ >+ return std::nullopt; >+ } >+ return result; >+} >+ >+std::optional<Lexer::Token> Parser::peek() >+{ >+ if (auto token = m_lexer.consumeToken()) { >+ m_lexer.unconsumeToken(Lexer::Token(*token)); >+ return token; >+ } >+ return std::nullopt; >+} >+ >+std::optional<Lexer::Token> Parser::peekType(Lexer::Token::Type type) >+{ >+ if (auto token = m_lexer.consumeToken()) { >+ m_lexer.unconsumeToken(Lexer::Token(*token)); >+ if (token->type == type) >+ return token; >+ } >+ return std::nullopt; >+} >+ >+std::optional<Lexer::Token> Parser::consumeType(Lexer::Token::Type type) >+{ >+ if (auto token = m_lexer.consumeToken()) { >+ if (token->type == type) >+ return token; >+ } >+ return std::nullopt; >+} >+ >+std::optional<Lexer::Token> Parser::consumeTypes(Vector<Lexer::Token::Type> types) >+{ >+ if (auto token = m_lexer.consumeToken()) { >+ if (std::find(types.begin(), types.end(), token->type) != types.end()) >+ return token; >+ } >+ return std::nullopt; >+} >+ >+std::optional<Lexer::Token> Parser::parseLiteral() >+{ >+ auto token = m_lexer.consumeToken(); >+ if (!token) >+ return std::nullopt; >+ switch (token->type) { >+ case Lexer::Token::Type::IntLiteral: >+ case Lexer::Token::Type::FloatLiteral: >+ case Lexer::Token::Type::Null: >+ case Lexer::Token::Type::True: >+ case Lexer::Token::Type::False: >+ return *token; >+ default: >+ return std::nullopt; >+ } >+} >+ >+std::optional<AST::ConstExpr> Parser::parseConstExpr() >+{ >+ auto literal = backtrackingScope<std::optional<Lexer::Token>>([&]() -> std::optional<Lexer::Token> { >+ return parseLiteral(); >+ }); >+ if (literal) >+ return AST::ConstExpr::createWithLiteral(WTFMove(*literal)); >+ if (auto identifier1 = consumeType(Lexer::Token::Type::Identifier)) { >+ auto constExpr = backtrackingScope<std::optional<AST::ConstExpr>>([&]() -> std::optional<AST::ConstExpr> { >+ if (consumeType(Lexer::Token::Type::FullStop)) { >+ if (auto identifier2 = consumeType(Lexer::Token::Type::Identifier)) >+ return AST::ConstExpr::createWithIdentifierDotIdentifier(WTFMove(*identifier1), WTFMove(*identifier2)); >+ } >+ return std::nullopt; >+ }); >+ if (constExpr) >+ return *constExpr; >+ return AST::ConstExpr::createWithIdentifier(WTFMove(*identifier1)); >+ } >+ return std::nullopt; >+} >+ >+std::optional<AST::TypeArgument> Parser::parseTypeArgument() >+{ >+ auto constExpr = backtrackingScope<std::optional<AST::ConstExpr>>([&]() -> std::optional<AST::ConstExpr> { >+ return parseConstExpr(); >+ }); >+ if (constExpr) >+ return {*constExpr}; >+ if (peekType(Lexer::Token::Type::Identifier)) >+ return {*consumeType(Lexer::Token::Type::Identifier)}; >+ return std::nullopt; >+} >+ >+std::optional<AST::TypeArguments> Parser::parseTypeArguments() >+{ >+ auto typeArguments = backtrackingScope<std::optional<AST::TypeArguments>>([&]() -> std::optional<AST::TypeArguments> { >+ auto lessThanSign = consumeType(Lexer::Token::Type::LessThanSign); >+ if (!lessThanSign) >+ return std::nullopt; >+ AST::TypeArguments typeArguments; >+ auto typeArgument = parseTypeArgument(); >+ if (!typeArgument) >+ return std::nullopt; >+ typeArguments.append(WTFMove(*typeArgument)); >+ while (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto typeArgument = parseTypeArgument(); >+ if (!typeArgument) >+ return std::nullopt; >+ typeArguments.append(WTFMove(*typeArgument)); >+ } >+ auto greaterThanSign = consumeType(Lexer::Token::Type::GreaterThanSign); >+ if (!greaterThanSign) >+ return std::nullopt; >+ return typeArguments; >+ }); >+ if (typeArguments) >+ return *typeArguments; >+ >+ typeArguments = backtrackingScope<std::optional<AST::TypeArguments>>([&]() -> std::optional<AST::TypeArguments> { >+ auto lessThanSign = consumeType(Lexer::Token::Type::LessThanSign); >+ if (!lessThanSign) >+ return std::nullopt; >+ auto greaterThanSign = consumeType(Lexer::Token::Type::GreaterThanSign); >+ if (!greaterThanSign) >+ return std::nullopt; >+ return {{}}; >+ }); >+ if (typeArguments) >+ return *typeArguments; >+ >+ return {{}}; >+} >+ >+static int hexDigit(UChar character) { >+ if (character >= '0' && character <= '9') >+ return character - '0'; >+ else if (character >= 'a' && character <= 'f') >+ return character - 'a' + 10; >+ return character - 'A' + 10; >+} >+ >+static int decimalDigit(UChar character) { >+ return character - '0'; >+} >+ >+static std::optional<Variant<int, unsigned>> intLiteralToInt(StringView text) >+{ >+ // FIXME: Return nullopt if the value overflows. >+ bool negate = false; >+ if (text.startsWith(String("-", String::ConstructFromLiteral))) { >+ negate = true; >+ text = text.substring(1); >+ } >+ if (text.startsWith(String("0x", String::ConstructFromLiteral))) { >+ text = text.substring(2); >+ if (text.endsWith(String("u", String::ConstructFromLiteral))) { >+ text = text.substring(0, text.length() - 1); >+ unsigned result = 0; >+ for (unsigned i = 0; i < text.length(); ++i) { >+ unsigned digit = hexDigit(text[i]); >+ result = result * 16 + digit; >+ } >+ return {result}; >+ } else { >+ int result = 0; >+ for (unsigned i = 0; i < text.length(); ++i) { >+ int digit = hexDigit(text[i]); >+ result = result * 16 + digit; >+ } >+ if (negate) >+ result *= -1; >+ return {result}; >+ } >+ } else { >+ if (text.endsWith(String("u", String::ConstructFromLiteral))) { >+ text = text.substring(0, text.length() - 1); >+ unsigned result = 0; >+ for (unsigned i = 0; i < text.length(); ++i) { >+ unsigned digit = decimalDigit(text[i]); >+ result = result * 10 + digit; >+ } >+ return {result}; >+ } else { >+ int result = 0; >+ for (unsigned i = 0; i < text.length(); ++i) { >+ int digit = decimalDigit(text[i]); >+ result = result * 10 + digit; >+ } >+ if (negate) >+ result *= -1; >+ return {result}; >+ } >+ } >+} >+ >+auto Parser::parseTypeSuffixAbbreviated() -> std::optional<TypeSuffixAbbreviated> >+{ >+ auto token = consumeTypes({ Lexer::Token::Type::Star, Lexer::Token::Type::SquareBracketPair, Lexer::Token::Type::LeftSquareBracket }); >+ if (!token) >+ return std::nullopt; >+ if (token->type == Lexer::Token::Type::LeftSquareBracket) { >+ auto intLiteral = consumeType(Lexer::Token::Type::IntLiteral); >+ if (!intLiteral) >+ return std::nullopt; >+ auto intValue = intLiteralToInt(intLiteral->stringView); >+ if (!intValue) >+ return std::nullopt; >+ auto numElements = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { return x; }), *intValue); >+ if (!consumeType(Lexer::Token::Type::RightSquareBracket)) >+ return std::nullopt; >+ return {{ *token, numElements }}; >+ } >+ return {{ *token, std::nullopt }}; >+} >+ >+auto Parser::parseTypeSuffixNonAbbreviated() -> std::optional<TypeSuffixNonAbbreviated> >+{ >+ auto token = consumeTypes({ Lexer::Token::Type::Star, Lexer::Token::Type::SquareBracketPair, Lexer::Token::Type::LeftSquareBracket }); >+ if (!token) >+ return std::nullopt; >+ if (token->type == Lexer::Token::Type::LeftSquareBracket) { >+ auto intLiteral = consumeType(Lexer::Token::Type::IntLiteral); >+ if (!intLiteral) >+ return std::nullopt; >+ auto intValue = intLiteralToInt(intLiteral->stringView); >+ if (!intValue) >+ return std::nullopt; >+ auto numElements = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { return x; }), *intValue); >+ if (!consumeType(Lexer::Token::Type::RightSquareBracket)) >+ return std::nullopt; >+ return {{ *intLiteral, std::nullopt, numElements }}; >+ } >+ auto addressSpace = consumeTypes({ Lexer::Token::Type::Constant, Lexer::Token::Type::Device, Lexer::Token::Type::Threadgroup, Lexer::Token::Type::Thread}); >+ if (!addressSpace) >+ return std::nullopt; >+ return {{ *token, { *addressSpace }, std::nullopt }}; >+} >+ >+std::unique_ptr<AST::Type> Parser::parseType() >+{ >+ auto type = backtrackingScope<std::unique_ptr<AST::Type>>([&]() -> std::unique_ptr<AST::Type> { >+ auto addressSpace = consumeTypes({ Lexer::Token::Type::Constant, Lexer::Token::Type::Device, Lexer::Token::Type::Threadgroup, Lexer::Token::Type::Thread}); >+ if (!addressSpace) >+ return nullptr; >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return nullptr; >+ auto typeArguments = parseTypeArguments(); >+ if (!typeArguments) >+ return nullptr; >+ >+ auto constructTypeFromSuffixAbbreviated = [&](TypeSuffixAbbreviated typeSuffixAbbreviated) -> std::function<std::unique_ptr<AST::Type>(std::unique_ptr<AST::Type>&&)> { >+ switch (typeSuffixAbbreviated.token.type) { >+ case Lexer::Token::Type::Star: >+ return [=](std::unique_ptr<AST::Type>&& next) -> std::unique_ptr<AST::Type> { >+ return std::make_unique<AST::PointerType>(Lexer::Token(typeSuffixAbbreviated.token), addressSpace->stringView.toString(), WTFMove(next)); >+ }; >+ case Lexer::Token::Type::SquareBracketPair: >+ return [=](std::unique_ptr<AST::Type>&& next) -> std::unique_ptr<AST::Type> { >+ return std::make_unique<AST::ArrayReferenceType>(Lexer::Token(typeSuffixAbbreviated.token), addressSpace->stringView.toString(), WTFMove(next)); >+ }; >+ case Lexer::Token::Type::LeftSquareBracket: >+ return [=](std::unique_ptr<AST::Type>&& next) -> std::unique_ptr<AST::Type> { >+ return std::make_unique<AST::ArrayType>(Lexer::Token(typeSuffixAbbreviated.token), WTFMove(next), *typeSuffixAbbreviated.numElements); >+ }; >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ }; >+ >+ Vector<std::function<std::unique_ptr<AST::Type>(std::unique_ptr<AST::Type>)>> builders; >+ auto firstTypeSuffixAbbreviated = parseTypeSuffixAbbreviated(); >+ if (!firstTypeSuffixAbbreviated) >+ return nullptr; >+ builders.append(constructTypeFromSuffixAbbreviated(*firstTypeSuffixAbbreviated)); >+ while (true) { >+ auto typeSuffixAbbreviated = backtrackingScope<std::optional<TypeSuffixAbbreviated>>([&]() -> std::optional<TypeSuffixAbbreviated> { >+ return parseTypeSuffixAbbreviated(); >+ }); >+ if (!typeSuffixAbbreviated) >+ break; >+ builders.append(constructTypeFromSuffixAbbreviated(*typeSuffixAbbreviated)); >+ } >+ >+ std::unique_ptr<AST::Type> result = std::make_unique<AST::TypeRef>(Lexer::Token(*addressSpace), name->stringView.toString(), WTFMove(*typeArguments)); >+ for (auto iter = builders.rbegin(); iter != builders.rend(); ++iter) { >+ result = (*iter)(WTFMove(result)); >+ } >+ return result; >+ }); >+ if (type) >+ return type; >+ >+ type = backtrackingScope<std::unique_ptr<AST::Type>>([&]() -> std::unique_ptr<AST::Type> { >+ auto origin = peek(); >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return nullptr; >+ auto typeArguments = parseTypeArguments(); >+ if (!typeArguments) >+ return nullptr; >+ >+ auto constructTypeFromSuffixNonAbbreviated = [&](TypeSuffixNonAbbreviated typeSuffixNonAbbreviated) -> std::function<std::unique_ptr<AST::Type>(std::unique_ptr<AST::Type>&&)> { >+ switch (typeSuffixNonAbbreviated.token.type) { >+ case Lexer::Token::Type::Star: >+ return [=](std::unique_ptr<AST::Type>&& next) -> std::unique_ptr<AST::Type> { >+ return std::make_unique<AST::PointerType>(Lexer::Token(typeSuffixNonAbbreviated.token), typeSuffixNonAbbreviated.addressSpace->stringView.toString(), WTFMove(next)); >+ }; >+ case Lexer::Token::Type::SquareBracketPair: >+ return [=](std::unique_ptr<AST::Type>&& next) -> std::unique_ptr<AST::Type> { >+ return std::make_unique<AST::ArrayReferenceType>(Lexer::Token(typeSuffixNonAbbreviated.token), typeSuffixNonAbbreviated.addressSpace->stringView.toString(), WTFMove(next)); >+ }; >+ case Lexer::Token::Type::LeftSquareBracket: >+ return [=](std::unique_ptr<AST::Type>&& next) -> std::unique_ptr<AST::Type> { >+ return std::make_unique<AST::ArrayType>(Lexer::Token(typeSuffixNonAbbreviated.token), WTFMove(next), *typeSuffixNonAbbreviated.numElements); >+ }; >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ }; >+ >+ Vector<std::function<std::unique_ptr<AST::Type>(std::unique_ptr<AST::Type>)>> builders; >+ while (true) { >+ auto typeSuffixNonAbbreviated = backtrackingScope<std::optional<TypeSuffixNonAbbreviated>>([&]() -> std::optional<TypeSuffixNonAbbreviated> { >+ return parseTypeSuffixNonAbbreviated(); >+ }); >+ if (!typeSuffixNonAbbreviated) >+ break; >+ builders.append(constructTypeFromSuffixNonAbbreviated(*typeSuffixNonAbbreviated)); >+ } >+ >+ std::unique_ptr<AST::Type> result = std::make_unique<AST::TypeRef>(WTFMove(*origin), name->stringView.toString(), WTFMove(*typeArguments)); >+ for (auto iter = builders.rbegin(); iter != builders.rend(); ++iter) { >+ result = (*iter)(WTFMove(result)); >+ } >+ return result; >+ }); >+ if (type) >+ return type; >+ >+ return nullptr; >+} >+ >+std::optional<AST::TypeDef> Parser::parseTypeDef() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Typedef); >+ if (!origin) >+ return std::nullopt; >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::EqualsSign)) >+ return std::nullopt; >+ auto type = parseType(); >+ if (!type) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ return AST::TypeDef(WTFMove(*origin), name->stringView.toString(), WTFMove(type)); >+} >+ >+std::optional<AST::BuiltInSemantic> Parser::parseBuiltInSemantic() >+{ >+ auto origin = consumeTypes({ >+ Lexer::Token::Type::SVInstanceID, >+ Lexer::Token::Type::SVVertexID, >+ Lexer::Token::Type::PSize, >+ Lexer::Token::Type::SVPosition, >+ Lexer::Token::Type::SVIsFrontFace, >+ Lexer::Token::Type::SVSampleIndex, >+ Lexer::Token::Type::SVInnerCoverage, >+ Lexer::Token::Type::SVTarget, >+ Lexer::Token::Type::SVDepth, >+ Lexer::Token::Type::SVCoverage, >+ Lexer::Token::Type::SVDispatchThreadID, >+ Lexer::Token::Type::SVGroupID, >+ Lexer::Token::Type::SVGroupIndex, >+ Lexer::Token::Type::SVGroupThreadID}); >+ if (!origin) >+ return std::nullopt; >+ >+ switch (origin->type) { >+ case Lexer::Token::Type::SVInstanceID: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVInstanceID); >+ case Lexer::Token::Type::SVVertexID: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVVertexID); >+ case Lexer::Token::Type::PSize: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::PSize); >+ case Lexer::Token::Type::SVPosition: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVPosition); >+ case Lexer::Token::Type::SVIsFrontFace: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVIsFrontFace); >+ case Lexer::Token::Type::SVSampleIndex: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVSampleIndex); >+ case Lexer::Token::Type::SVInnerCoverage: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVInnerCoverage); >+ case Lexer::Token::Type::SVTarget: { >+ auto target = consumeType(Lexer::Token::Type::IntLiteral); >+ if (!target) >+ return std::nullopt; >+ auto targetIndex = intLiteralToInt(target->stringView); >+ if (!targetIndex) >+ return std::nullopt; >+ auto targetIndexValue = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { return x; }), *targetIndex); >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVTarget, targetIndexValue); >+ } >+ case Lexer::Token::Type::SVDepth: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVDepth); >+ case Lexer::Token::Type::SVCoverage: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVCoverage); >+ case Lexer::Token::Type::SVDispatchThreadID: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVDispatchThreadID); >+ case Lexer::Token::Type::SVGroupID: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVGroupID); >+ case Lexer::Token::Type::SVGroupIndex: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVGroupIndex); >+ case Lexer::Token::Type::SVGroupThreadID: >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVGroupThreadID); >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+} >+ >+std::optional<AST::ResourceSemantic> Parser::parseResourceSemantic() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Register); >+ if (!origin) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ auto info = consumeType(Lexer::Token::Type::Identifier); >+ if (!info) >+ return std::nullopt; >+ if (info->stringView.length() < 2 || (info->stringView[0] != 'u' >+ && info->stringView[0] != 't' >+ && info->stringView[0] != 'b' >+ && info->stringView[0] != 's')) >+ return std::nullopt; >+ for (unsigned i = 1; i < info->stringView.length(); ++i) { >+ if (info->stringView[i] < '0' || info->stringView[i] > '9') >+ return std::nullopt; >+ } >+ >+ AST::ResourceSemantic::Mode mode; >+ switch (info->stringView[0]) { >+ case 'u': >+ mode = AST::ResourceSemantic::Mode::U; >+ break; >+ case 't': >+ mode = AST::ResourceSemantic::Mode::T; >+ break; >+ case 'b': >+ mode = AST::ResourceSemantic::Mode::B; >+ break; >+ case 's': >+ mode = AST::ResourceSemantic::Mode::S; >+ break; >+ } >+ >+ auto indexValue = intLiteralToInt(info->stringView.substring(1)); >+ if (!indexValue) >+ return std::nullopt; >+ auto index = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { return x; }), *indexValue); >+ >+ unsigned space = 0; >+ if (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto spaceToken = consumeType(Lexer::Token::Type::Identifier); >+ if (!spaceToken) >+ return std::nullopt; >+ auto prefix = String("space", String::ConstructFromLiteral); >+ if (!spaceToken->stringView.startsWith(StringView(prefix))) >+ return std::nullopt; >+ if (spaceToken->stringView.length() <= prefix.length()) >+ return std::nullopt; >+ for (unsigned i = prefix.length(); i < spaceToken->stringView.length(); ++i) { >+ if (spaceToken->stringView[i] < '0' || spaceToken->stringView[i] > '9') >+ return std::nullopt; >+ } >+ auto spaceValue = intLiteralToInt(spaceToken->stringView.substring(prefix.length())); >+ if (!spaceValue) >+ return std::nullopt; >+ space = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { return x; }), *spaceValue); >+ } >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ return AST::ResourceSemantic(WTFMove(*origin), mode, index, space); >+} >+ >+std::optional<AST::SpecializationConstantSemantic> Parser::parseSpecializationConstantSemantic() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Specialized); >+ if (!origin) >+ return std::nullopt; >+ return AST::SpecializationConstantSemantic(WTFMove(*origin)); >+} >+ >+std::optional<AST::StageInOutSemantic> Parser::parseStageInOutSemantic() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Attribute); >+ if (!origin) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ auto index = consumeType(Lexer::Token::Type::IntLiteral); >+ if (!index) >+ return std::nullopt; >+ >+ auto indexValue = intLiteralToInt(index->stringView); >+ if (!indexValue) >+ return std::nullopt; >+ auto indexValueResult = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { return x; }), *indexValue); >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ return AST::StageInOutSemantic(WTFMove(*origin), indexValueResult); >+} >+ >+std::optional<AST::Semantic> Parser::parseSemantic() >+{ >+ auto builtInSemantic = backtrackingScope<std::optional<AST::BuiltInSemantic>>([&]() -> std::optional<AST::BuiltInSemantic> { >+ return parseBuiltInSemantic(); >+ }); >+ if (builtInSemantic) >+ return { *builtInSemantic }; >+ >+ auto resourceSemantic = backtrackingScope<std::optional<AST::ResourceSemantic>>([&]() -> std::optional<AST::ResourceSemantic> { >+ return parseResourceSemantic(); >+ }); >+ if (resourceSemantic) >+ return { *resourceSemantic }; >+ >+ auto specializationConstantSemantic = backtrackingScope<std::optional<AST::SpecializationConstantSemantic>>([&]() -> std::optional<AST::SpecializationConstantSemantic> { >+ return parseSpecializationConstantSemantic(); >+ }); >+ if (specializationConstantSemantic) >+ return { *specializationConstantSemantic }; >+ >+ auto stageInOutSemantic = backtrackingScope<std::optional<AST::StageInOutSemantic>>([&]() -> std::optional<AST::StageInOutSemantic> { >+ return parseStageInOutSemantic(); >+ }); >+ if (stageInOutSemantic) >+ return { *stageInOutSemantic }; >+ >+ return std::nullopt; >+} >+ >+std::optional<AST::Field> Parser::parseStructElement() >+{ >+ std::optional<Lexer::Token> origin; >+ Vector<AST::Qualifier> qualifiers; >+ while (true) { >+ if (auto next = peekType(Lexer::Token::Type::Qualifier)) { >+ consumeType(Lexer::Token::Type::Qualifier); >+ if (!origin) >+ origin = *next; >+ if ("nointerpolation" == next->stringView) >+ qualifiers.append(AST::Qualifier::Nointerpolation); >+ else if ("noperspective" == next->stringView) >+ qualifiers.append(AST::Qualifier::Noperspective); >+ else if ("uniform" == next->stringView) >+ qualifiers.append(AST::Qualifier::Uniform); >+ else if ("centroid" == next->stringView) >+ qualifiers.append(AST::Qualifier::Centroid); >+ else if ("sample" == next->stringView) >+ qualifiers.append(AST::Qualifier::Sample); >+ else >+ ASSERT_NOT_REACHED(); >+ } else >+ break; >+ } >+ >+ if (!origin) >+ origin = peek(); >+ if (!origin) >+ return std::nullopt; >+ >+ auto type = parseType(); >+ if (!type) >+ return std::nullopt; >+ >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return std::nullopt; >+ >+ std::optional<AST::Semantic> semantic; >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto parsedSemantic = parseSemantic(); >+ if (!parsedSemantic) >+ return std::nullopt; >+ semantic = *parsedSemantic; >+ } >+ >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ >+ return AST::Field(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), name->stringView.toString(), WTFMove(semantic)); >+} >+ >+std::optional<AST::StructType> Parser::parseStructDef() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Struct); >+ if (!origin) >+ return std::nullopt; >+ >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftCurlyBracket)) >+ return std::nullopt; >+ >+ Vector<AST::Field> fields; >+ while (true) { >+ auto structElement = backtrackingScope<std::optional<AST::Field>>([&]() -> std::optional<AST::Field> { >+ return parseStructElement(); >+ }); >+ if (structElement) >+ fields.append(WTFMove(*structElement)); >+ else >+ break; >+ } >+ >+ if (!consumeType(Lexer::Token::Type::RightCurlyBracket)) >+ return std::nullopt; >+ >+ return AST::StructType(WTFMove(*origin), name->stringView.toString(), WTFMove(fields)); >+} >+ >+std::optional<AST::EnumType> Parser::parseEnumDef() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Enum); >+ if (!origin) >+ return std::nullopt; >+ >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return std::nullopt; >+ >+ std::unique_ptr<AST::Type> type; >+ if (peekType(Lexer::Token::Type::Colon)) { >+ type = parseType(); >+ if (!type) >+ return std::nullopt; >+ } >+ >+ if (!consumeType(Lexer::Token::Type::LeftCurlyBracket)) >+ return std::nullopt; >+ >+ auto firstEnumMember = parseEnumMember(); >+ if (!firstEnumMember) >+ return std::nullopt; >+ >+ Vector<AST::EnumMember> members; >+ members.append(WTFMove(*firstEnumMember)); >+ >+ while (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto member = parseEnumMember(); >+ if (!member) >+ return std::nullopt; >+ members.append(WTFMove(*member)); >+ } >+ >+ if (!consumeType(Lexer::Token::Type::RightCurlyBracket)) >+ return std::nullopt; >+ >+ return AST::EnumType(WTFMove(*origin), name->stringView.toString(), WTFMove(type), WTFMove(members)); >+} >+ >+std::optional<AST::EnumMember> Parser::parseEnumMember() >+{ >+ auto identifier = consumeType(Lexer::Token::Type::Identifier); >+ if (!identifier) >+ return std::nullopt; >+ >+ if (peekType(Lexer::Token::Type::EqualsSign) { >+ consumeType(Lexer::Token::Type::EqualsSign); >+ auto constExpr = parseConstExpr(); >+ if (!constExpr) >+ return std::nullopt; >+ return AST::EnumMember(Lexer::Token(*identifier), WTFMove(*identifier), *constExpr); >+ } >+ return AST::EnumMember(Lexer::Token(*identifier), WTFMove(*identifer)); >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >new file mode 100644 >index 0000000000000000000000000000000000000000..eea5952f7f57ce13deb80490c2f4cd9b8efe6fcc >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >@@ -0,0 +1,105 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTField.h" >+#include "WHLSLASTStructType.h" >+#include "WHLSLASTTypeArgument.h" >+#include "WHLSLASTTypeDef.h" >+#include "WHLSLLexer.h" >+#include "WHLSLProgram.h" >+#include "WHLSLASTSemantic.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class Parser { >+public: >+ Parser(StringView); >+ >+ std::optional<Program> parse(); >+ >+private: >+ template<typename T> T backtrackingScope(std::function<T()> callback) >+ { >+ auto state = m_lexer.state(); >+ if (auto result = callback()) >+ return result; >+ m_lexer.setState(WTFMove(state)); >+ return {}; >+ } >+ >+ template<typename T> bool testScope(std::function<T()> callback) >+ { >+ auto state = m_lexer.state(); >+ bool result = callback(); >+ m_lexer.setState(WTFMove(state)); >+ return result; >+ } >+ >+ std::optional<Lexer::Token> peek(); >+ std::optional<Lexer::Token> peekType(Lexer::Token::Type); >+ std::optional<Lexer::Token> consumeType(Lexer::Token::Type); >+ std::optional<Lexer::Token> consumeTypes(Vector<Lexer::Token::Type>); >+ >+ std::optional<Lexer::Token> parseLiteral(); >+ std::optional<AST::ConstExpr> parseConstExpr(); >+ std::optional<AST::TypeArgument> parseTypeArgument(); >+ std::optional<AST::TypeArguments> parseTypeArguments(); >+ struct TypeSuffixAbbreviated { >+ Lexer::Token token; >+ std::optional<unsigned> numElements; >+ }; >+ std::optional<TypeSuffixAbbreviated> parseTypeSuffixAbbreviated(); >+ struct TypeSuffixNonAbbreviated { >+ Lexer::Token token; >+ std::optional<Lexer::Token> addressSpace; >+ std::optional<unsigned> numElements; >+ }; >+ std::optional<TypeSuffixNonAbbreviated> parseTypeSuffixNonAbbreviated(); >+ std::unique_ptr<AST::Type> parseType(); >+ std::optional<AST::TypeDef> parseTypeDef(); >+ std::optional<AST::BuiltInSemantic> parseBuiltInSemantic(); >+ std::optional<AST::ResourceSemantic> parseResourceSemantic(); >+ std::optional<AST::SpecializationConstantSemantic> parseSpecializationConstantSemantic(); >+ std::optional<AST::StageInOutSemantic> parseStageInOutSemantic(); >+ std::optional<AST::Semantic> parseSemantic(); >+ std::optional<AST::Field> parseStructElement(); >+ std::optional<AST::StructType> parseStructDef(); >+ std::optional<AST::EnumType> parseEnumDef(); >+ std::optional<AST::EnumMember> parseEnumMember(); >+ >+ Lexer m_lexer; >+}; >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..3f23f76284042368cda8756e1f0e914fc1a2c9e6 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.cpp >@@ -0,0 +1,41 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLProgram.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >new file mode 100644 >index 0000000000000000000000000000000000000000..5ba06c528c52036c1b05cd12533be59b9815ec17 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >@@ -0,0 +1,64 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLASTEnumType.h" >+#include "WHLSLASTTypeDef.h" >+#include "WHLSLASTStructType.h" >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class Program { >+public: >+ void append(AST::TypeDef&& typeDef) >+ { >+ m_typeDefs.append(WTFMove(typeDef)); >+ } >+ void append(AST::StructType&& structType) >+ { >+ m_structTypes.append(WTFMove(structType)); >+ } >+ void append(AST::EnumType&& enumType) >+ { >+ m_enumTypes.append(WTFMove(enumType)); >+ } >+ >+private: >+ Vector<AST::TypeDef> m_typeDefs; >+ Vector<AST::StructType> m_structTypes; >+ Vector<AST::EnumType> m_enumTypes; >+}; >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 6a9882dc90c81d487ad80f55babac42ddaa2b3d8..ae52fe5ea358705ab1902acf36f8bbed91147c7e 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -301,6 +301,32 @@ Modules/websockets/WebSocketHandshake.cpp > Modules/websockets/WorkerThreadableWebSocketChannel.cpp > > Modules/webgpu/DOMWindowWebGPU.cpp >+Modules/webgpu/WHLSL/WHLSLLexer.cpp >+Modules/webgpu/WHLSL/WHLSLParser.cpp >+Modules/webgpu/WHLSL/WHLSLASTVariableDecl.cpp >+Modules/webgpu/WHLSL/WHLSLASTTypeDef.cpp >+Modules/webgpu/WHLSL/WHLSLASTStructDef.cpp >+Modules/webgpu/WHLSL/WHLSLASTEnumDef.cpp >+Modules/webgpu/WHLSL/WHLSLASTFuncDef.cpp >+Modules/webgpu/WHLSL/WHLSLASTNativeFuncDecl.cpp >+Modules/webgpu/WHLSL/WHLSLASTNativeTypeDecl.cpp >+Modules/webgpu/WHLSL/WHLSLProgram.cpp >+Modules/webgpu/WHLSL/WHLSLASTType.cpp >+Modules/webgpu/WHLSL/WHLSLASTTypeRef.cpp >+Modules/webgpu/WHLSL/WHLSLASTConstExpr.cpp >+Modules/webgpu/WHLSL/WHLSLASTPointerType.cpp >+Modules/webgpu/WHLSL/WHLSLASTArrayReferenceType.cpp >+Modules/webgpu/WHLSL/WHLSLASTArrayType.cpp >+Modules/webgpu/WHLSL/WHLSLASTReferenceType.cpp >+Modules/webgpu/WHLSL/WHLSLASTField.cpp >+Modules/webgpu/WHLSL/WHLSLASTStructType.cpp >+Modules/webgpu/WHLSL/WHLSLASTBaseSemantic.cpp >+Modules/webgpu/WHLSL/WHLSLASTBuiltInSemantic.cpp >+Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.cpp >+Modules/webgpu/WHLSL/WHLSLASTSpecializationConstantSemantic.cpp >+Modules/webgpu/WHLSL/WHLSLASTStageInOutSemantic.cpp >+Modules/webgpu/WHLSL/WHLSLASTEnumType.cpp >+Modules/webgpu/WHLSL/WHLSLASTEnumMember.cpp > Modules/webgpu/WebGPU.cpp > Modules/webgpu/WebGPUAdapter.cpp > Modules/webgpu/WebGPUCommandBuffer.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index df2c955f019ae10ca5a6d588718340f4da4fda68..76398fa18600c6456491321569995f2c86060c3b 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -6401,6 +6401,26 @@ > 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = "<group>"; }; > 1C66260E1C6E7CA600AB527C /* FontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFace.cpp; sourceTree = "<group>"; }; > 1C66260F1C6E7CA600AB527C /* FontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFace.h; sourceTree = "<group>"; }; >+ 1C80596B21BA164A006B0906 /* WHLSLASTNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTNode.h; sourceTree = "<group>"; }; >+ 1C80596E21BB02D3006B0906 /* WHLSLASTPointerType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTPointerType.cpp; sourceTree = "<group>"; }; >+ 1C80596F21BB02D3006B0906 /* WHLSLASTPointerType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTPointerType.h; sourceTree = "<group>"; }; >+ 1C80597121BB02EA006B0906 /* WHLSLASTArrayReferenceType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTArrayReferenceType.cpp; sourceTree = "<group>"; }; >+ 1C80597221BB02EA006B0906 /* WHLSLASTArrayReferenceType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTArrayReferenceType.h; sourceTree = "<group>"; }; >+ 1C80597321BB02FB006B0906 /* WHLSLASTArrayType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTArrayType.cpp; sourceTree = "<group>"; }; >+ 1C80597421BB02FB006B0906 /* WHLSLASTArrayType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTArrayType.h; sourceTree = "<group>"; }; >+ 1C80597521BB0577006B0906 /* WHLSLASTReferenceType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTReferenceType.cpp; sourceTree = "<group>"; }; >+ 1C80597621BB0577006B0906 /* WHLSLASTReferenceType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTReferenceType.h; sourceTree = "<group>"; }; >+ 1C80597C21BF55A7006B0906 /* WHLSLASTBaseSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTBaseSemantic.cpp; sourceTree = "<group>"; }; >+ 1C80597D21BF55A7006B0906 /* WHLSLASTBaseSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTBaseSemantic.h; sourceTree = "<group>"; }; >+ 1C80597F21BF55BA006B0906 /* WHLSLASTBuiltInSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTBuiltInSemantic.cpp; sourceTree = "<group>"; }; >+ 1C80598021BF55BA006B0906 /* WHLSLASTBuiltInSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTBuiltInSemantic.h; sourceTree = "<group>"; }; >+ 1C80598121BF55D1006B0906 /* WHLSLASTResourceSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTResourceSemantic.cpp; sourceTree = "<group>"; }; >+ 1C80598221BF55D1006B0906 /* WHLSLASTResourceSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTResourceSemantic.h; sourceTree = "<group>"; }; >+ 1C80598321BF55ED006B0906 /* WHLSLASTSpecializationConstantSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTSpecializationConstantSemantic.cpp; sourceTree = "<group>"; }; >+ 1C80598421BF55ED006B0906 /* WHLSLASTSpecializationConstantSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTSpecializationConstantSemantic.h; sourceTree = "<group>"; }; >+ 1C80598521BF5601006B0906 /* WHLSLASTStageInOutSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTStageInOutSemantic.cpp; sourceTree = "<group>"; }; >+ 1C80598621BF5601006B0906 /* WHLSLASTStageInOutSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTStageInOutSemantic.h; sourceTree = "<group>"; }; >+ 1C80598721BF5781006B0906 /* WHLSLASTSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTSemantic.h; sourceTree = "<group>"; }; > 1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; }; > 1C81B9570E97330800266E07 /* InspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorController.cpp; sourceTree = "<group>"; }; > 1C81B9580E97330800266E07 /* InspectorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorClient.h; sourceTree = "<group>"; }; >@@ -6412,6 +6432,9 @@ > 1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObjectPrivate.h; sourceTree = "<group>"; }; > 1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextDecorationThickness.h; sourceTree = "<group>"; }; > 1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextUnderlineOffset.h; sourceTree = "<group>"; }; >+ 1CC46F2621B77860000998DE /* WHLSLASTTypeRef.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTTypeRef.cpp; sourceTree = "<group>"; }; >+ 1CC46F2721B77860000998DE /* WHLSLASTTypeRef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTTypeRef.h; sourceTree = "<group>"; }; >+ 1CC46F2921B77A32000998DE /* WHLSLASTTypeArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTTypeArgument.h; sourceTree = "<group>"; }; > 1CCDF5BB1990332400BCEBAD /* SVGToOTFFontConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGToOTFFontConversion.cpp; sourceTree = "<group>"; }; > 1CCDF5BC1990332400BCEBAD /* SVGToOTFFontConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGToOTFFontConversion.h; sourceTree = "<group>"; }; > 1CDD45E40BA9C84600F90147 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; }; >@@ -13198,6 +13221,8 @@ > C11A9ED22140578B00CFB20A /* SwitchingGPUClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SwitchingGPUClient.cpp; sourceTree = "<group>"; }; > C1E1D235203DF15400584665 /* ScreenProperties.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScreenProperties.h; sourceTree = "<group>"; }; > C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontVariantBuilder.h; sourceTree = "<group>"; }; >+ C210E91121B4BD1000B7F83D /* WHLSLLexer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLLexer.cpp; sourceTree = "<group>"; }; >+ C210E91221B4BD1000B7F83D /* WHLSLLexer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLLexer.h; sourceTree = "<group>"; }; > C21DF2E71D9E4E9900F5B24C /* CSSFontVariationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontVariationValue.cpp; sourceTree = "<group>"; }; > C21DF2E81D9E4E9900F5B24C /* CSSFontVariationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontVariationValue.h; sourceTree = "<group>"; }; > C2458E611FE8979E00594759 /* FontCacheCoreText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontCacheCoreText.h; sourceTree = "<group>"; }; >@@ -13215,6 +13240,37 @@ > C2E38EFC1E8396FD00CA3ADF /* CSSFontStyleValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontStyleValue.h; sourceTree = "<group>"; }; > C2E38EFF1E84573500CA3ADF /* CSSFontStyleRangeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontStyleRangeValue.cpp; sourceTree = "<group>"; }; > C2E38F001E84573500CA3ADF /* CSSFontStyleRangeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontStyleRangeValue.h; sourceTree = "<group>"; }; >+ C2ECEB4C21B63CBB008F8DE9 /* WHLSLParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLParser.cpp; sourceTree = "<group>"; }; >+ C2ECEB4D21B63CBB008F8DE9 /* WHLSLParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLParser.h; sourceTree = "<group>"; }; >+ C2ECEB4F21B64C72008F8DE9 /* WHLSLASTVariableDecl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTVariableDecl.cpp; sourceTree = "<group>"; }; >+ C2ECEB5021B64C72008F8DE9 /* WHLSLASTVariableDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTVariableDecl.h; sourceTree = "<group>"; }; >+ C2ECEB5121B64C84008F8DE9 /* WHLSLASTTypeDef.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTTypeDef.cpp; sourceTree = "<group>"; }; >+ C2ECEB5221B64C84008F8DE9 /* WHLSLASTTypeDef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTTypeDef.h; sourceTree = "<group>"; }; >+ C2ECEB5321B64C97008F8DE9 /* WHLSLASTStructDef.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTStructDef.cpp; sourceTree = "<group>"; }; >+ C2ECEB5421B64C97008F8DE9 /* WHLSLASTStructDef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTStructDef.h; sourceTree = "<group>"; }; >+ C2ECEB5521B64CAB008F8DE9 /* WHLSLASTEnumDef.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTEnumDef.cpp; sourceTree = "<group>"; }; >+ C2ECEB5621B64CAB008F8DE9 /* WHLSLASTEnumDef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTEnumDef.h; sourceTree = "<group>"; }; >+ C2ECEB5721B64CBE008F8DE9 /* WHLSLASTFuncDef.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTFuncDef.cpp; sourceTree = "<group>"; }; >+ C2ECEB5821B64CBE008F8DE9 /* WHLSLASTFuncDef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTFuncDef.h; sourceTree = "<group>"; }; >+ C2ECEB5921B64CD5008F8DE9 /* WHLSLASTNativeFuncDecl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTNativeFuncDecl.cpp; sourceTree = "<group>"; }; >+ C2ECEB5A21B64CD5008F8DE9 /* WHLSLASTNativeFuncDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTNativeFuncDecl.h; sourceTree = "<group>"; }; >+ C2ECEB5B21B64CE4008F8DE9 /* WHLSLASTNativeTypeDecl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTNativeTypeDecl.cpp; sourceTree = "<group>"; }; >+ C2ECEB5C21B64CE4008F8DE9 /* WHLSLASTNativeTypeDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTNativeTypeDecl.h; sourceTree = "<group>"; }; >+ C2ECEB5D21B64D6F008F8DE9 /* WHLSLProgram.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLProgram.cpp; sourceTree = "<group>"; }; >+ C2ECEB5E21B64D6F008F8DE9 /* WHLSLProgram.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLProgram.h; sourceTree = "<group>"; }; >+ C2ECEB5F21B64DC6008F8DE9 /* WHLSLASTType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTType.cpp; sourceTree = "<group>"; }; >+ C2ECEB6021B64DC6008F8DE9 /* WHLSLASTType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTType.h; sourceTree = "<group>"; }; >+ C2ECEB6421B7A7CF008F8DE9 /* WHLSLASTConstExpr.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTConstExpr.cpp; sourceTree = "<group>"; }; >+ C2ECEB6521B7A7CF008F8DE9 /* WHLSLASTConstExpr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTConstExpr.h; sourceTree = "<group>"; }; >+ C2ECEB6B21BE4896008F8DE9 /* WHLSLASTField.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTField.cpp; sourceTree = "<group>"; }; >+ C2ECEB6C21BE4896008F8DE9 /* WHLSLASTField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTField.h; sourceTree = "<group>"; }; >+ C2ECEB6E21BE48D1008F8DE9 /* WHLSLASTStructType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTStructType.cpp; sourceTree = "<group>"; }; >+ C2ECEB6F21BE48D1008F8DE9 /* WHLSLASTStructType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTStructType.h; sourceTree = "<group>"; }; >+ C2ECEB7421BF7F3A008F8DE9 /* WHLSLASTQualifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTQualifier.h; sourceTree = "<group>"; }; >+ C2ECEB7621BF8DF7008F8DE9 /* WHLSLASTEnumType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTEnumType.cpp; sourceTree = "<group>"; }; >+ C2ECEB7721BF8DF7008F8DE9 /* WHLSLASTEnumType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTEnumType.h; sourceTree = "<group>"; }; >+ C2ECEB7821BF8E05008F8DE9 /* WHLSLASTEnumMember.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTEnumMember.cpp; sourceTree = "<group>"; }; >+ C2ECEB7921BF8E05008F8DE9 /* WHLSLASTEnumMember.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTEnumMember.h; sourceTree = "<group>"; }; > C2F4E7881E45AEDF006D7105 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; }; > C2F4E7891E45AEDF006D7105 /* ComplexTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplexTextController.h; sourceTree = "<group>"; }; > C330A22113EC196B0000B45B /* ColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorChooser.h; sourceTree = "<group>"; }; >@@ -25140,6 +25196,69 @@ > tabWidth = 4; > usesTabs = 0; > }; >+ C210E90D21B4BCA400B7F83D /* WHLSL */ = { >+ isa = PBXGroup; >+ children = ( >+ 1C80597121BB02EA006B0906 /* WHLSLASTArrayReferenceType.cpp */, >+ 1C80597221BB02EA006B0906 /* WHLSLASTArrayReferenceType.h */, >+ 1C80597321BB02FB006B0906 /* WHLSLASTArrayType.cpp */, >+ 1C80597421BB02FB006B0906 /* WHLSLASTArrayType.h */, >+ 1C80597C21BF55A7006B0906 /* WHLSLASTBaseSemantic.cpp */, >+ 1C80597D21BF55A7006B0906 /* WHLSLASTBaseSemantic.h */, >+ 1C80597F21BF55BA006B0906 /* WHLSLASTBuiltInSemantic.cpp */, >+ 1C80598021BF55BA006B0906 /* WHLSLASTBuiltInSemantic.h */, >+ C2ECEB6421B7A7CF008F8DE9 /* WHLSLASTConstExpr.cpp */, >+ C2ECEB6521B7A7CF008F8DE9 /* WHLSLASTConstExpr.h */, >+ C2ECEB5521B64CAB008F8DE9 /* WHLSLASTEnumDef.cpp */, >+ C2ECEB5621B64CAB008F8DE9 /* WHLSLASTEnumDef.h */, >+ C2ECEB7821BF8E05008F8DE9 /* WHLSLASTEnumMember.cpp */, >+ C2ECEB7921BF8E05008F8DE9 /* WHLSLASTEnumMember.h */, >+ C2ECEB7621BF8DF7008F8DE9 /* WHLSLASTEnumType.cpp */, >+ C2ECEB7721BF8DF7008F8DE9 /* WHLSLASTEnumType.h */, >+ C2ECEB6B21BE4896008F8DE9 /* WHLSLASTField.cpp */, >+ C2ECEB6C21BE4896008F8DE9 /* WHLSLASTField.h */, >+ C2ECEB5721B64CBE008F8DE9 /* WHLSLASTFuncDef.cpp */, >+ C2ECEB5821B64CBE008F8DE9 /* WHLSLASTFuncDef.h */, >+ C2ECEB5921B64CD5008F8DE9 /* WHLSLASTNativeFuncDecl.cpp */, >+ C2ECEB5A21B64CD5008F8DE9 /* WHLSLASTNativeFuncDecl.h */, >+ C2ECEB5B21B64CE4008F8DE9 /* WHLSLASTNativeTypeDecl.cpp */, >+ C2ECEB5C21B64CE4008F8DE9 /* WHLSLASTNativeTypeDecl.h */, >+ 1C80596B21BA164A006B0906 /* WHLSLASTNode.h */, >+ 1C80596E21BB02D3006B0906 /* WHLSLASTPointerType.cpp */, >+ 1C80596F21BB02D3006B0906 /* WHLSLASTPointerType.h */, >+ C2ECEB7421BF7F3A008F8DE9 /* WHLSLASTQualifier.h */, >+ 1C80597521BB0577006B0906 /* WHLSLASTReferenceType.cpp */, >+ 1C80597621BB0577006B0906 /* WHLSLASTReferenceType.h */, >+ 1C80598121BF55D1006B0906 /* WHLSLASTResourceSemantic.cpp */, >+ 1C80598221BF55D1006B0906 /* WHLSLASTResourceSemantic.h */, >+ 1C80598721BF5781006B0906 /* WHLSLASTSemantic.h */, >+ 1C80598321BF55ED006B0906 /* WHLSLASTSpecializationConstantSemantic.cpp */, >+ 1C80598421BF55ED006B0906 /* WHLSLASTSpecializationConstantSemantic.h */, >+ 1C80598521BF5601006B0906 /* WHLSLASTStageInOutSemantic.cpp */, >+ 1C80598621BF5601006B0906 /* WHLSLASTStageInOutSemantic.h */, >+ C2ECEB5321B64C97008F8DE9 /* WHLSLASTStructDef.cpp */, >+ C2ECEB5421B64C97008F8DE9 /* WHLSLASTStructDef.h */, >+ C2ECEB6E21BE48D1008F8DE9 /* WHLSLASTStructType.cpp */, >+ C2ECEB6F21BE48D1008F8DE9 /* WHLSLASTStructType.h */, >+ C2ECEB5F21B64DC6008F8DE9 /* WHLSLASTType.cpp */, >+ C2ECEB6021B64DC6008F8DE9 /* WHLSLASTType.h */, >+ 1CC46F2921B77A32000998DE /* WHLSLASTTypeArgument.h */, >+ C2ECEB5121B64C84008F8DE9 /* WHLSLASTTypeDef.cpp */, >+ C2ECEB5221B64C84008F8DE9 /* WHLSLASTTypeDef.h */, >+ 1CC46F2621B77860000998DE /* WHLSLASTTypeRef.cpp */, >+ 1CC46F2721B77860000998DE /* WHLSLASTTypeRef.h */, >+ C2ECEB4F21B64C72008F8DE9 /* WHLSLASTVariableDecl.cpp */, >+ C2ECEB5021B64C72008F8DE9 /* WHLSLASTVariableDecl.h */, >+ C210E91121B4BD1000B7F83D /* WHLSLLexer.cpp */, >+ C210E91221B4BD1000B7F83D /* WHLSLLexer.h */, >+ C2ECEB4C21B63CBB008F8DE9 /* WHLSLParser.cpp */, >+ C2ECEB4D21B63CBB008F8DE9 /* WHLSLParser.h */, >+ C2ECEB5D21B64D6F008F8DE9 /* WHLSLProgram.cpp */, >+ C2ECEB5E21B64D6F008F8DE9 /* WHLSLProgram.h */, >+ ); >+ path = WHLSL; >+ sourceTree = "<group>"; >+ }; > C96F5EBF1B5872260091EA9D /* mediasession */ = { > isa = PBXGroup; > children = ( >@@ -25482,6 +25601,7 @@ > D00F593E216ECC43000D71DB /* webgpu */ = { > isa = PBXGroup; > children = ( >+ C210E90D21B4BCA400B7F83D /* WHLSL */, > D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */, > D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */, > D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */, >@@ -29986,7 +30106,6 @@ > 11310CF620BA4A560065A8D0 /* LayoutChildIterator.h in Headers */, > 1199FA46208E35A3002358CC /* LayoutContainer.h in Headers */, > 11310CF520BA4A4C0065A8D0 /* LayoutDescendantIterator.h in Headers */, >- 6F7CA3C6208C2957002F29AB /* LayoutState.h in Headers */, > 1199FA53208E38D3002358CC /* LayoutInlineBox.h in Headers */, > 1199FA4F208E3899002358CC /* LayoutInlineContainer.h in Headers */, > 11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */, >@@ -29997,7 +30116,7 @@ > A12538D413F9B60A00024754 /* LayoutRepainter.h in Headers */, > 11310CF320BA4A370065A8D0 /* LayoutReplaced.h in Headers */, > 141DC054164834B900371E5A /* LayoutSize.h in Headers */, >- 2D9066070BE141D400956998 /* RenderLayoutState.h in Headers */, >+ 6F7CA3C6208C2957002F29AB /* LayoutState.h in Headers */, > 11310CF220BA4A320065A8D0 /* LayoutTreeBuilder.h in Headers */, > 141DC0481648348F00371E5A /* LayoutUnit.h in Headers */, > CDE8B5ED1A69777300B4B66A /* LegacyCDMPrivateClearKey.h in Headers */, >@@ -30598,6 +30717,7 @@ > 0F580CFF0F12DE9B0051D689 /* RenderLayerBacking.h in Headers */, > 0F580CFD0F12DE9B0051D689 /* RenderLayerCompositor.h in Headers */, > 3C244FEAA375AC633F88BE6F /* RenderLayerModelObject.h in Headers */, >+ 2D9066070BE141D400956998 /* RenderLayoutState.h in Headers */, > 0BE030A20F3112FB003C1A46 /* RenderLineBoxList.h in Headers */, > BCEA4864097D93020094C9E4 /* RenderLineBreak.h in Headers */, > ABB5419F0ACDDFE4002820EB /* RenderListBox.h in Headers */,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192355
:
356468
|
356569
|
356570
|
356585
|
356695
|
356778
|
356863
|
356947
|
357031
|
357035
|
357038
|
357081
|
357103
|
357199
|
357207
|
357225
|
357245
|
357268
|
357277
|
357303
|
357304
|
357361
|
357410
|
357430
|
357458
|
357520
|
357602
|
357749
|
357754
|
357765
|
357869
|
357889
|
357929
|
357932
|
357975
|
358866
|
358880
|
358902
|
359250