WebKit Bugzilla
Attachment 357103 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-20181211221333.patch (text/plain), 252.46 KB, created by
Myles C. Maxfield
on 2018-12-11 22:13:34 PST
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-12-11 22:13:34 PST
Size:
252.46 KB
patch
obsolete
>Subversion Revision: 239091 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 79fc819330710166f237804bc50a0c09b53e8a55..530d12ebe9eb284d33fbf5d5c49b988360262200 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,75 @@ >+2018-12-11 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Add a handwritten parser >+ https://bugs.webkit.org/show_bug.cgi?id=192355 >+ >+ Reviewed by NOBODY (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-11 Jer Noble <jer.noble@apple.com> > > Globally namespaced objects shouldn't use framework-prefixed names >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAnonymousVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAnonymousVariableDeclaration.h >new file mode 100644 >index 0000000000000000000000000000000000000000..eba6bf683e0a34fa60988174edbc59558616df13 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAnonymousVariableDeclaration.h >@@ -0,0 +1,62 @@ >+/* >+ * 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 "WHLSLASTValue.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class AnonymousVariableDeclaration : public Value { >+public: >+ AnonymousVariableDeclaration(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~AnonymousVariableDeclaration() >+ { >+ } >+ >+ Lexer::Token origin() const { return m_origin; } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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.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/WHLSLASTAssignmentExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAssignmentExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..24ad70a25dee226e7b3a34acdb8c619e5e7c9506 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAssignmentExpression.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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class AssignmentExpression : public Expression { >+public: >+ AssignmentExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& left, std::unique_ptr<Expression>&& right) >+ : Expression(WTFMove(origin)) >+ , m_left(WTFMove(left)) >+ , m_right(WTFMove(right)) >+ { >+ } >+ >+ virtual ~AssignmentExpression() >+ { >+ } >+ >+private: >+ std::unique_ptr<Expression> m_left; >+ std::unique_ptr<Expression> m_right; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseFunctionAttribute.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseFunctionAttribute.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ac3eb999605d2e037ca5760378b6e95596d1d99b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseFunctionAttribute.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 BaseFunctionAttribute : public Node { >+public: >+ BaseFunctionAttribute(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~BaseFunctionAttribute() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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/WHLSLASTBooleanLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBooleanLiteral.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0daeeb1651cc501d52861e5ed69cb9597fb3e713 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBooleanLiteral.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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class BooleanLiteral : public Expression { >+public: >+ BooleanLiteral(Lexer::Token&& origin, bool value) >+ : Expression(WTFMove(origin)) >+ , m_value(value) >+ { >+ } >+ >+ virtual ~BooleanLiteral() >+ { >+ } >+ >+ bool value() const { return m_value; } >+ >+private: >+ bool m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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/WHLSLASTCallExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTCallExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..5b24aaf23fde4d3bc8a3698f1535eb8e16dc7f3e >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTCallExpression.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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class CallExpression : public Expression { >+public: >+ CallExpression(Lexer::Token&& origin, String&& name, Vector<std::unique_ptr<Expression>>&& arguments) >+ : Expression(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_arguments(WTFMove(arguments)) >+ { >+ } >+ >+ virtual ~CallExpression() >+ { >+ } >+ >+private: >+ String m_name; >+ Vector<std::unique_ptr<Expression>> m_arguments; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTCommaExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTCommaExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..9b487a5ce112547d76d97848dbd6cab5f2ce038e >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTCommaExpression.h >@@ -0,0 +1,62 @@ >+/* >+ * 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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class CommaExpression : public Expression { >+public: >+ CommaExpression(Lexer::Token&& origin, Vector<std::unique_ptr<Expression>>&& list) >+ : Expression(WTFMove(origin)) >+ , m_list(WTFMove(list)) >+ { >+ } >+ >+ virtual ~CommaExpression() >+ { >+ } >+ >+private: >+ Vector<std::unique_ptr<Expression>> m_list; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstantExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstantExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0bfd13f64b6cbcde603866d972943040072a052a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstantExpression.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 ConstantExpression : public Node { >+public: >+ static ConstantExpression createWithLiteral(Lexer::Token&& token) >+ { >+ ConstantExpression result; >+ result.first = WTFMove(token); >+ result.type = Type::Literal; >+ return result; >+ } >+ >+ static ConstantExpression createWithIdentifier(Lexer::Token&& token) >+ { >+ ConstantExpression result; >+ result.first = WTFMove(token); >+ result.type = Type::Identifier; >+ return result; >+ } >+ >+ static ConstantExpression createWithIdentifierDotIdentifier(Lexer::Token&& token1, Lexer::Token&& token2) >+ { >+ ConstantExpression result; >+ result.first = WTFMove(token1); >+ result.second = WTFMove(token2); >+ result.type = Type::Identifier; >+ return result; >+ } >+ >+ virtual ~ConstantExpression() >+ { >+ } >+ >+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/WHLSLASTDereferenceExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDereferenceExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..09d95e0c00f475d5215f4f523b4866d7771a6205 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDereferenceExpression.h >@@ -0,0 +1,61 @@ >+/* >+ * 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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class DereferenceExpression : public Expression { >+public: >+ DereferenceExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& pointer) >+ : Expression(WTFMove(origin)) >+ , m_pointer(WTFMove(pointer)) >+ { >+ } >+ >+ virtual ~DereferenceExpression() >+ { >+ } >+ >+private: >+ std::unique_ptr<Expression> m_pointer; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDotExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDotExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7de079661fedb065d1ef1bdd58ba73f5383aefd8 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDotExpression.h >@@ -0,0 +1,61 @@ >+/* >+ * 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 "WHLSLASTPropertyAccessExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class DotExpression : public PropertyAccessExpression { >+public: >+ DotExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& base, String&& fieldName) >+ : PropertyAccessExpression(WTFMove(origin), WTFMove(base)) >+ , m_fieldName(WTFMove(fieldName)) >+ { >+ } >+ >+ virtual ~DotExpression() >+ { >+ } >+ >+private: >+ String m_fieldName; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumerationDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumerationDefinition.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0d2e99f13f94c6811f32fe93385654205345adaf >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumerationDefinition.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 "WHLSLASTEnumerationMember.h" >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class EnumerationDefinition : public Type { >+public: >+ EnumerationDefinition(Lexer::Token&& origin, String&& name, std::unique_ptr<Type>&& type, Vector<EnumerationMember> members) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_type(WTFMove(type)) >+ , m_members(WTFMove(members)) >+ { >+ } >+ >+ virtual ~EnumerationDefinition() >+ { >+ } >+ >+ EnumerationDefinition(EnumerationDefinition&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ std::unique_ptr<Type> m_type; >+ Vector<EnumerationMember> m_members; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumerationMember.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumerationMember.h >new file mode 100644 >index 0000000000000000000000000000000000000000..74b4703248e0a75f5979f78ee0a307f19478a2ae >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumerationMember.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 "WHLSLASTConstantExpression.h" >+#include "WHLSLASTNode.h" >+#include "WHLSLLexer.h" >+#include <wtf/Optional.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class EnumerationMember : public Node { >+public: >+ EnumerationMember(Lexer::Token&& origin, String&& name, std::optional<ConstantExpression>&& value = std::nullopt) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_value(WTFMove(value)) >+ { >+ } >+ >+ virtual ~EnumerationMember() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ std::optional<ConstantExpression> m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..9c2e822b9f7c289da39033bcedb1ab782e3f4c72 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTExpression.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 "WHLSLASTValue.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Expression : public Value { >+public: >+ Expression(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~Expression() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFloatLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFloatLiteral.h >new file mode 100644 >index 0000000000000000000000000000000000000000..365dde5c711dcd6e61300f0f2a31f4a7dd18b755 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFloatLiteral.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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class FloatLiteral : public Expression { >+public: >+ FloatLiteral(Lexer::Token&& origin, float value) >+ : Expression(WTFMove(origin)) >+ , m_value(value) >+ { >+ } >+ >+ virtual ~FloatLiteral() >+ { >+ } >+ >+ float value() const { return m_value; } >+ >+private: >+ float m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionAttribute.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionAttribute.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ec2dff4d606d47b122acad2967de9ac88fc97acd >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionAttribute.h >@@ -0,0 +1,49 @@ >+/* >+ * 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 "WHLSLASTNumThreadsFunctionAttribute.h" >+#include <wtf/Variant.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+typedef Variant<NumThreadsFunctionAttribute> FunctionAttribute; >+typedef Vector<FunctionAttribute> AttributeBlock; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionDeclaration.h >new file mode 100644 >index 0000000000000000000000000000000000000000..160cec5af6a9cc94c699a454cfd6b068ac9cbdc8 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionDeclaration.h >@@ -0,0 +1,93 @@ >+/* >+ * 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 "WHLSLASTFunctionAttribute.h" >+#include "WHLSLASTNode.h" >+#include "WHLSLASTParameter.h" >+#include "WHLSLASTSemantic.h" >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class FunctionDeclaration : public Node { >+public: >+ enum class EntryPointType { >+ Vertex, >+ Fragment, >+ Compute >+ }; >+ >+ FunctionDeclaration(Lexer::Token&& origin, AttributeBlock&& attributeBlock, std::optional<EntryPointType> entryPointType, std::unique_ptr<AST::Type>&& type, String&& name, Parameters&& parameters, std::optional<AST::Semantic>&& semantic) >+ : m_origin(WTFMove(origin)) >+ , m_attributeBlock(WTFMove(attributeBlock)) >+ , m_entryPointType(entryPointType) >+ , m_type(WTFMove(type)) >+ , m_name(WTFMove(name)) >+ , m_parameters(WTFMove(parameters)) >+ , m_semantic(WTFMove(semantic)) >+ { >+ } >+ >+ virtual ~FunctionDeclaration() >+ { >+ } >+ >+ FunctionDeclaration(FunctionDeclaration&&) = default; >+ >+ Lexer::Token&& takeOrigin() { return WTFMove(m_origin); } >+ AttributeBlock&& takeAttributeBlock() { return WTFMove(m_attributeBlock); } >+ std::optional<EntryPointType>&& takeEntryPointType() { return WTFMove(m_entryPointType); } >+ std::unique_ptr<AST::Type>&& takeType() { return WTFMove(m_type); } >+ String&& takeName() { return WTFMove(m_name); } >+ Parameters&& takeParameters() { return WTFMove(m_parameters); } >+ std::optional<AST::Semantic>&& takeSemantic() { return WTFMove(m_semantic); } >+ >+private: >+ Lexer::Token m_origin; >+ AttributeBlock m_attributeBlock; >+ std::optional<EntryPointType> m_entryPointType; >+ std::unique_ptr<AST::Type> m_type; >+ String m_name; >+ Parameters m_parameters; >+ std::optional<AST::Semantic> m_semantic; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionDefinition.h >new file mode 100644 >index 0000000000000000000000000000000000000000..81d058abb2a51542b651cc0764ba62c6ba2e1f42 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionDefinition.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 "WHLSLASTFunctionDeclaration.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class FunctionDefinition : public FunctionDeclaration { >+public: >+ virtual ~FunctionDefinition() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIndexExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIndexExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..5d29b3a656ced383e988b711aa112019f2a5bfa4 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIndexExpression.h >@@ -0,0 +1,61 @@ >+/* >+ * 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 "WHLSLASTPropertyAccessExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class IndexExpression : public PropertyAccessExpression { >+public: >+ IndexExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& base, std::unique_ptr<Expression>&& index) >+ : PropertyAccessExpression(WTFMove(origin), WTFMove(base)) >+ , m_index(WTFMove(index)) >+ { >+ } >+ >+ virtual ~IndexExpression() >+ { >+ } >+ >+private: >+ std::unique_ptr<Expression> m_index; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIntegerLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIntegerLiteral.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c22cba578ffe0175d37bb251128633bc926a0e89 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIntegerLiteral.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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class IntegerLiteral : public Expression { >+public: >+ IntegerLiteral(Lexer::Token&& origin, int value) >+ : Expression(WTFMove(origin)) >+ , m_value(value) >+ { >+ } >+ >+ virtual ~IntegerLiteral() >+ { >+ } >+ >+ int value() const { return m_value; } >+ >+private: >+ int m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTLogicalExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTLogicalExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c8eca560dd678b64c7495c88f95b8fc46a6bbfc3 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTLogicalExpression.h >@@ -0,0 +1,72 @@ >+/* >+ * 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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class LogicalExpression : public Expression { >+public: >+ enum class Type { >+ And, >+ Or >+ }; >+ >+ LogicalExpression(Lexer::Token&& origin, Type type, std::unique_ptr<Expression>&& left, std::unique_ptr<Expression>&& right) >+ : Expression(WTFMove(origin)) >+ , m_type(type) >+ , m_left(WTFMove(left)) >+ , m_right(WTFMove(right)) >+ { >+ } >+ >+ virtual ~LogicalExpression() >+ { >+ } >+ >+ Type type() const { return m_type; } >+ >+private: >+ Type m_type; >+ std::unique_ptr<Expression> m_left; >+ std::unique_ptr<Expression> m_right; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTLogicalNotExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTLogicalNotExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..bc0e2ae7c3c4925ad3811d42ae0f7e82421796c0 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTLogicalNotExpression.h >@@ -0,0 +1,61 @@ >+/* >+ * 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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class LogicalNotExpression : public Expression { >+public: >+ LogicalNotExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& operand) >+ : Expression(WTFMove(origin)) >+ , m_operand(WTFMove(operand)) >+ { >+ } >+ >+ virtual ~LogicalNotExpression() >+ { >+ } >+ >+private: >+ std::unique_ptr<Expression> m_operand; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTMakeArrayReferenceExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTMakeArrayReferenceExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c7af080597eb0a2f76383eb477f26369cf2efaf3 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTMakeArrayReferenceExpression.h >@@ -0,0 +1,61 @@ >+/* >+ * 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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class MakeArrayReferenceExpression : public Expression { >+public: >+ MakeArrayReferenceExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& lValue) >+ : Expression(WTFMove(origin)) >+ , m_lValue(WTFMove(lValue)) >+ { >+ } >+ >+ virtual ~MakeArrayReferenceExpression() >+ { >+ } >+ >+private: >+ std::unique_ptr<Expression> m_lValue; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTMakePointerExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTMakePointerExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d9fc6520c0db14d96b25a582b94cc185da96aee0 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTMakePointerExpression.h >@@ -0,0 +1,61 @@ >+/* >+ * 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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class MakePointerExpression : public Expression { >+public: >+ MakePointerExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& lValue) >+ : Expression(WTFMove(origin)) >+ , m_lValue(WTFMove(lValue)) >+ { >+ } >+ >+ virtual ~MakePointerExpression() >+ { >+ } >+ >+private: >+ std::unique_ptr<Expression> m_lValue; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFunctionDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFunctionDeclaration.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8ac3617f132e75d94748c0be98f2c321ec93cfed >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFunctionDeclaration.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 "WHLSLASTFunctionDeclaration.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class NativeFunctionDeclaration : public FunctionDeclaration { >+public: >+ NativeFunctionDeclaration(Lexer::Token&& origin, AttributeBlock&& attributeBlock, std::optional<EntryPointType> entryPointType, std::unique_ptr<AST::Type>&& type, String&& name, Parameters&& parameters, std::optional<AST::Semantic>&& semantic, bool restricted) >+ : FunctionDeclaration(WTFMove(origin), WTFMove(attributeBlock), WTFMove(entryPointType), WTFMove(type), WTFMove(name), WTFMove(parameters), WTFMove(semantic)) >+ , m_restricted(restricted) >+ { >+ } >+ >+ virtual ~NativeFunctionDeclaration() >+ { >+ } >+ >+ NativeFunctionDeclaration(NativeFunctionDeclaration&&) = default; >+ >+ bool restricted() const { return m_restricted; } >+ >+private: >+ bool m_restricted; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDeclaration.h >new file mode 100644 >index 0000000000000000000000000000000000000000..08b133634a4ca912bf431acb0352086e4e2fe8d7 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDeclaration.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 NativeTypeDeclaration : public Type { >+public: >+ NativeTypeDeclaration(Lexer::Token&& origin, String&& name, TypeArguments&& typeArguments) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_typeArguments(WTFMove(typeArguments)) >+ { >+ } >+ >+ virtual ~NativeTypeDeclaration() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ TypeArguments m_typeArguments; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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/WHLSLASTNullLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNullLiteral.h >new file mode 100644 >index 0000000000000000000000000000000000000000..b933816274f589d42b567002f8155d16715f98db >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNullLiteral.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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class NullLiteral : public Expression { >+public: >+ NullLiteral(Lexer::Token&& origin) >+ : Expression(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~NullLiteral() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNumThreadsFunctionAttribute.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNumThreadsFunctionAttribute.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d83248722641b72042691becc97f9ae5fb09abcb >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNumThreadsFunctionAttribute.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 "WHLSLASTBaseFunctionAttribute.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class NumThreadsFunctionAttribute : public BaseFunctionAttribute { >+public: >+ NumThreadsFunctionAttribute(Lexer::Token&& origin, unsigned width, unsigned height, unsigned depth) >+ : BaseFunctionAttribute(WTFMove(origin)) >+ , m_width(width) >+ , m_height(height) >+ , m_depth(depth) >+ { >+ } >+ >+ virtual ~NumThreadsFunctionAttribute() >+ { >+ } >+ >+ unsigned width() const { return m_width; } >+ unsigned height() const { return m_height; } >+ unsigned depth() const { return m_depth; } >+ >+private: >+ unsigned m_width; >+ unsigned m_height; >+ unsigned m_depth; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTParameter.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTParameter.h >new file mode 100644 >index 0000000000000000000000000000000000000000..afca064110600b41efe7ea4f841279d06c5059d7 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTParameter.h >@@ -0,0 +1,77 @@ >+/* >+ * 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 "WHLSLASTQualifier.h" >+#include "WHLSLASTSemantic.h" >+#include "WHLSLASTType.h" >+#include "WHLSLASTValue.h" >+#include "WHLSLLexer.h" >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Parameter : public Value { >+public: >+ Parameter(Lexer::Token&& origin, Qualifiers&& qualifiers, std::unique_ptr<AST::Type>&& type, std::optional<String>&& name, std::optional<AST::Semantic>&& semantic) >+ : m_origin(WTFMove(origin)) >+ , m_qualifiers(WTFMove(qualifiers)) >+ , m_type(WTFMove(type)) >+ , m_name(WTFMove(name)) >+ , m_semantic(WTFMove(semantic)) >+ { >+ } >+ >+ virtual ~Parameter() >+ { >+ } >+ >+ Parameter(Parameter&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+ Qualifiers m_qualifiers; >+ std::unique_ptr<AST::Type> m_type; >+ std::optional<String> m_name; >+ std::optional<AST::Semantic> m_semantic; >+}; >+ >+typedef Vector<Parameter> Parameters; >+ >+} >+ >+} >+ >+} >+ >+#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/WHLSLASTPropertyAccessExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPropertyAccessExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..be37fc25f5e3dc0d7661071c5881847acb06f335 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPropertyAccessExpression.h >@@ -0,0 +1,61 @@ >+/* >+ * 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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class PropertyAccessExpression : public Expression { >+public: >+ PropertyAccessExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& base) >+ : Expression(WTFMove(origin)) >+ , m_base(WTFMove(base)) >+ { >+ } >+ >+ virtual ~PropertyAccessExpression() >+ { >+ } >+ >+private: >+ std::unique_ptr<Expression> m_base; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..57fda540729a72cb228570554b050a84fef6c508 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTQualifier.h >@@ -0,0 +1,57 @@ >+/* >+ * 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/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+enum class Qualifier { >+ Nointerpolation, >+ Noperspective, >+ Uniform, >+ Centroid, >+ Sample >+}; >+ >+typedef Vector<Qualifier> Qualifiers; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReadModifyWriteExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReadModifyWriteExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7d1747d16feaa6619d2f6d573a53291ebc8da62b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReadModifyWriteExpression.h >@@ -0,0 +1,98 @@ >+/* >+ * 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 "WHLSLASTAnonymousVariableDeclaration.h" >+#include "WHLSLASTExpression.h" >+#include "WHLSLASTVariableReference.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+/* >+ * 1. Evaluate m_lValue >+ * 2. Assign the result to m_oldValue >+ * 3. Evaluate m_newValueExpression >+ * 4. Assign the result to m_newValue >+ * 5. Assign the result to m_lValue >+ * 6. Evaluate m_resultExpression >+ * 7. Return the result >+ */ >+class ReadModifyWriteExpression : public Expression { >+public: >+ ReadModifyWriteExpression(Lexer::Token&& origin, std::unique_ptr<Expression> lValue) >+ : Expression(Lexer::Token(origin)) >+ , m_lValue(WTFMove(lValue)) >+ , m_oldValue(Lexer::Token(origin)) >+ , m_newValue(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~ReadModifyWriteExpression() >+ { >+ } >+ >+ void setNewValueExpression(std::unique_ptr<Expression>&& newValueExpression) >+ { >+ m_newValueExpression = WTFMove(newValueExpression); >+ } >+ >+ void setResultExpression(std::unique_ptr<Expression>&& resultExpression) >+ { >+ m_resultExpression = WTFMove(resultExpression); >+ } >+ >+ std::unique_ptr<VariableReference> oldVariableReference() >+ { >+ return std::make_unique<VariableReference>(VariableReference::wrap(m_oldValue)); >+ } >+ >+ std::unique_ptr<VariableReference> newVariableReference() >+ { >+ return std::make_unique<VariableReference>(VariableReference::wrap(m_newValue)); >+ } >+ >+private: >+ std::unique_ptr<Expression> m_lValue; >+ AnonymousVariableDeclaration m_oldValue; >+ AnonymousVariableDeclaration m_newValue; >+ std::unique_ptr<Expression> m_newValueExpression; >+ std::unique_ptr<Expression> m_resultExpression; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.h >new file mode 100644 >index 0000000000000000000000000000000000000000..37ddd8d259b71a629c11ce33fee615c05c0a1213 >--- /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 { >+ UnorderedAccessView, >+ Texture, >+ Buffer, >+ Sampler >+ }; >+ >+ 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.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.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/WHLSLASTStructureDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructureDefinition.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d005cee6700240c5e994b8fb6caa60f0da4098cb >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructureDefinition.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 "WHLSLASTStructureElement.h" >+#include "WHLSLASTType.h" >+#include "WHLSLLexer.h" >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class StructureDefinition : public Type { >+public: >+ StructureDefinition(Lexer::Token&& origin, String&& name, StructureElements&& structureElements) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_structureElements(WTFMove(structureElements)) >+ { >+ } >+ >+ virtual ~StructureDefinition() >+ { >+ } >+ >+ StructureDefinition(StructureDefinition&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ StructureElements m_structureElements; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructureElement.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructureElement.h >new file mode 100644 >index 0000000000000000000000000000000000000000..925081883076eb62bbc9827b26e977c6d5bb3280 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructureElement.h >@@ -0,0 +1,75 @@ >+/* >+ * 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 StructureElement : public Node { >+public: >+ StructureElement(Lexer::Token&& origin, Qualifiers&& 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 ~StructureElement() >+ { >+ } >+ >+ StructureElement(StructureElement&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+ Qualifiers m_qualifiers; >+ std::unique_ptr<Type> m_type; >+ String m_name; >+ std::optional<Semantic> m_semantic; >+}; >+ >+typedef Vector<StructureElement> StructureElements; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTernaryExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTernaryExpression.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0fff6041b047202a30a8aba7057ce0d06ce9aa5f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTernaryExpression.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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class TernaryExpression : public Expression { >+public: >+ TernaryExpression(Lexer::Token&& origin, std::unique_ptr<Expression>&& predicate, std::unique_ptr<Expression>&& bodyExpression, std::unique_ptr<Expression>&& elseExpression) >+ : Expression(WTFMove(origin)) >+ , m_predicate(WTFMove(predicate)) >+ , m_bodyExpression(WTFMove(bodyExpression)) >+ , m_elseExpression(WTFMove(elseExpression)) >+ { >+ } >+ >+ virtual ~TernaryExpression() >+ { >+ } >+ >+private: >+ std::unique_ptr<Expression> m_predicate; >+ std::unique_ptr<Expression> m_bodyExpression; >+ std::unique_ptr<Expression> m_elseExpression; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..9204a03b952fd0387ffe5ce73b31d26149a6b291 >--- /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 "WHLSLASTConstantExpression.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<ConstantExpression, Lexer::Token> TypeArgument; >+typedef Vector<TypeArgument> TypeArguments; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDefinition.h >new file mode 100644 >index 0000000000000000000000000000000000000000..1a019a13f0b896426570f6d761f883a4ce7a9d08 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDefinition.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 TypeDefinition : public Type { >+public: >+ TypeDefinition(Lexer::Token&& origin, String&& name, std::unique_ptr<AST::Type>&& type) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_type(WTFMove(type)) >+ { >+ } >+ >+ TypeDefinition(TypeDefinition&&) = default; >+ >+ virtual ~TypeDefinition() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ std::unique_ptr<AST::Type> m_type; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeReference.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeReference.h >new file mode 100644 >index 0000000000000000000000000000000000000000..516ab404307e3289664cfd8b03b14181f3b792dc >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeReference.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 TypeReference : public Type { >+public: >+ TypeReference(Lexer::Token&& origin, String&& name, TypeArguments&& typeArguments) >+ : m_origin(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ , m_typeArguments(WTFMove(typeArguments)) >+ { >+ } >+ >+ virtual ~TypeReference() >+ { >+ } >+ >+private: >+ Lexer::Token m_origin; >+ String m_name; >+ TypeArguments m_typeArguments; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTUnsignedIntegerLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTUnsignedIntegerLiteral.h >new file mode 100644 >index 0000000000000000000000000000000000000000..be6f654aecfba3957a0fbfe810e5f7991f9277e6 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTUnsignedIntegerLiteral.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 "WHLSLASTExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class UnsignedIntegerLiteral : public Expression { >+public: >+ UnsignedIntegerLiteral(Lexer::Token&& origin, unsigned value) >+ : Expression(WTFMove(origin)) >+ , m_value(value) >+ { >+ } >+ >+ virtual ~UnsignedIntegerLiteral() >+ { >+ } >+ >+ unsigned value() const { return m_value; } >+ >+private: >+ unsigned m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTValue.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTValue.h >new file mode 100644 >index 0000000000000000000000000000000000000000..321ec0dcdf416ccb752ddc611e80e9002d0df374 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTValue.h >@@ -0,0 +1,57 @@ >+/* >+ * 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 Value : public Node { >+public: >+ Value() >+ { >+ } >+ >+ virtual ~Value() >+ { >+ } >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDeclaration.h >new file mode 100644 >index 0000000000000000000000000000000000000000..914fb124e4e901d7c975d26e1d6d60a171da38c0 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDeclaration.h >@@ -0,0 +1,62 @@ >+/* >+ * 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 "WHLSLASTValue.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class VariableDeclaration : public Value { >+public: >+ VariableDeclaration(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~VariableDeclaration() >+ { >+ } >+ >+ Lexer::Token origin() const { return m_origin; } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableReference.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableReference.h >new file mode 100644 >index 0000000000000000000000000000000000000000..efc98f16913390cedcf1ed3cc25a3ff4d7fc7a2a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableReference.h >@@ -0,0 +1,84 @@ >+/* >+ * 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 "WHLSLASTAnonymousVariableDeclaration.h" >+#include "WHLSLASTExpression.h" >+#include "WHLSLASTVariableDeclaration.h" >+#include "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class VariableReference : public Expression { >+public: >+ VariableReference(Lexer::Token&& origin, String&& name) >+ : Expression(WTFMove(origin)) >+ , m_name(WTFMove(name)) >+ { >+ } >+ >+ virtual ~VariableReference() >+ { >+ } >+ >+ static VariableReference wrap(VariableDeclaration& variableDeclaration) >+ { >+ VariableReference result(Lexer::Token(variableDeclaration.origin())); >+ result.m_variable = { &variableDeclaration }; >+ return result; >+ } >+ >+ static VariableReference wrap(AnonymousVariableDeclaration& anonymousVariableDeclaration) >+ { >+ VariableReference result(Lexer::Token(anonymousVariableDeclaration.origin())); >+ result.m_variable = { &anonymousVariableDeclaration }; >+ return result; >+ } >+ >+private: >+ VariableReference(Lexer::Token&& origin) >+ : Expression(WTFMove(origin)) >+ { >+ } >+ >+ String m_name; >+ std::optional<Variant<VariableDeclaration*, AnonymousVariableDeclaration*>> m_variable; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..069bb4b70005aba8f60f29eb955eeb645b76cf00 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp >@@ -0,0 +1,588 @@ >+/* >+ * 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::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..e6f544a3953f1b796553faf0730cd48864242891 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h >@@ -0,0 +1,254 @@ >+/* >+ * 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, >+ 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> 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..876afe46796ac7ff6b804016a40541213074ed75 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >@@ -0,0 +1,1729 @@ >+/* >+ * 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 "WHLSLASTArrayReferenceType.h" >+#include "WHLSLASTArrayType.h" >+#include "WHLSLASTAssignmentExpression.h" >+#include "WHLSLASTBooleanLiteral.h" >+#include "WHLSLASTCallExpression.h" >+#include "WHLSLASTCommaExpression.h" >+#include "WHLSLASTDereferenceExpression.h" >+#include "WHLSLASTDotExpression.h" >+#include "WHLSLASTFloatLiteral.h" >+#include "WHLSLASTIndexExpression.h" >+#include "WHLSLASTIntegerLiteral.h" >+#include "WHLSLASTLogicalExpression.h" >+#include "WHLSLASTLogicalNotExpression.h" >+#include "WHLSLASTMakeArrayReferenceExpression.h" >+#include "WHLSLASTMakePointerExpression.h" >+#include "WHLSLASTNullLiteral.h" >+#include "WHLSLASTPointerType.h" >+#include "WHLSLASTQualifier.h" >+#include "WHLSLASTReadModifyWriteExpression.h" >+#include "WHLSLASTTernaryExpression.h" >+#include "WHLSLASTTypeReference.h" >+#include "WHLSLASTUnsignedIntegerLiteral.h" >+#include "WHLSLASTVariableReference.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 typeDefinition = backtrackingScope<std::optional<AST::TypeDefinition>>([&]() -> std::optional<AST::TypeDefinition> { >+ return parseTypeDefinition(); >+ }); >+ if (typeDefinition) { >+ result.append(WTFMove(*typeDefinition)); >+ continue; >+ } >+ >+ auto structureDefinition = backtrackingScope<std::optional<AST::StructureDefinition>>([&]() -> std::optional<AST::StructureDefinition> { >+ return parseStructureDefinition(); >+ }); >+ if (structureDefinition) { >+ result.append(WTFMove(*structureDefinition)); >+ continue; >+ } >+ >+ auto enumerationDefinition = backtrackingScope<std::optional<AST::EnumerationDefinition>>([&]() -> std::optional<AST::EnumerationDefinition> { >+ return parseEnumerationDefinition(); >+ }); >+ if (enumerationDefinition) { >+ result.append(WTFMove(*enumerationDefinition)); >+ continue; >+ } >+ >+ auto nativeFunctionDeclaration = backtrackingScope<std::optional<AST::NativeFunctionDeclaration>>([&]() -> std::optional<AST::NativeFunctionDeclaration> { >+ return parseNativeFunctionDeclaration(); >+ }); >+ if (nativeFunctionDeclaration) { >+ result.append(WTFMove(*nativeFunctionDeclaration)); >+ continue; >+ } >+ >+ auto nativeTypeDeclaration = backtrackingScope<std::optional<AST::NativeTypeDeclaration>>([&]() -> std::optional<AST::NativeTypeDeclaration> { >+ return parseNativeTypeDeclaration(); >+ }); >+ if (nativeTypeDeclaration) { >+ result.append(WTFMove(*nativeTypeDeclaration)); >+ 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::peekTypes(Vector<Lexer::Token::Type> types) >+{ >+ if (auto token = m_lexer.consumeToken()) { >+ m_lexer.unconsumeToken(Lexer::Token(*token)); >+ if (std::find(types.begin(), types.end(), token->type) != types.end()) >+ 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::ConstantExpression> Parser::parseConstantExpression() >+{ >+ auto literal = backtrackingScope<std::optional<Lexer::Token>>([&]() -> std::optional<Lexer::Token> { >+ return parseLiteral(); >+ }); >+ if (literal) >+ return AST::ConstantExpression::createWithLiteral(WTFMove(*literal)); >+ if (auto identifier1 = consumeType(Lexer::Token::Type::Identifier)) { >+ auto constantExpression = backtrackingScope<std::optional<AST::ConstantExpression>>([&]() -> std::optional<AST::ConstantExpression> { >+ if (consumeType(Lexer::Token::Type::FullStop)) { >+ if (auto identifier2 = consumeType(Lexer::Token::Type::Identifier)) >+ return AST::ConstantExpression::createWithIdentifierDotIdentifier(WTFMove(*identifier1), WTFMove(*identifier2)); >+ } >+ return std::nullopt; >+ }); >+ if (constantExpression) >+ return *constantExpression; >+ return AST::ConstantExpression::createWithIdentifier(WTFMove(*identifier1)); >+ } >+ return std::nullopt; >+} >+ >+std::optional<AST::TypeArgument> Parser::parseTypeArgument() >+{ >+ auto constantExpression = backtrackingScope<std::optional<AST::ConstantExpression>>([&]() -> std::optional<AST::ConstantExpression> { >+ return parseConstantExpression(); >+ }); >+ if (constantExpression) >+ return {*constantExpression}; >+ 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'; >+ 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}; >+ } >+ 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 }; >+ } >+ 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 }; >+ } >+ 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::TypeReference>(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::TypeReference>(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::TypeDefinition> Parser::parseTypeDefinition() >+{ >+ 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::TypeDefinition(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::UnorderedAccessView; >+ break; >+ case 't': >+ mode = AST::ResourceSemantic::Mode::Texture; >+ break; >+ case 'b': >+ mode = AST::ResourceSemantic::Mode::Buffer; >+ break; >+ case 's': >+ mode = AST::ResourceSemantic::Mode::Sampler; >+ 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; >+} >+ >+AST::Qualifiers Parser::parseQualifiers() >+{ >+ AST::Qualifiers qualifiers; >+ while (true) { >+ if (auto next = peekType(Lexer::Token::Type::Qualifier)) { >+ consumeType(Lexer::Token::Type::Qualifier); >+ 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; >+ } >+ return qualifiers; >+} >+ >+std::optional<AST::StructureElement> Parser::parseStructureElement() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return std::nullopt; >+ >+ AST::Qualifiers qualifiers = parseQualifiers(); >+ >+ 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::StructureElement(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), name->stringView.toString(), WTFMove(semantic)); >+} >+ >+std::optional<AST::StructureDefinition> Parser::parseStructureDefinition() >+{ >+ 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; >+ >+ AST::StructureElements structureElements; >+ while (true) { >+ auto structureElement = backtrackingScope<std::optional<AST::StructureElement>>([&]() -> std::optional<AST::StructureElement> { >+ return parseStructureElement(); >+ }); >+ if (structureElement) >+ structureElements.append(WTFMove(*structureElement)); >+ else >+ break; >+ } >+ >+ if (!consumeType(Lexer::Token::Type::RightCurlyBracket)) >+ return std::nullopt; >+ >+ return AST::StructureDefinition(WTFMove(*origin), name->stringView.toString(), WTFMove(structureElements)); >+} >+ >+std::optional<AST::EnumerationDefinition> Parser::parseEnumerationDefinition() >+{ >+ 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 firstEnumerationMember = parseEnumerationMember(); >+ if (!firstEnumerationMember) >+ return std::nullopt; >+ >+ Vector<AST::EnumerationMember> members; >+ members.append(WTFMove(*firstEnumerationMember)); >+ >+ while (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto member = parseEnumerationMember(); >+ if (!member) >+ return std::nullopt; >+ members.append(WTFMove(*member)); >+ } >+ >+ if (!consumeType(Lexer::Token::Type::RightCurlyBracket)) >+ return std::nullopt; >+ >+ return AST::EnumerationDefinition(WTFMove(*origin), name->stringView.toString(), WTFMove(type), WTFMove(members)); >+} >+ >+std::optional<AST::EnumerationMember> Parser::parseEnumerationMember() >+{ >+ auto identifier = consumeType(Lexer::Token::Type::Identifier); >+ if (!identifier) >+ return std::nullopt; >+ auto name = identifier->stringView.toString(); >+ >+ if (peekType(Lexer::Token::Type::EqualsSign)) { >+ consumeType(Lexer::Token::Type::EqualsSign); >+ auto constantExpression = parseConstantExpression(); >+ if (!constantExpression) >+ return std::nullopt; >+ return AST::EnumerationMember(Lexer::Token(*identifier), WTFMove(name), WTFMove(*constantExpression)); >+ } >+ return AST::EnumerationMember(Lexer::Token(*identifier), WTFMove(name)); >+} >+ >+std::optional<AST::NativeTypeDeclaration> Parser::parseNativeTypeDeclaration() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Native); >+ if (!origin) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::Typedef)) >+ return std::nullopt; >+ >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return std::nullopt; >+ >+ auto typeArguments = parseTypeArguments(); >+ if (!typeArguments) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ >+ return AST::NativeTypeDeclaration(WTFMove(*origin), name->stringView.toString(), WTFMove(*typeArguments)); >+} >+ >+std::optional<AST::NumThreadsFunctionAttribute> Parser::parseNumThreadsFunctionAttribute() >+{ >+ auto origin = consumeType(Lexer::Token::Type::NumThreads); >+ if (!origin) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ auto widthLiteral = consumeType(Lexer::Token::Type::IntLiteral); >+ if (!widthLiteral) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::Comma)) >+ return std::nullopt; >+ >+ auto heightLiteral = consumeType(Lexer::Token::Type::IntLiteral); >+ if (!heightLiteral) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::Comma)) >+ return std::nullopt; >+ >+ auto depthLiteral = consumeType(Lexer::Token::Type::IntLiteral); >+ if (!depthLiteral) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ auto widthValue = intLiteralToInt(widthLiteral->stringView); >+ if (!widthValue) >+ return std::nullopt; >+ auto width = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { >+ return x; >+ }), *widthValue); >+ >+ auto heightValue = intLiteralToInt(heightLiteral->stringView); >+ if (!heightValue) >+ return std::nullopt; >+ auto height = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { >+ return x; >+ }), *heightValue); >+ >+ auto depthValue = intLiteralToInt(depthLiteral->stringView); >+ if (!depthValue) >+ return std::nullopt; >+ auto depth = WTF::visit(WTF::makeVisitor([](auto x) -> unsigned { >+ return x; >+ }), *depthValue); >+ >+ return AST::NumThreadsFunctionAttribute(WTFMove(*origin), width, height, depth); >+} >+ >+std::optional<AST::AttributeBlock> Parser::parseAttributeBlock() >+{ >+ if (!consumeType(Lexer::Token::Type::LeftSquareBracket)) >+ return std::nullopt; >+ >+ AST::AttributeBlock result; >+ >+ while (true) { >+ auto numThreadsFunctionAttribute = backtrackingScope<std::optional<AST::NumThreadsFunctionAttribute>>([&]() -> std::optional<AST::NumThreadsFunctionAttribute> { >+ return parseNumThreadsFunctionAttribute(); >+ }); >+ if (numThreadsFunctionAttribute) { >+ result.append(WTFMove(*numThreadsFunctionAttribute)); >+ continue; >+ } >+ >+ break; >+ } >+ >+ if (!consumeType(Lexer::Token::Type::RightSquareBracket)) >+ return std::nullopt; >+ >+ return result; >+} >+ >+std::optional<AST::Parameter> Parser::parseParameter() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return std::nullopt; >+ >+ AST::Qualifiers qualifiers = parseQualifiers(); >+ >+ auto type = parseType(); >+ if (!type) >+ return std::nullopt; >+ >+ std::optional<String> name; >+ if (peekType(Lexer::Token::Type::Identifier)) { >+ auto token = consumeType(Lexer::Token::Type::Identifier); >+ name = token->stringView.toString(); >+ } >+ >+ std::optional<AST::Semantic> semantic; >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto parsedSemantic = parseSemantic(); >+ if (!parsedSemantic) >+ return std::nullopt; >+ } >+ >+ return AST::Parameter(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), WTFMove(name), WTFMove(semantic)); >+} >+ >+std::optional<AST::Parameters> Parser::parseParameters() >+{ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ if (peekType(Lexer::Token::Type::RightParenthesis)) { >+ consumeType(Lexer::Token::Type::RightParenthesis); >+ return {{ }}; >+ } >+ >+ AST::Parameters parameters; >+ auto firstParameter = parseParameter(); >+ if (!firstParameter) >+ return std::nullopt; >+ parameters.append(WTFMove(*firstParameter)); >+ >+ while (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto parameter = parseParameter(); >+ if (!parameter) >+ return std::nullopt; >+ parameters.append(WTFMove(*parameter)); >+ } >+ >+ return parameters; >+} >+ >+std::optional<AST::FunctionDeclaration> Parser::parseEntryPointFunctionDeclaration() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return std::nullopt; >+ >+ AST::AttributeBlock attributeBlock; >+ AST::FunctionDeclaration::EntryPointType entryPointType; >+ >+ auto parsedAttributeBlock = backtrackingScope<std::optional<AST::AttributeBlock>>([&]() -> std::optional<AST::AttributeBlock> { >+ return parseAttributeBlock(); >+ }); >+ if (parsedAttributeBlock) { >+ if (!consumeType(Lexer::Token::Type::Compute)) >+ return std::nullopt; >+ attributeBlock = *parsedAttributeBlock; >+ entryPointType = AST::FunctionDeclaration::EntryPointType::Compute; >+ } else { >+ auto type = consumeTypes({ Lexer::Token::Type::Vertex, Lexer::Token::Type::Fragment }); >+ if (!type) >+ return std::nullopt; >+ >+ switch (origin->type) { >+ case Lexer::Token::Type::Vertex: >+ entryPointType = AST::FunctionDeclaration::EntryPointType::Vertex; >+ break; >+ case Lexer::Token::Type::Fragment: >+ entryPointType = AST::FunctionDeclaration::EntryPointType::Fragment; >+ break; >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ } >+ >+ auto type = parseType(); >+ if (!type) >+ return std::nullopt; >+ >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return std::nullopt; >+ >+ auto parameters = parseParameters(); >+ if (!parameters) >+ return std::nullopt; >+ >+ std::optional<AST::Semantic> semantic; >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto parsedSemantic = parseSemantic(); >+ if (!parsedSemantic) >+ return std::nullopt; >+ } >+ >+ return AST::FunctionDeclaration(WTFMove(*origin), WTFMove(attributeBlock), entryPointType, WTFMove(type), name->stringView.toString(), WTFMove(*parameters), WTFMove(semantic)); >+} >+ >+std::optional<AST::FunctionDeclaration> Parser::parseRegularFunctionDeclaration() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return std::nullopt; >+ >+ auto type = parseType(); >+ if (!type) >+ return std::nullopt; >+ >+ auto name = consumeTypes({ Lexer::Token::Type::Identifier, Lexer::Token::Type::OperatorName }); >+ if (!name) >+ return std::nullopt; >+ >+ auto parameters = parseParameters(); >+ if (!parameters) >+ return std::nullopt; >+ >+ std::optional<AST::Semantic> semantic; >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto parsedSemantic = parseSemantic(); >+ if (!parsedSemantic) >+ return std::nullopt; >+ } >+ >+ return AST::FunctionDeclaration(WTFMove(*origin), { }, std::nullopt, WTFMove(type), name->stringView.toString(), WTFMove(*parameters), WTFMove(semantic)); >+} >+ >+std::optional<AST::FunctionDeclaration> Parser::parseOperatorFunctionDeclaration() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Operator); >+ if (!origin) >+ return std::nullopt; >+ >+ auto type = parseType(); >+ if (!type) >+ return std::nullopt; >+ >+ auto parameters = parseParameters(); >+ if (!parameters) >+ return std::nullopt; >+ >+ std::optional<AST::Semantic> semantic; >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto parsedSemantic = parseSemantic(); >+ if (!parsedSemantic) >+ return std::nullopt; >+ } >+ >+ return AST::FunctionDeclaration(WTFMove(*origin), { }, std::nullopt, WTFMove(type), String("Operator Cast", String::ConstructFromLiteral), WTFMove(*parameters), WTFMove(semantic)); >+} >+ >+std::optional<AST::FunctionDeclaration> Parser::parseFunctionDeclaration() >+{ >+ auto entryPointFunctionDeclaration = backtrackingScope<std::optional<AST::FunctionDeclaration>>([&]() -> std::optional<AST::FunctionDeclaration> { >+ return parseEntryPointFunctionDeclaration(); >+ }); >+ if (entryPointFunctionDeclaration) { >+ auto result = WTFMove(*entryPointFunctionDeclaration); >+ return result; >+ } >+ >+ auto regularFunctionDeclaration = backtrackingScope<std::optional<AST::FunctionDeclaration>>([&]() -> std::optional<AST::FunctionDeclaration> { >+ return parseRegularFunctionDeclaration(); >+ }); >+ if (regularFunctionDeclaration) { >+ auto result = WTFMove(*regularFunctionDeclaration); >+ return result; >+ } >+ >+ auto operatorFunctionDeclaration = backtrackingScope<std::optional<AST::FunctionDeclaration>>([&]() -> std::optional<AST::FunctionDeclaration> { >+ return parseOperatorFunctionDeclaration(); >+ }); >+ if (operatorFunctionDeclaration) { >+ auto result = WTFMove(*operatorFunctionDeclaration); >+ return result; >+ } >+ >+ return std::nullopt; >+} >+ >+std::optional<AST::NativeFunctionDeclaration> Parser::parseNativeFunctionDeclaration() >+{ >+ std::optional<Lexer::Token> origin; >+ >+ bool restricted = false; >+ auto restrictedValue = peekType(Lexer::Token::Type::Restricted); >+ if (restrictedValue) { >+ consumeType(Lexer::Token::Type::Restricted); >+ origin = *restrictedValue; >+ restricted = true; >+ } >+ >+ auto native = consumeType(Lexer::Token::Type::Native); >+ if (!native) >+ return std::nullopt; >+ if (!origin) >+ origin = *native; >+ >+ auto functionDeclaration = parseFunctionDeclaration(); >+ if (!functionDeclaration) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ >+ return AST::NativeFunctionDeclaration(functionDeclaration->takeOrigin(), functionDeclaration->takeAttributeBlock(), functionDeclaration->takeEntryPointType(), functionDeclaration->takeType(), functionDeclaration->takeName(), functionDeclaration->takeParameters(), functionDeclaration->takeSemantic(), restricted); >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseExpression() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return nullptr; >+ >+ auto first = parsePossibleTernaryConditional(); >+ if (!first) >+ return nullptr; >+ >+ Vector<std::unique_ptr<AST::Expression>> expressions; >+ expressions.append(WTFMove(first)); >+ >+ while (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto expression = parsePossibleTernaryConditional(); >+ if (!expression) >+ return nullptr; >+ expressions.append(WTFMove(expression)); >+ } >+ >+ if (expressions.size() == 1) { >+ auto result = WTFMove(expressions[0]); >+ return result; >+ } >+ return std::make_unique<AST::CommaExpression>(WTFMove(*origin), WTFMove(expressions)); >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseTernaryConditional() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return nullptr; >+ >+ auto predicate = parsePossibleLogicalBinaryOperation(); >+ if (!predicate) >+ return nullptr; >+ >+ if (!consumeType(Lexer::Token::Type::QuestionMark)) >+ return nullptr; >+ >+ auto bodyExpression = parseExpression(); >+ if (!bodyExpression) >+ return nullptr; >+ >+ if (!consumeType(Lexer::Token::Type::Colon)) >+ return nullptr; >+ >+ auto elseExpression = parsePossibleTernaryConditional(); >+ if (!elseExpression) >+ return nullptr; >+ >+ // FIXME: Cast the predicate to a bool. >+ return std::make_unique<AST::TernaryExpression>(WTFMove(*origin), WTFMove(predicate), WTFMove(bodyExpression), WTFMove(elseExpression)); >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseAssignment() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return nullptr; >+ >+ auto left = parsePossiblePrefix(); >+ if (!left) >+ return nullptr; >+ >+ auto assignmentOperator = consumeTypes({ >+ Lexer::Token::Type::EqualsSign, >+ Lexer::Token::Type::PlusEquals, >+ Lexer::Token::Type::MinusEquals, >+ Lexer::Token::Type::TimesEquals, >+ Lexer::Token::Type::DivideEquals, >+ Lexer::Token::Type::ModEquals, >+ Lexer::Token::Type::XorEquals, >+ Lexer::Token::Type::AndEquals, >+ Lexer::Token::Type::OrEquals, >+ Lexer::Token::Type::RightShiftEquals, >+ Lexer::Token::Type::LeftShiftEquals >+ }); >+ if (!assignmentOperator) >+ return nullptr; >+ >+ auto right = parsePossibleTernaryConditional(); >+ if (!right) >+ return nullptr; >+ >+ if (assignmentOperator->type == Lexer::Token::Type::EqualsSign) >+ return std::make_unique<AST::AssignmentExpression>(WTFMove(*origin), WTFMove(left), WTFMove(right)); >+ >+ String name; >+ switch (assignmentOperator->type) { >+ case Lexer::Token::Type::PlusEquals: >+ name = String("operator+", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::MinusEquals: >+ name = String("operator-", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::TimesEquals: >+ name = String("operator*", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::DivideEquals: >+ name = String("operator/", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::ModEquals: >+ name = String("operator%", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::XorEquals: >+ name = String("operator^", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::AndEquals: >+ name = String("operator&", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::OrEquals: >+ name = String("operator|", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::RightShiftEquals: >+ name = String("operator>>", String::ConstructFromLiteral); >+ break; >+ case Lexer::Token::Type::LeftShiftEquals: >+ name = String("operator<<", String::ConstructFromLiteral); >+ break; >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ >+ auto result = std::make_unique<AST::ReadModifyWriteExpression>(Lexer::Token(*origin), WTFMove(left)); >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(result->oldVariableReference()); >+ callArguments.append(WTFMove(right)); >+ result->setNewValueExpression(std::make_unique<AST::CallExpression>(WTFMove(*origin), WTFMove(name), WTFMove(callArguments))); >+ result->setResultExpression(result->newVariableReference()); >+ return result; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parsePossibleTernaryConditional() >+{ >+ auto ternaryExpression = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parseTernaryConditional(); >+ }); >+ if (ternaryExpression) >+ return ternaryExpression; >+ >+ auto assignmentExpression = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parseAssignment(); >+ }); >+ if (assignmentExpression) >+ return assignmentExpression; >+ >+ auto binaryOperation = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parsePossibleLogicalBinaryOperation(); >+ }); >+ if (binaryOperation) >+ return binaryOperation; >+ >+ return nullptr; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parsePossibleLogicalBinaryOperation() >+{ >+ auto previous = parsePossibleRelationalBinaryOperation(); >+ if (!previous) >+ return nullptr; >+ >+ while (peekTypes({ >+ Lexer::Token::Type::OrOr, >+ Lexer::Token::Type::AndAnd, >+ Lexer::Token::Type::Or, >+ Lexer::Token::Type::Xor, >+ Lexer::Token::Type::And >+ })) { >+ auto logicalBinaryOperation = consumeTypes({ >+ Lexer::Token::Type::OrOr, >+ Lexer::Token::Type::AndAnd, >+ Lexer::Token::Type::Or, >+ Lexer::Token::Type::Xor, >+ Lexer::Token::Type::And >+ }); >+ >+ auto next = parsePossibleRelationalBinaryOperation(); >+ if (!next) >+ return nullptr; >+ >+ switch (logicalBinaryOperation->type) { >+ case Lexer::Token::Type::OrOr: >+ previous = std::make_unique<AST::LogicalExpression>(WTFMove(*logicalBinaryOperation), AST::LogicalExpression::Type::Or, WTFMove(previous), WTFMove(next)); >+ break; >+ case Lexer::Token::Type::AndAnd: >+ previous = std::make_unique<AST::LogicalExpression>(WTFMove(*logicalBinaryOperation), AST::LogicalExpression::Type::And, WTFMove(previous), WTFMove(next)); >+ break; >+ case Lexer::Token::Type::Or: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*logicalBinaryOperation), String("operator|", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::Xor: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*logicalBinaryOperation), String("operator^", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::And: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*logicalBinaryOperation), String("operator&", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ } >+ >+ return previous; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parsePossibleRelationalBinaryOperation() >+{ >+ auto previous = parsePossibleShift(); >+ if (!previous) >+ return nullptr; >+ >+ while (peekTypes({ >+ Lexer::Token::Type::LessThanSign, >+ Lexer::Token::Type::GreaterThanSign, >+ Lexer::Token::Type::LessThanOrEqualTo, >+ Lexer::Token::Type::GreaterThanOrEqualTo, >+ Lexer::Token::Type::EqualComparison, >+ Lexer::Token::Type::NotEqual >+ })) { >+ auto relationalBinaryOperation = consumeTypes({ >+ Lexer::Token::Type::LessThanSign, >+ Lexer::Token::Type::GreaterThanSign, >+ Lexer::Token::Type::LessThanOrEqualTo, >+ Lexer::Token::Type::GreaterThanOrEqualTo, >+ Lexer::Token::Type::EqualComparison, >+ Lexer::Token::Type::NotEqual, >+ }); >+ >+ auto next = parsePossibleShift(); >+ if (!next) >+ return nullptr; >+ >+ switch (relationalBinaryOperation->type) { >+ case Lexer::Token::Type::LessThanSign: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*relationalBinaryOperation), String("operator<", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::GreaterThanSign: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*relationalBinaryOperation), String("operator>", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::LessThanOrEqualTo: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*relationalBinaryOperation), String("operator<=", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::GreaterThanOrEqualTo: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*relationalBinaryOperation), String("operator>=", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::EqualComparison: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*relationalBinaryOperation), String("operator==", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::NotEqual: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(Lexer::Token(*relationalBinaryOperation), String("operator==", String::ConstructFromLiteral), WTFMove(callArguments)); >+ // FIXME: Cast the argument to a bool >+ previous = std::make_unique<AST::LogicalNotExpression>(WTFMove(*relationalBinaryOperation), WTFMove(previous)); >+ break; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ } >+ >+ return previous; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parsePossibleShift() >+{ >+ auto previous = parsePossibleAdd(); >+ if (!previous) >+ return nullptr; >+ >+ while (peekTypes({ >+ Lexer::Token::Type::LeftShift, >+ Lexer::Token::Type::RightShift >+ })) { >+ auto shift = consumeTypes({ >+ Lexer::Token::Type::LeftShift, >+ Lexer::Token::Type::RightShift >+ }); >+ >+ auto next = parsePossibleAdd(); >+ if (!next) >+ return nullptr; >+ >+ switch (shift->type) { >+ case Lexer::Token::Type::LeftShift: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*shift), String("operator<<", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::RightShift: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*shift), String("operator>>", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ } >+ >+ return previous; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parsePossibleAdd() >+{ >+ auto previous = parsePossibleMultiply(); >+ if (!previous) >+ return nullptr; >+ >+ while (peekTypes({ >+ Lexer::Token::Type::Plus, >+ Lexer::Token::Type::Minus >+ })) { >+ auto add = consumeTypes({ >+ Lexer::Token::Type::Plus, >+ Lexer::Token::Type::Minus >+ }); >+ >+ auto next = parsePossibleMultiply(); >+ if (!next) >+ return nullptr; >+ >+ switch (add->type) { >+ case Lexer::Token::Type::Plus: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*add), String("operator+", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::Minus: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*add), String("operator-", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ } >+ >+ return previous; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parsePossibleMultiply() >+{ >+ auto previous = parsePossiblePrefix(); >+ if (!previous) >+ return nullptr; >+ >+ while (peekTypes({ >+ Lexer::Token::Type::Star, >+ Lexer::Token::Type::Divide, >+ Lexer::Token::Type::Mod >+ })) { >+ auto multiply = consumeTypes({ >+ Lexer::Token::Type::Star, >+ Lexer::Token::Type::Divide, >+ Lexer::Token::Type::Mod, >+ }); >+ >+ auto next = parsePossiblePrefix(); >+ if (!next) >+ return nullptr; >+ >+ switch (multiply->type) { >+ case Lexer::Token::Type::Star: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*multiply), String("operator*", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::Divide: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*multiply), String("operator/", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ case Lexer::Token::Type::Mod: { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ callArguments.append(WTFMove(next)); >+ previous = std::make_unique<AST::CallExpression>(WTFMove(*multiply), String("operator%", String::ConstructFromLiteral), WTFMove(callArguments)); >+ break; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ } >+ >+ return previous; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parsePossiblePrefix() >+{ >+ Vector<std::function<std::unique_ptr<AST::Expression>(std::unique_ptr<AST::Expression>&&)>> builders; >+ while (peekTypes({ >+ Lexer::Token::Type::PlusPlus, >+ Lexer::Token::Type::MinusMinus, >+ Lexer::Token::Type::Plus, >+ Lexer::Token::Type::Minus, >+ Lexer::Token::Type::Tilde, >+ Lexer::Token::Type::ExclamationPoint, >+ Lexer::Token::Type::And, >+ Lexer::Token::Type::At, >+ Lexer::Token::Type::Star >+ })) { >+ auto prefix = consumeTypes({ >+ Lexer::Token::Type::PlusPlus, >+ Lexer::Token::Type::MinusMinus, >+ Lexer::Token::Type::Plus, >+ Lexer::Token::Type::Minus, >+ Lexer::Token::Type::Tilde, >+ Lexer::Token::Type::ExclamationPoint, >+ Lexer::Token::Type::And, >+ Lexer::Token::Type::At, >+ Lexer::Token::Type::Star >+ }); >+ >+ switch (prefix->type) { >+ case Lexer::Token::Type::PlusPlus: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ auto result = std::make_unique<AST::ReadModifyWriteExpression>(Lexer::Token(*prefix), WTFMove(previous)); >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(result->oldVariableReference()); >+ result->setNewValueExpression(std::make_unique<AST::CallExpression>(Lexer::Token(*prefix), String("operator++", String::ConstructFromLiteral), WTFMove(callArguments))); >+ result->setResultExpression(result->newVariableReference()); >+ return result; >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ case Lexer::Token::Type::MinusMinus: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ auto result = std::make_unique<AST::ReadModifyWriteExpression>(Lexer::Token(*prefix), WTFMove(previous)); >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(result->oldVariableReference()); >+ result->setNewValueExpression(std::make_unique<AST::CallExpression>(Lexer::Token(*prefix), String("operator--", String::ConstructFromLiteral), WTFMove(callArguments))); >+ result->setResultExpression(result->newVariableReference()); >+ return result; >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ case Lexer::Token::Type::Plus: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ return std::make_unique<AST::CallExpression>(Lexer::Token(*prefix), String("operator+", String::ConstructFromLiteral), WTFMove(callArguments)); >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ case Lexer::Token::Type::Minus: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ return std::make_unique<AST::CallExpression>(Lexer::Token(*prefix), String("operator-", String::ConstructFromLiteral), WTFMove(callArguments)); >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ case Lexer::Token::Type::Tilde: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(WTFMove(previous)); >+ return std::make_unique<AST::CallExpression>(Lexer::Token(*prefix), String("operator~", String::ConstructFromLiteral), WTFMove(callArguments)); >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ case Lexer::Token::Type::ExclamationPoint: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ return std::make_unique<AST::LogicalNotExpression>(Lexer::Token(*prefix), WTFMove(previous)); >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ case Lexer::Token::Type::And: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ return std::make_unique<AST::MakePointerExpression>(Lexer::Token(*prefix), WTFMove(previous)); >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ case Lexer::Token::Type::At: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ return std::make_unique<AST::MakeArrayReferenceExpression>(Lexer::Token(*prefix), WTFMove(previous)); >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ case Lexer::Token::Type::Star: { >+ auto builder = [=](std::unique_ptr<AST::Expression>&& previous) -> std::unique_ptr<AST::Expression> { >+ return std::make_unique<AST::DereferenceExpression>(Lexer::Token(*prefix), WTFMove(previous)); >+ }; >+ builders.append(WTFMove(builder)); >+ break; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ } >+ >+ auto result = parsePossibleSuffix(); >+ if (!result) >+ return nullptr; >+ >+ for (auto builder = builders.rbegin(); builder != builders.rend(); ++builder) >+ result = (*builder)(WTFMove(result)); >+ >+ return result; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parsePossibleSuffix() >+{ >+ return nullptr; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseCallExpression() >+{ >+ return nullptr; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseTerm() >+{ >+ return nullptr; >+} >+ >+} >+ >+} >+ >+#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..7e0051f16ba7cf98f202102e53e8c3f7b364b418 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >@@ -0,0 +1,136 @@ >+/* >+ * 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 "WHLSLASTExpression.h" >+#include "WHLSLASTFunctionAttribute.h" >+#include "WHLSLASTFunctionDeclaration.h" >+#include "WHLSLASTNativeTypeDeclaration.h" >+#include "WHLSLASTParameter.h" >+#include "WHLSLASTSemantic.h" >+#include "WHLSLASTStructureDefinition.h" >+#include "WHLSLASTStructureElement.h" >+#include "WHLSLASTTypeArgument.h" >+#include "WHLSLASTTypeDefinition.h" >+#include "WHLSLLexer.h" >+#include "WHLSLProgram.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> peekTypes(Vector<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::ConstantExpression> parseConstantExpression(); >+ 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::TypeDefinition> parseTypeDefinition(); >+ 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(); >+ AST::Qualifiers parseQualifiers(); >+ std::optional<AST::StructureElement> parseStructureElement(); >+ std::optional<AST::StructureDefinition> parseStructureDefinition(); >+ std::optional<AST::EnumerationDefinition> parseEnumerationDefinition(); >+ std::optional<AST::EnumerationMember> parseEnumerationMember(); >+ std::optional<AST::NativeTypeDeclaration> parseNativeTypeDeclaration(); >+ std::optional<AST::NumThreadsFunctionAttribute> parseNumThreadsFunctionAttribute(); >+ std::optional<AST::AttributeBlock> parseAttributeBlock(); >+ std::optional<AST::Parameter> parseParameter(); >+ std::optional<AST::Parameters> parseParameters(); >+ std::optional<AST::FunctionDeclaration> parseEntryPointFunctionDeclaration(); >+ std::optional<AST::FunctionDeclaration> parseRegularFunctionDeclaration(); >+ std::optional<AST::FunctionDeclaration> parseOperatorFunctionDeclaration(); >+ std::optional<AST::FunctionDeclaration> parseFunctionDeclaration(); >+ std::optional<AST::NativeFunctionDeclaration> parseNativeFunctionDeclaration(); >+ >+ std::unique_ptr<AST::Expression> parseExpression(); >+ std::unique_ptr<AST::Expression> parseTernaryConditional(); >+ std::unique_ptr<AST::Expression> parseAssignment(); >+ std::unique_ptr<AST::Expression> parsePossibleTernaryConditional(); >+ std::unique_ptr<AST::Expression> parsePossibleLogicalBinaryOperation(); >+ std::unique_ptr<AST::Expression> parsePossibleRelationalBinaryOperation(); >+ std::unique_ptr<AST::Expression> parsePossibleShift(); >+ std::unique_ptr<AST::Expression> parsePossibleAdd(); >+ std::unique_ptr<AST::Expression> parsePossibleMultiply(); >+ std::unique_ptr<AST::Expression> parsePossiblePrefix(); >+ std::unique_ptr<AST::Expression> parsePossibleSuffix(); >+ std::unique_ptr<AST::Expression> parseCallExpression(); >+ std::unique_ptr<AST::Expression> parseTerm(); >+ >+ Lexer m_lexer; >+}; >+ >+} >+ >+} >+ >+#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..52d77d09d11430eb40dae61fcbca4d862c6f7579 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.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 "WHLSLASTEnumerationDefinition.h" >+#include "WHLSLASTNativeFunctionDeclaration.h" >+#include "WHLSLASTNativeTypeDeclaration.h" >+#include "WHLSLASTStructureDefinition.h" >+#include "WHLSLASTTypeDefinition.h" >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class Program { >+public: >+ void append(AST::TypeDefinition&& typeDefinition) >+ { >+ m_typeDefinitions.append(WTFMove(typeDefinition)); >+ } >+ void append(AST::StructureDefinition&& structureDefinition) >+ { >+ m_structureDefinitions.append(WTFMove(structureDefinition)); >+ } >+ void append(AST::EnumerationDefinition&& enumerationDefinition) >+ { >+ m_enumerationDefinitions.append(WTFMove(enumerationDefinition)); >+ } >+ void append(AST::NativeFunctionDeclaration&& nativeFunctionDeclaration) >+ { >+ m_nativeFunctionDeclarations.append(WTFMove(nativeFunctionDeclaration)); >+ } >+ void append(AST::NativeTypeDeclaration&& nativeTypeDeclaration) >+ { >+ m_nativeTypeDeclarations.append(WTFMove(nativeTypeDeclaration)); >+ } >+ >+private: >+ Vector<AST::TypeDefinition> m_typeDefinitions; >+ Vector<AST::StructureDefinition> m_structureDefinitions; >+ Vector<AST::EnumerationDefinition> m_enumerationDefinitions; >+ Vector<AST::NativeFunctionDeclaration> m_nativeFunctionDeclarations; >+ Vector<AST::NativeTypeDeclaration> m_nativeTypeDeclarations; >+}; >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 73494873b7547ec46e88d485c4ccb404f4a5022c..d7207de7ec90f901cf57ab7eee457426c25af5bc 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -301,6 +301,8 @@ Modules/websockets/WebSocketHandshake.cpp > Modules/websockets/WorkerThreadableWebSocketChannel.cpp > > Modules/webgpu/DOMWindowWebGPU.cpp >+Modules/webgpu/WHLSL/WHLSLLexer.cpp >+Modules/webgpu/WHLSL/WHLSLParser.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 5e1ec89de06e7038a6c37fd3b67193d517dd90d0..7954b4b6583a1202e4ad275dba4c172c2d7670af 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -6401,6 +6401,17 @@ > 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>"; }; >+ 1C80596F21BB02D3006B0906 /* WHLSLASTPointerType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTPointerType.h; sourceTree = "<group>"; }; >+ 1C80597221BB02EA006B0906 /* WHLSLASTArrayReferenceType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTArrayReferenceType.h; sourceTree = "<group>"; }; >+ 1C80597421BB02FB006B0906 /* WHLSLASTArrayType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTArrayType.h; sourceTree = "<group>"; }; >+ 1C80597621BB0577006B0906 /* WHLSLASTReferenceType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTReferenceType.h; sourceTree = "<group>"; }; >+ 1C80597D21BF55A7006B0906 /* WHLSLASTBaseSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTBaseSemantic.h; sourceTree = "<group>"; }; >+ 1C80598021BF55BA006B0906 /* WHLSLASTBuiltInSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTBuiltInSemantic.h; sourceTree = "<group>"; }; >+ 1C80598221BF55D1006B0906 /* WHLSLASTResourceSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTResourceSemantic.h; sourceTree = "<group>"; }; >+ 1C80598421BF55ED006B0906 /* WHLSLASTSpecializationConstantSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTSpecializationConstantSemantic.h; 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 +6423,8 @@ > 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>"; }; >+ 1CC46F2721B77860000998DE /* WHLSLASTTypeReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTTypeReference.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>"; }; >@@ -13200,11 +13213,40 @@ > 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>"; }; >+ C22F76C021C0A45800C5434E /* WHLSLASTExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTExpression.h; sourceTree = "<group>"; }; >+ C22F76C121C0A63E00C5434E /* WHLSLASTCommaExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTCommaExpression.h; sourceTree = "<group>"; }; >+ C22F76C221C0A6DE00C5434E /* WHLSLASTTernaryExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTTernaryExpression.h; sourceTree = "<group>"; }; >+ C22F76C321C0A75500C5434E /* WHLSLASTAssignmentExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTAssignmentExpression.h; sourceTree = "<group>"; }; >+ C22F76C421C0A76300C5434E /* WHLSLASTReadModifyWriteExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTReadModifyWriteExpression.h; sourceTree = "<group>"; }; >+ C22F76C521C0A7AE00C5434E /* WHLSLASTLogicalExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTLogicalExpression.h; sourceTree = "<group>"; }; >+ C22F76C621C0A7BD00C5434E /* WHLSLASTCallExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTCallExpression.h; sourceTree = "<group>"; }; >+ C22F76C721C0A8CF00C5434E /* WHLSLASTDereferenceExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTDereferenceExpression.h; sourceTree = "<group>"; }; >+ C22F76C821C0A8E000C5434E /* WHLSLASTMakePointerExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTMakePointerExpression.h; sourceTree = "<group>"; }; >+ C22F76C921C0A8F200C5434E /* WHLSLASTMakeArrayReferenceExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTMakeArrayReferenceExpression.h; sourceTree = "<group>"; }; >+ C22F76CA21C0A90400C5434E /* WHLSLASTLogicalNotExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTLogicalNotExpression.h; sourceTree = "<group>"; }; >+ C22F76CB21C0A98B00C5434E /* WHLSLASTNullLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTNullLiteral.h; sourceTree = "<group>"; }; >+ C22F76CC21C0A9A700C5434E /* WHLSLASTVariableReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTVariableReference.h; sourceTree = "<group>"; }; >+ C22F76CD21C0A9BA00C5434E /* WHLSLASTIntegerLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTIntegerLiteral.h; sourceTree = "<group>"; }; >+ C22F76CE21C0A9C900C5434E /* WHLSLASTUnsignedIntegerLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTUnsignedIntegerLiteral.h; sourceTree = "<group>"; }; >+ C22F76CF21C0A9F100C5434E /* WHLSLASTFloatLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTFloatLiteral.h; sourceTree = "<group>"; }; >+ C22F76D021C0AA1400C5434E /* WHLSLASTBooleanLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTBooleanLiteral.h; sourceTree = "<group>"; }; >+ C22F76D121C0AA5300C5434E /* WHLSLASTDotExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTDotExpression.h; sourceTree = "<group>"; }; >+ C22F76D221C0AA6300C5434E /* WHLSLASTIndexExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTIndexExpression.h; sourceTree = "<group>"; }; >+ C22F76D321C0AC5300C5434E /* WHLSLASTAnonymousVariableDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTAnonymousVariableDeclaration.h; sourceTree = "<group>"; }; >+ C22F76D421C0AFCF00C5434E /* WHLSLASTPropertyAccessExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTPropertyAccessExpression.h; sourceTree = "<group>"; }; > C2458E611FE8979E00594759 /* FontCacheCoreText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontCacheCoreText.h; sourceTree = "<group>"; }; > C26017A11C72DC9900F74A16 /* CSSFontFaceSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontFaceSet.cpp; sourceTree = "<group>"; }; > C26017A21C72DC9900F74A16 /* CSSFontFaceSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFaceSet.h; sourceTree = "<group>"; }; >+ C274F13521C032D6003410BD /* WHLSLASTFunctionDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTFunctionDeclaration.h; sourceTree = "<group>"; }; >+ C274F13721C03E95003410BD /* WHLSLASTBaseFunctionAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTBaseFunctionAttribute.h; sourceTree = "<group>"; }; >+ C274F13921C03EAC003410BD /* WHLSLASTNumThreadsFunctionAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTNumThreadsFunctionAttribute.h; sourceTree = "<group>"; }; >+ C274F13B21C03EBF003410BD /* WHLSLASTFunctionAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTFunctionAttribute.h; sourceTree = "<group>"; }; >+ C274F13D21C04AD5003410BD /* WHLSLASTParameter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTParameter.h; sourceTree = "<group>"; }; >+ C274F13F21C04D57003410BD /* WHLSLASTValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTValue.h; sourceTree = "<group>"; }; > C280833C1C6DB194001451B6 /* FontFace.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FontFace.idl; sourceTree = "<group>"; }; > C280833D1C6DC22C001451B6 /* JSFontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSFontFace.cpp; path = DerivedSources/WebCore/JSFontFace.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; > C280833E1C6DC22C001451B6 /* JSFontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSFontFace.h; path = DerivedSources/WebCore/JSFontFace.h; sourceTree = BUILT_PRODUCTS_DIR; }; >@@ -13217,6 +13259,21 @@ > 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>"; }; >+ C2ECEB5021B64C72008F8DE9 /* WHLSLASTVariableDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTVariableDeclaration.h; sourceTree = "<group>"; }; >+ C2ECEB5221B64C84008F8DE9 /* WHLSLASTTypeDefinition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTTypeDefinition.h; sourceTree = "<group>"; }; >+ C2ECEB5421B64C97008F8DE9 /* WHLSLASTStructureDefinition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTStructureDefinition.h; sourceTree = "<group>"; }; >+ C2ECEB5621B64CAB008F8DE9 /* WHLSLASTEnumerationDefinition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTEnumerationDefinition.h; sourceTree = "<group>"; }; >+ C2ECEB5821B64CBE008F8DE9 /* WHLSLASTFunctionDefinition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTFunctionDefinition.h; sourceTree = "<group>"; }; >+ C2ECEB5A21B64CD5008F8DE9 /* WHLSLASTNativeFunctionDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTNativeFunctionDeclaration.h; sourceTree = "<group>"; }; >+ C2ECEB5C21B64CE4008F8DE9 /* WHLSLASTNativeTypeDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTNativeTypeDeclaration.h; sourceTree = "<group>"; }; >+ C2ECEB5E21B64D6F008F8DE9 /* WHLSLProgram.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLProgram.h; sourceTree = "<group>"; }; >+ C2ECEB6021B64DC6008F8DE9 /* WHLSLASTType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTType.h; sourceTree = "<group>"; }; >+ C2ECEB6521B7A7CF008F8DE9 /* WHLSLASTConstantExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTConstantExpression.h; sourceTree = "<group>"; }; >+ C2ECEB6C21BE4896008F8DE9 /* WHLSLASTStructureElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTStructureElement.h; sourceTree = "<group>"; }; >+ C2ECEB7421BF7F3A008F8DE9 /* WHLSLASTQualifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTQualifier.h; sourceTree = "<group>"; }; >+ C2ECEB7921BF8E05008F8DE9 /* WHLSLASTEnumerationMember.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTEnumerationMember.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>"; }; >@@ -25144,6 +25201,70 @@ > tabWidth = 4; > usesTabs = 0; > }; >+ C210E90D21B4BCA400B7F83D /* WHLSL */ = { >+ isa = PBXGroup; >+ children = ( >+ C22F76D321C0AC5300C5434E /* WHLSLASTAnonymousVariableDeclaration.h */, >+ 1C80597221BB02EA006B0906 /* WHLSLASTArrayReferenceType.h */, >+ 1C80597421BB02FB006B0906 /* WHLSLASTArrayType.h */, >+ C22F76C321C0A75500C5434E /* WHLSLASTAssignmentExpression.h */, >+ C274F13721C03E95003410BD /* WHLSLASTBaseFunctionAttribute.h */, >+ 1C80597D21BF55A7006B0906 /* WHLSLASTBaseSemantic.h */, >+ C22F76D021C0AA1400C5434E /* WHLSLASTBooleanLiteral.h */, >+ 1C80598021BF55BA006B0906 /* WHLSLASTBuiltInSemantic.h */, >+ C22F76C621C0A7BD00C5434E /* WHLSLASTCallExpression.h */, >+ C22F76C121C0A63E00C5434E /* WHLSLASTCommaExpression.h */, >+ C2ECEB6521B7A7CF008F8DE9 /* WHLSLASTConstantExpression.h */, >+ C22F76C721C0A8CF00C5434E /* WHLSLASTDereferenceExpression.h */, >+ C22F76D121C0AA5300C5434E /* WHLSLASTDotExpression.h */, >+ C2ECEB5621B64CAB008F8DE9 /* WHLSLASTEnumerationDefinition.h */, >+ C2ECEB7921BF8E05008F8DE9 /* WHLSLASTEnumerationMember.h */, >+ C22F76C021C0A45800C5434E /* WHLSLASTExpression.h */, >+ C22F76CF21C0A9F100C5434E /* WHLSLASTFloatLiteral.h */, >+ C274F13B21C03EBF003410BD /* WHLSLASTFunctionAttribute.h */, >+ C274F13521C032D6003410BD /* WHLSLASTFunctionDeclaration.h */, >+ C2ECEB5821B64CBE008F8DE9 /* WHLSLASTFunctionDefinition.h */, >+ C22F76D221C0AA6300C5434E /* WHLSLASTIndexExpression.h */, >+ C22F76CD21C0A9BA00C5434E /* WHLSLASTIntegerLiteral.h */, >+ C22F76C521C0A7AE00C5434E /* WHLSLASTLogicalExpression.h */, >+ C22F76CA21C0A90400C5434E /* WHLSLASTLogicalNotExpression.h */, >+ C22F76C921C0A8F200C5434E /* WHLSLASTMakeArrayReferenceExpression.h */, >+ C22F76C821C0A8E000C5434E /* WHLSLASTMakePointerExpression.h */, >+ C2ECEB5A21B64CD5008F8DE9 /* WHLSLASTNativeFunctionDeclaration.h */, >+ C2ECEB5C21B64CE4008F8DE9 /* WHLSLASTNativeTypeDeclaration.h */, >+ 1C80596B21BA164A006B0906 /* WHLSLASTNode.h */, >+ C22F76CB21C0A98B00C5434E /* WHLSLASTNullLiteral.h */, >+ C274F13921C03EAC003410BD /* WHLSLASTNumThreadsFunctionAttribute.h */, >+ C274F13D21C04AD5003410BD /* WHLSLASTParameter.h */, >+ 1C80596F21BB02D3006B0906 /* WHLSLASTPointerType.h */, >+ C22F76D421C0AFCF00C5434E /* WHLSLASTPropertyAccessExpression.h */, >+ C2ECEB7421BF7F3A008F8DE9 /* WHLSLASTQualifier.h */, >+ C22F76C421C0A76300C5434E /* WHLSLASTReadModifyWriteExpression.h */, >+ 1C80597621BB0577006B0906 /* WHLSLASTReferenceType.h */, >+ 1C80598221BF55D1006B0906 /* WHLSLASTResourceSemantic.h */, >+ 1C80598721BF5781006B0906 /* WHLSLASTSemantic.h */, >+ 1C80598421BF55ED006B0906 /* WHLSLASTSpecializationConstantSemantic.h */, >+ 1C80598621BF5601006B0906 /* WHLSLASTStageInOutSemantic.h */, >+ C2ECEB5421B64C97008F8DE9 /* WHLSLASTStructureDefinition.h */, >+ C2ECEB6C21BE4896008F8DE9 /* WHLSLASTStructureElement.h */, >+ C22F76C221C0A6DE00C5434E /* WHLSLASTTernaryExpression.h */, >+ C2ECEB6021B64DC6008F8DE9 /* WHLSLASTType.h */, >+ 1CC46F2921B77A32000998DE /* WHLSLASTTypeArgument.h */, >+ C2ECEB5221B64C84008F8DE9 /* WHLSLASTTypeDefinition.h */, >+ 1CC46F2721B77860000998DE /* WHLSLASTTypeReference.h */, >+ C22F76CE21C0A9C900C5434E /* WHLSLASTUnsignedIntegerLiteral.h */, >+ C274F13F21C04D57003410BD /* WHLSLASTValue.h */, >+ C2ECEB5021B64C72008F8DE9 /* WHLSLASTVariableDeclaration.h */, >+ C22F76CC21C0A9A700C5434E /* WHLSLASTVariableReference.h */, >+ C210E91121B4BD1000B7F83D /* WHLSLLexer.cpp */, >+ C210E91221B4BD1000B7F83D /* WHLSLLexer.h */, >+ C2ECEB4C21B63CBB008F8DE9 /* WHLSLParser.cpp */, >+ C2ECEB4D21B63CBB008F8DE9 /* WHLSLParser.h */, >+ C2ECEB5E21B64D6F008F8DE9 /* WHLSLProgram.h */, >+ ); >+ path = WHLSL; >+ sourceTree = "<group>"; >+ }; > C96F5EBF1B5872260091EA9D /* mediasession */ = { > isa = PBXGroup; > children = ( >@@ -25486,6 +25607,7 @@ > D00F593E216ECC43000D71DB /* webgpu */ = { > isa = PBXGroup; > children = ( >+ C210E90D21B4BCA400B7F83D /* WHLSL */, > D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */, > D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */, > D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */,
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