WebKit Bugzilla
Attachment 357225 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]
First draft
bug-192355-20181213043708.patch (text/plain), 334.37 KB, created by
Myles C. Maxfield
on 2018-12-13 04:37:09 PST
(
hide
)
Description:
First draft
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-12-13 04:37:09 PST
Size:
334.37 KB
patch
obsolete
>Subversion Revision: 239149 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1056f21cb57d27703f88d6c3353f3dcf973bfe79..fcd15096f2e2ff7632329f2dac5f9cb9d46c79e3 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,75 @@ >+2018-12-12 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-13 Ryosuke Niwa <rniwa@webkit.org> > > Make TextInputController.legacyAttributedString take DOM nodes and offsets >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAnonymousVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAnonymousVariableDeclaration.h >new file mode 100644 >index 0000000000000000000000000000000000000000..fbb9fccc455f31cbf8eb33e47a185022664fda48 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAnonymousVariableDeclaration.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 "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() = default; >+ >+ AnonymousVariableDeclaration(const AnonymousVariableDeclaration&) = delete; >+ AnonymousVariableDeclaration(AnonymousVariableDeclaration&&) = default; >+ >+ 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..2397868353fe2d5a7725f3d9a9a9f638450ee5c2 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayReferenceType.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 "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() = default; >+ >+ ArrayReferenceType(const ArrayReferenceType&) = delete; >+ ArrayReferenceType(ArrayReferenceType&&) = default; >+ >+ std::unique_ptr<Type> clone() const override >+ { >+ return std::make_unique<ArrayReferenceType>(Lexer::Token(origin()), String(addressSpace()), elementType()->clone()); >+ } >+ >+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..bf388fb8f6b9a642eeb610f0d7637454abd606f1 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTArrayType.h >@@ -0,0 +1,74 @@ >+/* >+ * 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() = default; >+ >+ ArrayType(const ArrayType&) = delete; >+ ArrayType(ArrayType&&) = default; >+ >+ unsigned numElements() const { return m_numElements; } >+ >+ std::unique_ptr<Type> clone() const override >+ { >+ return std::make_unique<ArrayType>(Lexer::Token(m_origin), m_elementType->clone(), 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..c66c6dc35ec3d39993bdb6eb1f33fb00b222d09c >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTAssignmentExpression.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 "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() = default; >+ >+ AssignmentExpression(const AssignmentExpression&) = delete; >+ AssignmentExpression(AssignmentExpression&&) = default; >+ >+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..69c6511c82b14b49976d1e7bd2062d1fd0eec2fc >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseFunctionAttribute.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 "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() = default; >+ >+ BaseFunctionAttribute(const BaseFunctionAttribute&) = delete; >+ BaseFunctionAttribute(BaseFunctionAttribute&&) = default; >+ >+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..44feceee9b7c003187838d258a78a15504f64de3 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBaseSemantic.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 "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() = default; >+ >+ BaseSemantic(const BaseSemantic&) = delete; >+ BaseSemantic(BaseSemantic&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBlock.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBlock.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8b73f7f04c4ec3461a18a04c82114a458d5f7267 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBlock.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Block : public Statement { >+public: >+ Block(Lexer::Token&& origin, Vector<std::unique_ptr<Statement>>&& statements) >+ : Statement(WTFMove(origin)) >+ , m_statements(WTFMove(statements)) >+ { >+ } >+ >+ virtual ~Block() = default; >+ >+ Block(const Block&) = delete; >+ Block(Block&&) = default; >+ >+private: >+ Vector<std::unique_ptr<Statement>> m_statements; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..0c3ba78652e1278524ee3699ac47e34e9b22ffb8 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBooleanLiteral.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 "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() = default; >+ >+ explicit BooleanLiteral(const BooleanLiteral&) = default; >+ BooleanLiteral(BooleanLiteral&&) = default; >+ >+ bool value() const { return m_value; } >+ >+private: >+ bool m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBreak.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBreak.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7c2b10ac72740b53181306006c023629bd88f2dd >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBreak.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Break : public Statement { >+public: >+ Break(Lexer::Token&& origin) >+ : Statement(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~Break() = default; >+ >+ Break(const Break&) = delete; >+ Break(Break&&) = default; >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..ee4012b30427853bcccb265abeda75f1d5cec6de >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTBuiltInSemantic.h >@@ -0,0 +1,83 @@ >+/* >+ * 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() = default; >+ >+ BuiltInSemantic(const BuiltInSemantic&) = delete; >+ BuiltInSemantic(BuiltInSemantic&&) = default; >+ >+ 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..68af89ead854b2d1533a7549ee4d2e27889f45d2 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTCallExpression.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 "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() = default; >+ >+ CallExpression(const CallExpression&) = delete; >+ CallExpression(CallExpression&&) = default; >+ >+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..77bf3dcf50b7356f8ab500cf3a2d63a53e47b314 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTCommaExpression.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" >+#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() = default; >+ >+ CommaExpression(const CommaExpression&) = delete; >+ CommaExpression(CommaExpression&&) = default; >+ >+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..8c7d7d060cd81ea92cb17c801a18d9c77389d9d0 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstantExpression.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 "WHLSLASTBooleanLiteral.h" >+#include "WHLSLASTConstantExpressionEnumerationMemberReference.h" >+#include "WHLSLASTFloatLiteral.h" >+#include "WHLSLASTIntegerLiteral.h" >+#include "WHLSLASTNullLiteral.h" >+#include "WHLSLASTUnsignedIntegerLiteral.h" >+#include <wtf/Variant.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+typedef Variant< >+ IntegerLiteral, >+ UnsignedIntegerLiteral, >+ FloatLiteral, >+ NullLiteral, >+ BooleanLiteral, >+ ConstantExpressionEnumerationMemberReference >+ > ConstantExpression; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstantExpressionEnumerationMemberReference.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstantExpressionEnumerationMemberReference.h >new file mode 100644 >index 0000000000000000000000000000000000000000..2c24a98b2cabb0f9ea85c0ba1e090a6608de824f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTConstantExpressionEnumerationMemberReference.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 "WHLSLLexer.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class ConstantExpressionEnumerationMemberReference : public Node { >+public: >+ ConstantExpressionEnumerationMemberReference(Lexer::Token&& origin, String&& left, String&& right) >+ : m_origin(WTFMove(origin)) >+ , m_left(WTFMove(left)) >+ , m_right(WTFMove(right)) >+ { >+ } >+ >+ virtual ~ConstantExpressionEnumerationMemberReference() = default; >+ >+ explicit ConstantExpressionEnumerationMemberReference(const ConstantExpressionEnumerationMemberReference&) = default; >+ ConstantExpressionEnumerationMemberReference(ConstantExpressionEnumerationMemberReference&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+ String m_left; >+ String m_right; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTContinue.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTContinue.h >new file mode 100644 >index 0000000000000000000000000000000000000000..1681024e813c53d0ad2583cb6fe3c24bf5bd260d >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTContinue.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Continue : public Statement { >+public: >+ Continue(Lexer::Token&& origin) >+ : Statement(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~Continue() = default; >+ >+ Continue(const Continue&) = delete; >+ Continue(Continue&&) = default; >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..2d2f1717805536b570630ee2da3370258a507ee7 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDereferenceExpression.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" >+ >+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() = default; >+ >+ DereferenceExpression(const DereferenceExpression&) = delete; >+ DereferenceExpression(DereferenceExpression&&) = default; >+ >+private: >+ std::unique_ptr<Expression> m_pointer; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDoWhileLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDoWhileLoop.h >new file mode 100644 >index 0000000000000000000000000000000000000000..6cc69c27fea53528ab2ef9d5e068d52024e1701e >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDoWhileLoop.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class DoWhileLoop : public Statement { >+public: >+ DoWhileLoop(Lexer::Token&& origin, std::unique_ptr<Statement>&& body, std::unique_ptr<Expression>&& conditional) >+ : Statement(WTFMove(origin)) >+ , m_body(WTFMove(body)) >+ , m_conditional(WTFMove(conditional)) >+ { >+ } >+ >+ virtual ~DoWhileLoop() = default; >+ >+ DoWhileLoop(const DoWhileLoop&) = delete; >+ DoWhileLoop(DoWhileLoop&&) = default; >+ >+private: >+ std::unique_ptr<Statement> m_body; >+ std::unique_ptr<Expression> m_conditional; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..3ecafa2cb2ced72f84c4f97a96349179d7262d2a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDotExpression.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 "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() = default; >+ >+ DotExpression(const DotExpression&) = delete; >+ DotExpression(DotExpression&&) = default; >+ >+private: >+ String m_fieldName; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEffectfulExpressionStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEffectfulExpressionStatement.h >new file mode 100644 >index 0000000000000000000000000000000000000000..fd9aa730804e5e1c0d0e9ceb61b483ba9f6ee673 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEffectfulExpressionStatement.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class EffectfulExpressionStatement : public Statement { >+public: >+ EffectfulExpressionStatement(std::unique_ptr<Expression>&& effectfulExpression) >+ : Statement(Lexer::Token(effectfulExpression->origin())) >+ , m_effectfulExpression(WTFMove(effectfulExpression)) >+ { >+ } >+ >+ virtual ~EffectfulExpressionStatement() = default; >+ >+ EffectfulExpressionStatement(const EffectfulExpressionStatement&) = delete; >+ EffectfulExpressionStatement(EffectfulExpressionStatement&&) = default; >+ >+private: >+ std::unique_ptr<Expression> m_effectfulExpression; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..ab4c59c93851c43b495b5ab1f1271c14386dfe3a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumerationDefinition.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 "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() = default; >+ >+ EnumerationDefinition(const EnumerationDefinition&) = delete; >+ EnumerationDefinition(EnumerationDefinition&&) = default; >+ >+ std::unique_ptr<Type> clone() const override >+ { >+ ASSERT_NOT_REACHED(); >+ } >+ >+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..1ec91eabe9fb42f9897c83ebf2a2e48c9f0ef216 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTEnumerationMember.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 "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() = default; >+ >+ EnumerationMember(const EnumerationMember&) = delete; >+ EnumerationMember(EnumerationMember&&) = default; >+ >+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..82680321a3175b0b4c218cd68a30dd3fbc8673f2 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTExpression.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 "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() = default; >+ >+ explicit Expression(const Expression&) = default; >+ Expression(Expression&&) = default; >+ >+ Lexer::Token origin() const { return m_origin; } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFallthrough.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFallthrough.h >new file mode 100644 >index 0000000000000000000000000000000000000000..f7e3bb50186bd3900bf196402ee8c124a66843a9 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFallthrough.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Fallthrough : public Statement { >+public: >+ Fallthrough(Lexer::Token&& origin) >+ : Statement(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~Fallthrough() = default; >+ >+ Fallthrough(const Fallthrough&) = delete; >+ Fallthrough(Fallthrough&&) = default; >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..e450bd272895a7ccf34b039884b0603661052488 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFloatLiteral.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 "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() = default; >+ >+ explicit FloatLiteral(const FloatLiteral&) = default; >+ FloatLiteral(FloatLiteral&&) = default; >+ >+ float value() const { return m_value; } >+ >+private: >+ float m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTForLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTForLoop.h >new file mode 100644 >index 0000000000000000000000000000000000000000..226063847645d5f07621e68a2e3a9c517f9636ff >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTForLoop.h >@@ -0,0 +1,74 @@ >+/* >+ * 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 "WHLSLASTStatement.h" >+#include "WHLSLASTVariableDeclarationsStatement.h" >+#include "WHLSLLexer.h" >+#include <wtf/Variant.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class ForLoop : public Statement { >+public: >+ ForLoop(Lexer::Token&& origin, Variant<VariableDeclarationsStatement, std::unique_ptr<Expression>>&& initialization, std::unique_ptr<Expression>&& condition, std::unique_ptr<Expression>&& increment, std::unique_ptr<Statement>&& body) >+ : Statement(WTFMove(origin)) >+ , m_initialization(WTFMove(initialization)) >+ , m_condition(WTFMove(condition)) >+ , m_increment(WTFMove(increment)) >+ , m_body(WTFMove(body)) >+ { >+ } >+ >+ virtual ~ForLoop() >+ { >+ } >+ >+ ForLoop(const ForLoop&) = delete; >+ ForLoop(ForLoop&&) = default; >+ >+private: >+ Variant<VariableDeclarationsStatement, std::unique_ptr<Expression>> m_initialization; >+ std::unique_ptr<Expression> m_condition; // nullable >+ std::unique_ptr<Expression> m_increment; // nullable >+ std::unique_ptr<Statement> m_body; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..ff78c4d8b9a6fb009b09b9c105d60c44da5cea5d >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionDeclaration.h >@@ -0,0 +1,92 @@ >+/* >+ * 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() = default; >+ >+ FunctionDeclaration(const FunctionDeclaration&) = delete; >+ 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..8d7209a6c7f2751d889e447541233b8ee641de14 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTFunctionDefinition.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 "WHLSLASTBlock.h" >+#include "WHLSLASTFunctionDeclaration.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class FunctionDefinition : public FunctionDeclaration { >+public: >+ FunctionDefinition(FunctionDeclaration&& functionDeclaration, Block&& block, bool restricted) >+ : FunctionDeclaration(WTFMove(functionDeclaration)) >+ , m_block(WTFMove(block)) >+ , m_restricted(restricted) >+ { >+ } >+ >+ virtual ~FunctionDefinition() = default; >+ >+ FunctionDefinition(const FunctionDefinition&) = delete; >+ FunctionDefinition(FunctionDefinition&&) = default; >+ >+ bool restricted() const { return m_restricted; } >+ >+private: >+ Block m_block; >+ bool m_restricted; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIfStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIfStatement.h >new file mode 100644 >index 0000000000000000000000000000000000000000..18131e443b3168299c2f86cd5b9a4f22095513e4 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIfStatement.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 "WHLSLASTExpression.h" >+#include "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class IfStatement : public Statement { >+public: >+ IfStatement(Lexer::Token&& origin, std::unique_ptr<Expression>&& conditional, std::unique_ptr<Statement>&& body, std::unique_ptr<Statement>&& elseBody) >+ : Statement(WTFMove(origin)) >+ , m_conditional(WTFMove(conditional)) >+ , m_body(WTFMove(body)) >+ , m_elseBody(WTFMove(elseBody)) >+ { >+ } >+ >+ virtual ~IfStatement() = default; >+ >+ IfStatement(const IfStatement&) = delete; >+ IfStatement(IfStatement&&) = default; >+ >+private: >+ std::unique_ptr<Expression> m_conditional; >+ std::unique_ptr<Statement> m_body; >+ std::unique_ptr<Statement> m_elseBody; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..0412fa0fdc99a8217101346093a99a9b69ffdebe >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIndexExpression.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 "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() = default; >+ >+ IndexExpression(const IndexExpression&) = delete; >+ IndexExpression(IndexExpression&&) = default; >+ >+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..d6b51d18fceaf5155f94e8865877cfec02c4d0e2 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTIntegerLiteral.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 "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() = default; >+ >+ explicit IntegerLiteral(const IntegerLiteral&) = default; >+ IntegerLiteral(IntegerLiteral&&) = default; >+ >+ 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..77beb1e3b9103eca0d9917665c28aa6b1f71edaf >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTLogicalExpression.h >@@ -0,0 +1,73 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "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() = default; >+ >+ LogicalExpression(const LogicalExpression&) = delete; >+ LogicalExpression(LogicalExpression&&) = default; >+ >+ 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..8c93d8857613ad5ef7aa2b15de0d960c07061180 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTLogicalNotExpression.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" >+ >+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() = default; >+ >+ LogicalNotExpression(const LogicalNotExpression&) = delete; >+ LogicalNotExpression(LogicalNotExpression&&) = default; >+ >+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..10f8206e88a67187cf0d00c6520e65f3730f7b70 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTMakeArrayReferenceExpression.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" >+ >+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() = default; >+ >+ MakeArrayReferenceExpression(const MakeArrayReferenceExpression&) = delete; >+ MakeArrayReferenceExpression(MakeArrayReferenceExpression&&) = default; >+ >+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..69fa9240e10f3ee6537f19cfbf41f74de21c5337 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTMakePointerExpression.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" >+ >+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() = default; >+ >+ MakePointerExpression(const MakePointerExpression&) = delete; >+ MakePointerExpression(MakePointerExpression&&) = default; >+ >+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..1a7ea684d0f2801e94b7b943e7d5aa1ce1dd74be >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeFunctionDeclaration.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 "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() = default; >+ >+ NativeFunctionDeclaration(const NativeFunctionDeclaration&) = delete; >+ 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..c8050005dd1767882f30bec86374ad4ab0c0d449 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNativeTypeDeclaration.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 "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() = default; >+ >+ NativeTypeDeclaration(const NativeTypeDeclaration&) = delete; >+ NativeTypeDeclaration(NativeTypeDeclaration&&) = default; >+ >+ std::unique_ptr<Type> clone() const override >+ { >+ ASSERT_NOT_REACHED(); >+ } >+ >+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..f6c4f0060c04d7722fe64b2c31727b54b2b2e166 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNode.h >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Node { >+public: >+ Node() = default; >+ >+ virtual ~Node() = default; >+ >+ explicit Node(const Node&) = default; >+ Node(Node&&) = default; >+ >+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..5ba7f687e837ddba06b7c78ab53a444286754751 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNullLiteral.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 "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() = default; >+ >+ explicit NullLiteral(const NullLiteral&) = default; >+ NullLiteral(NullLiteral&&) = default; >+ >+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..eb1681d22a6227f6358e711560d4da10b35a4452 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTNumThreadsFunctionAttribute.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 "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() = default; >+ >+ NumThreadsFunctionAttribute(const NumThreadsFunctionAttribute&) = delete; >+ NumThreadsFunctionAttribute(NumThreadsFunctionAttribute&&) = default; >+ >+ 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..6b919fa5753e3f61bbfa21360370b8f0d2db8a26 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTParameter.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 "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() = default; >+ >+ Parameter(const Parameter&) = delete; >+ 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..4d4bf5cacf58b30367fcccd712e4a62b86d17bf8 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPointerType.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 "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() = default; >+ >+ PointerType(const PointerType&) = delete; >+ PointerType(PointerType&&) = default; >+ >+ std::unique_ptr<Type> clone() const override >+ { >+ return std::make_unique<PointerType>(Lexer::Token(origin()), String(addressSpace()), elementType()->clone()); >+ } >+ >+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..f12b3b28a21768cd0174743bc307ada97cb791c1 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTPropertyAccessExpression.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" >+ >+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() = default; >+ >+ PropertyAccessExpression(const PropertyAccessExpression&) = delete; >+ PropertyAccessExpression(PropertyAccessExpression&&) = default; >+ >+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..7814e58aa01aa9dd96bc2adfad70ce0eb6f659ec >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReadModifyWriteExpression.h >@@ -0,0 +1,99 @@ >+/* >+ * 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() = default; >+ >+ ReadModifyWriteExpression(const ReadModifyWriteExpression&) = delete; >+ ReadModifyWriteExpression(ReadModifyWriteExpression&&) = default; >+ >+ 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..701bbb1ba57df979bf9d09917b9b6bd41486f83b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReferenceType.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 "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() = default; >+ >+ ReferenceType(const ReferenceType&) = delete; >+ ReferenceType(ReferenceType&&) = default; >+ >+protected: >+ const Lexer::Token& origin() const { return m_origin; } >+ const String& addressSpace() const { return m_addressSpace; } >+ const std::unique_ptr<Type>& elementType() const { return m_elementType; } >+ >+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..811cece3486db42aed610512bbedbe844249b227 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTResourceSemantic.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 "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() = default; >+ >+ ResourceSemantic(const ResourceSemantic&) = delete; >+ ResourceSemantic(ResourceSemantic&&) = default; >+ >+ 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/WHLSLASTReturn.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReturn.h >new file mode 100644 >index 0000000000000000000000000000000000000000..10d786fcec6766f92d0f308d53d18cff9f750801 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTReturn.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Return : public Statement { >+public: >+ Return(Lexer::Token&& origin, std::unique_ptr<Expression>&& value) >+ : Statement(WTFMove(origin)) >+ , m_value(WTFMove(value)) >+ { >+ } >+ >+ virtual ~Return() = default; >+ >+ Return(const Return&) = delete; >+ Return(Return&&) = default; >+ >+private: >+ std::unique_ptr<Expression> m_value; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..07d9498c55f104337eb53960ab2ee97129df91e5 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSpecializationConstantSemantic.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 "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() = default; >+ >+ SpecializationConstantSemantic(const SpecializationConstantSemantic&) = delete; >+ SpecializationConstantSemantic(SpecializationConstantSemantic&&) = default; >+ >+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..5be924a7309a9804ea46287a39f38907cfc085d4 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStageInOutSemantic.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 "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() = default; >+ >+ StageInOutSemantic(const StageInOutSemantic&) = delete; >+ StageInOutSemantic(StageInOutSemantic&&) = default; >+ >+ unsigned index() const { return m_index; } >+ >+private: >+ unsigned m_index; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStatement.h >new file mode 100644 >index 0000000000000000000000000000000000000000..2686edff4d66dbe7ad33fe8f96273420bcb8451d >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStatement.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 "WHLSLASTValue.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Statement : public Value { >+public: >+ Statement(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~Statement() = default; >+ >+ Statement(const Statement&) = delete; >+ Statement(Statement&&) = default; >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..b1f0b4d0d9ad2be5674a9933ca92b8156c8c7160 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructureDefinition.h >@@ -0,0 +1,73 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "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() = default; >+ >+ StructureDefinition(const StructureDefinition&) = delete; >+ StructureDefinition(StructureDefinition&&) = default; >+ >+ std::unique_ptr<Type> clone() const override >+ { >+ ASSERT_NOT_REACHED(); >+ } >+ >+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..fc59990f120d0b2fd3a2175b220026fe74c049f5 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTStructureElement.h >@@ -0,0 +1,74 @@ >+/* >+ * 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() = default; >+ >+ StructureElement(const StructureElement&) = delete; >+ 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/WHLSLASTSwitchCase.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSwitchCase.h >new file mode 100644 >index 0000000000000000000000000000000000000000..b44d0ecf74eb01d783471d7c4bd0b9279cb19484 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSwitchCase.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 "WHLSLASTBlock.h" >+#include "WHLSLASTConstantExpression.h" >+#include "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+#include <wtf/Optional.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class SwitchCase : public Statement { >+public: >+ SwitchCase(Lexer::Token&& origin, std::optional<ConstantExpression>&& value, Block&& block) >+ : Statement(WTFMove(origin)) >+ , m_value(WTFMove(value)) >+ , m_block(WTFMove(block)) >+ { >+ } >+ >+ virtual ~SwitchCase() = default; >+ >+ SwitchCase(const SwitchCase&) = delete; >+ SwitchCase(SwitchCase&&) = default; >+ >+private: >+ std::optional<ConstantExpression> m_value; >+ Block m_block; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSwitchStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSwitchStatement.h >new file mode 100644 >index 0000000000000000000000000000000000000000..736ef1168481738dc07dcc646ec698ccef31d59c >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTSwitchStatement.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 "WHLSLASTExpression.h" >+#include "WHLSLASTStatement.h" >+#include "WHLSLASTSwitchCase.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class SwitchStatement : public Statement { >+public: >+ SwitchStatement(Lexer::Token&& origin, std::unique_ptr<Expression>&& value, Vector<SwitchCase>&& switchCases) >+ : Statement(WTFMove(origin)) >+ , m_value(WTFMove(value)) >+ , m_switchCases(WTFMove(switchCases)) >+ { >+ } >+ >+ virtual ~SwitchStatement() = default; >+ >+ SwitchStatement(const SwitchStatement&) = delete; >+ SwitchStatement(SwitchStatement&&) = default; >+ >+private: >+ std::unique_ptr<Expression> m_value; >+ Vector<SwitchCase> m_switchCases; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..cbfb5968a6dab9fd335c06f00254e6b66ca60d0d >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTernaryExpression.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 "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() = default; >+ >+ TernaryExpression(const TernaryExpression&) = delete; >+ TernaryExpression(TernaryExpression&&) = default; >+ >+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/WHLSLASTTrap.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTrap.h >new file mode 100644 >index 0000000000000000000000000000000000000000..577714b2596483e454028258bb835cc4362a6134 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTrap.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class Trap : public Statement { >+public: >+ Trap(Lexer::Token&& origin) >+ : Statement(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~Trap() = default; >+ >+ Trap(const Trap&) = delete; >+ Trap(Trap&&) = default; >+ >+private: >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..df6ecec669becef93a8fdf284cce16fd74017521 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTType.h >@@ -0,0 +1,58 @@ >+/* >+ * 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: >+ Type() = default; >+ >+ virtual ~Type() = default; >+ >+ Type(const Type&) = delete; >+ Type(Type&&) = default; >+ >+ virtual std::unique_ptr<Type> clone() const = 0; >+ >+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..a416896ad4a851582654e708500396c6b0d68c87 >--- /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, String> 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..724c2132ee6598df3b22861ba875d0ae4ffbed84 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeDefinition.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 "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)) >+ { >+ } >+ >+ virtual ~TypeDefinition() = default; >+ >+ TypeDefinition(const TypeDefinition&) = delete; >+ TypeDefinition(TypeDefinition&&) = default; >+ >+ std::unique_ptr<Type> clone() const override >+ { >+ ASSERT_NOT_REACHED(); >+ } >+ >+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..6bbab389950b0a4384ebf9d7888a776bafcbe0c4 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTTypeReference.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 "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() = default; >+ >+ TypeReference(const TypeReference&) = delete; >+ TypeReference(TypeReference&&) = default; >+ >+ std::unique_ptr<Type> clone() const override >+ { >+ return std::make_unique<TypeReference>(Lexer::Token(m_origin), String(m_name), TypeArguments(m_typeArguments)); >+ } >+ >+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..67b9c22793a8f11ae2db0c998cb9879c4369e99d >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTUnsignedIntegerLiteral.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 "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() = default; >+ >+ explicit UnsignedIntegerLiteral(const UnsignedIntegerLiteral&) = default; >+ UnsignedIntegerLiteral(UnsignedIntegerLiteral&&) = default; >+ >+ 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..bc7067eff72064c6b5b72ff8d6e9fbccbcb3deaf >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTValue.h >@@ -0,0 +1,58 @@ >+/* >+ * 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() = default; >+ >+ explicit Value(const Value&) = default; >+ Value(Value&&) = default; >+ >+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..1a9c81ace341f84e85f892d742a8a9757baf76c0 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDeclaration.h >@@ -0,0 +1,79 @@ >+/* >+ * 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 "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 VariableDeclaration : public Value { >+public: >+ VariableDeclaration(Lexer::Token&& origin, Qualifiers&& qualifiers, std::unique_ptr<AST::Type>&& type, String&& name, std::optional<Semantic>&& semantic, std::unique_ptr<Expression>&& initializer) >+ : m_origin(WTFMove(origin)) >+ , m_qualifiers(WTFMove(qualifiers)) >+ , m_type(WTFMove(type)) >+ , m_name(WTFMove(name)) >+ , m_semantic(WTFMove(semantic)) >+ , m_initializer(WTFMove(initializer)) >+ { >+ } >+ >+ virtual ~VariableDeclaration() = default; >+ >+ VariableDeclaration(const VariableDeclaration&) = delete; >+ VariableDeclaration(VariableDeclaration&&) = default; >+ >+ Lexer::Token origin() const { return m_origin; } >+ >+private: >+ Lexer::Token m_origin; >+ Qualifiers m_qualifiers; >+ std::unique_ptr<AST::Type> m_type; >+ String m_name; >+ std::optional<Semantic> m_semantic; >+ std::unique_ptr<Expression> m_initializer; >+}; >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDeclarationsStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDeclarationsStatement.h >new file mode 100644 >index 0000000000000000000000000000000000000000..30be3f45b98797861e14d84a1cb445d10ee6fd0b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableDeclarationsStatement.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 "WHLSLASTStatement.h" >+#include "WHLSLASTVariableDeclaration.h" >+#include "WHLSLLexer.h" >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class VariableDeclarationsStatement : public Statement { >+public: >+ VariableDeclarationsStatement(Lexer::Token&& origin, Vector<VariableDeclaration>&& variableDeclarations) >+ : Statement(WTFMove(origin)) >+ , m_variableDeclarations(WTFMove(variableDeclarations)) >+ { >+ } >+ >+ virtual ~VariableDeclarationsStatement() = default; >+ >+ VariableDeclarationsStatement(const VariableDeclarationsStatement&) = delete; >+ VariableDeclarationsStatement(VariableDeclarationsStatement&&) = default; >+ >+private: >+ Vector<VariableDeclaration>&& m_variableDeclarations; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..33b6fc61d5f8d13939aba9055ce937946f7f844f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTVariableReference.h >@@ -0,0 +1,85 @@ >+/* >+ * 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() = default; >+ >+ VariableReference(const VariableReference&) = delete; >+ VariableReference(VariableReference&&) = default; >+ >+ 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/WHLSLASTWhileLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTWhileLoop.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8aea2c1b2d9f98ed36fcd2b6ffdfa18ba7274839 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTWhileLoop.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 "WHLSLASTStatement.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class WhileLoop : public Statement { >+public: >+ WhileLoop(Lexer::Token&& origin, std::unique_ptr<Expression>&& conditional, std::unique_ptr<Statement>&& body) >+ : Statement(WTFMove(origin)) >+ , m_conditional(WTFMove(conditional)) >+ , m_body(WTFMove(body)) >+ { >+ } >+ >+ virtual ~WhileLoop() = default; >+ >+ WhileLoop(const WhileLoop&) = delete; >+ WhileLoop(WhileLoop&&) = default; >+ >+private: >+ std::unique_ptr<Expression> m_conditional; >+ std::unique_ptr<Statement> m_body; >+}; >+ >+} >+ >+} >+ >+} >+ >+#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..d997e6346abeb8205fbf5347ada6986adf39dc1d >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp >@@ -0,0 +1,595 @@ >+/* >+ * 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 = uintLiteral(m_offset)) >+ return prepare(*newOffset, Token::Type::UintLiteral); >+ 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 = hexadecimalIntLiteral(offset)) >+ return result; >+ return std::nullopt; >+} >+ >+std::optional<unsigned> Lexer::uintLiteral(unsigned offset) const >+{ >+ if (auto result = decimalUintLiteral(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') >+ ++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..81c3a50576a9da9f3e6b795ff607f1902d1e4e02 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h >@@ -0,0 +1,262 @@ >+/* >+ * 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 { >+ Token() = delete; >+ Token(const Token&) = default; >+ Token(Token&&) = default; >+ Token& operator=(const Token&) = default; >+ Token& operator=(Token&&) = default; >+ >+ StringView stringView; >+ enum class Type { >+ IntLiteral, >+ UintLiteral, >+ 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> uintLiteral(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..35f7caa9df38191ab7fabffe041513aca907f86f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >@@ -0,0 +1,2574 @@ >+/* >+ * 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 "WHLSLASTBreak.h" >+#include "WHLSLASTCallExpression.h" >+#include "WHLSLASTCommaExpression.h" >+#include "WHLSLASTContinue.h" >+#include "WHLSLASTDereferenceExpression.h" >+#include "WHLSLASTDotExpression.h" >+#include "WHLSLASTEffectfulExpressionStatement.h" >+#include "WHLSLASTFallthrough.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 "WHLSLASTReturn.h" >+#include "WHLSLASTTernaryExpression.h" >+#include "WHLSLASTTrap.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; >+} >+ >+static int digitValue(UChar character) >+{ >+ if (character >= '0' && character <= '9') >+ return character - '0'; >+ if (character >= 'a' && character <= 'f') >+ return character - 'a' + 10; >+ return character - 'A' + 10; >+} >+ >+static std::optional<int> intLiteralToInt(StringView text) >+{ >+ bool negate = false; >+ if (text.startsWith(String("-", String::ConstructFromLiteral))) { >+ negate = true; >+ text = text.substring(1); >+ } >+ int base = 10; >+ if (text.startsWith(String("0x", String::ConstructFromLiteral))) { >+ text = text.substring(2); >+ base = 16; >+ } >+ >+ int result = 0; >+ for (unsigned i = 0; i < text.length(); ++i) { >+ int digit = digitValue(text[i]); >+ auto previous = result; >+ result = result * base + digit; >+ if (result < previous) // FIXME: overflow on signed integers is undefined >+ return std::nullopt; >+ } >+ if (negate) >+ result *= -1; >+ // FIXME: This algorithm makes it impossible to represent 0x800000 (the most negative representable value) >+ return { result }; >+} >+ >+static std::optional<unsigned> uintLiteralToUint(StringView text) >+{ >+ unsigned base = 10; >+ if (text.startsWith(String("0x", String::ConstructFromLiteral))) { >+ text = text.substring(2); >+ base = 16; >+ } >+ ASSERT(text.substring(text.length() - 1) == "u"); >+ text = text.substring(0, text.length() - 1); >+ unsigned result = 0; >+ for (unsigned i = 0; i < text.length(); ++i) { >+ unsigned digit = digitValue(text[i]); >+ auto previous = result; >+ result = result * base + digit; >+ if (result < previous) >+ return std::nullopt; >+ } >+ return { result }; >+} >+ >+static std::optional<float> floatLiteralToFloat(StringView text) >+{ >+ bool negate = false; >+ if (text.length() > 0 && text[0] == '-') { >+ negate = true; >+ text = text.substring(1); >+ } >+ if (text.length() > 0 && text[text.length() - 1] == 'f') >+ text = text.substring(0, text.length() - 1); >+ float result; >+ unsigned index = 0; >+ for (index = 0; index < text.length() && text[index] != '.'; ++index) { >+ ASSERT(text[index] >= 0 && text[index] <= 9); >+ result = result * 10 + (text[index] - '0'); >+ } >+ ASSERT(index < text.length()); >+ ASSERT(text[index] == '.'); >+ float decimal = 1.0f / 10.0f; >+ for (++index; index < text.length(); ++index) { >+ ASSERT(text[index] >= 0 && text[index] <= 9); >+ result += decimal * (text[index] - '0'); >+ decimal /= 10.0f; >+ } >+ if (negate) >+ result *= -1; >+ return result; >+} >+ >+std::optional<Variant<int, unsigned>> Parser::consumeIntegralLiteral() >+{ >+ auto integralLiteralToken = consumeTypes({ Lexer::Token::Type::IntLiteral, Lexer::Token::Type::UintLiteral }); >+ if (!integralLiteralToken) >+ return std::nullopt; >+ >+ switch (integralLiteralToken->type) { >+ case Lexer::Token::Type::IntLiteral: >+ if (auto result = intLiteralToInt(integralLiteralToken->stringView)) >+ return {{ *result }}; >+ return std::nullopt; >+ case Lexer::Token::Type::UintLiteral: >+ if (auto result = uintLiteralToUint(integralLiteralToken->stringView)) >+ return {{ *result }}; >+ return std::nullopt; >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+} >+ >+std::optional<unsigned> Parser::consumeNonNegativeIntegralLiteral() >+{ >+ auto integralLiteral = consumeIntegralLiteral(); >+ if (!integralLiteral) >+ return std::nullopt; >+ return WTF::visit(WTF::makeVisitor([](int x) -> std::optional<unsigned> { >+ return x; >+ }, [](unsigned x) -> std::optional<unsigned> { >+ if (x < 0) >+ return std::nullopt; >+ return x; >+ }), *integralLiteral); >+} >+ >+static std::optional<unsigned> recognizeSimpleUnsignedInteger(StringView stringView) >+{ >+ unsigned result = 0; >+ for (unsigned i = 0; i < stringView.length(); ++i) { >+ if (stringView[i] < '0' || stringView[i] > '9') >+ return std::nullopt; >+ auto previous = result; >+ result = result * 10 + (stringView[i] - '0'); >+ if (result < previous) >+ return std::nullopt; >+ } >+ return result; >+} >+ >+std::optional<AST::ConstantExpression> Parser::parseConstantExpression() >+{ >+ auto type = consumeTypes({ >+ Lexer::Token::Type::IntLiteral, >+ Lexer::Token::Type::UintLiteral, >+ Lexer::Token::Type::FloatLiteral, >+ Lexer::Token::Type::Null, >+ Lexer::Token::Type::True, >+ Lexer::Token::Type::False, >+ Lexer::Token::Type::Identifier, >+ }); >+ if (!type) >+ return std::nullopt; >+ >+ switch (type->type) { >+ case Lexer::Token::Type::IntLiteral: { >+ auto value = intLiteralToInt(type->stringView); >+ if (!value) >+ return std::nullopt; >+ return {{ AST::IntegerLiteral(WTFMove(*type), *value) }}; >+ } >+ case Lexer::Token::Type::UintLiteral: { >+ auto value = uintLiteralToUint(type->stringView); >+ if (!value) >+ return std::nullopt; >+ return {{ AST::UnsignedIntegerLiteral(WTFMove(*type), *value) }}; >+ } >+ case Lexer::Token::Type::FloatLiteral: { >+ auto value = floatLiteralToFloat(type->stringView); >+ if (!value) >+ return std::nullopt; >+ return {{ AST::FloatLiteral(WTFMove(*type), *value) }}; >+ } >+ case Lexer::Token::Type::Null: >+ return { AST::NullLiteral(WTFMove(*type)) }; >+ case Lexer::Token::Type::True: >+ return { AST::BooleanLiteral(WTFMove(*type), true) }; >+ case Lexer::Token::Type::False: >+ return { AST::BooleanLiteral(WTFMove(*type), false) }; >+ case Lexer::Token::Type::Identifier: { >+ auto origin = consumeType(Lexer::Token::Type::FullStop); >+ if (!origin) >+ return std::nullopt; >+ auto next = consumeType(Lexer::Token::Type::Identifier); >+ if (!next) >+ return std::nullopt; >+ return { AST::ConstantExpressionEnumerationMemberReference(WTFMove(*origin), type->stringView.toString(), next->stringView.toString()) }; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+} >+ >+std::optional<AST::TypeArgument> Parser::parseTypeArgument() >+{ >+ auto constantExpression = backtrackingScope<std::optional<AST::ConstantExpression>>([&]() -> std::optional<AST::ConstantExpression> { >+ return parseConstantExpression(); >+ }); >+ if (constantExpression) { >+ AST::TypeArgument result = WTFMove(*constantExpression); >+ return result; >+ } >+ if (peekType(Lexer::Token::Type::Identifier)) >+ return { consumeType(Lexer::Token::Type::Identifier)->stringView.toString() }; >+ 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) { >+ auto result = WTFMove(*typeArguments); >+ return result; >+ } >+ >+ 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) { >+ auto result = WTFMove(*typeArguments); >+ return result; >+ } >+ >+ return {{ }}; >+} >+ >+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 numElements = consumeNonNegativeIntegralLiteral(); >+ if (!numElements) >+ return std::nullopt; >+ 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 numElements = consumeNonNegativeIntegralLiteral(); >+ if (!numElements) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::RightSquareBracket)) >+ return std::nullopt; >+ return {{ *token, 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(); >+ } >+ }; >+ >+ // FIXME: Do this more elegantly >+ 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 = consumeNonNegativeIntegralLiteral(); >+ if (!target) >+ return std::nullopt; >+ return AST::BuiltInSemantic(WTFMove(*origin), AST::BuiltInSemantic::Variable::SVTarget, *target); >+ } >+ 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 index = recognizeSimpleUnsignedInteger(info->stringView.substring(1)); >+ if (!index) >+ return std::nullopt; >+ >+ 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 = recognizeSimpleUnsignedInteger(spaceToken->stringView.substring(prefix.length())); >+ if (!spaceValue) >+ return std::nullopt; >+ space = *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 = consumeNonNegativeIntegralLiteral(); >+ if (!index) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ return AST::StageInOutSemantic(WTFMove(*origin), *index); >+} >+ >+std::optional<AST::Semantic> Parser::parseSemantic() >+{ >+ auto builtInSemantic = backtrackingScope<std::optional<AST::BuiltInSemantic>>([&]() -> std::optional<AST::BuiltInSemantic> { >+ return parseBuiltInSemantic(); >+ }); >+ if (builtInSemantic) { >+ AST::Semantic result = WTFMove(*builtInSemantic); >+ return result; >+ } >+ >+ auto resourceSemantic = backtrackingScope<std::optional<AST::ResourceSemantic>>([&]() -> std::optional<AST::ResourceSemantic> { >+ return parseResourceSemantic(); >+ }); >+ if (resourceSemantic) { >+ AST::Semantic result = WTFMove(*resourceSemantic); >+ return result; >+ } >+ >+ auto specializationConstantSemantic = backtrackingScope<std::optional<AST::SpecializationConstantSemantic>>([&]() -> std::optional<AST::SpecializationConstantSemantic> { >+ return parseSpecializationConstantSemantic(); >+ }); >+ if (specializationConstantSemantic) { >+ AST::Semantic result = WTFMove(*specializationConstantSemantic); >+ return result; >+ } >+ >+ auto stageInOutSemantic = backtrackingScope<std::optional<AST::StageInOutSemantic>>([&]() -> std::optional<AST::StageInOutSemantic> { >+ return parseStageInOutSemantic(); >+ }); >+ if (stageInOutSemantic) { >+ AST::Semantic result = WTFMove(*stageInOutSemantic); >+ return result; >+ } >+ >+ 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; >+ >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto semantic = parseSemantic(); >+ if (!semantic) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ >+ return AST::StructureElement(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), name->stringView.toString(), WTFMove(*semantic)); >+ } >+ >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ >+ return AST::StructureElement(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), name->stringView.toString(), std::nullopt); >+} >+ >+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 width = consumeNonNegativeIntegralLiteral(); >+ if (!width) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::Comma)) >+ return std::nullopt; >+ >+ auto height = consumeNonNegativeIntegralLiteral(); >+ if (!height) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::Comma)) >+ return std::nullopt; >+ >+ auto depth = consumeNonNegativeIntegralLiteral(); >+ if (!depth) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ 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(); >+ } >+ >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto semantic = parseSemantic(); >+ if (!semantic) >+ return std::nullopt; >+ return AST::Parameter(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), WTFMove(name), WTFMove(*semantic)); >+ } >+ >+ return AST::Parameter(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), WTFMove(name), std::nullopt); >+} >+ >+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::FunctionDefinition> Parser::parseFunctionDefinition() >+{ >+ bool restricted = false; >+ if (peekType(Lexer::Token::Type::Restricted)) { >+ auto restrictedValue = consumeType(Lexer::Token::Type::Restricted); >+ restricted = true; >+ } >+ >+ auto functionDeclaration = parseFunctionDeclaration(); >+ if (!functionDeclaration) >+ return std::nullopt; >+ >+ auto block = parseBlock(); >+ if (!block) >+ return std::nullopt; >+ >+ return AST::FunctionDefinition(WTFMove(*functionDeclaration), WTFMove(*block), restricted); >+} >+ >+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 = WTFMove(*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; >+ >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto semantic = parseSemantic(); >+ if (!semantic) >+ return std::nullopt; >+ return AST::FunctionDeclaration(WTFMove(*origin), WTFMove(attributeBlock), entryPointType, WTFMove(type), name->stringView.toString(), WTFMove(*parameters), WTFMove(*semantic)); >+ } >+ >+ return AST::FunctionDeclaration(WTFMove(*origin), WTFMove(attributeBlock), entryPointType, WTFMove(type), name->stringView.toString(), WTFMove(*parameters), std::nullopt); >+} >+ >+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; >+ >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto semantic = parseSemantic(); >+ if (!semantic) >+ return std::nullopt; >+ return AST::FunctionDeclaration(WTFMove(*origin), { }, std::nullopt, WTFMove(type), name->stringView.toString(), WTFMove(*parameters), WTFMove(*semantic)); >+ } >+ >+ return AST::FunctionDeclaration(WTFMove(*origin), { }, std::nullopt, WTFMove(type), name->stringView.toString(), WTFMove(*parameters), std::nullopt); >+} >+ >+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; >+ >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto semantic = parseSemantic(); >+ if (!semantic) >+ return std::nullopt; >+ return AST::FunctionDeclaration(WTFMove(*origin), { }, std::nullopt, WTFMove(type), String("Operator Cast", String::ConstructFromLiteral), WTFMove(*parameters), WTFMove(*semantic)); >+ } >+ >+ return AST::FunctionDeclaration(WTFMove(*origin), { }, std::nullopt, WTFMove(type), String("Operator Cast", String::ConstructFromLiteral), WTFMove(*parameters), std::nullopt); >+} >+ >+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; >+ if (peekType(Lexer::Token::Type::Restricted)) { >+ auto 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::optional<AST::Block> Parser::parseBlock() >+{ >+ auto origin = consumeType(Lexer::Token::Type::LeftCurlyBracket); >+ if (!origin) >+ return std::nullopt; >+ >+ auto result = parseBlockBody(WTFMove(*origin)); >+ >+ if (!consumeType(Lexer::Token::Type::RightCurlyBracket)) >+ return std::nullopt; >+ >+ return result; >+} >+ >+AST::Block Parser::parseBlockBody(Lexer::Token&& origin) >+{ >+ Vector<std::unique_ptr<AST::Statement>> statements; >+ while (true) { >+ auto statement = backtrackingScope<std::unique_ptr<AST::Statement>>([&]() -> std::unique_ptr<AST::Statement> { >+ return parseStatement(); >+ }); >+ if (statement) >+ statements.append(WTFMove(statement)); >+ else >+ break; >+ } >+ return AST::Block(WTFMove(origin), WTFMove(statements)); >+} >+ >+std::optional<AST::IfStatement> Parser::parseIfStatement() >+{ >+ auto origin = consumeType(Lexer::Token::Type::If); >+ if (!origin) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ auto conditional = parseExpression(); >+ if (!conditional) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ auto body = parseStatement(); >+ if (!body) >+ return std::nullopt; >+ >+ std::unique_ptr<AST::Statement> elseBody; >+ if (peekType(Lexer::Token::Type::Else)) { >+ consumeType(Lexer::Token::Type::Else); >+ elseBody = parseStatement(); >+ if (!elseBody) >+ return std::nullopt; >+ } >+ >+ return AST::IfStatement(WTFMove(*origin), WTFMove(conditional), WTFMove(body), WTFMove(elseBody)); >+} >+ >+std::optional<AST::SwitchStatement> Parser::parseSwitchStatement() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Switch); >+ if (!origin) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ auto value = parseExpression(); >+ if (!value) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftCurlyBracket)) >+ return std::nullopt; >+ >+ Vector<AST::SwitchCase> switchCases; >+ while (true) { >+ auto switchCase = backtrackingScope<std::optional<AST::SwitchCase>>([&]() -> std::optional<AST::SwitchCase> { >+ return parseSwitchCase(); >+ }); >+ if (switchCase) >+ switchCases.append(WTFMove(*switchCase)); >+ else >+ break; >+ } >+ >+ return AST::SwitchStatement(WTFMove(*origin), WTFMove(value), WTFMove(switchCases)); >+} >+ >+std::optional<AST::SwitchCase> Parser::parseSwitchCase() >+{ >+ auto origin = consumeTypes({ Lexer::Token::Type::Case, Lexer::Token::Type::Default }); >+ if (!origin) >+ return std::nullopt; >+ >+ switch (origin->type) { >+ case Lexer::Token::Type::Case: { >+ auto value = parseConstantExpression(); >+ if (!value) >+ return std::nullopt; >+ >+ auto origin = consumeType(Lexer::Token::Type::Colon); >+ if (!origin) >+ return std::nullopt; >+ >+ auto block = parseBlockBody(Lexer::Token(*origin)); >+ >+ return AST::SwitchCase(WTFMove(*origin), WTFMove(*value), WTFMove(block)); >+ } >+ case Lexer::Token::Type::Default: { >+ auto origin = consumeType(Lexer::Token::Type::Colon); >+ if (!origin) >+ return std::nullopt; >+ >+ auto block = parseBlockBody(Lexer::Token(*origin)); >+ >+ return AST::SwitchCase(WTFMove(*origin), std::nullopt, WTFMove(block)); >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+} >+ >+std::optional<AST::ForLoop> Parser::parseForLoop() >+{ >+ auto origin = consumeType(Lexer::Token::Type::For); >+ if (!origin) >+ return std::nullopt; >+ >+ auto parseRemainder = [&](Variant<AST::VariableDeclarationsStatement, std::unique_ptr<AST::Expression>>&& initialization) -> std::optional<AST::ForLoop> { >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ >+ auto condition = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parseExpression(); >+ }); >+ >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ >+ auto increment = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parseExpression(); >+ }); >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ auto body = parseStatement(); >+ if (!body) >+ return std::nullopt; >+ >+ return AST::ForLoop(WTFMove(*origin), WTFMove(initialization), WTFMove(condition), WTFMove(increment), WTFMove(body)); >+ }; >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ auto variableDeclarations = backtrackingScope<std::optional<AST::VariableDeclarationsStatement>>([&]() -> std::optional<AST::VariableDeclarationsStatement> { >+ return parseVariableDeclarations(); >+ }); >+ if (variableDeclarations) >+ return parseRemainder(WTFMove(*variableDeclarations)); >+ >+ auto effectfulExpression = parseEffectfulExpression(); >+ if (!effectfulExpression) >+ return std::nullopt; >+ >+ return parseRemainder(WTFMove(effectfulExpression)); >+} >+ >+std::optional<AST::WhileLoop> Parser::parseWhileLoop() >+{ >+ auto origin = consumeType(Lexer::Token::Type::While); >+ if (!origin) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ auto conditional = parseExpression(); >+ if (!conditional) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ auto body = parseStatement(); >+ if (!body) >+ return std::nullopt; >+ >+ return AST::WhileLoop(WTFMove(*origin), WTFMove(conditional), WTFMove(body)); >+} >+ >+std::optional<AST::DoWhileLoop> Parser::parseDoWhileLoop() >+{ >+ auto origin = consumeType(Lexer::Token::Type::Do); >+ if (!origin) >+ return std::nullopt; >+ >+ auto body = parseStatement(); >+ if (!body) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::While)) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return std::nullopt; >+ >+ auto conditional = parseExpression(); >+ if (!conditional) >+ return std::nullopt; >+ >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return std::nullopt; >+ >+ return AST::DoWhileLoop(WTFMove(*origin), WTFMove(body), WTFMove(conditional)); >+} >+ >+std::optional<AST::VariableDeclaration> Parser::parseVariableDeclaration(std::unique_ptr<AST::Type>&& type) >+{ >+ auto origin = peek(); >+ if (!origin) >+ return std::nullopt; >+ >+ auto qualifiers = parseQualifiers(); >+ >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return std::nullopt; >+ >+ if (peekType(Lexer::Token::Type::Colon)) { >+ auto semantic = parseSemantic(); >+ if (!semantic) >+ return std::nullopt; >+ >+ if (peekType(Lexer::Token::Type::EqualsSign)) { >+ auto initializer = parseExpression(); >+ if (!initializer) >+ return std::nullopt; >+ return AST::VariableDeclaration(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), name->stringView.toString(), WTFMove(*semantic), WTFMove(initializer)); >+ } >+ >+ return AST::VariableDeclaration(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), name->stringView.toString(), WTFMove(*semantic), nullptr); >+ } >+ >+ if (peekType(Lexer::Token::Type::EqualsSign)) { >+ auto initializer = parseExpression(); >+ if (!initializer) >+ return std::nullopt; >+ return AST::VariableDeclaration(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), name->stringView.toString(), std::nullopt, WTFMove(initializer)); >+ } >+ >+ return AST::VariableDeclaration(WTFMove(*origin), WTFMove(qualifiers), WTFMove(type), name->stringView.toString(), std::nullopt, nullptr); >+} >+ >+std::optional<AST::VariableDeclarationsStatement> Parser::parseVariableDeclarations() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return std::nullopt; >+ >+ auto type = parseType(); >+ if (!type) >+ return std::nullopt; >+ >+ auto firstVariableDeclaration = parseVariableDeclaration(std::unique_ptr<AST::Type>(type->clone())); >+ if (!firstVariableDeclaration) >+ return std::nullopt; >+ >+ Vector<AST::VariableDeclaration> result; >+ result.append(WTFMove(*firstVariableDeclaration)); >+ >+ while (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto variableDeclaration = parseVariableDeclaration(std::unique_ptr<AST::Type>(type->clone())); >+ if (!variableDeclaration) >+ return std::nullopt; >+ result.append(WTFMove(*variableDeclaration)); >+ } >+ >+ return AST::VariableDeclarationsStatement(WTFMove(*origin), WTFMove(result)); >+} >+ >+std::unique_ptr<AST::Statement> Parser::parseStatement() >+{ >+ { >+ auto block = backtrackingScope<std::optional<AST::Block>>([&]() -> std::optional<AST::Block> { >+ return parseBlock(); >+ }); >+ if (block) >+ return std::make_unique<AST::Block>(WTFMove(*block)); >+ } >+ >+ { >+ auto ifStatement = backtrackingScope<std::optional<AST::IfStatement>>([&]() -> std::optional<AST::IfStatement> { >+ return parseIfStatement(); >+ }); >+ if (ifStatement) >+ return std::make_unique<AST::IfStatement>(WTFMove(*ifStatement)); >+ } >+ >+ { >+ auto switchStatement = backtrackingScope<std::optional<AST::SwitchStatement>>([&]() -> std::optional<AST::SwitchStatement> { >+ return parseSwitchStatement(); >+ }); >+ if (switchStatement) >+ return std::make_unique<AST::SwitchStatement>(WTFMove(*switchStatement)); >+ } >+ >+ { >+ auto forLoop = backtrackingScope<std::optional<AST::ForLoop>>([&]() -> std::optional<AST::ForLoop> { >+ return parseForLoop(); >+ }); >+ if (forLoop) >+ return std::make_unique<AST::ForLoop>(WTFMove(*forLoop)); >+ } >+ >+ { >+ auto whileLoop = backtrackingScope<std::optional<AST::WhileLoop>>([&]() -> std::optional<AST::WhileLoop> { >+ return parseWhileLoop(); >+ }); >+ if (whileLoop) >+ return std::make_unique<AST::WhileLoop>(WTFMove(*whileLoop)); >+ } >+ >+ { >+ auto doWhileLoop = backtrackingScope<std::optional<AST::DoWhileLoop>>([&]() -> std::optional<AST::DoWhileLoop> { >+ auto result = parseDoWhileLoop(); >+ if (!result) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ return result; >+ }); >+ if (doWhileLoop) >+ return std::make_unique<AST::DoWhileLoop>(WTFMove(*doWhileLoop)); >+ } >+ >+ { >+ auto breakObject = backtrackingScope<std::optional<AST::Break>>([&]() -> std::optional<AST::Break> { >+ auto origin = consumeType(Lexer::Token::Type::Break); >+ if (!origin) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ return AST::Break(WTFMove(*origin)); >+ }); >+ if (breakObject) >+ return std::make_unique<AST::Break>(WTFMove(*breakObject)); >+ } >+ >+ { >+ auto continueObject = backtrackingScope<std::optional<AST::Continue>>([&]() -> std::optional<AST::Continue> { >+ auto origin = consumeType(Lexer::Token::Type::Continue); >+ if (!origin) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ return AST::Continue(WTFMove(*origin)); >+ }); >+ if (continueObject) >+ return std::make_unique<AST::Continue>(WTFMove(*continueObject)); >+ } >+ >+ { >+ auto fallthroughObject = backtrackingScope<std::optional<AST::Fallthrough>>([&]() -> std::optional<AST::Fallthrough> { >+ auto origin = consumeType(Lexer::Token::Type::Fallthrough); >+ if (!origin) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ return AST::Fallthrough(WTFMove(*origin)); >+ }); >+ if (fallthroughObject) >+ return std::make_unique<AST::Fallthrough>(WTFMove(*fallthroughObject)); >+ } >+ >+ { >+ auto trapObject = backtrackingScope<std::optional<AST::Trap>>([&]() -> std::optional<AST::Trap> { >+ auto origin = consumeType(Lexer::Token::Type::Trap); >+ if (!origin) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ return AST::Trap(WTFMove(*origin)); >+ }); >+ if (trapObject) >+ return std::make_unique<AST::Trap>(WTFMove(*trapObject)); >+ } >+ >+ { >+ auto returnObject = backtrackingScope<std::optional<AST::Return>>([&]() -> std::optional<AST::Return> { >+ auto origin = consumeType(Lexer::Token::Type::Return); >+ if (!origin) >+ return std::nullopt; >+ if (peekType(Lexer::Token::Type::Semicolon)) { >+ consumeType(Lexer::Token::Type::Semicolon); >+ return AST::Return(WTFMove(*origin), nullptr); >+ } >+ auto expression = parseExpression(); >+ if (!expression) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ return AST::Return(WTFMove(*origin), WTFMove(expression)); >+ }); >+ if (returnObject) >+ return std::make_unique<AST::Return>(WTFMove(*returnObject)); >+ } >+ >+ { >+ auto variableDeclarations = backtrackingScope<std::optional<AST::VariableDeclarationsStatement>>([&]() -> std::optional<AST::VariableDeclarationsStatement> { >+ auto result = parseVariableDeclarations(); >+ if (!result) >+ return std::nullopt; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return std::nullopt; >+ return result; >+ }); >+ if (variableDeclarations) >+ return std::make_unique<AST::VariableDeclarationsStatement>(WTFMove(*variableDeclarations)); >+ } >+ >+ { >+ auto effectfulExpression = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ auto result = parseEffectfulExpression(); >+ if (!result) >+ return nullptr; >+ if (!consumeType(Lexer::Token::Type::Semicolon)) >+ return nullptr; >+ return result; >+ }); >+ if (effectfulExpression) >+ return std::make_unique<AST::EffectfulExpressionStatement>(WTFMove(effectfulExpression)); >+ } >+ >+ return nullptr; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseEffectfulExpression() >+{ >+ auto origin = peek(); >+ if (!origin) >+ return nullptr; >+ >+ Vector<std::unique_ptr<AST::Expression>> expressions; >+ >+ auto first = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parseEffectfulAssignment(); >+ }); >+ if (!first) >+ return std::make_unique<AST::CommaExpression>(WTFMove(*origin), WTFMove(expressions)); >+ >+ expressions.append(WTFMove(first)); >+ >+ while (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto expression = parseEffectfulAssignment(); >+ 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::parseEffectfulAssignment() >+{ >+ auto assignment = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parseAssignment(); >+ }); >+ if (assignment) >+ return assignment; >+ >+ assignment = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parseEffectfulPrefix(); >+ }); >+ if (assignment) >+ return assignment; >+ >+ return nullptr; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseEffectfulPrefix() >+{ >+ auto prefix = consumeTypes({ Lexer::Token::Type::PlusPlus, Lexer::Token::Type::MinusMinus }); >+ if (!prefix) >+ return nullptr; >+ >+ auto previous = parsePossiblePrefix(); >+ if (!previous) >+ return nullptr; >+ >+ switch (prefix->type) { >+ case Lexer::Token::Type::PlusPlus: { >+ 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>(WTFMove(*prefix), String("operator++", String::ConstructFromLiteral), WTFMove(callArguments))); >+ result->setResultExpression(result->newVariableReference()); >+ return result; >+ } >+ case Lexer::Token::Type::MinusMinus: { >+ 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>(WTFMove(*prefix), String("operator--", String::ConstructFromLiteral), WTFMove(callArguments))); >+ result->setResultExpression(result->newVariableReference()); >+ return result; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseEffectfulSuffix() >+{ >+ auto effectfulSuffix = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ auto previous = parsePossibleSuffix(); >+ if (!previous) >+ return nullptr; >+ >+ auto suffix = consumeTypes({ Lexer::Token::Type::PlusPlus, Lexer::Token::Type::MinusMinus }); >+ if (!suffix) >+ return nullptr; >+ >+ switch (suffix->type) { >+ case Lexer::Token::Type::PlusPlus: { >+ auto result = std::make_unique<AST::ReadModifyWriteExpression>(Lexer::Token(*suffix), WTFMove(previous)); >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(result->oldVariableReference()); >+ result->setNewValueExpression(std::make_unique<AST::CallExpression>(WTFMove(*suffix), String("operator++", String::ConstructFromLiteral), WTFMove(callArguments))); >+ result->setResultExpression(result->oldVariableReference()); >+ return result; >+ } >+ case Lexer::Token::Type::MinusMinus: { >+ auto result = std::make_unique<AST::ReadModifyWriteExpression>(Lexer::Token(*suffix), WTFMove(previous)); >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(result->oldVariableReference()); >+ result->setNewValueExpression(std::make_unique<AST::CallExpression>(WTFMove(*suffix), String("operator--", String::ConstructFromLiteral), WTFMove(callArguments))); >+ result->setResultExpression(result->oldVariableReference()); >+ return result; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ }); >+ if (effectfulSuffix) >+ return effectfulSuffix; >+ >+ effectfulSuffix = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ return parseCallExpression(); >+ }); >+ if (effectfulSuffix) >+ return effectfulSuffix; >+ >+ effectfulSuffix = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return nullptr; >+ auto expression = parseExpression(); >+ if (!expression) >+ return nullptr; >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return nullptr; >+ return expression; >+ }); >+ if (effectfulSuffix) >+ return effectfulSuffix; >+ >+ return nullptr; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseLimitedSuffixOperator(std::unique_ptr<AST::Expression>&& previous) >+{ >+ auto type = consumeTypes({ Lexer::Token::Type::FullStop, Lexer::Token::Type::Arrow, Lexer::Token::Type::LeftSquareBracket }); >+ if (!type) >+ return nullptr; >+ >+ switch (type->type) { >+ case Lexer::Token::Type::FullStop: { >+ auto identifier = consumeType(Lexer::Token::Type::Identifier); >+ if (!identifier) >+ return nullptr; >+ return std::make_unique<AST::DotExpression>(WTFMove(*type), WTFMove(previous), identifier->stringView.toString()); >+ } >+ case Lexer::Token::Type::Arrow: { >+ auto identifier = consumeType(Lexer::Token::Type::Identifier); >+ if (!identifier) >+ return nullptr; >+ return std::make_unique<AST::DotExpression>(Lexer::Token(*type), std::make_unique<AST::DereferenceExpression>(WTFMove(*type), WTFMove(previous)), identifier->stringView.toString()); >+ } >+ case Lexer::Token::Type::LeftSquareBracket: { >+ auto expression = parseExpression(); >+ if (!expression) >+ return nullptr; >+ if (!consumeType(Lexer::Token::Type::RightSquareBracket)) >+ return nullptr; >+ return std::make_unique<AST::IndexExpression>(WTFMove(*type), WTFMove(previous), WTFMove(expression)); >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseSuffixOperator(std::unique_ptr<AST::Expression>&& previous) >+{ >+ auto suffix = consumeTypes({ Lexer::Token::Type::FullStop, Lexer::Token::Type::Arrow, Lexer::Token::Type::LeftSquareBracket, Lexer::Token::Type::PlusPlus, Lexer::Token::Type::MinusMinus }); >+ if (!suffix) >+ return nullptr; >+ >+ switch (suffix->type) { >+ case Lexer::Token::Type::FullStop: { >+ auto identifier = consumeType(Lexer::Token::Type::Identifier); >+ if (!identifier) >+ return nullptr; >+ return std::make_unique<AST::DotExpression>(WTFMove(*suffix), WTFMove(previous), identifier->stringView.toString()); >+ } >+ case Lexer::Token::Type::Arrow: { >+ auto identifier = consumeType(Lexer::Token::Type::Identifier); >+ if (!identifier) >+ return nullptr; >+ return std::make_unique<AST::DotExpression>(Lexer::Token(*suffix), std::make_unique<AST::DereferenceExpression>(WTFMove(*suffix), WTFMove(previous)), identifier->stringView.toString()); >+ } >+ case Lexer::Token::Type::LeftSquareBracket: { >+ auto expression = parseExpression(); >+ if (!expression) >+ return nullptr; >+ if (!consumeType(Lexer::Token::Type::RightSquareBracket)) >+ return nullptr; >+ return std::make_unique<AST::IndexExpression>(WTFMove(*suffix), WTFMove(previous), WTFMove(expression)); >+ } >+ case Lexer::Token::Type::PlusPlus: { >+ auto result = std::make_unique<AST::ReadModifyWriteExpression>(Lexer::Token(*suffix), WTFMove(previous)); >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(result->oldVariableReference()); >+ result->setNewValueExpression(std::make_unique<AST::CallExpression>(WTFMove(*suffix), String("operator++", String::ConstructFromLiteral), WTFMove(callArguments))); >+ result->setResultExpression(result->oldVariableReference()); >+ return result; >+ } >+ case Lexer::Token::Type::MinusMinus: { >+ auto result = std::make_unique<AST::ReadModifyWriteExpression>(Lexer::Token(*suffix), WTFMove(previous)); >+ Vector<std::unique_ptr<AST::Expression>> callArguments; >+ callArguments.append(result->oldVariableReference()); >+ result->setNewValueExpression(std::make_unique<AST::CallExpression>(WTFMove(*suffix), String("operator--", String::ConstructFromLiteral), WTFMove(callArguments))); >+ result->setResultExpression(result->oldVariableReference()); >+ return result; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+} >+ >+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() >+{ >+ // FIXME: Do this more elegantly >+ 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() >+{ >+ auto suffix = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ auto expression = parseCallExpression(); >+ if (!expression) >+ return nullptr; >+ >+ while (true) { >+ expression = parseLimitedSuffixOperator(WTFMove(expression)); >+ if (!expression) >+ return nullptr; >+ } >+ return expression; >+ }); >+ if (suffix) >+ return suffix; >+ >+ suffix = backtrackingScope<std::unique_ptr<AST::Expression>>([&]() -> std::unique_ptr<AST::Expression> { >+ auto expression = parseTerm(); >+ if (!expression) >+ return nullptr; >+ >+ while (true) { >+ expression = parseSuffixOperator(WTFMove(expression)); >+ if (!expression) >+ return nullptr; >+ } >+ return expression; >+ }); >+ if (suffix) >+ return suffix; >+ >+ return nullptr; >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseCallExpression() >+{ >+ auto name = consumeType(Lexer::Token::Type::Identifier); >+ if (!name) >+ return nullptr; >+ auto callName = name->stringView.toString(); >+ >+ if (!consumeType(Lexer::Token::Type::LeftParenthesis)) >+ return nullptr; >+ >+ Vector<std::unique_ptr<AST::Expression>> arguments; >+ if (peekType(Lexer::Token::Type::RightParenthesis)) { >+ consumeType(Lexer::Token::Type::RightParenthesis); >+ return std::make_unique<AST::CallExpression>(WTFMove(*name), WTFMove(callName), WTFMove(arguments)); >+ } >+ >+ auto firstArgument = parsePossibleTernaryConditional(); >+ if (!firstArgument) >+ return nullptr; >+ arguments.append(WTFMove(firstArgument)); >+ while (peekType(Lexer::Token::Type::Comma)) { >+ consumeType(Lexer::Token::Type::Comma); >+ auto argument = parsePossibleTernaryConditional(); >+ if (!argument) >+ return nullptr; >+ arguments.append(WTFMove(argument)); >+ } >+ return std::make_unique<AST::CallExpression>(WTFMove(*name), WTFMove(callName), WTFMove(arguments)); >+} >+ >+std::unique_ptr<AST::Expression> Parser::parseTerm() >+{ >+ auto type = consumeTypes({ >+ Lexer::Token::Type::IntLiteral, >+ Lexer::Token::Type::UintLiteral, >+ Lexer::Token::Type::FloatLiteral, >+ Lexer::Token::Type::Null, >+ Lexer::Token::Type::True, >+ Lexer::Token::Type::False, >+ Lexer::Token::Type::Identifier, >+ Lexer::Token::Type::LeftParenthesis >+ }); >+ if (!type) >+ return nullptr; >+ >+ switch (type->type) { >+ case Lexer::Token::Type::IntLiteral: { >+ auto value = intLiteralToInt(type->stringView); >+ if (!value) >+ return nullptr; >+ return std::make_unique<AST::IntegerLiteral>(WTFMove(*type), *value); >+ } >+ case Lexer::Token::Type::UintLiteral: { >+ auto value = uintLiteralToUint(type->stringView); >+ if (!value) >+ return nullptr; >+ return std::make_unique<AST::UnsignedIntegerLiteral>(WTFMove(*type), *value); >+ } >+ case Lexer::Token::Type::FloatLiteral: { >+ auto value = floatLiteralToFloat(type->stringView); >+ if (!value) >+ return nullptr; >+ return std::make_unique<AST::FloatLiteral>(WTFMove(*type), *value); >+ } >+ case Lexer::Token::Type::Null: >+ return std::make_unique<AST::NullLiteral>(WTFMove(*type)); >+ case Lexer::Token::Type::True: >+ return std::make_unique<AST::BooleanLiteral>(WTFMove(*type), true); >+ case Lexer::Token::Type::False: >+ return std::make_unique<AST::BooleanLiteral>(WTFMove(*type), false); >+ case Lexer::Token::Type::Identifier: { >+ auto name = type->stringView.toString(); >+ return std::make_unique<AST::VariableReference>(WTFMove(*type), WTFMove(name)); >+ } >+ case Lexer::Token::Type::LeftParenthesis: { >+ auto expression = parseExpression(); >+ if (!expression) >+ return nullptr; >+ if (!consumeType(Lexer::Token::Type::RightParenthesis)) >+ return nullptr; >+ return expression; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+} >+ >+} >+ >+} >+ >+#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..5cb41edb3dcca9f7e954b06786ea981affe8a67b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >@@ -0,0 +1,170 @@ >+/* >+ * 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 "WHLSLASTBlock.h" >+#include "WHLSLASTCommaExpression.h" >+#include "WHLSLASTConstantExpression.h" >+#include "WHLSLASTDoWhileLoop.h" >+#include "WHLSLASTExpression.h" >+#include "WHLSLASTForLoop.h" >+#include "WHLSLASTFunctionAttribute.h" >+#include "WHLSLASTFunctionDeclaration.h" >+#include "WHLSLASTFunctionDefinition.h" >+#include "WHLSLASTIfStatement.h" >+#include "WHLSLASTNativeTypeDeclaration.h" >+#include "WHLSLASTParameter.h" >+#include "WHLSLASTSemantic.h" >+#include "WHLSLASTStatement.h" >+#include "WHLSLASTStructureDefinition.h" >+#include "WHLSLASTStructureElement.h" >+#include "WHLSLASTSwitchCase.h" >+#include "WHLSLASTSwitchStatement.h" >+#include "WHLSLASTTypeArgument.h" >+#include "WHLSLASTTypeDefinition.h" >+#include "WHLSLASTVariableDeclaration.h" >+#include "WHLSLASTVariableDeclarationsStatement.h" >+#include "WHLSLASTWhileLoop.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<Variant<int, unsigned>> consumeIntegralLiteral(); >+ std::optional<unsigned> consumeNonNegativeIntegralLiteral(); >+ 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::FunctionDefinition> parseFunctionDefinition(); >+ std::optional<AST::NativeFunctionDeclaration> parseNativeFunctionDeclaration(); >+ >+ std::optional<AST::Block> parseBlock(); >+ AST::Block parseBlockBody(Lexer::Token&& origin); >+ std::optional<AST::IfStatement> parseIfStatement(); >+ std::optional<AST::SwitchStatement> parseSwitchStatement(); >+ std::optional<AST::SwitchCase> parseSwitchCase(); >+ std::optional<AST::ForLoop> parseForLoop(); >+ std::optional<AST::WhileLoop> parseWhileLoop(); >+ std::optional<AST::DoWhileLoop> parseDoWhileLoop(); >+ std::optional<AST::VariableDeclaration> parseVariableDeclaration(std::unique_ptr<AST::Type>&&); >+ std::optional<AST::VariableDeclarationsStatement> parseVariableDeclarations(); >+ std::unique_ptr<AST::Statement> parseStatement(); >+ >+ std::unique_ptr<AST::Expression> parseEffectfulExpression(); >+ std::unique_ptr<AST::Expression> parseEffectfulAssignment(); >+ std::unique_ptr<AST::Expression> parseEffectfulPrefix(); >+ std::unique_ptr<AST::Expression> parseEffectfulSuffix(); >+ std::unique_ptr<AST::Expression> parseLimitedSuffixOperator(std::unique_ptr<AST::Expression>&&); >+ std::unique_ptr<AST::Expression> parseSuffixOperator(std::unique_ptr<AST::Expression>&&); >+ >+ 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..7b609e53c247ae33a5b6e3103d076745c3bfceda >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >@@ -0,0 +1,79 @@ >+/* >+ * 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: >+ Program() = default; >+ Program(Program&&) = default; >+ >+ 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 b4bdb25b5170687440ba663f06a09bec401e0e2f..4bdb5a1cdcd4c6a52503d126c6c3a192893167bc 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/WebGPUBuffer.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index edeb4a8e7d6ea6e694b80609e0974a092395da51..170c73148ca74eb7d36c54302d8319a2fb56ddc6 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -6404,6 +6404,30 @@ > 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>"; }; >+ 1C80598D21C1FD74006B0906 /* WHLSLASTIfStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTIfStatement.h; sourceTree = "<group>"; }; >+ 1C80598F21C1FD83006B0906 /* WHLSLASTSwitchStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTSwitchStatement.h; sourceTree = "<group>"; }; >+ 1C80599021C1FDAD006B0906 /* WHLSLASTSwitchCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTSwitchCase.h; sourceTree = "<group>"; }; >+ 1C80599121C1FDC3006B0906 /* WHLSLASTForLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTForLoop.h; sourceTree = "<group>"; }; >+ 1C80599221C1FDDA006B0906 /* WHLSLASTWhileLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTWhileLoop.h; sourceTree = "<group>"; }; >+ 1C80599321C1FDE8006B0906 /* WHLSLASTDoWhileLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTDoWhileLoop.h; sourceTree = "<group>"; }; >+ 1C80599421C1FDFE006B0906 /* WHLSLASTBreak.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTBreak.h; sourceTree = "<group>"; }; >+ 1C80599521C1FE07006B0906 /* WHLSLASTContinue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTContinue.h; sourceTree = "<group>"; }; >+ 1C80599621C1FE14006B0906 /* WHLSLASTFallthrough.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTFallthrough.h; sourceTree = "<group>"; }; >+ 1C80599721C1FE20006B0906 /* WHLSLASTTrap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTTrap.h; sourceTree = "<group>"; }; >+ 1C80599821C1FE2E006B0906 /* WHLSLASTReturn.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTReturn.h; sourceTree = "<group>"; }; >+ 1C80599A21C1FEA0006B0906 /* WHLSLASTStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTStatement.h; sourceTree = "<group>"; }; >+ 1C80599C21C2009D006B0906 /* WHLSLASTBlock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTBlock.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>"; }; >@@ -6415,6 +6439,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>"; }; >@@ -13207,11 +13233,44 @@ > 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>"; }; >+ C22F76DD21C2508500C5434E /* WHLSLASTConstantExpressionEnumerationMemberReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTConstantExpressionEnumerationMemberReference.h; sourceTree = "<group>"; }; >+ C22F76DE21C2512800C5434E /* WHLSLASTConstantExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTConstantExpression.h; sourceTree = "<group>"; }; >+ C22F76DF21C26F4700C5434E /* WHLSLASTVariableDeclarationsStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTVariableDeclarationsStatement.h; sourceTree = "<group>"; }; >+ C22F76E021C26F5B00C5434E /* WHLSLASTEffectfulExpressionStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLASTEffectfulExpressionStatement.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; }; >@@ -13224,6 +13283,20 @@ > 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>"; }; >+ 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>"; }; >@@ -25191,6 +25264,86 @@ > 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 */, >+ 1C80599C21C2009D006B0906 /* WHLSLASTBlock.h */, >+ C22F76D021C0AA1400C5434E /* WHLSLASTBooleanLiteral.h */, >+ 1C80599421C1FDFE006B0906 /* WHLSLASTBreak.h */, >+ 1C80598021BF55BA006B0906 /* WHLSLASTBuiltInSemantic.h */, >+ C22F76C621C0A7BD00C5434E /* WHLSLASTCallExpression.h */, >+ C22F76C121C0A63E00C5434E /* WHLSLASTCommaExpression.h */, >+ C22F76DE21C2512800C5434E /* WHLSLASTConstantExpression.h */, >+ C22F76DD21C2508500C5434E /* WHLSLASTConstantExpressionEnumerationMemberReference.h */, >+ 1C80599521C1FE07006B0906 /* WHLSLASTContinue.h */, >+ C22F76C721C0A8CF00C5434E /* WHLSLASTDereferenceExpression.h */, >+ C22F76D121C0AA5300C5434E /* WHLSLASTDotExpression.h */, >+ 1C80599321C1FDE8006B0906 /* WHLSLASTDoWhileLoop.h */, >+ C22F76E021C26F5B00C5434E /* WHLSLASTEffectfulExpressionStatement.h */, >+ C2ECEB5621B64CAB008F8DE9 /* WHLSLASTEnumerationDefinition.h */, >+ C2ECEB7921BF8E05008F8DE9 /* WHLSLASTEnumerationMember.h */, >+ C22F76C021C0A45800C5434E /* WHLSLASTExpression.h */, >+ 1C80599621C1FE14006B0906 /* WHLSLASTFallthrough.h */, >+ C22F76CF21C0A9F100C5434E /* WHLSLASTFloatLiteral.h */, >+ 1C80599121C1FDC3006B0906 /* WHLSLASTForLoop.h */, >+ C274F13B21C03EBF003410BD /* WHLSLASTFunctionAttribute.h */, >+ C274F13521C032D6003410BD /* WHLSLASTFunctionDeclaration.h */, >+ C2ECEB5821B64CBE008F8DE9 /* WHLSLASTFunctionDefinition.h */, >+ 1C80598D21C1FD74006B0906 /* WHLSLASTIfStatement.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 */, >+ 1C80599821C1FE2E006B0906 /* WHLSLASTReturn.h */, >+ 1C80598721BF5781006B0906 /* WHLSLASTSemantic.h */, >+ 1C80598421BF55ED006B0906 /* WHLSLASTSpecializationConstantSemantic.h */, >+ 1C80598621BF5601006B0906 /* WHLSLASTStageInOutSemantic.h */, >+ 1C80599A21C1FEA0006B0906 /* WHLSLASTStatement.h */, >+ C2ECEB5421B64C97008F8DE9 /* WHLSLASTStructureDefinition.h */, >+ C2ECEB6C21BE4896008F8DE9 /* WHLSLASTStructureElement.h */, >+ 1C80599021C1FDAD006B0906 /* WHLSLASTSwitchCase.h */, >+ 1C80598F21C1FD83006B0906 /* WHLSLASTSwitchStatement.h */, >+ C22F76C221C0A6DE00C5434E /* WHLSLASTTernaryExpression.h */, >+ 1C80599721C1FE20006B0906 /* WHLSLASTTrap.h */, >+ C2ECEB6021B64DC6008F8DE9 /* WHLSLASTType.h */, >+ 1CC46F2921B77A32000998DE /* WHLSLASTTypeArgument.h */, >+ C2ECEB5221B64C84008F8DE9 /* WHLSLASTTypeDefinition.h */, >+ 1CC46F2721B77860000998DE /* WHLSLASTTypeReference.h */, >+ C22F76CE21C0A9C900C5434E /* WHLSLASTUnsignedIntegerLiteral.h */, >+ C274F13F21C04D57003410BD /* WHLSLASTValue.h */, >+ C2ECEB5021B64C72008F8DE9 /* WHLSLASTVariableDeclaration.h */, >+ C22F76DF21C26F4700C5434E /* WHLSLASTVariableDeclarationsStatement.h */, >+ C22F76CC21C0A9A700C5434E /* WHLSLASTVariableReference.h */, >+ 1C80599221C1FDDA006B0906 /* WHLSLASTWhileLoop.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 = ( >@@ -25533,6 +25686,7 @@ > D00F593E216ECC43000D71DB /* webgpu */ = { > isa = PBXGroup; > children = ( >+ C210E90D21B4BCA400B7F83D /* WHLSL */, > D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */, > D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */, > D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */, >@@ -25549,9 +25703,7 @@ > D0D8648E21B70676003C983C /* WebGPUBuffer.idl */, > D0D8648221B61727003C983C /* WebGPUBufferDescriptor.h */, > D0D8648321B61727003C983C /* WebGPUBufferDescriptor.idl */, >- D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */, > D063AE3F21C05DDD000E6A35 /* WebGPUBufferUsage.h */, >- D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */, > D063AE4021C05DDD000E6A35 /* WebGPUBufferUsage.idl */, > D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */, > D001D9AD21B0C81A0023B9BC /* WebGPUColor.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