WebKit Bugzilla
Attachment 358169 Details for
Bug 193007
: [WHLSL] Implement the NameResolver
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
patch.txt (text/plain), 233.09 KB, created by
Myles C. Maxfield
on 2019-01-01 00:41:14 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-01-01 00:41:14 PST
Size:
233.09 KB
patch
obsolete
>diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h >index 2d567f00e70..eb390e42e7f 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h >@@ -39,8 +39,8 @@ 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)) >+ ArrayReferenceType(Lexer::Token&& origin, AddressSpace addressSpace, std::unique_ptr<UnnamedType>&& elementType) >+ : ReferenceType(WTFMove(origin), addressSpace, WTFMove(elementType)) > { > } > >@@ -49,11 +49,11 @@ public: > ArrayReferenceType(const ArrayReferenceType&) = delete; > ArrayReferenceType(ArrayReferenceType&&) = default; > >- bool isArrayReferenceType() const override { return false; } >+ bool isArrayReferenceType() const override { return true; } > >- std::unique_ptr<Type> clone() const override >+ std::unique_ptr<UnnamedType> clone() const override > { >- return std::make_unique<ArrayReferenceType>(Lexer::Token(origin()), String(addressSpace()), elementType().clone()); >+ return std::make_unique<ArrayReferenceType>(Lexer::Token(origin()), addressSpace(), elementType().clone()); > } > > private: >@@ -65,6 +65,6 @@ private: > > } > >-SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(ArrayReferenceType, isArrayReferenceType()) >+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(ArrayReferenceType, isArrayReferenceType()) > > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h >index 40b5f8df6fe..a2871404cd5 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h >@@ -28,7 +28,7 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLLexer.h" >-#include "WHLSLType.h" >+#include "WHLSLUnnamedType.h" > #include "WHLSLTypeArgument.h" > #include <wtf/text/WTFString.h> > >@@ -38,10 +38,10 @@ namespace WHLSL { > > namespace AST { > >-class ArrayType : public Type { >+class ArrayType : public UnnamedType { > public: >- ArrayType(Lexer::Token&& origin, std::unique_ptr<Type>&& elementType, unsigned numElements) >- : m_origin(WTFMove(origin)) >+ ArrayType(Lexer::Token&& origin, std::unique_ptr<UnnamedType>&& elementType, unsigned numElements) >+ : UnnamedType(WTFMove(origin)) > , m_elementType(WTFMove(elementType)) > , m_numElements(numElements) > { >@@ -52,20 +52,19 @@ public: > ArrayType(const ArrayType&) = delete; > ArrayType(ArrayType&&) = default; > >- unsigned numElements() const { return m_numElements; } >- >- bool isArrayType() const override { return false; } >+ bool isArrayType() const override { return true; } > >- Type& type() { return *m_elementType; } >+ UnnamedType& type() { return *m_elementType; } >+ const UnnamedType& type() const { return *m_elementType; } >+ unsigned numElements() const { return m_numElements; } > >- std::unique_ptr<Type> clone() const override >+ std::unique_ptr<UnnamedType> clone() const override > { >- return std::make_unique<ArrayType>(Lexer::Token(m_origin), m_elementType->clone(), m_numElements); >+ return std::make_unique<ArrayType>(Lexer::Token(origin()), m_elementType->clone(), m_numElements); > } > > private: >- Lexer::Token m_origin; >- std::unique_ptr<Type> m_elementType; >+ std::unique_ptr<UnnamedType> m_elementType; > unsigned m_numElements; > }; > >@@ -75,6 +74,6 @@ private: > > } > >-SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(ArrayType, isArrayType()) >+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(ArrayType, isArrayType()) > > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h >index 64af713299c..8b2bdaf4bf6 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h >@@ -28,6 +28,7 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLExpression.h" >+#include "WHLSLFunctionDeclaration.h" > #include "WHLSLLexer.h" > > namespace WebCore { >@@ -54,9 +55,31 @@ public: > > Vector<std::unique_ptr<Expression>>& arguments() { return m_arguments; } > >+ String& name() { return m_name; } >+ >+ void setCastData() >+ { >+ // FIXME: Implement this >+ } >+ >+ bool hasOverloads() const { return static_cast<bool>(m_overloads); } >+ void setOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) >+ { >+ assert(!hasOverloads()); >+ m_overloads = overloads; >+ } >+ >+ void setFunction(FunctionDeclaration& functionDeclaration) >+ { >+ assert(!m_function); >+ m_function = &functionDeclaration; >+ } >+ > private: > String m_name; > Vector<std::unique_ptr<Expression>> m_arguments; >+ Optional<Vector<std::reference_wrapper<FunctionDeclaration>, 1>> m_overloads; >+ FunctionDeclaration* m_function { nullptr }; > }; > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >index a38b0d5b3a1..f042053247c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >@@ -76,11 +76,69 @@ public: > { > } > >+ IntegerLiteral& integerLiteral() >+ { >+ ASSERT(WTF::holds_alternative<IntegerLiteral>(m_variant)); >+ return WTF::get<IntegerLiteral>(m_variant); >+ } >+ > template<typename T> void visit(T&& t) > { > WTF::visit(WTFMove(t), m_variant); > } > >+ template<typename T> void visit(T&& t) const >+ { >+ WTF::visit(WTFMove(t), m_variant); >+ } >+ >+ bool matches(const ConstantExpression& other) const >+ { >+ Optional<bool> result; >+ double value; >+ visit(WTF::makeVisitor([&](const IntegerLiteral& integerLiteral) { >+ value = integerLiteral.value(); >+ }, [&](const UnsignedIntegerLiteral& unsignedIntegerLiteral) { >+ value = unsignedIntegerLiteral.value(); >+ }, [&](const FloatLiteral& floatLiteral) { >+ value = floatLiteral.value(); >+ }, [&](const NullLiteral&) { >+ result = WTF::holds_alternative<NullLiteral>(other.m_variant); >+ }, [&](const BooleanLiteral& booleanLiteral) { >+ if (WTF::holds_alternative<BooleanLiteral>(other.m_variant)) { >+ const auto& otherBooleanLiteral = WTF::get<BooleanLiteral>(other.m_variant); >+ result = booleanLiteral.value() == otherBooleanLiteral.value(); >+ } else >+ result = false; >+ }, [&](const ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) { >+ if (WTF::holds_alternative<ConstantExpressionEnumerationMemberReference>(other.m_variant)) { >+ const auto& otherMemberReference = WTF::get<ConstantExpressionEnumerationMemberReference>(other.m_variant); >+ result = &constantExpressionEnumerationMemberReference.enumerationMember() == &otherMemberReference.enumerationMember(); >+ } else >+ result = false; >+ })); >+ >+ if (result) >+ return *result; >+ >+ other.visit(WTF::makeVisitor([&](const IntegerLiteral& integerLiteral) { >+ result = value == integerLiteral.value(); >+ }, [&](const UnsignedIntegerLiteral& unsignedIntegerLiteral) { >+ result = value == unsignedIntegerLiteral.value(); >+ }, [&](const FloatLiteral& floatLiteral) { >+ result = value == floatLiteral.value(); >+ }, [&](const NullLiteral&) { >+ result = false; >+ }, [&](const BooleanLiteral&) { >+ result = false; >+ }, [&](const ConstantExpressionEnumerationMemberReference&) { >+ result = false; >+ })); >+ >+ ASSERT(result); >+ return *result; >+ } >+ > private: > Variant< > IntegerLiteral, >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h >index 2c24a98b2ca..2100d7ca40a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h >@@ -36,10 +36,12 @@ namespace WHLSL { > > namespace AST { > >-class ConstantExpressionEnumerationMemberReference : public Node { >+class EnumerationMember; >+ >+class ConstantExpressionEnumerationMemberReference : public Expression { > public: > ConstantExpressionEnumerationMemberReference(Lexer::Token&& origin, String&& left, String&& right) >- : m_origin(WTFMove(origin)) >+ : Expression(WTFMove(origin)) > , m_left(WTFMove(left)) > , m_right(WTFMove(right)) > { >@@ -50,10 +52,30 @@ public: > explicit ConstantExpressionEnumerationMemberReference(const ConstantExpressionEnumerationMemberReference&) = default; > ConstantExpressionEnumerationMemberReference(ConstantExpressionEnumerationMemberReference&&) = default; > >+ const String& left() const { return m_left; } >+ const String& right() const { return m_right; } >+ >+ AST::EnumerationMember& enumerationMember() >+ { >+ ASSERT(m_enumerationMember); >+ return *m_enumerationMember; >+ } >+ >+ const AST::EnumerationMember& enumerationMember() const >+ { >+ ASSERT(m_enumerationMember); >+ return *m_enumerationMember; >+ } >+ >+ void setEnumerationMember(AST::EnumerationMember& enumerationMember) >+ { >+ m_enumerationMember = &enumerationMember; >+ } >+ > private: >- Lexer::Token m_origin; > String m_left; > String m_right; >+ AST::EnumerationMember* m_enumerationMember { nullptr }; > }; > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h >index c43c69ee541..ebf72326cd0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h >@@ -49,6 +49,25 @@ public: > DotExpression(const DotExpression&) = delete; > DotExpression(DotExpression&&) = default; > >+ bool isDotExpression() const override { return true; } >+ >+ String getFunctionName() const override >+ { >+ return String::format("operator.%s", m_fieldName.utf8().data()); >+ } >+ >+ String setFunctionName() const override >+ { >+ return String::format("operator.%s=", m_fieldName.utf8().data()); >+ } >+ >+ String andFunctionName() const override >+ { >+ return String::format("operator&.%s", m_fieldName.utf8().data()); >+ } >+ >+ String& fieldName() { return m_fieldName; } >+ > private: > String m_fieldName; > }; >@@ -59,4 +78,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(DotExpression, isDotExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h >index 7970b59e54a..24a8d59db3a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h >@@ -29,8 +29,11 @@ > > #include "WHLSLEnumerationMember.h" > #include "WHLSLLexer.h" >-#include "WHLSLType.h" >+#include "WHLSLNamedType.h" >+#include "WHLSLUnnamedType.h" >+#include <wtf/HashMap.h> > #include <wtf/Vector.h> >+#include <wtf/text/StringHash.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -39,13 +42,11 @@ namespace WHLSL { > > namespace AST { > >-class EnumerationDefinition : public Node { >+class EnumerationDefinition : public NamedType { > public: >- EnumerationDefinition(Lexer::Token&& origin, String&& name, std::unique_ptr<Type>&& type, EnumerationMembers&& members) >- : m_origin(WTFMove(origin)) >- , m_name(WTFMove(name)) >+ EnumerationDefinition(Lexer::Token&& origin, String&& name, std::unique_ptr<UnnamedType>&& type) >+ : NamedType(WTFMove(origin), WTFMove(name)) > , m_type(WTFMove(type)) >- , m_members(WTFMove(members)) > { > } > >@@ -54,14 +55,35 @@ public: > EnumerationDefinition(const EnumerationDefinition&) = delete; > EnumerationDefinition(EnumerationDefinition&&) = default; > >- Type& type() { return *m_type; } >- EnumerationMembers& enumerationMembers() { return m_members; } >+ bool isEnumerationDefinition() const override { return true; } >+ >+ UnnamedType& type() { return *m_type; } >+ >+ bool add(EnumerationMember&& member) >+ { >+ auto result = m_members.add(member.name(), std::make_unique<EnumerationMember>(WTFMove(member))); >+ return !result.isNewEntry; >+ } >+ >+ EnumerationMember* memberByName(const String& name) >+ { >+ auto iterator = m_members.find(name); >+ if (iterator == m_members.end()) >+ return nullptr; >+ return iterator->value.get(); >+ } >+ >+ Vector<std::reference_wrapper<EnumerationMember>> enumerationMembers() >+ { >+ Vector<std::reference_wrapper<EnumerationMember>> result; >+ for (auto& pair : m_members) >+ result.append(*pair.value); >+ return result; >+ } > > private: >- Lexer::Token m_origin; >- String m_name; >- std::unique_ptr<Type> m_type; >- EnumerationMembers m_members; >+ std::unique_ptr<UnnamedType> m_type; >+ HashMap<String, std::unique_ptr<EnumerationMember>> m_members; > }; > > } >@@ -70,4 +92,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(EnumerationDefinition, isEnumerationDefinition()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h >index 9d9d854883e..4f385195508 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h >@@ -54,6 +54,7 @@ public: > EnumerationMember(const EnumerationMember&) = delete; > EnumerationMember(EnumerationMember&&) = default; > >+ String& name() { return m_name; } > Optional<ConstantExpression>& value() { return m_value; } > > private: >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h >new file mode 100644 >index 00000000000..c9e96293980 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.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 "WHLSLEnumerationMember.h" >+#include "WHLSLExpression.h" >+#include "WHLSLLexer.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class EnumerationMemberLiteral : public Expression { >+public: >+ EnumerationMemberLiteral(Lexer::Token&& origin, EnumerationMember& enumerationMember) >+ : Expression(WTFMove(origin)) >+ , m_enumerationMember(enumerationMember) >+ { >+ } >+ >+ virtual ~EnumerationMemberLiteral() = default; >+ >+ explicit EnumerationMemberLiteral(const EnumerationMemberLiteral&) = default; >+ EnumerationMemberLiteral(EnumerationMemberLiteral&&) = default; >+ >+ bool isEnumerationMemberLiteral() const override { return true; } >+ >+ EnumerationMember& enumerationMember() { return m_enumerationMember; } >+ >+private: >+ EnumerationMember& m_enumerationMember; >+}; >+ >+} >+ >+} >+ >+} >+ >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(EnumerationMemberLiteral, isEnumerationMemberLiteral()) >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h >index e368383646d..a7886fba6b0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h >@@ -55,7 +55,9 @@ public: > virtual bool isCallExpression() const { return false; } > virtual bool isCommaExpression() const { return false; } > virtual bool isDereferenceExpression() const { return false; } >+ virtual bool isDotExpression() const { return false; } > virtual bool isFloatLiteral() const { return false; } >+ virtual bool isIndexExpression() const { return false; } > virtual bool isIntegerLiteral() const { return false; } > virtual bool isLogicalExpression() const { return false; } > virtual bool isLogicalNotExpression() const { return false; } >@@ -67,6 +69,7 @@ public: > virtual bool isTernaryExpression() const { return false; } > virtual bool isUnsignedIntegerLiteral() const { return false; } > virtual bool isVariableReference() const { return false; } >+ virtual bool isEnumerationMemberLiteral() const { return false; } > > private: > Lexer::Token m_origin; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h >index 7a7e0a0656c..8235666d940 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h >@@ -30,9 +30,9 @@ > #include "WHLSLFunctionAttribute.h" > #include "WHLSLLexer.h" > #include "WHLSLNode.h" >-#include "WHLSLParameter.h" > #include "WHLSLSemantic.h" >-#include "WHLSLType.h" >+#include "WHLSLUnnamedType.h" >+#include "WHLSLVariableDeclaration.h" > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -49,7 +49,7 @@ public: > Compute > }; > >- FunctionDeclaration(Lexer::Token&& origin, AttributeBlock&& attributeBlock, Optional<EntryPointType> entryPointType, std::unique_ptr<AST::Type>&& type, String&& name, Parameters&& parameters, Optional<AST::Semantic>&& semantic) >+ FunctionDeclaration(Lexer::Token&& origin, AttributeBlock&& attributeBlock, Optional<EntryPointType> entryPointType, std::unique_ptr<AST::UnnamedType>&& type, String&& name, VariableDeclarations&& parameters, Optional<AST::Semantic>&& semantic) > : m_origin(WTFMove(origin)) > , m_attributeBlock(WTFMove(attributeBlock)) > , m_entryPointType(entryPointType) >@@ -65,26 +65,34 @@ public: > FunctionDeclaration(const FunctionDeclaration&) = delete; > FunctionDeclaration(FunctionDeclaration&&) = default; > >+ virtual bool isFunctionDefinition() const { return false; } >+ virtual bool isNativeFunctionDeclaration() const { return false; } >+ > AttributeBlock& attributeBlock() { return m_attributeBlock; } >- AST::Type& type() { return *m_type; } >- Parameters& parameters() { return m_parameters; } >+ const AST::UnnamedType& type() const { return *m_type; } >+ AST::UnnamedType& type() { return *m_type; } >+ const String& name() const { return m_name; } >+ String& name() { return m_name; } >+ bool isCast() const { return m_name == "operator cast"; } >+ const VariableDeclarations& parameters() const { return m_parameters; } >+ VariableDeclarations& parameters() { return m_parameters; } > Optional<AST::Semantic>& semantic() { return m_semantic; } > > Lexer::Token&& takeOrigin() { return WTFMove(m_origin); } > AttributeBlock&& takeAttributeBlock() { return WTFMove(m_attributeBlock); } > Optional<EntryPointType>&& takeEntryPointType() { return WTFMove(m_entryPointType); } >- std::unique_ptr<AST::Type>&& takeType() { return WTFMove(m_type); } >+ std::unique_ptr<AST::UnnamedType>&& takeType() { return WTFMove(m_type); } > String&& takeName() { return WTFMove(m_name); } >- Parameters&& takeParameters() { return WTFMove(m_parameters); } >+ VariableDeclarations&& takeParameters() { return WTFMove(m_parameters); } > Optional<AST::Semantic>&& takeSemantic() { return WTFMove(m_semantic); } > > private: > Lexer::Token m_origin; > AttributeBlock m_attributeBlock; > Optional<EntryPointType> m_entryPointType; >- std::unique_ptr<AST::Type> m_type; >+ std::unique_ptr<UnnamedType> m_type; > String m_name; >- Parameters m_parameters; >+ VariableDeclarations m_parameters; > Optional<AST::Semantic> m_semantic; > }; > >@@ -94,4 +102,9 @@ private: > > } > >+#define SPECIALIZE_TYPE_TRAITS_WHLSL_FUNCTION_DECLARATION(ToValueTypeName, predicate) \ >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \ >+ static bool isType(const WebCore::WHLSL::AST::FunctionDeclaration& type) { return type.predicate; } \ >+SPECIALIZE_TYPE_TRAITS_END() >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h >index a4907b0d298..b6b7ba077d3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h >@@ -50,6 +50,8 @@ public: > FunctionDefinition(const FunctionDefinition&) = delete; > FunctionDefinition(FunctionDefinition&&) = default; > >+ bool isFunctionDefinition() const override { return true; } >+ > Block& block() { return m_block; } > bool restricted() const { return m_restricted; } > >@@ -64,4 +66,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_FUNCTION_DECLARATION(FunctionDefinition, isFunctionDefinition()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h >index 6bb6a0f0dab..43e60a10498 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h >@@ -49,6 +49,25 @@ public: > IndexExpression(const IndexExpression&) = delete; > IndexExpression(IndexExpression&&) = default; > >+ bool isIndexExpression() const override { return true; } >+ >+ String getFunctionName() const override >+ { >+ return String("operator[]", String::ConstructFromLiteral); >+ } >+ >+ String setFunctionName() const override >+ { >+ return String("operator&[]", String::ConstructFromLiteral); >+ } >+ >+ String andFunctionName() const override >+ { >+ return String("operator[]=", String::ConstructFromLiteral); >+ } >+ >+ Expression& indexExpression() { return *m_index; } >+ > private: > std::unique_ptr<Expression> m_index; > }; >@@ -59,4 +78,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(IndexExpression, isIndexExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLParameter.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNamedType.h >similarity index 61% >rename from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLParameter.h >rename to Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNamedType.h >index 92586f8691f..2447ec74ee2 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLParameter.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNamedType.h >@@ -28,11 +28,8 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLLexer.h" >-#include "WHLSLQualifier.h" >-#include "WHLSLSemantic.h" >+#include "WHLSLNode.h" > #include "WHLSLType.h" >-#include "WHLSLValue.h" >-#include <wtf/Vector.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -41,39 +38,46 @@ namespace WHLSL { > > namespace AST { > >-class Parameter : public Value { >+class NamedType : public Type { > public: >- Parameter(Lexer::Token&& origin, Qualifiers&& qualifiers, std::unique_ptr<AST::Type>&& type, Optional<String>&& name, Optional<AST::Semantic>&& semantic) >+ NamedType(Lexer::Token&& origin, String&& name) > : m_origin(WTFMove(origin)) >- , m_qualifiers(WTFMove(qualifiers)) >- , m_type(WTFMove(type)) > , m_name(WTFMove(name)) >- , m_semantic(WTFMove(semantic)) > { > } > >- virtual ~Parameter() = default; >+ virtual ~NamedType() = default; > >- Parameter(const Parameter&) = delete; >- Parameter(Parameter&&) = default; >+ NamedType(const NamedType&) = delete; >+ NamedType(NamedType&&) = default; > >- Type& type() { return *m_type; } >- Optional<AST::Semantic>& semantic() { return m_semantic; } >+ Lexer::Token& origin() { return m_origin; } >+ String& name() { return m_name; } >+ >+ bool isNamedType() const override { return true; } >+ virtual bool isTypeDefinition() const { return false; } >+ virtual bool isStructureDefinition() const { return false; } >+ virtual bool isEnumerationDefinition() const { return false; } >+ virtual bool isNativeTypeDeclaration() const { return false; } >+ >+ virtual const Type& unifyNode() const { return *this; } > > private: > Lexer::Token m_origin; >- Qualifiers m_qualifiers; >- std::unique_ptr<AST::Type> m_type; >- Optional<String> m_name; >- Optional<AST::Semantic> m_semantic; >+ String m_name; > }; > >-typedef Vector<Parameter> Parameters; >- > } > > } > > } > >+#define SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(ToValueTypeName, predicate) \ >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \ >+ static bool isType(const WebCore::WHLSL::AST::NamedType& type) { return type.predicate; } \ >+SPECIALIZE_TYPE_TRAITS_END() >+ >+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(NamedType, isNamedType()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h >index 010e6eba700..244e841011c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h >@@ -37,7 +37,7 @@ namespace AST { > > class NativeFunctionDeclaration : public FunctionDeclaration { > public: >- NativeFunctionDeclaration(Lexer::Token&& origin, AttributeBlock&& attributeBlock, Optional<EntryPointType> entryPointType, std::unique_ptr<AST::Type>&& type, String&& name, Parameters&& parameters, Optional<AST::Semantic>&& semantic, bool restricted) >+ NativeFunctionDeclaration(Lexer::Token&& origin, AttributeBlock&& attributeBlock, Optional<EntryPointType> entryPointType, std::unique_ptr<AST::UnnamedType>&& type, String&& name, VariableDeclarations&& parameters, Optional<AST::Semantic>&& semantic, bool restricted) > : FunctionDeclaration(WTFMove(origin), WTFMove(attributeBlock), WTFMove(entryPointType), WTFMove(type), WTFMove(name), WTFMove(parameters), WTFMove(semantic)) > , m_restricted(restricted) > { >@@ -48,6 +48,8 @@ public: > NativeFunctionDeclaration(const NativeFunctionDeclaration&) = delete; > NativeFunctionDeclaration(NativeFunctionDeclaration&&) = default; > >+ bool isNativeFunctionDeclaration() const override { return true; } >+ > bool restricted() const { return m_restricted; } > > private: >@@ -60,4 +62,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_FUNCTION_DECLARATION(NativeFunctionDeclaration, isNativeFunctionDeclaration()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >index 320abc3c475..6ed98ec7413 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >@@ -28,7 +28,7 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLLexer.h" >-#include "WHLSLType.h" >+#include "WHLSLNamedType.h" > #include "WHLSLTypeArgument.h" > #include <wtf/text/WTFString.h> > >@@ -38,11 +38,10 @@ namespace WHLSL { > > namespace AST { > >-class NativeTypeDeclaration : public Type { >+class NativeTypeDeclaration : public NamedType { > public: > NativeTypeDeclaration(Lexer::Token&& origin, String&& name, TypeArguments&& typeArguments) >- : m_origin(WTFMove(origin)) >- , m_name(WTFMove(name)) >+ : NamedType(WTFMove(origin), WTFMove(name)) > , m_typeArguments(WTFMove(typeArguments)) > { > } >@@ -52,16 +51,13 @@ public: > NativeTypeDeclaration(const NativeTypeDeclaration&) = delete; > NativeTypeDeclaration(NativeTypeDeclaration&&) = default; > >- TypeArguments& typeArguments() { return m_typeArguments; } >+ bool isNativeTypeDeclaration() const override { return true; } > >- std::unique_ptr<Type> clone() const override >- { >- ASSERT_NOT_REACHED(); >- return nullptr; >- } >+ const String& name() const { return m_name; } >+ String& name() { return m_name; } >+ TypeArguments& typeArguments() { return m_typeArguments; } > > private: >- Lexer::Token m_origin; > String m_name; > TypeArguments m_typeArguments; > }; >@@ -72,4 +68,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(NativeTypeDeclaration, isNativeTypeDeclaration()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h >index 1529426a2ed..63c2093c50e 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h >@@ -39,8 +39,8 @@ 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)) >+ PointerType(Lexer::Token&& origin, AddressSpace addressSpace, std::unique_ptr<UnnamedType> elementType) >+ : ReferenceType(WTFMove(origin), addressSpace, WTFMove(elementType)) > { > } > >@@ -49,11 +49,11 @@ public: > PointerType(const PointerType&) = delete; > PointerType(PointerType&&) = default; > >- bool isPointerType() const override { return false; } >+ bool isPointerType() const override { return true; } > >- std::unique_ptr<Type> clone() const override >+ std::unique_ptr<UnnamedType> clone() const override > { >- return std::make_unique<PointerType>(Lexer::Token(origin()), String(addressSpace()), elementType().clone()); >+ return std::make_unique<PointerType>(Lexer::Token(origin()), addressSpace(), elementType().clone()); > } > > private: >@@ -65,6 +65,6 @@ private: > > } > >-SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(PointerType, isPointerType()) >+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(PointerType, isPointerType()) > > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h >index ba38a5c01ea..d05a72c1fc5 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h >@@ -51,10 +51,30 @@ public: > > bool isPropertyAccessExpression() const override { return true; } > >+ virtual String getFunctionName() const = 0; >+ virtual String setFunctionName() const = 0; >+ virtual String andFunctionName() const = 0; >+ >+ void setPossibleGetOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) >+ { >+ m_possibleGetOverloads = overloads; >+ } >+ void setPossibleSetOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) >+ { >+ m_possibleSetOverloads = overloads; >+ } >+ void setPossibleAndOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) >+ { >+ m_possibleAndOverloads = overloads; >+ } >+ > Expression& base() { return *m_base; } > > private: > std::unique_ptr<Expression> m_base; >+ Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleGetOverloads; >+ Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleSetOverloads; >+ Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleAndOverloads; > }; > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h >index a4c14ce1cf3..cd556320db0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h >@@ -27,7 +27,7 @@ > > #if ENABLE(WEBGPU) > >-#include "WHLSLAnonymousVariableDeclaration.h" >+#include "WHLSLVariableDeclaration.h" > #include "WHLSLExpression.h" > #include "WHLSLLexer.h" > #include "WHLSLVariableReference.h" >@@ -52,8 +52,8 @@ 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)) >+ , m_oldValue(Lexer::Token(origin), Qualifiers(), nullptr, String(), WTF::nullopt, nullptr) >+ , m_newValue(WTFMove(origin), Qualifiers(), nullptr, String(), WTF::nullopt, nullptr) > { > } > >@@ -87,15 +87,15 @@ public: > bool isReadModifyWriteExpression() const override { return true; } > > Expression& lValue() { return *m_lValue; } >- AnonymousVariableDeclaration& oldValue() { return m_oldValue; } >- AnonymousVariableDeclaration& newValue() { return m_newValue; } >+ VariableDeclaration& oldValue() { return m_oldValue; } >+ VariableDeclaration& newValue() { return m_newValue; } > Expression& newValueExpression() { return *m_newValueExpression; } > Expression& resultExpression() { return *m_resultExpression; } > > private: > std::unique_ptr<Expression> m_lValue; >- AnonymousVariableDeclaration m_oldValue; >- AnonymousVariableDeclaration m_newValue; >+ VariableDeclaration m_oldValue; >+ VariableDeclaration m_newValue; > std::unique_ptr<Expression> m_newValueExpression; > std::unique_ptr<Expression> m_resultExpression; > }; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h >index 2257f9be240..4e69f79b8e5 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h >@@ -28,7 +28,7 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLLexer.h" >-#include "WHLSLType.h" >+#include "WHLSLUnnamedType.h" > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -37,11 +37,18 @@ namespace WHLSL { > > namespace AST { > >-class ReferenceType : public Type { >+class ReferenceType : public UnnamedType { > public: >- ReferenceType(Lexer::Token&& origin, String&& addressSpace, std::unique_ptr<Type>&& elementType) >- : m_origin(WTFMove(origin)) >- , m_addressSpace(WTFMove(addressSpace)) >+ enum class AddressSpace { >+ Constant, >+ Device, >+ Threadgroup, >+ Thread >+ }; >+ >+ ReferenceType(Lexer::Token&& origin, AddressSpace addressSpace, std::unique_ptr<UnnamedType>&& elementType) >+ : UnnamedType(WTFMove(origin)) >+ , m_addressSpace(addressSpace) > , m_elementType(WTFMove(elementType)) > { > } >@@ -50,18 +57,16 @@ public: > > ReferenceType(const ReferenceType&) = delete; > ReferenceType(ReferenceType&&) = default; >- >- Type& elementType() { return *m_elementType; } > >-protected: >- const Lexer::Token& origin() const { return m_origin; } >- const String& addressSpace() const { return m_addressSpace; } >- const Type& elementType() const { return *m_elementType; } >+ bool isReferenceType() const override { return false; } >+ >+ AddressSpace addressSpace() const { return m_addressSpace; } >+ const UnnamedType& elementType() const { return *m_elementType; } >+ UnnamedType& elementType() { return *m_elementType; } > > private: >- Lexer::Token m_origin; >- String m_addressSpace; >- std::unique_ptr<Type> m_elementType; >+ AddressSpace m_addressSpace; >+ std::unique_ptr<UnnamedType> m_elementType; > }; > > } >@@ -70,4 +75,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(ReferenceType, isReferenceType()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h >index c5bfc9e4286..ac9323d2419 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h >@@ -54,8 +54,11 @@ public: > > Expression* value() { return m_value.get(); } > >+ void setFunction(FunctionDefinition* functionDefinition) { m_function = functionDefinition; } >+ > private: > std::unique_ptr<Expression> m_value; // nullable >+ FunctionDefinition* m_function; > }; > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h >index 87cc62f2356..a8c98e99b4c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h >@@ -29,7 +29,7 @@ > > #include "WHLSLLexer.h" > #include "WHLSLStructureElement.h" >-#include "WHLSLType.h" >+#include "WHLSLNamedType.h" > #include <wtf/Vector.h> > #include <wtf/text/WTFString.h> > >@@ -39,11 +39,10 @@ namespace WHLSL { > > namespace AST { > >-class StructureDefinition : public Type { >+class StructureDefinition : public NamedType { > public: > StructureDefinition(Lexer::Token&& origin, String&& name, StructureElements&& structureElements) >- : m_origin(WTFMove(origin)) >- , m_name(WTFMove(name)) >+ : NamedType(WTFMove(origin), WTFMove(name)) > , m_structureElements(WTFMove(structureElements)) > { > } >@@ -53,17 +52,11 @@ public: > StructureDefinition(const StructureDefinition&) = delete; > StructureDefinition(StructureDefinition&&) = default; > >- StructureElements& structureElements() { return m_structureElements; } >+ bool isStructureDefinition() const override { return true; } > >- std::unique_ptr<Type> clone() const override >- { >- ASSERT_NOT_REACHED(); >- return nullptr; >- } >+ StructureElements& structureElements() { return m_structureElements; } > > private: >- Lexer::Token m_origin; >- String m_name; > StructureElements m_structureElements; > }; > >@@ -73,4 +66,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(StructureDefinition, isStructureDefinition()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h >index 14be41c7298..a8cbf98df55 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h >@@ -41,7 +41,7 @@ namespace AST { > > class StructureElement : public Node { > public: >- StructureElement(Lexer::Token&& origin, Qualifiers&& qualifiers, std::unique_ptr<Type>&& type, String&& name, Optional<Semantic> semantic) >+ StructureElement(Lexer::Token&& origin, Qualifiers&& qualifiers, std::unique_ptr<UnnamedType>&& type, String&& name, Optional<Semantic> semantic) > : m_origin(WTFMove(origin)) > , m_qualifiers(WTFMove(qualifiers)) > , m_type(WTFMove(type)) >@@ -55,13 +55,15 @@ public: > StructureElement(const StructureElement&) = delete; > StructureElement(StructureElement&&) = default; > >- Type& type() { return *m_type; } >+ Lexer::Token& origin() { return m_origin; } >+ UnnamedType& type() { return *m_type; } >+ const String& name() { return m_name; } > Optional<Semantic>& semantic() { return m_semantic; } > > private: > Lexer::Token m_origin; > Qualifiers m_qualifiers; >- std::unique_ptr<Type> m_type; >+ std::unique_ptr<UnnamedType> m_type; > String m_name; > Optional<Semantic> m_semantic; > }; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h >index cf4cbc88790..573a8bb68c7 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h >@@ -45,12 +45,8 @@ public: > Type(const Type&) = delete; > Type(Type&&) = default; > >- virtual bool isTypeReference() const { return false; } >- virtual bool isPointerType() const { return false; } >- virtual bool isArrayReferenceType() const { return false; } >- virtual bool isArrayType() const { return false; } >- >- virtual std::unique_ptr<Type> clone() const = 0; >+ virtual bool isNamedType() const { return false; } >+ virtual bool isUnnamedType() const { return false; } > > private: > }; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp >index 7e5801e3b56..1b8af41c299 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp >@@ -28,9 +28,11 @@ > #if ENABLE(WEBGPU) > > #include "config.h" >-#include "WHLSLLexer.h" >+#include "WHLSLTypeArgument.h" > >-#include <wtf/Optional.h> >+#include "WHLSLConstantExpression.h" >+#include "WHLSLTypeReference.h" >+#include <wtf/Variant.h> > > namespace WebCore { > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h >index f73629e29b1..69aa23a1fa4 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h >@@ -29,7 +29,8 @@ > > #include "WHLSLLexer.h" > #include "WHLSLNode.h" >-#include "WHLSLType.h" >+#include "WHLSLNamedType.h" >+#include "WHLSLUnnamedType.h" > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -38,11 +39,10 @@ namespace WHLSL { > > namespace AST { > >-class TypeDefinition : public Type { >+class TypeDefinition : public NamedType { > public: >- TypeDefinition(Lexer::Token&& origin, String&& name, std::unique_ptr<AST::Type>&& type) >- : m_origin(WTFMove(origin)) >- , m_name(WTFMove(name)) >+ TypeDefinition(Lexer::Token&& origin, String&& name, std::unique_ptr<AST::UnnamedType>&& type) >+ : NamedType(WTFMove(origin), WTFMove(name)) > , m_type(WTFMove(type)) > { > } >@@ -52,18 +52,18 @@ public: > TypeDefinition(const TypeDefinition&) = delete; > TypeDefinition(TypeDefinition&&) = default; > >- AST::Type& type() { return *m_type; } >+ bool isTypeDefinition() const override { return true; } > >- std::unique_ptr<Type> clone() const override >+ AST::UnnamedType& type() { return *m_type; } >+ >+ const Type& unifyNode() const override > { >- ASSERT_NOT_REACHED(); >- return nullptr; >+ ASSERT(m_type); >+ return m_type->unifyNode(); > } > > private: >- Lexer::Token m_origin; >- String m_name; >- std::unique_ptr<AST::Type> m_type; >+ std::unique_ptr<AST::UnnamedType> m_type; > }; > > } >@@ -72,4 +72,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(TypeDefinition, isTypeDefinition()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h >index 49441d8b5c7..9293aa264e8 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h >@@ -28,8 +28,9 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLLexer.h" >-#include "WHLSLType.h" >+#include "WHLSLNativeTypeDeclaration.h" > #include "WHLSLTypeArgument.h" >+#include "WHLSLUnnamedType.h" > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -38,10 +39,10 @@ namespace WHLSL { > > namespace AST { > >-class TypeReference : public Type { >+class TypeReference : public UnnamedType { > public: > TypeReference(Lexer::Token&& origin, String&& name, TypeArguments&& typeArguments) >- : m_origin(WTFMove(origin)) >+ : UnnamedType(WTFMove(origin)) > , m_name(WTFMove(name)) > , m_typeArguments(WTFMove(typeArguments)) > { >@@ -52,24 +53,47 @@ public: > TypeReference(const TypeReference&) = delete; > TypeReference(TypeReference&&) = default; > >+ static std::unique_ptr<TypeReference> wrap(Lexer::Token&& origin, NamedType& resolvedType) >+ { >+ TypeArguments typeArguments; >+ if (is<NativeTypeDeclaration>(resolvedType)) >+ typeArguments = AST::clone(downcast<NativeTypeDeclaration>(resolvedType).typeArguments()); >+ auto result = std::make_unique<TypeReference>(WTFMove(origin), String(resolvedType.name()), WTFMove(typeArguments)); >+ result->setResolvedType(resolvedType); >+ return result; >+ } >+ > bool isTypeReference() const override { return true; } > >+ String& name() { return m_name; } > TypeArguments& typeArguments() { return m_typeArguments; } >+ NamedType* resolvedType() { return m_resolvedType; } >+ >+ const Type& unifyNode() const override >+ { >+ ASSERT(m_resolvedType); >+ return m_resolvedType->unifyNode(); >+ } >+ >+ void setResolvedType(NamedType& resolvedType) >+ { >+ m_resolvedType = &resolvedType; >+ } > > std::unique_ptr<TypeReference> cloneTypeReference() const > { >- return std::make_unique<TypeReference>(Lexer::Token(m_origin), String(m_name), AST::clone(m_typeArguments)); >+ return std::make_unique<TypeReference>(Lexer::Token(origin()), String(m_name), AST::clone(m_typeArguments)); > } > >- std::unique_ptr<Type> clone() const override >+ std::unique_ptr<UnnamedType> clone() const override > { > return cloneTypeReference(); > } > > private: >- Lexer::Token m_origin; > String m_name; > TypeArguments m_typeArguments; >+ NamedType* m_resolvedType { nullptr }; > }; > > } >@@ -78,6 +102,6 @@ private: > > } > >-SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(TypeReference, isTypeReference()) >+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(TypeReference, isTypeReference()) > > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h >new file mode 100644 >index 00000000000..73a8f0a0c46 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.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 "WHLSLLexer.h" >+#include "WHLSLNode.h" >+#include "WHLSLType.h" >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class UnnamedType : public Type { >+public: >+ UnnamedType(Lexer::Token&& origin) >+ : m_origin(WTFMove(origin)) >+ { >+ } >+ >+ virtual ~UnnamedType() = default; >+ >+ UnnamedType(const UnnamedType&) = delete; >+ UnnamedType(UnnamedType&&) = default; >+ >+ bool isUnnamedType() const override { return true; } >+ virtual bool isTypeReference() const { return false; } >+ virtual bool isPointerType() const { return false; } >+ virtual bool isArrayReferenceType() const { return false; } >+ virtual bool isArrayType() const { return false; } >+ virtual bool isReferenceType() const { return false; } >+ >+ virtual const Type& unifyNode() const { return *this; } >+ >+ virtual std::unique_ptr<UnnamedType> clone() const = 0; >+ >+ const Lexer::Token& origin() const { return m_origin; } >+ >+private: >+ Lexer::Token m_origin; >+}; >+ >+} >+ >+} >+ >+} >+ >+#define SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(ToValueTypeName, predicate) \ >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \ >+ static bool isType(const WebCore::WHLSL::AST::UnnamedType& type) { return type.predicate; } \ >+SPECIALIZE_TYPE_TRAITS_END() >+ >+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(UnnamedType, isUnnamedType()) >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >index ff0368193bd..8520cadcc35 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >@@ -44,7 +44,7 @@ namespace AST { > > class VariableDeclaration : public Value { > public: >- VariableDeclaration(Lexer::Token&& origin, Qualifiers&& qualifiers, std::unique_ptr<AST::Type>&& type, String&& name, Optional<Semantic>&& semantic, std::unique_ptr<Expression>&& initializer) >+ VariableDeclaration(Lexer::Token&& origin, Qualifiers&& qualifiers, std::unique_ptr<AST::UnnamedType>&& type, String&& name, Optional<Semantic>&& semantic, std::unique_ptr<Expression>&& initializer) > : m_origin(WTFMove(origin)) > , m_qualifiers(WTFMove(qualifiers)) > , m_type(WTFMove(type)) >@@ -60,20 +60,23 @@ public: > VariableDeclaration(VariableDeclaration&&) = default; > > Lexer::Token origin() const { return m_origin; } >+ String& name() { return m_name; } > >- Type& type() { return *m_type; } >+ UnnamedType& type() { return *m_type; } > Optional<Semantic>& semantic() { return m_semantic; } > Expression* initializer() { return m_initializer.get(); } > > private: > Lexer::Token m_origin; > Qualifiers m_qualifiers; >- std::unique_ptr<AST::Type> m_type; >+ std::unique_ptr<AST::UnnamedType> m_type; > String m_name; > Optional<Semantic> m_semantic; > std::unique_ptr<Expression> m_initializer; > }; > >+typedef Vector<VariableDeclaration> VariableDeclarations; >+ > } > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h >index 2ae828d5295..e39ecf5c59f 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h >@@ -27,7 +27,7 @@ > > #if ENABLE(WEBGPU) > >-#include "WHLSLAnonymousVariableDeclaration.h" >+#include "WHLSLVariableDeclaration.h" > #include "WHLSLExpression.h" > #include "WHLSLLexer.h" > #include "WHLSLVariableDeclaration.h" >@@ -55,19 +55,21 @@ public: > static VariableReference wrap(VariableDeclaration& variableDeclaration) > { > VariableReference result(Lexer::Token(variableDeclaration.origin())); >- result.m_variable = { &variableDeclaration }; >+ result.m_variable = &variableDeclaration; > return result; > } > >- static VariableReference wrap(AnonymousVariableDeclaration& anonymousVariableDeclaration) >+ bool isVariableReference() const override { return true; } >+ >+ String& name() { return m_name; } >+ >+ VariableDeclaration* variable() { return m_variable; } >+ >+ void setVariable(VariableDeclaration& variableDeclaration) > { >- VariableReference result(Lexer::Token(anonymousVariableDeclaration.origin())); >- result.m_variable = { &anonymousVariableDeclaration }; >- return result; >+ m_variable = &variableDeclaration; > } > >- bool isVariableReference() const override { return true; } >- > private: > VariableReference(Lexer::Token&& origin) > : Expression(WTFMove(origin)) >@@ -75,7 +77,7 @@ private: > } > > String m_name; >- Optional<Variant<VariableDeclaration*, AnonymousVariableDeclaration*>> m_variable; >+ VariableDeclaration* m_variable; > }; > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp >new file mode 100644 >index 00000000000..6d5ef375675 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp >@@ -0,0 +1,122 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLCheckDuplicateFunctions.h" >+ >+#include "WHLSLArrayReferenceType.h" >+#include "WHLSLArrayType.h" >+#include "WHLSLInferTypes.h" >+#include "WHLSLTypeReference.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+bool checkDuplicateFunctions(const Program& program) >+{ >+ Vector<std::reference_wrapper<AST::FunctionDeclaration>> functions; >+ for (auto& functionDefinition : program.functionDefinitions()) >+ functions.append(*functionDefinition); >+ for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) >+ functions.append(*nativeFunctionDeclaration); >+ >+ std::sort(functions.begin(), functions.end(), [](const AST::FunctionDeclaration& a, const AST::FunctionDeclaration& b) -> bool { >+ for (unsigned i = 0; i < std::min(a.name().length(), b.name().length()); ++i) { >+ if (a.name()[i] < b.name()[i]) >+ return true; >+ if (a.name()[i] > b.name()[i]) >+ return false; >+ } >+ return a.name().length() < b.name().length(); >+ }); >+ for (size_t i = 0; i < functions.size(); ++i) { >+ for (size_t j = i + 1; j < functions.size(); ++i) { >+ if (functions[i].get().name() != functions[j].get().name()) >+ break; >+ if (is<AST::NativeFunctionDeclaration>(functions[i].get()) && is<AST::NativeFunctionDeclaration>(functions[j].get())) >+ continue; >+ if (functions[i].get().parameters().size() != functions[j].get().parameters().size()) >+ continue; >+ if (functions[i].get().isCast()) { >+ bool same = true; >+ if (!matches(functions[i].get().type(), functions[j].get().type())) >+ same = false; >+ else { >+ for (size_t k = 0; k < functions[i].get().parameters().size(); ++k) { >+ if (!matches(functions[i].get().parameters()[k].type(), functions[j].get().parameters()[k].type())) { >+ same = false; >+ break; >+ } >+ } >+ } >+ if (same) >+ return false; >+ } else { >+ bool same = true; >+ for (size_t k = 0; k < functions[i].get().parameters().size(); ++k) { >+ if (!matches(functions[i].get().parameters()[k].type(), functions[j].get().parameters()[k].type())) { >+ same = false; >+ break; >+ } >+ } >+ if (same) >+ return false; >+ } >+ } >+ >+ if (functions[i].get().name() == "operator&[]" && functions[i].get().parameters().size() == 2 >+ && is<AST::ArrayReferenceType>(functions[i].get().parameters()[0].type())) { >+ auto& type = functions[i].get().parameters()[1].type(); >+ if (is<AST::TypeReference>(type)) { >+ if (auto* resolvedType = downcast<AST::TypeReference>(type).resolvedType()) { >+ if (is<AST::NativeTypeDeclaration>(*resolvedType)) { >+ auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(*resolvedType); >+ if (nativeTypeDeclaration.name() == "uint") >+ return false; >+ } >+ } >+ } >+ } else if (functions[i].get().name() == "operator.length" && functions[i].get().parameters().size() == 1 >+ && (is<AST::ArrayReferenceType>(functions[i].get().parameters()[0].type()) >+ || is<AST::ArrayType>(functions[i].get().parameters()[0].type()))) >+ return false; >+ else if (functions[i].get().name() == "operator==" >+ && functions[i].get().parameters().size() == 2 >+ && is<AST::ReferenceType>(functions[i].get().parameters()[0].type()) >+ && is<AST::ReferenceType>(functions[i].get().parameters()[1].type()) >+ && matches(functions[i].get().parameters()[0].type(), functions[i].get().parameters()[1].type())) >+ return false; >+ } >+ return true; >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.h >new file mode 100644 >index 00000000000..7ecee782c5f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.h >@@ -0,0 +1,43 @@ >+/* >+ * 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 "WHLSLProgram.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+bool checkDuplicateFunctions(const Program&); >+ >+} >+ >+} >+ >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >new file mode 100644 >index 00000000000..cf40730cc6c >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >@@ -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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLChecker.h" >+ >+#include "WHLSLProgram.h" >+#include "WHLSLVisitor.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class Checker : public Visitor { >+public: >+ ~Checker() = default; >+ >+ bool error() { return m_error; } >+ >+private: >+ bool m_error { false }; // FIXME: Migrate this to be some sort of descriptive string. >+ // FIXME: Consider moving the error into Visitor >+}; >+ >+bool check(Program& program) >+{ >+ Checker checker; >+ checker.visit(program); >+ return !checker.error(); >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.h >new file mode 100644 >index 00000000000..ed268d7341f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.h >@@ -0,0 +1,42 @@ >+/* >+ * 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 { >+ >+class Program; >+ >+bool check(Program&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp >new file mode 100644 >index 00000000000..58195156227 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp >@@ -0,0 +1,125 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLInferTypes.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+bool matches(const AST::UnnamedType& unnamedType, const AST::UnnamedType& other) >+{ >+ auto& unifyThis = unnamedType.unifyNode(); >+ auto& unifyOther = other.unifyNode(); >+ >+ if (&unifyThis == &unifyOther) >+ return true; >+ >+ if (is<AST::NamedType>(unifyThis) && is<AST::NamedType>(unifyOther)) { >+#if !ASSERT_DISABLED >+ auto& namedThis = downcast<AST::NamedType>(unifyThis); >+ auto& namedOther = downcast<AST::NamedType>(unifyOther); >+ ASSERT(!is<AST::TypeDefinition>(namedThis) && !is<AST::TypeDefinition>(namedOther)); >+#endif >+ return false; >+ } else if (is<AST::UnnamedType>(unifyThis) && is<AST::UnnamedType>(unifyOther)) { >+ auto& unnamedThis = downcast<AST::UnnamedType>(unifyThis); >+ auto& unnamedOther = downcast<AST::UnnamedType>(unifyOther); >+ ASSERT(!is<AST::TypeReference>(unnamedThis) && !is<AST::TypeReference>(unnamedOther)); >+ if (is<AST::PointerType>(unnamedThis) && is<AST::PointerType>(unnamedOther)) { >+ auto& pointerThis = downcast<AST::PointerType>(unnamedThis); >+ auto& pointerOther = downcast<AST::PointerType>(unnamedOther); >+ if (pointerThis.addressSpace() != pointerOther.addressSpace()) >+ return false; >+ return matches(pointerThis.elementType(), pointerOther.elementType()); >+ } >+ if (is<AST::ArrayReferenceType>(unnamedThis) && is<AST::ArrayReferenceType>(unnamedOther)){ >+ auto& arrayReferenceThis = downcast<AST::ArrayReferenceType>(unnamedThis); >+ auto& arrayReferenceOther = downcast<AST::ArrayReferenceType>(unnamedOther); >+ if (arrayReferenceThis.addressSpace() != arrayReferenceOther.addressSpace()) >+ return false; >+ return matches(arrayReferenceThis.elementType(), arrayReferenceOther.elementType()); >+ } >+ if (is<AST::ArrayType>(unnamedThis) && is<AST::ArrayType>(unnamedOther)) { >+ auto& arrayThis = downcast<AST::ArrayType>(unnamedThis); >+ auto& arrayOther = downcast<AST::ArrayType>(unnamedOther); >+ if (arrayThis.numElements() != arrayOther.numElements()) >+ return false; >+ return matches(arrayThis.type(), arrayOther.type()); >+ } >+ return false; >+ } >+ return false; >+} >+ >+bool inferTypesForTypeArguments(AST::NamedType& possibleType, AST::TypeArguments& typeArguments) >+{ >+ if (is<AST::TypeDefinition>(possibleType) >+ || is<AST::StructureDefinition>(possibleType) >+ || is<AST::EnumerationDefinition>(possibleType)) { >+ return typeArguments.isEmpty(); >+ } >+ >+ ASSERT(is<AST::NativeTypeDeclaration>(possibleType)); >+ auto& nativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(possibleType); >+ if (nativeTypeDeclaration.typeArguments().size() != typeArguments.size()) >+ return false; >+ for (size_t i = 0; i < nativeTypeDeclaration.typeArguments().size(); ++i) { >+ AST::ConstantExpression* typeArgumentExpression = nullptr; >+ AST::TypeReference* typeArgumentTypeReference = nullptr; >+ AST::ConstantExpression* nativeTypeArgumentExpression = nullptr; >+ AST::TypeReference* nativeTypeArgumentTypeReference = nullptr; >+ >+ auto assign = [&](AST::TypeArgument& typeArgument, AST::ConstantExpression*& expression, AST::TypeReference*& typeReference) { >+ WTF::visit(WTF::makeVisitor([&](AST::ConstantExpression& constantExpression) { >+ expression = &constantExpression; >+ }, [&](std::unique_ptr<AST::TypeReference>& theTypeReference) { >+ typeReference = theTypeReference.get(); >+ }), typeArgument); >+ }; >+ >+ assign(typeArguments[i], typeArgumentExpression, typeArgumentTypeReference); >+ assign(nativeTypeDeclaration.typeArguments()[i], nativeTypeArgumentExpression, nativeTypeArgumentTypeReference); >+ >+ if (typeArgumentExpression && nativeTypeArgumentExpression) { >+ if (!typeArgumentExpression->matches(*nativeTypeArgumentExpression)) >+ return false; >+ } else if (typeArgumentTypeReference && nativeTypeArgumentTypeReference) { >+ if (!matches(*typeArgumentTypeReference, *nativeTypeArgumentTypeReference)) >+ return false; >+ } >+ } >+ >+ return true; >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAnonymousVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.h >similarity index 73% >rename from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAnonymousVariableDeclaration.h >rename to Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.h >index ef61ed12619..0f7d441fded 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAnonymousVariableDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.h >@@ -27,8 +27,7 @@ > > #if ENABLE(WEBGPU) > >-#include "WHLSLLexer.h" >-#include "WHLSLValue.h" >+#include "WHLSLTypeArgument.h" > > namespace WebCore { > >@@ -36,26 +35,14 @@ 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; >-}; >+class UnnamedType; >+class NamedType; > > } > >+bool matches(const AST::UnnamedType&, const AST::UnnamedType&); >+bool inferTypesForTypeArguments(AST::NamedType& possibleType, AST::TypeArguments& typeArguments); >+ > } > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >new file mode 100644 >index 00000000000..0c4422d5113 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >@@ -0,0 +1,259 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLIntrinsics.h" >+ >+#include "WHLSLConstantExpression.h" >+#include "WHLSLTypeArgument.h" >+#include "WHLSLTypeReference.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+Intrinsics::Intrinsics() >+ : m_textureTypeNames { String("Texture1D", String::ConstructFromLiteral), >+ String("RWTexture1D", String::ConstructFromLiteral), >+ String("Texture1DArray", String::ConstructFromLiteral), >+ String("RWTexture1DArray", String::ConstructFromLiteral), >+ String("Texture2D", String::ConstructFromLiteral), >+ String("RWTexture2D", String::ConstructFromLiteral), >+ String("Texture2DArray", String::ConstructFromLiteral), >+ String("RWTexture2DArray", String::ConstructFromLiteral), >+ String("Texture3D", String::ConstructFromLiteral), >+ String("RWTexture3D", String::ConstructFromLiteral), >+ String("TextureCube", String::ConstructFromLiteral) } >+ , m_textureInnerTypeNames { String("uchar", String::ConstructFromLiteral), >+ String("ushort", String::ConstructFromLiteral), >+ String("uint", String::ConstructFromLiteral), >+ String("char", String::ConstructFromLiteral), >+ String("short", String::ConstructFromLiteral), >+ String("int", String::ConstructFromLiteral), >+ String("half", String::ConstructFromLiteral), >+ String("float", String::ConstructFromLiteral) } >+ , m_depthTextureInnerTypes { String("half", String::ConstructFromLiteral), >+ String("float", String::ConstructFromLiteral) } >+{ >+ ASSERT(m_textureTypeNames.size() == 11); // fullTextures hardcodes the length of this array. >+ ASSERT(m_textureInnerTypeNames.size() == 8); // fullTextures hardcodes the length of this array. >+ ASSERT(m_depthTextureInnerTypes.size() == 2); // textureDepth2D & friends hardcodes the length of this array. >+} >+ >+void Intrinsics::add(AST::NativeFunctionDeclaration&) >+{ >+ // FIXME: Populate this. >+} >+ >+bool Intrinsics::addPrimitive(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ if (nativeTypeDeclaration.typeArguments().size() != 0) >+ return false; >+ >+ if (nativeTypeDeclaration.name() == "void") >+ m_voidType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "bool") >+ m_boolType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "uchar") >+ m_ucharType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "ushort") >+ m_ushortType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "uint") >+ m_uintType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "char") >+ m_charType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "short") >+ m_shortType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "int") >+ m_intType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "half") >+ m_halfType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "float") >+ m_floatType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "atomic_int") >+ m_atomicIntType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "atomic_uint") >+ m_atomicUintType = &nativeTypeDeclaration; >+ else if (nativeTypeDeclaration.name() == "sampler") >+ m_samplerType = &nativeTypeDeclaration; >+ else >+ ASSERT_NOT_REACHED(); >+ return true; >+} >+ >+bool Intrinsics::addVector(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ if (nativeTypeDeclaration.name() != "vector") >+ return false; >+ >+ ASSERT(nativeTypeDeclaration.typeArguments().size() == 2); >+ ASSERT(WTF::holds_alternative<std::unique_ptr<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); >+ ASSERT(WTF::holds_alternative<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1])); >+ auto& innerTypePointer = WTF::get<std::unique_ptr<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); >+ auto& lengthExpression = WTF::get<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1]); >+ ASSERT(innerTypePointer); >+ auto& innerType = *innerTypePointer; >+ ASSERT(innerType.typeArguments().size() == 0); >+ AST::NativeTypeDeclaration** array; >+ if (innerType.name() == "bool") >+ array = m_vectorBool; >+ else if (innerType.name() == "uchar") >+ array = m_vectorUchar; >+ else if (innerType.name() == "ushort") >+ array = m_vectorUshort; >+ else if (innerType.name() == "uint") >+ array = m_vectorUint; >+ else if (innerType.name() == "char") >+ array = m_vectorChar; >+ else if (innerType.name() == "short") >+ array = m_vectorShort; >+ else if (innerType.name() == "int") >+ array = m_vectorInt; >+ else if (innerType.name() == "half") >+ array = m_vectorHalf; >+ else if (innerType.name() == "float") >+ array = m_vectorFloat; >+ else >+ ASSERT_NOT_REACHED(); >+ int length = lengthExpression.integerLiteral().value(); >+ ASSERT(length >= 2 && length <= 4); >+ array[length - 2] = &nativeTypeDeclaration; >+ return true; >+} >+ >+bool Intrinsics::addMatrix(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ if (nativeTypeDeclaration.name() != "matrix") >+ return false; >+ >+ ASSERT(nativeTypeDeclaration.typeArguments().size() == 3); >+ ASSERT(WTF::holds_alternative<std::unique_ptr<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); >+ ASSERT(WTF::holds_alternative<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1])); >+ ASSERT(WTF::holds_alternative<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[2])); >+ auto& innerTypePointer = WTF::get<std::unique_ptr<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); >+ auto& rowExpression = WTF::get<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1]); >+ auto& columnExpression = WTF::get<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[2]); >+ ASSERT(innerTypePointer); >+ auto& innerType = *innerTypePointer; >+ ASSERT(innerType.typeArguments().size() == 0); >+ AST::NativeTypeDeclaration* (*array)[3]; >+ if (innerType.name() == "half") >+ array = m_matrixHalf; >+ if (innerType.name() == "float") >+ array = m_matrixFloat; >+ int row = rowExpression.integerLiteral().value(); >+ ASSERT(row >= 2 && row <= 4); >+ int column = columnExpression.integerLiteral().value(); >+ ASSERT(column >= 2 && column <= 4); >+ array[row - 2][column - 2] = &nativeTypeDeclaration; >+ return true; >+} >+ >+bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType) >+{ >+ unsigned textureTypeIndex = m_textureTypeNames.size(); >+ for (unsigned i = 0; i < m_textureTypeNames.size(); ++i) { >+ if (nativeTypeDeclaration.name() == m_textureTypeNames[i]) >+ textureTypeIndex = i; >+ } >+ if (textureTypeIndex == m_textureTypeNames.size()) >+ return false; >+ >+ unsigned innerTypeIndex = m_textureInnerTypeNames.size(); >+ unsigned vectorLength; >+ for (unsigned i = 0; i < m_textureInnerTypeNames.size(); ++i) { >+ if (innerType.name().startsWith(m_textureInnerTypeNames[i])) { >+ textureTypeIndex = i; >+ if (innerType.name() == m_textureInnerTypeNames[i]) >+ vectorLength = 1; >+ else { >+ ASSERT(innerType.name().length() == m_textureInnerTypeNames[i].length() + 1); >+ ASSERT(innerType.name()[innerType.name().length() - 1] == '2' >+ || innerType.name()[innerType.name().length() - 1] == '3' >+ || innerType.name()[innerType.name().length() - 1] == '4'); >+ vectorLength = innerType.name()[innerType.name().length() - 1] - '0'; >+ } >+ } >+ } >+ ASSERT(innerTypeIndex != m_textureInnerTypeNames.size()); >+ m_fullTextures[textureTypeIndex][innerTypeIndex][vectorLength - 1] = &nativeTypeDeclaration; >+ return true; >+} >+ >+void Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration, AST::TypeReference& innerType) >+{ >+ AST::NativeTypeDeclaration** texture; >+ if (nativeTypeDeclaration.name() == "TextureDepth2D") >+ texture = m_textureDepth2D; >+ else if (nativeTypeDeclaration.name() == "RWTextureDepth2D") >+ texture = m_rwTextureDepth2D; >+ else if (nativeTypeDeclaration.name() == "TextureDepth2DArray") >+ texture = m_textureDepth2DArray; >+ else if (nativeTypeDeclaration.name() == "RWTextureDepth2DArray") >+ texture = m_rwTextureDepth2DArray; >+ else if (nativeTypeDeclaration.name() == "TextureDepthCube") >+ texture = m_textureDepthCube; >+ else >+ ASSERT_NOT_REACHED(); >+ unsigned innerTypeIndex = m_depthTextureInnerTypes.size(); >+ for (unsigned i = 0; i < m_depthTextureInnerTypes.size(); ++i) { >+ if (innerType.name() == m_depthTextureInnerTypes[i]) >+ innerTypeIndex = i; >+ } >+ ASSERT(innerTypeIndex != m_depthTextureInnerTypes.size()); >+ texture[innerTypeIndex] = &nativeTypeDeclaration; >+} >+ >+void Intrinsics::addTexture(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ ASSERT(nativeTypeDeclaration.typeArguments().size() == 1); >+ ASSERT(WTF::holds_alternative<std::unique_ptr<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); >+ auto& innerTypePointer = WTF::get<std::unique_ptr<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]); >+ ASSERT(innerTypePointer); >+ auto& innerType = *innerTypePointer; >+ ASSERT(innerType.typeArguments().size() == 0); >+ if (addFullTexture(nativeTypeDeclaration, innerType)) >+ return; >+ addDepthTexture(nativeTypeDeclaration, innerType); >+} >+ >+void Intrinsics::add(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ if (addPrimitive(nativeTypeDeclaration)) >+ return; >+ if (addVector(nativeTypeDeclaration)) >+ return; >+ if (addMatrix(nativeTypeDeclaration)) >+ return; >+ addTexture(nativeTypeDeclaration); >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >new file mode 100644 >index 00000000000..d7b4e38721a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >@@ -0,0 +1,112 @@ >+/* >+ * 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 "WHLSLNativeFunctionDeclaration.h" >+#include "WHLSLNativeTypeDeclaration.h" >+#include <cstring> >+#include <wtf/StdLibExtras.h> >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class Intrinsics { >+public: >+ Intrinsics(); >+ >+ void add(AST::NativeFunctionDeclaration&); >+ void add(AST::NativeTypeDeclaration&); >+ >+ AST::NativeTypeDeclaration& boolType() >+ { >+ ASSERT(m_boolType); >+ return *m_boolType; >+ } >+ >+ AST::NativeTypeDeclaration& uintType() >+ { >+ ASSERT(m_uintType); >+ return *m_uintType; >+ } >+ >+private: >+ bool addPrimitive(AST::NativeTypeDeclaration&); >+ bool addVector(AST::NativeTypeDeclaration&); >+ bool addMatrix(AST::NativeTypeDeclaration&); >+ bool addFullTexture(AST::NativeTypeDeclaration&, AST::TypeReference&); >+ void addDepthTexture(AST::NativeTypeDeclaration&, AST::TypeReference&); >+ void addTexture(AST::NativeTypeDeclaration&); >+ >+ AST::NativeTypeDeclaration* m_voidType; >+ AST::NativeTypeDeclaration* m_boolType; >+ AST::NativeTypeDeclaration* m_ucharType; >+ AST::NativeTypeDeclaration* m_ushortType; >+ AST::NativeTypeDeclaration* m_uintType; >+ AST::NativeTypeDeclaration* m_charType; >+ AST::NativeTypeDeclaration* m_shortType; >+ AST::NativeTypeDeclaration* m_intType; >+ AST::NativeTypeDeclaration* m_halfType; >+ AST::NativeTypeDeclaration* m_floatType; >+ AST::NativeTypeDeclaration* m_atomicIntType; >+ AST::NativeTypeDeclaration* m_atomicUintType; >+ AST::NativeTypeDeclaration* m_samplerType; >+ >+ AST::NativeTypeDeclaration* m_vectorBool[3]; >+ AST::NativeTypeDeclaration* m_vectorUchar[3]; >+ AST::NativeTypeDeclaration* m_vectorUshort[3]; >+ AST::NativeTypeDeclaration* m_vectorUint[3]; >+ AST::NativeTypeDeclaration* m_vectorChar[3]; >+ AST::NativeTypeDeclaration* m_vectorShort[3]; >+ AST::NativeTypeDeclaration* m_vectorInt[3]; >+ AST::NativeTypeDeclaration* m_vectorHalf[3]; >+ AST::NativeTypeDeclaration* m_vectorFloat[3]; >+ >+ AST::NativeTypeDeclaration* m_matrixHalf[3][3]; >+ AST::NativeTypeDeclaration* m_matrixFloat[3][3]; >+ >+ Vector<String> m_textureTypeNames; >+ Vector<String> m_textureInnerTypeNames; >+ >+ AST::NativeTypeDeclaration* m_fullTextures[11][8][4]; >+ >+ Vector<String> m_depthTextureInnerTypes; >+ AST::NativeTypeDeclaration* m_textureDepth2D[2]; >+ AST::NativeTypeDeclaration* m_rwTextureDepth2D[2]; >+ AST::NativeTypeDeclaration* m_textureDepth2DArray[2]; >+ AST::NativeTypeDeclaration* m_rwTextureDepth2DArray[2]; >+ AST::NativeTypeDeclaration* m_textureDepthCube[2]; >+}; >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameContext.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameContext.cpp >new file mode 100644 >index 00000000000..ed9efe7a300 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameContext.cpp >@@ -0,0 +1,155 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLNameContext.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+NameContext::NameContext(NameContext* parent) >+ : m_parent(parent) >+{ >+} >+ >+bool NameContext::add(AST::TypeDefinition& typeDefinition) >+{ >+ if (exists(typeDefinition.name())) >+ return false; >+ auto result = m_types.add(typeDefinition.name(), Vector<std::reference_wrapper<AST::NamedType>, 1>()); >+ if (!result.isNewEntry) >+ return false; >+ result.iterator->value.append(typeDefinition); >+ return true; >+} >+ >+bool NameContext::add(AST::StructureDefinition& structureDefinition) >+{ >+ if (exists(structureDefinition.name())) >+ return false; >+ auto result = m_types.add(structureDefinition.name(), Vector<std::reference_wrapper<AST::NamedType>, 1>()); >+ if (!result.isNewEntry) >+ return false; >+ result.iterator->value.append(structureDefinition); >+ return true; >+} >+ >+bool NameContext::add(AST::EnumerationDefinition& enumerationDefinition) >+{ >+ if (exists(enumerationDefinition.name())) >+ return false; >+ auto result = m_types.add(enumerationDefinition.name(), Vector<std::reference_wrapper<AST::NamedType>, 1>()); >+ if (!result.isNewEntry) >+ return false; >+ result.iterator->value.append(enumerationDefinition); >+ return true; >+} >+ >+bool NameContext::add(AST::FunctionDefinition& functionDefinition) >+{ >+ if (m_types.find(functionDefinition.name()) != m_types.end() >+ || m_variables.find(functionDefinition.name()) != m_variables.end()) >+ return false; >+ auto result = m_functions.add(functionDefinition.name(), Vector<std::reference_wrapper<AST::FunctionDeclaration>, 1>()); >+ result.iterator->value.append(functionDefinition); >+ return true; >+} >+ >+bool NameContext::add(AST::NativeFunctionDeclaration& nativeFunctionDeclaration) >+{ >+ if (m_types.find(nativeFunctionDeclaration.name()) != m_types.end() >+ || m_variables.find(nativeFunctionDeclaration.name()) != m_variables.end()) >+ return false; >+ auto result = m_functions.add(nativeFunctionDeclaration.name(), Vector<std::reference_wrapper<AST::FunctionDeclaration>, 1>()); >+ result.iterator->value.append(nativeFunctionDeclaration); >+ return true; >+} >+ >+bool NameContext::add(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ if (m_functions.find(nativeTypeDeclaration.name()) != m_functions.end() >+ || m_variables.find(nativeTypeDeclaration.name()) != m_variables.end()) >+ return false; >+ auto result = m_types.add(nativeTypeDeclaration.name(), Vector<std::reference_wrapper<AST::NamedType>, 1>()); >+ result.iterator->value.append(nativeTypeDeclaration); >+ return true; >+} >+ >+bool NameContext::add(AST::VariableDeclaration& variableDeclaration) >+{ >+ if (exists(variableDeclaration.name())) >+ return false; >+ auto result = m_variables.add(String(variableDeclaration.name()), &variableDeclaration); >+ return result.isNewEntry; >+} >+ >+Vector<std::reference_wrapper<AST::NamedType>, 1>* NameContext::getTypes(const String& name) >+{ >+ auto iterator = m_types.find(name); >+ if (iterator == m_types.end()) { >+ if (m_parent) >+ return m_parent->getTypes(name); >+ return nullptr; >+ } >+ return &iterator->value; >+} >+ >+Vector<std::reference_wrapper<AST::FunctionDeclaration>, 1>* NameContext::getFunctions(const String& name) >+{ >+ auto iterator = m_functions.find(name); >+ if (iterator == m_functions.end()) { >+ if (m_parent) >+ return m_parent->getFunctions(name); >+ return nullptr; >+ } >+ return &iterator->value; >+} >+ >+AST::VariableDeclaration* NameContext::getVariable(const String& name) >+{ >+ auto iterator = m_variables.find(name); >+ if (iterator == m_variables.end()) { >+ if (m_parent) >+ return m_parent->getVariable(name); >+ return nullptr; >+ } >+ return iterator->value; >+} >+ >+bool NameContext::exists(String& name) >+{ >+ return m_types.find(name) != m_types.end() >+ || m_functions.find(name) != m_functions.end() >+ || m_variables.find(name) != m_variables.end(); >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameContext.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameContext.h >new file mode 100644 >index 00000000000..d3df80014ae >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameContext.h >@@ -0,0 +1,82 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include <functional> >+#include <wtf/HashMap.h> >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class NamedType; >+class FunctionDeclaration; >+class TypeDefinition; >+class StructureDefinition; >+class EnumerationDefinition; >+class FunctionDefinition; >+class NativeFunctionDeclaration; >+class NativeTypeDeclaration; >+class VariableDeclaration; >+ >+} >+ >+class NameContext { >+public: >+ NameContext(NameContext* parent = nullptr); >+ >+ bool add(AST::TypeDefinition&); >+ bool add(AST::StructureDefinition&); >+ bool add(AST::EnumerationDefinition&); >+ bool add(AST::FunctionDefinition&); >+ bool add(AST::NativeFunctionDeclaration&); >+ bool add(AST::NativeTypeDeclaration&); >+ bool add(AST::VariableDeclaration&); >+ >+ Vector<std::reference_wrapper<AST::NamedType>, 1>* getTypes(const String&); >+ Vector<std::reference_wrapper<AST::FunctionDeclaration>, 1>* getFunctions(const String&); >+ AST::VariableDeclaration* getVariable(const String&); >+ >+private: >+ bool exists(String&); >+ >+ HashMap<String, Vector<std::reference_wrapper<AST::NamedType>, 1>> m_types; >+ HashMap<String, Vector<std::reference_wrapper<AST::FunctionDeclaration>, 1>> m_functions; >+ HashMap<String, AST::VariableDeclaration*> m_variables; >+ NameContext* m_parent; >+}; >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >index 780d5c5425a..52fc02cba1a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >@@ -28,19 +28,287 @@ > #include "config.h" > #include "WHLSLNameResolver.h" > >-#include "WHLSLVisitor.h" >+#include "WHLSLEnumerationMemberLiteral.h" >+#include "WHLSLNameContext.h" >+#include "WHLSLResolveOverloadImpl.h" >+#include "WHLSLTypeReference.h" >+#include "WHLSLFunctionDefinition.h" >+#include "WHLSLIfStatement.h" >+#include "WHLSLWhileLoop.h" >+#include "WHLSLDoWhileLoop.h" >+#include "WHLSLForLoop.h" >+#include "WHLSLVariableDeclaration.h" >+#include "WHLSLVariableReference.h" >+#include "WHLSLReturn.h" >+#include "WHLSLPropertyAccessExpression.h" >+#include "WHLSLDotExpression.h" >+#include "WHLSLEnumerationDefinition.h" >+#include "WHLSLCallExpression.h" >+#include "WHLSLProgram.h" > > namespace WebCore { > > namespace WHLSL { > >-class NameResolver : public Visitor { >- ~NameResolver() = default; >-}; >+NameResolver::NameResolver(NameContext& nameContext) >+ : m_nameContext(nameContext) >+{ >+} >+ >+void NameResolver::visit(AST::TypeReference& typeReference) >+{ >+ if (m_error) >+ return; >+ >+ Visitor::visit(typeReference); >+ if (typeReference.resolvedType()) >+ return; >+ >+ auto* candidates = m_nameContext.getTypes(typeReference.name()); >+ if (candidates == nullptr) { >+ m_error = true; >+ return; >+ } >+ if (auto result = resolveTypeOverloadImpl(*candidates, typeReference.typeArguments())) >+ typeReference.setResolvedType(*result); >+ else { >+ m_error = true; >+ return; >+ } >+} >+ >+void NameResolver::visit(AST::FunctionDefinition& functionDefinition) >+{ >+ if (m_error) >+ return; >+ >+ NameContext newNameContext(&m_nameContext); >+ NameResolver newNameResolver(newNameContext); >+ visitUnnamedType(functionDefinition.type()); >+ for (auto& parameter : functionDefinition.parameters()) { >+ newNameResolver.Visitor::visit(parameter); >+ auto success = newNameContext.add(parameter); >+ if (!success) { >+ m_error = true; >+ return; >+ } >+ } >+ newNameResolver.visit(functionDefinition.block()); >+} >+ >+void NameResolver::visit(AST::Block& block) >+{ >+ if (m_error) >+ return; >+ >+ NameContext nameContext(&m_nameContext); >+ NameResolver(nameContext).Visitor::visit(block); >+} >+ >+void NameResolver::visit(AST::IfStatement& ifStatement) >+{ >+ if (m_error) >+ return; >+ >+ Visitor::visit(ifStatement.conditional()); >+ NameContext nameContext(&m_nameContext); >+ NameResolver(nameContext).Visitor::visit(ifStatement.body()); >+ if (ifStatement.elseBody()) { >+ NameContext nameContext(&m_nameContext); >+ NameResolver(nameContext).Visitor::visit(*ifStatement.elseBody()); >+ } >+} >+ >+void NameResolver::visit(AST::WhileLoop& whileLoop) >+{ >+ if (m_error) >+ return; >+ >+ Visitor::visit(whileLoop.conditional()); >+ NameContext nameContext(&m_nameContext); >+ NameResolver(nameContext).Visitor::visit(whileLoop.body()); >+} >+ >+void NameResolver::visit(AST::DoWhileLoop& whileLoop) >+{ >+ if (m_error) >+ return; >+ >+ NameContext nameContext(&m_nameContext); >+ NameResolver(nameContext).Visitor::visit(whileLoop.body()); >+ Visitor::visit(whileLoop.conditional()); >+} >+ >+void NameResolver::visit(AST::ForLoop& forLoop) >+{ >+ if (m_error) >+ return; >+ >+ NameContext nameContext(&m_nameContext); >+ NameResolver(nameContext).Visitor::visit(forLoop); >+} >+ >+void NameResolver::visit(AST::VariableDeclaration& variableDeclaration) >+{ >+ if (m_error) >+ return; >+ >+ m_nameContext.add(variableDeclaration); >+ Visitor::visit(variableDeclaration); >+} >+ >+void NameResolver::visit(AST::VariableReference& variableReference) >+{ >+ if (m_error) >+ return; >+ >+ if (variableReference.variable()) >+ return; >+ >+ if (auto* variable = m_nameContext.getVariable(variableReference.name())) >+ variableReference.setVariable(*variable); >+ else { >+ m_error = true; >+ return; >+ } >+} >+ >+void NameResolver::visit(AST::Return& returnNode) >+{ >+ if (m_error) >+ return; >+ >+ ASSERT(m_currentFunction); >+ returnNode.setFunction(m_currentFunction); >+ Visitor::visit(returnNode); >+} >+ >+void NameResolver::visit(AST::PropertyAccessExpression& propertyAccessExpression) >+{ >+ if (m_error) >+ return; >+ >+ if (auto* getFunctions = m_nameContext.getFunctions(propertyAccessExpression.getFunctionName())) >+ propertyAccessExpression.setPossibleGetOverloads(*getFunctions); >+ if (auto* setFunctions = m_nameContext.getFunctions(propertyAccessExpression.setFunctionName())) >+ propertyAccessExpression.setPossibleSetOverloads(*setFunctions); >+ if (auto* andFunctions = m_nameContext.getFunctions(propertyAccessExpression.andFunctionName())) >+ propertyAccessExpression.setPossibleAndOverloads(*andFunctions); >+ Visitor::visit(propertyAccessExpression); >+} > >-void resolveNamesInTypes(Program&) >+void NameResolver::visit(AST::DotExpression& dotExpression) > { >+ if (m_error) >+ return; > >+ if (is<AST::VariableReference>(dotExpression.base())) { >+ if (auto enumerationTypes = m_nameContext.getTypes(downcast<AST::VariableReference>(dotExpression.base()).name())) { >+ ASSERT(enumerationTypes->size() == 1); >+ AST::NamedType& type = (*enumerationTypes)[0]; >+ if (is<AST::EnumerationDefinition>(type)) { >+ AST::EnumerationDefinition& enumerationDefinition = downcast<AST::EnumerationDefinition>(type); >+ if (auto* member = enumerationDefinition.memberByName(dotExpression.fieldName())) { >+ static_assert(sizeof(AST::EnumerationMemberLiteral) <= sizeof(AST::DotExpression), "Dot expressions need to be able to become EnumerationMemberLiterals without updating backreferences"); >+ Lexer::Token origin = dotExpression.origin(); >+ // FIXME: Perhaps do this with variants or a Rewriter instead. >+ dotExpression.~DotExpression(); >+ new (&dotExpression) AST::EnumerationMemberLiteral(WTFMove(origin), *member); >+ return; >+ } else { >+ m_error = true; >+ return; >+ } >+ } >+ } >+ } >+ >+ Visitor::visit(dotExpression); >+} >+ >+void NameResolver::visit(AST::CallExpression& callExpression) >+{ >+ if (m_error) >+ return; >+ >+ if (!callExpression.hasOverloads()) { >+ if (auto* functions = m_nameContext.getFunctions(callExpression.name())) >+ callExpression.setOverloads(*functions); >+ else { >+ callExpression.setCastData(); >+ if (auto* functions = m_nameContext.getFunctions(callExpression.name())) >+ callExpression.setOverloads(*functions); >+ else { >+ m_error = true; >+ return; >+ } >+ } >+ } >+ Visitor::visit(callExpression); >+} >+ >+void NameResolver::visit(AST::ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) >+{ >+ if (m_error) >+ return; >+ >+ if (auto enumerationTypes = m_nameContext.getTypes(constantExpressionEnumerationMemberReference.left())) { >+ ASSERT(enumerationTypes->size() == 1); >+ AST::NamedType& type = (*enumerationTypes)[0]; >+ if (is<AST::EnumerationDefinition>(type)) { >+ AST::EnumerationDefinition& enumerationDefinition = downcast<AST::EnumerationDefinition>(type); >+ if (auto* member = enumerationDefinition.memberByName(constantExpressionEnumerationMemberReference.right())) { >+ constantExpressionEnumerationMemberReference.setEnumerationMember(*member); >+ return; >+ } >+ } >+ } >+ >+ m_error = true; >+} >+ >+// FIXME: Make sure all the names have been resolved. >+ >+bool resolveNamesInTypes(Program& program, NameResolver& nameResolver) >+{ >+ for (auto& typeDefinition : program.typeDefinitions()) { >+ nameResolver.Visitor::visit(*typeDefinition); >+ if (nameResolver.error()) >+ return false; >+ } >+ for (auto& structureDefinition : program.structureDefinitions()) { >+ nameResolver.Visitor::visit(*structureDefinition); >+ if (nameResolver.error()) >+ return false; >+ } >+ for (auto& enumerationDefinition : program.enumerationDefinitions()) { >+ nameResolver.Visitor::visit(*enumerationDefinition); >+ if (nameResolver.error()) >+ return false; >+ } >+ for (auto& nativeTypeDeclaration : program.nativeTypeDeclarations()) { >+ nameResolver.Visitor::visit(*nativeTypeDeclaration); >+ if (nameResolver.error()) >+ return false; >+ } >+ return true; >+} >+ >+bool resolveNamesInFunctions(Program& program, NameResolver& nameResolver) >+{ >+ for (auto& functionDefinition : program.functionDefinitions()) { >+ nameResolver.setCurrentFunctionDefinition(functionDefinition.get()); >+ nameResolver.visit(*functionDefinition); >+ if (nameResolver.error()) >+ return false; >+ } >+ nameResolver.setCurrentFunctionDefinition(nullptr); >+ for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) { >+ nameResolver.Visitor::visit(*nativeFunctionDeclaration); >+ if (nameResolver.error()) >+ return false; >+ } >+ return true; > } > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >index 47d4d6a5793..e75c746a906 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >@@ -27,13 +27,53 @@ > > #if ENABLE(WEBGPU) > >-#include "WHLSLProgram.h" >+#include "WHLSLNameContext.h" >+#include "WHLSLVisitor.h" > > namespace WebCore { > > namespace WHLSL { > >-void resolveNamesInTypes(Program& program); >+class Program; >+ >+class NameResolver : public Visitor { >+public: >+ NameResolver(NameContext&); >+ >+ virtual ~NameResolver() = default; >+ >+ void visit(AST::FunctionDefinition& functionDefinition) override; >+ >+ void setCurrentFunctionDefinition(AST::FunctionDefinition* functionDefinition) >+ { >+ m_currentFunction = functionDefinition; >+ } >+ >+ bool error() { return m_error; } >+ >+private: >+ void visit(AST::TypeReference& typeReference) override; >+ void visit(AST::Block& block) override; >+ void visit(AST::IfStatement& ifStatement) override; >+ void visit(AST::WhileLoop& whileLoop) override; >+ void visit(AST::DoWhileLoop& whileLoop) override; >+ void visit(AST::ForLoop& forLoop) override; >+ void visit(AST::VariableDeclaration& variableDeclaration) override; >+ void visit(AST::VariableReference& variableReference) override; >+ void visit(AST::Return& returnNode) override; >+ void visit(AST::PropertyAccessExpression& propertyAccessExpression) override; >+ void visit(AST::DotExpression& dotExpression) override; >+ void visit(AST::CallExpression& callExpression) override; >+ void visit(AST::ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) override; >+ >+ NameContext m_nameContext; >+ AST::FunctionDefinition* m_currentFunction { nullptr }; >+ bool m_error { false }; // FIXME: Migrate this to be some sort of descriptive string. >+ // FIXME: Consider moving the error into Visitor >+}; >+ >+bool resolveNamesInTypes(Program&, NameResolver&); >+bool resolveNamesInFunctions(Program&, NameResolver&); > > } > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >index bc6e73e6a1f..3336b9b2ea6 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >@@ -38,7 +38,8 @@ Parser::Parser() > { > } > >-auto Parser::parse(Program& result, StringView stringView, Mode mode) -> Optional<Error> >+// FIXME: Return a better error code from this, and report it to JavaScript. >+auto Parser::parse(Program& program, StringView stringView, Mode mode) -> Optional<Error> > { > m_lexer = Lexer(stringView); > m_mode = mode; >@@ -54,7 +55,11 @@ auto Parser::parse(Program& result, StringView stringView, Mode mode) -> Optiona > return parseTypeDefinition(); > }); > if (typeDefinition) { >- result.append(WTFMove(*typeDefinition)); >+ auto success = program.append(WTFMove(*typeDefinition)); >+ if (!success) { >+ WTFLogAlways("Name Error! %s", typeDefinition->name().utf8().data()); >+ return WTF::nullopt; >+ } > continue; > } > } >@@ -64,7 +69,11 @@ auto Parser::parse(Program& result, StringView stringView, Mode mode) -> Optiona > return parseStructureDefinition(); > }); > if (structureDefinition) { >- result.append(WTFMove(*structureDefinition)); >+ auto success = program.append(WTFMove(*structureDefinition)); >+ if (!success) { >+ WTFLogAlways("Name Error! %s", structureDefinition->name().utf8().data()); >+ return WTF::nullopt; >+ } > continue; > } > } >@@ -74,7 +83,11 @@ auto Parser::parse(Program& result, StringView stringView, Mode mode) -> Optiona > return parseEnumerationDefinition(); > }); > if (enumerationDefinition) { >- result.append(WTFMove(*enumerationDefinition)); >+ auto success = program.append(WTFMove(*enumerationDefinition)); >+ if (!success) { >+ WTFLogAlways("Name Error! %s", enumerationDefinition->name().utf8().data()); >+ return WTF::nullopt; >+ } > continue; > } > } >@@ -85,7 +98,11 @@ auto Parser::parse(Program& result, StringView stringView, Mode mode) -> Optiona > return parseFunctionDefinition(); > }); > if (functionDefinition) { >- result.append(WTFMove(*functionDefinition)); >+ auto success = program.append(WTFMove(*functionDefinition)); >+ if (!success) { >+ WTFLogAlways("Name Error! %s", functionDefinition->name().utf8().data()); >+ return WTF::nullopt; >+ } > continue; > } > error = functionDefinition.error(); >@@ -96,7 +113,11 @@ auto Parser::parse(Program& result, StringView stringView, Mode mode) -> Optiona > return parseNativeFunctionDeclaration(); > }); > if (nativeFunctionDeclaration) { >- result.append(WTFMove(*nativeFunctionDeclaration)); >+ auto success = program.append(WTFMove(*nativeFunctionDeclaration)); >+ if (!success) { >+ WTFLogAlways("Name Error! %s", nativeFunctionDeclaration->name().utf8().data()); >+ return WTF::nullopt; >+ } > continue; > } > } >@@ -106,7 +127,11 @@ auto Parser::parse(Program& result, StringView stringView, Mode mode) -> Optiona > return parseNativeTypeDeclaration(); > }); > if (nativeTypeDeclaration) { >- result.append(WTFMove(*nativeTypeDeclaration)); >+ auto success = program.append(WTFMove(*nativeTypeDeclaration)); >+ if (!success) { >+ WTFLogAlways("Name Error! %s", nativeTypeDeclaration->name().utf8().data()); >+ return WTF::nullopt; >+ } > continue; > } > } >@@ -454,16 +479,52 @@ auto Parser::parseTypeSuffixNonAbbreviated() -> Expected<TypeSuffixNonAbbreviate > return Unexpected<Error>(rightSquareBracket.error()); > return {{ *token, WTF::nullopt, *numElements }}; > } >- auto addressSpace = consumeTypes({ Lexer::Token::Type::Constant, Lexer::Token::Type::Device, Lexer::Token::Type::Threadgroup, Lexer::Token::Type::Thread}); >- if (!addressSpace) >- return Unexpected<Error>(addressSpace.error()); >- return {{ *token, { *addressSpace }, WTF::nullopt }}; >+ auto addressSpaceToken = consumeTypes({ Lexer::Token::Type::Constant, Lexer::Token::Type::Device, Lexer::Token::Type::Threadgroup, Lexer::Token::Type::Thread}); >+ if (!addressSpaceToken) >+ return Unexpected<Error>(addressSpaceToken.error()); >+ AST::ReferenceType::AddressSpace addressSpace; >+ switch (addressSpaceToken->type) { >+ case Lexer::Token::Type::Constant: >+ addressSpace = AST::ReferenceType::AddressSpace::Constant; >+ break; >+ case Lexer::Token::Type::Device: >+ addressSpace = AST::ReferenceType::AddressSpace::Device; >+ break; >+ case Lexer::Token::Type::Threadgroup: >+ addressSpace = AST::ReferenceType::AddressSpace::Threadgroup; >+ break; >+ case Lexer::Token::Type::Thread: >+ addressSpace = AST::ReferenceType::AddressSpace::Thread; >+ break; >+ default: >+ ASSERT_NOT_REACHED(); >+ return Unexpected<Error>(Error(String("Something really bad happened", String::ConstructFromLiteral))); >+ } >+ return {{ *token, { addressSpace }, WTF::nullopt }}; > } > >-auto Parser::parseAddressSpaceType() -> Expected<std::unique_ptr<AST::Type>, Error> { >- auto addressSpace = consumeTypes({ Lexer::Token::Type::Constant, Lexer::Token::Type::Device, Lexer::Token::Type::Threadgroup, Lexer::Token::Type::Thread}); >- if (!addressSpace) >- return Unexpected<Error>(addressSpace.error()); >+auto Parser::parseAddressSpaceType() -> Expected<std::unique_ptr<AST::UnnamedType>, Error> { >+ auto addressSpaceToken = consumeTypes({ Lexer::Token::Type::Constant, Lexer::Token::Type::Device, Lexer::Token::Type::Threadgroup, Lexer::Token::Type::Thread}); >+ if (!addressSpaceToken) >+ return Unexpected<Error>(addressSpaceToken.error()); >+ AST::ReferenceType::AddressSpace addressSpace; >+ switch (addressSpaceToken->type) { >+ case Lexer::Token::Type::Constant: >+ addressSpace = AST::ReferenceType::AddressSpace::Constant; >+ break; >+ case Lexer::Token::Type::Device: >+ addressSpace = AST::ReferenceType::AddressSpace::Device; >+ break; >+ case Lexer::Token::Type::Threadgroup: >+ addressSpace = AST::ReferenceType::AddressSpace::Threadgroup; >+ break; >+ case Lexer::Token::Type::Thread: >+ addressSpace = AST::ReferenceType::AddressSpace::Thread; >+ break; >+ default: >+ ASSERT_NOT_REACHED(); >+ return Unexpected<Error>(Error(String("Something really bad happened", String::ConstructFromLiteral))); >+ } > auto name = consumeType(Lexer::Token::Type::Identifier); > if (!name) > return Unexpected<Error>(name.error()); >@@ -471,12 +532,12 @@ auto Parser::parseAddressSpaceType() -> Expected<std::unique_ptr<AST::Type>, Err > if (!typeArguments) > return Unexpected<Error>(typeArguments.error()); > >- auto constructTypeFromSuffixAbbreviated = [&](const TypeSuffixAbbreviated& typeSuffixAbbreviated, std::unique_ptr<AST::Type>&& previous) -> std::unique_ptr<AST::Type> { >+ auto constructTypeFromSuffixAbbreviated = [&](const TypeSuffixAbbreviated& typeSuffixAbbreviated, std::unique_ptr<AST::UnnamedType>&& previous) -> std::unique_ptr<AST::UnnamedType> { > switch (typeSuffixAbbreviated.token.type) { > case Lexer::Token::Type::Star: >- return std::make_unique<AST::PointerType>(Lexer::Token(typeSuffixAbbreviated.token), addressSpace->stringView.toString(), WTFMove(previous)); >+ return std::make_unique<AST::PointerType>(Lexer::Token(typeSuffixAbbreviated.token), addressSpace, WTFMove(previous)); > case Lexer::Token::Type::SquareBracketPair: >- return std::make_unique<AST::ArrayReferenceType>(Lexer::Token(typeSuffixAbbreviated.token), addressSpace->stringView.toString(), WTFMove(previous)); >+ return std::make_unique<AST::ArrayReferenceType>(Lexer::Token(typeSuffixAbbreviated.token), addressSpace, WTFMove(previous)); > case Lexer::Token::Type::LeftSquareBracket: > return std::make_unique<AST::ArrayType>(Lexer::Token(typeSuffixAbbreviated.token), WTFMove(previous), *typeSuffixAbbreviated.numElements); > default: >@@ -488,7 +549,7 @@ auto Parser::parseAddressSpaceType() -> Expected<std::unique_ptr<AST::Type>, Err > auto firstTypeSuffixAbbreviated = parseTypeSuffixAbbreviated(); > if (!firstTypeSuffixAbbreviated) > return Unexpected<Error>(firstTypeSuffixAbbreviated.error()); >- std::unique_ptr<AST::Type> result = std::make_unique<AST::TypeReference>(Lexer::Token(*addressSpace), name->stringView.toString(), WTFMove(*typeArguments)); >+ std::unique_ptr<AST::UnnamedType> result = std::make_unique<AST::TypeReference>(WTFMove(*addressSpaceToken), name->stringView.toString(), WTFMove(*typeArguments)); > result = constructTypeFromSuffixAbbreviated(*firstTypeSuffixAbbreviated, WTFMove(result)); > while (true) { > auto typeSuffixAbbreviated = backtrackingScope<Expected<TypeSuffixAbbreviated, Error>>([&]() { >@@ -503,7 +564,7 @@ auto Parser::parseAddressSpaceType() -> Expected<std::unique_ptr<AST::Type>, Err > return WTFMove(result); > } > >-auto Parser::parseNonAddressSpaceType() -> Expected<std::unique_ptr<AST::Type>, Error> { >+auto Parser::parseNonAddressSpaceType() -> Expected<std::unique_ptr<AST::UnnamedType>, Error> { > auto origin = peek(); > if (!origin) > return Unexpected<Error>(origin.error()); >@@ -514,12 +575,12 @@ auto Parser::parseNonAddressSpaceType() -> Expected<std::unique_ptr<AST::Type>, > if (!typeArguments) > return Unexpected<Error>(typeArguments.error()); > >- auto constructTypeFromSuffixNonAbbreviated = [&](const TypeSuffixNonAbbreviated& typeSuffixNonAbbreviated, std::unique_ptr<AST::Type>&& previous) -> std::unique_ptr<AST::Type> { >+ auto constructTypeFromSuffixNonAbbreviated = [&](const TypeSuffixNonAbbreviated& typeSuffixNonAbbreviated, std::unique_ptr<AST::UnnamedType>&& previous) -> std::unique_ptr<AST::UnnamedType> { > switch (typeSuffixNonAbbreviated.token.type) { > case Lexer::Token::Type::Star: >- return std::make_unique<AST::PointerType>(Lexer::Token(typeSuffixNonAbbreviated.token), typeSuffixNonAbbreviated.addressSpace->stringView.toString(), WTFMove(previous)); >+ return std::make_unique<AST::PointerType>(Lexer::Token(typeSuffixNonAbbreviated.token), *typeSuffixNonAbbreviated.addressSpace, WTFMove(previous)); > case Lexer::Token::Type::SquareBracketPair: >- return std::make_unique<AST::ArrayReferenceType>(Lexer::Token(typeSuffixNonAbbreviated.token), typeSuffixNonAbbreviated.addressSpace->stringView.toString(), WTFMove(previous)); >+ return std::make_unique<AST::ArrayReferenceType>(Lexer::Token(typeSuffixNonAbbreviated.token), *typeSuffixNonAbbreviated.addressSpace, WTFMove(previous)); > case Lexer::Token::Type::LeftSquareBracket: > return std::make_unique<AST::ArrayType>(Lexer::Token(typeSuffixNonAbbreviated.token), WTFMove(previous), *typeSuffixNonAbbreviated.numElements); > default: >@@ -528,7 +589,7 @@ auto Parser::parseNonAddressSpaceType() -> Expected<std::unique_ptr<AST::Type>, > } > }; > >- std::unique_ptr<AST::Type> result = std::make_unique<AST::TypeReference>(WTFMove(*origin), name->stringView.toString(), WTFMove(*typeArguments)); >+ std::unique_ptr<AST::UnnamedType> result = std::make_unique<AST::TypeReference>(WTFMove(*origin), name->stringView.toString(), WTFMove(*typeArguments)); > while (true) { > auto typeSuffixNonAbbreviated = backtrackingScope<Expected<TypeSuffixNonAbbreviated, Error>>([&]() { > return parseTypeSuffixNonAbbreviated(); >@@ -542,14 +603,14 @@ auto Parser::parseNonAddressSpaceType() -> Expected<std::unique_ptr<AST::Type>, > return WTFMove(result); > } > >-auto Parser::parseType() -> Expected<std::unique_ptr<AST::Type>, Error> { >- auto type = backtrackingScope<Expected<std::unique_ptr<AST::Type>, Error>>([&]() { >+auto Parser::parseType() -> Expected<std::unique_ptr<AST::UnnamedType>, Error> { >+ auto type = backtrackingScope<Expected<std::unique_ptr<AST::UnnamedType>, Error>>([&]() { > return parseAddressSpaceType(); > }); > if (type) > return type; > >- type = backtrackingScope<Expected<std::unique_ptr<AST::Type>, Error>>([&]() { >+ type = backtrackingScope<Expected<std::unique_ptr<AST::UnnamedType>, Error>>([&]() { > return parseNonAddressSpaceType(); > }); > if (type) >@@ -847,7 +908,7 @@ auto Parser::parseEnumerationDefinition() -> Expected<AST::EnumerationDefinition > if (!name) > return Unexpected<Error>(name.error()); > >- std::unique_ptr<AST::Type> type; >+ std::unique_ptr<AST::UnnamedType> type; > if (tryType(Lexer::Token::Type::Colon)) { > auto parsedType = parseType(); > if (!parsedType) >@@ -863,21 +924,25 @@ auto Parser::parseEnumerationDefinition() -> Expected<AST::EnumerationDefinition > if (!firstEnumerationMember) > return Unexpected<Error>(firstEnumerationMember.error()); > >- AST::EnumerationMembers members; >- members.append(WTFMove(*firstEnumerationMember)); >+ AST::EnumerationDefinition result(WTFMove(*origin), name->stringView.toString(), WTFMove(type)); >+ auto success = result.add(WTFMove(*firstEnumerationMember)); >+ if (!success) >+ return fail(String("Cannot add enumeration member", String::ConstructFromLiteral)); > > while (tryType(Lexer::Token::Type::Comma)) { > auto member = parseEnumerationMember(); > if (!member) > return Unexpected<Error>(member.error()); >- members.append(WTFMove(*member)); >+ success = result.add(WTFMove(*member)); >+ if (!success) >+ return fail(String("Cannot add enumeration member", String::ConstructFromLiteral)); > } > > auto rightCurlyBracket = consumeType(Lexer::Token::Type::RightCurlyBracket); > if (!rightCurlyBracket) > return Unexpected<Error>(rightCurlyBracket.error()); > >- return AST::EnumerationDefinition(WTFMove(*origin), name->stringView.toString(), WTFMove(type), WTFMove(members)); >+ return WTFMove(result); > } > > auto Parser::parseEnumerationMember() -> Expected<AST::EnumerationMember, Error> { >@@ -981,7 +1046,7 @@ auto Parser::parseAttributeBlock() -> Expected<AST::AttributeBlock, Error> { > return WTFMove(result); > } > >-auto Parser::parseParameter() -> Expected<AST::Parameter, Error> { >+auto Parser::parseParameter() -> Expected<AST::VariableDeclaration, Error> { > auto origin = peek(); > if (!origin) > return Unexpected<Error>(origin.error()); >@@ -992,7 +1057,7 @@ auto Parser::parseParameter() -> Expected<AST::Parameter, Error> { > if (!type) > return Unexpected<Error>(type.error()); > >- Optional<String> name; >+ String name; > if (auto token = tryType(Lexer::Token::Type::Identifier)) > name = token->stringView.toString(); > >@@ -1000,18 +1065,18 @@ auto Parser::parseParameter() -> Expected<AST::Parameter, Error> { > auto semantic = parseSemantic(); > if (!semantic) > return Unexpected<Error>(semantic.error()); >- return AST::Parameter(WTFMove(*origin), WTFMove(qualifiers), WTFMove(*type), WTFMove(name), WTFMove(*semantic)); >+ return AST::VariableDeclaration(WTFMove(*origin), WTFMove(qualifiers), WTFMove(*type), WTFMove(name), WTFMove(*semantic), nullptr); > } > >- return AST::Parameter(WTFMove(*origin), WTFMove(qualifiers), WTFMove(*type), WTFMove(name), WTF::nullopt); >+ return AST::VariableDeclaration(WTFMove(*origin), WTFMove(qualifiers), WTFMove(*type), WTFMove(name), WTF::nullopt, nullptr); > } > >-auto Parser::parseParameters() -> Expected<AST::Parameters, Error> { >+auto Parser::parseParameters() -> Expected<AST::VariableDeclarations, Error> { > auto leftParenthesis = consumeType(Lexer::Token::Type::LeftParenthesis); > if (!leftParenthesis) > return Unexpected<Error>(leftParenthesis.error()); > >- AST::Parameters parameters; >+ AST::VariableDeclarations parameters; > if (tryType(Lexer::Token::Type::RightParenthesis)) > return WTFMove(parameters); > >@@ -1149,10 +1214,10 @@ auto Parser::parseOperatorFunctionDeclaration() -> Expected<AST::FunctionDeclara > auto semantic = parseSemantic(); > if (!semantic) > return Unexpected<Error>(semantic.error()); >- return AST::FunctionDeclaration(WTFMove(*origin), { }, WTF::nullopt, WTFMove(*type), String("Operator Cast", String::ConstructFromLiteral), WTFMove(*parameters), WTFMove(*semantic)); >+ return AST::FunctionDeclaration(WTFMove(*origin), { }, WTF::nullopt, WTFMove(*type), String("operator cast", String::ConstructFromLiteral), WTFMove(*parameters), WTFMove(*semantic)); > } > >- return AST::FunctionDeclaration(WTFMove(*origin), { }, WTF::nullopt, WTFMove(*type), String("Operator Cast", String::ConstructFromLiteral), WTFMove(*parameters), WTF::nullopt); >+ return AST::FunctionDeclaration(WTFMove(*origin), { }, WTF::nullopt, WTFMove(*type), String("operator cast", String::ConstructFromLiteral), WTFMove(*parameters), WTF::nullopt); > } > > auto Parser::parseFunctionDeclaration() -> Expected<AST::FunctionDeclaration, Error> { >@@ -1443,7 +1508,7 @@ auto Parser::parseDoWhileLoop() -> Expected<AST::DoWhileLoop, Error> { > return AST::DoWhileLoop(WTFMove(*origin), WTFMove(*body), WTFMove(*conditional)); > } > >-auto Parser::parseVariableDeclaration(std::unique_ptr<AST::Type>&& type) -> Expected<AST::VariableDeclaration, Error> { >+auto Parser::parseVariableDeclaration(std::unique_ptr<AST::UnnamedType>&& type) -> Expected<AST::VariableDeclaration, Error> { > auto origin = peek(); > if (!origin) > return Unexpected<Error>(origin.error()); >@@ -1488,7 +1553,7 @@ auto Parser::parseVariableDeclarations() -> Expected<AST::VariableDeclarationsSt > if (!type) > return Unexpected<Error>(type.error()); > >- auto firstVariableDeclaration = parseVariableDeclaration(std::unique_ptr<AST::Type>((*type)->clone())); >+ auto firstVariableDeclaration = parseVariableDeclaration((*type)->clone()); > if (!firstVariableDeclaration) > return Unexpected<Error>(firstVariableDeclaration.error()); > >@@ -1496,7 +1561,7 @@ auto Parser::parseVariableDeclarations() -> Expected<AST::VariableDeclarationsSt > result.append(WTFMove(*firstVariableDeclaration)); > > while (tryType(Lexer::Token::Type::Comma)) { >- auto variableDeclaration = parseVariableDeclaration(std::unique_ptr<AST::Type>((*type)->clone())); >+ auto variableDeclaration = parseVariableDeclaration((*type)->clone()); > if (!variableDeclaration) > return Unexpected<Error>(variableDeclaration.error()); > result.append(WTFMove(*variableDeclaration)); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >index da3e06b01e4..80139149804 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h >@@ -27,7 +27,6 @@ > > #if ENABLE(WEBGPU) > >-#include "WHLSLAnonymousVariableDeclaration.h" > #include "WHLSLArrayReferenceType.h" > #include "WHLSLArrayType.h" > #include "WHLSLAssignmentExpression.h" >@@ -68,7 +67,6 @@ > #include "WHLSLNode.h" > #include "WHLSLNullLiteral.h" > #include "WHLSLNumThreadsFunctionAttribute.h" >-#include "WHLSLParameter.h" > #include "WHLSLPointerType.h" > #include "WHLSLProgram.h" > #include "WHLSLPropertyAccessExpression.h" >@@ -154,13 +152,13 @@ private: > Expected<TypeSuffixAbbreviated, Error> parseTypeSuffixAbbreviated(); > struct TypeSuffixNonAbbreviated { > Lexer::Token token; >- Optional<Lexer::Token> addressSpace; >+ Optional<AST::ReferenceType::AddressSpace> addressSpace; > Optional<unsigned> numElements; > }; > Expected<TypeSuffixNonAbbreviated, Error> parseTypeSuffixNonAbbreviated(); >- Expected<std::unique_ptr<AST::Type>, Error> parseAddressSpaceType(); >- Expected<std::unique_ptr<AST::Type>, Error> parseNonAddressSpaceType(); >- Expected<std::unique_ptr<AST::Type>, Error> parseType(); >+ Expected<std::unique_ptr<AST::UnnamedType>, Error> parseAddressSpaceType(); >+ Expected<std::unique_ptr<AST::UnnamedType>, Error> parseNonAddressSpaceType(); >+ Expected<std::unique_ptr<AST::UnnamedType>, Error> parseType(); > Expected<AST::TypeDefinition, Error> parseTypeDefinition(); > Expected<AST::BuiltInSemantic, Error> parseBuiltInSemantic(); > Expected<AST::ResourceSemantic, Error> parseResourceSemantic(); >@@ -175,8 +173,8 @@ private: > Expected<AST::NativeTypeDeclaration, Error> parseNativeTypeDeclaration(); > Expected<AST::NumThreadsFunctionAttribute, Error> parseNumThreadsFunctionAttribute(); > Expected<AST::AttributeBlock, Error> parseAttributeBlock(); >- Expected<AST::Parameter, Error> parseParameter(); >- Expected<AST::Parameters, Error> parseParameters(); >+ Expected<AST::VariableDeclaration, Error> parseParameter(); >+ Expected<AST::VariableDeclarations, Error> parseParameters(); > Expected<AST::FunctionDeclaration, Error> parseEntryPointFunctionDeclaration(); > Expected<AST::FunctionDeclaration, Error> parseRegularFunctionDeclaration(); > Expected<AST::FunctionDeclaration, Error> parseOperatorFunctionDeclaration(); >@@ -192,7 +190,7 @@ private: > Expected<AST::ForLoop, Error> parseForLoop(); > Expected<AST::WhileLoop, Error> parseWhileLoop(); > Expected<AST::DoWhileLoop, Error> parseDoWhileLoop(); >- Expected<AST::VariableDeclaration, Error> parseVariableDeclaration(std::unique_ptr<AST::Type>&&); >+ Expected<AST::VariableDeclaration, Error> parseVariableDeclaration(std::unique_ptr<AST::UnnamedType>&&); > Expected<AST::VariableDeclarationsStatement, Error> parseVariableDeclarations(); > Expected<std::unique_ptr<AST::Statement>, Error> parseStatement(); > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp >index 0eb64decd4d..460e946fdda 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp >@@ -28,10 +28,17 @@ > #include "config.h" > #include "WHLSLPrepare.h" > >+#include "WHLSLCheckDuplicateFunctions.h" >+#include "WHLSLChecker.h" > #include "WHLSLNameResolver.h" > #include "WHLSLParser.h" > #include "WHLSLProgram.h" >+#include "WHLSLRecursiveTypeChecker.h" > #include "WHLSLStandardLibrary.h" >+#include "WHLSLSynthesizeArrayOperatorLength.h" >+#include "WHLSLSynthesizeConstructors.h" >+#include "WHLSLSynthesizeEnumerationFunctions.h" >+#include "WHLSLSynthesizeStructureAccessors.h" > > namespace WebCore { > >@@ -50,8 +57,23 @@ Optional<PreparationResult> prepare(StringView source) > if (!success) > return WTF::nullopt; > >- resolveNamesInTypes(program); >+ NameResolver nameResolver(program.nameContext()); >+ if (!resolveNamesInTypes(program, nameResolver)) >+ return WTF::nullopt; >+ if (!checkRecursiveTypes(program)) >+ return WTF::nullopt; >+ synthesizeStructureAccessors(program); >+ synthesizeEnumerationFunctions(program); >+ synthesizeArrayOperatorLength(program); >+ synthesizeConstructors(program); >+ if (!checkDuplicateFunctions(program)) >+ return WTF::nullopt; >+ if (!resolveNamesInFunctions(program, nameResolver)) >+ return WTF::nullopt; >+ > >+ if (check(program)) >+ return WTF::nullopt; > return PreparationResult(); > } > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >index 5630fe69ee4..60ee479015a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >@@ -29,6 +29,8 @@ > > #include "WHLSLEnumerationDefinition.h" > #include "WHLSLFunctionDefinition.h" >+#include "WHLSLIntrinsics.h" >+#include "WHLSLNameContext.h" > #include "WHLSLNativeFunctionDeclaration.h" > #include "WHLSLNativeTypeDeclaration.h" > #include "WHLSLStructureDefinition.h" >@@ -44,45 +46,64 @@ public: > Program() = default; > Program(Program&&) = default; > >- void append(AST::TypeDefinition&& typeDefinition) >+ bool append(AST::TypeDefinition&& typeDefinition) > { >- m_typeDefinitions.append(WTFMove(typeDefinition)); >+ m_typeDefinitions.append(std::make_unique<AST::TypeDefinition>(WTFMove(typeDefinition))); >+ return m_nameContext.add(*m_typeDefinitions.last()); > } >- void append(AST::StructureDefinition&& structureDefinition) >+ >+ bool append(AST::StructureDefinition&& structureDefinition) > { >- m_structureDefinitions.append(WTFMove(structureDefinition)); >+ m_structureDefinitions.append(std::make_unique<AST::StructureDefinition>(WTFMove(structureDefinition))); >+ return m_nameContext.add(*m_structureDefinitions.last()); > } >- void append(AST::EnumerationDefinition&& enumerationDefinition) >+ >+ bool append(AST::EnumerationDefinition&& enumerationDefinition) > { >- m_enumerationDefinitions.append(WTFMove(enumerationDefinition)); >+ m_enumerationDefinitions.append(std::make_unique<AST::EnumerationDefinition>(WTFMove(enumerationDefinition))); >+ return m_nameContext.add(*m_enumerationDefinitions.last()); > } >- void append(AST::FunctionDefinition&& functionDefinition) >+ >+ bool append(AST::FunctionDefinition&& functionDefinition) > { >- m_functionDefinitions.append(WTFMove(functionDefinition)); >+ m_functionDefinitions.append(std::make_unique<AST::FunctionDefinition>(WTFMove(functionDefinition))); >+ return m_nameContext.add(*m_functionDefinitions.last()); > } >- void append(AST::NativeFunctionDeclaration&& nativeFunctionDeclaration) >+ >+ bool append(AST::NativeFunctionDeclaration&& nativeFunctionDeclaration) > { >- m_nativeFunctionDeclarations.append(WTFMove(nativeFunctionDeclaration)); >+ m_nativeFunctionDeclarations.append(std::make_unique<AST::NativeFunctionDeclaration>(WTFMove(nativeFunctionDeclaration))); >+ m_intrinsics.add(*m_nativeFunctionDeclarations.last()); >+ return m_nameContext.add(*m_nativeFunctionDeclarations.last()); > } >- void append(AST::NativeTypeDeclaration&& nativeTypeDeclaration) >+ >+ bool append(AST::NativeTypeDeclaration&& nativeTypeDeclaration) > { >- m_nativeTypeDeclarations.append(WTFMove(nativeTypeDeclaration)); >+ m_nativeTypeDeclarations.append(std::make_unique<AST::NativeTypeDeclaration>(WTFMove(nativeTypeDeclaration))); >+ m_intrinsics.add(*m_nativeTypeDeclarations.last()); >+ return m_nameContext.add(*m_nativeTypeDeclarations.last()); > } > >- Vector<AST::TypeDefinition>& typeDefinitions() { return m_typeDefinitions; } >- Vector<AST::StructureDefinition>& structureDefinitions() { return m_structureDefinitions; } >- Vector<AST::EnumerationDefinition>& enumerationDefinitions() { return m_enumerationDefinitions; } >- Vector<AST::FunctionDefinition>& functionDefinitions() { return m_functionDefinitions; } >- Vector<AST::NativeFunctionDeclaration>& nativeFunctionDeclarations() { return m_nativeFunctionDeclarations; } >- Vector<AST::NativeTypeDeclaration>& nativeTypeDeclarations() { return m_nativeTypeDeclarations; } >+ NameContext& nameContext() { return m_nameContext; } >+ Intrinsics& intrinsics() { return m_intrinsics; } >+ Vector<std::unique_ptr<AST::TypeDefinition>>& typeDefinitions() { return m_typeDefinitions; } >+ Vector<std::unique_ptr<AST::StructureDefinition>>& structureDefinitions() { return m_structureDefinitions; } >+ Vector<std::unique_ptr<AST::EnumerationDefinition>>& enumerationDefinitions() { return m_enumerationDefinitions; } >+ const Vector<std::unique_ptr<AST::FunctionDefinition>>& functionDefinitions() const { return m_functionDefinitions; } >+ Vector<std::unique_ptr<AST::FunctionDefinition>>& functionDefinitions() { return m_functionDefinitions; } >+ const Vector<std::unique_ptr<AST::NativeFunctionDeclaration>>& nativeFunctionDeclarations() const { return m_nativeFunctionDeclarations; } >+ Vector<std::unique_ptr<AST::NativeFunctionDeclaration>>& nativeFunctionDeclarations() { return m_nativeFunctionDeclarations; } >+ Vector<std::unique_ptr<AST::NativeTypeDeclaration>>& nativeTypeDeclarations() { return m_nativeTypeDeclarations; } > > private: >- Vector<AST::TypeDefinition> m_typeDefinitions; >- Vector<AST::StructureDefinition> m_structureDefinitions; >- Vector<AST::EnumerationDefinition> m_enumerationDefinitions; >- Vector<AST::FunctionDefinition> m_functionDefinitions; >- Vector<AST::NativeFunctionDeclaration> m_nativeFunctionDeclarations; >- Vector<AST::NativeTypeDeclaration> m_nativeTypeDeclarations; >+ NameContext m_nameContext; >+ Intrinsics m_intrinsics; >+ Vector<std::unique_ptr<AST::TypeDefinition>> m_typeDefinitions; >+ Vector<std::unique_ptr<AST::StructureDefinition>> m_structureDefinitions; >+ Vector<std::unique_ptr<AST::EnumerationDefinition>> m_enumerationDefinitions; >+ Vector<std::unique_ptr<AST::FunctionDefinition>> m_functionDefinitions; >+ Vector<std::unique_ptr<AST::NativeFunctionDeclaration>> m_nativeFunctionDeclarations; >+ Vector<std::unique_ptr<AST::NativeTypeDeclaration>> m_nativeTypeDeclarations; > }; > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.cpp >new file mode 100644 >index 00000000000..8b3d0c2743e >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.cpp >@@ -0,0 +1,117 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLRecursiveTypeChecker.h" >+ >+#include "WHLSLVisitor.h" >+#include <wtf/HashSet.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class RecursiveTypeChecker : public Visitor { >+public: >+ ~RecursiveTypeChecker() = default; >+ >+ void visit(AST::TypeDefinition& typeDefinition) override >+ { >+ if (m_error) >+ return; >+ >+ auto addResult = m_types.add(&typeDefinition); >+ if (addResult.isNewEntry) { >+ m_error = true; >+ return; >+ } >+ >+ Visitor::visit(typeDefinition); >+ >+ auto success = m_types.remove(&typeDefinition); >+ ASSERT_UNUSED(success, success); >+ } >+ >+ void visit(AST::StructureDefinition& structureDefinition) override >+ { >+ if (m_error) >+ return; >+ >+ auto addResult = m_types.add(&structureDefinition); >+ if (addResult.isNewEntry) { >+ m_error = true; >+ return; >+ } >+ >+ Visitor::visit(structureDefinition); >+ >+ auto success = m_types.remove(&structureDefinition); >+ ASSERT_UNUSED(success, success); >+ } >+ >+ void visit(AST::TypeReference& typeReference) override >+ { >+ if (m_error) >+ return; >+ >+ auto addResult = m_types.add(&typeReference); >+ if (addResult.isNewEntry) { >+ m_error = true; >+ return; >+ } >+ >+ for (auto& typeArgument : typeReference.typeArguments()) >+ Visitor::visit(typeArgument); >+ visitNamedType(*typeReference.resolvedType()); >+ >+ auto success = m_types.remove(&typeReference); >+ ASSERT_UNUSED(success, success); >+ } >+ >+ void visit(AST::ReferenceType&) override >+ { >+ } >+ >+ bool error() { return m_error; } >+ >+private: >+ bool m_error { false }; >+ HashSet<AST::Type*> m_types; >+}; >+ >+bool checkRecursiveTypes(Program& program) >+{ >+ RecursiveTypeChecker recursiveTypeChecker; >+ recursiveTypeChecker.Visitor::visit(program); >+ return recursiveTypeChecker.error(); >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.h >new file mode 100644 >index 00000000000..9a3a19dce20 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.h >@@ -0,0 +1,43 @@ >+/* >+ * 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 { >+ >+class Program; >+ >+bool checkRecursiveTypes(Program&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLResolveOverloadImpl.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLResolveOverloadImpl.cpp >new file mode 100644 >index 00000000000..a22835f1e64 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLResolveOverloadImpl.cpp >@@ -0,0 +1,55 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLResolveOverloadImpl.h" >+ >+#include "WHLSLInferTypes.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+AST::NamedType* resolveTypeOverloadImpl(Vector<std::reference_wrapper<AST::NamedType>, 1>& possibleTypes, AST::TypeArguments& typeArguments) >+{ >+ AST::NamedType* result = nullptr; >+ for (auto& possibleType : possibleTypes) { >+ if (inferTypesForTypeArguments(possibleType, typeArguments)) { >+ if (result) >+ return nullptr; >+ result = &static_cast<AST::NamedType&>(possibleType); >+ } >+ } >+ >+ return result; >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLResolveOverloadImpl.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLResolveOverloadImpl.h >new file mode 100644 >index 00000000000..c3f60ea9d65 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLResolveOverloadImpl.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 "WHLSLTypeArgument.h" >+#include <functional> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+class NamedType; >+ >+} >+ >+AST::NamedType* resolveTypeOverloadImpl(Vector<std::reference_wrapper<AST::NamedType>, 1>&, AST::TypeArguments&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp >new file mode 100644 >index 00000000000..0b4bd50086b >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp >@@ -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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLSynthesizeArrayOperatorLength.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class FindArrayTypes : public Visitor { >+public: >+ ~FindArrayTypes() = default; >+ >+ void visit(AST::ArrayType& arrayType) override >+ { >+ m_arrayTypes.append(arrayType); >+ Visitor::visit(arrayType); >+ } >+ >+ Vector<std::reference_wrapper<AST::ArrayType>>&& takeArrayTypes() >+ { >+ return WTFMove(m_arrayTypes); >+ } >+ >+private: >+ Vector<std::reference_wrapper<AST::ArrayType>> m_arrayTypes; >+}; >+ >+void synthesizeArrayOperatorLength(Program& program) >+{ >+ FindArrayTypes findArrayTypes; >+ findArrayTypes.Visitor::visit(program); >+ auto arrayTypes = findArrayTypes.takeArrayTypes(); >+ >+ for (auto& arrayType : arrayTypes) { >+ AST::VariableDeclaration variableDeclaration(Lexer::Token(arrayType.get().origin()), AST::Qualifiers(), arrayType.get().clone(), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration)); >+ AST::NativeFunctionDeclaration nativeFunctionDeclaration(Lexer::Token(arrayType.get().origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(arrayType.get().origin()), program.intrinsics().uintType()), String("operator.length", String::ConstructFromLiteral), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(nativeFunctionDeclaration)); >+ } >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.h >new file mode 100644 >index 00000000000..e9a9a114f27 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.h >@@ -0,0 +1,42 @@ >+/* >+ * 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 { >+ >+class Program; >+ >+void synthesizeArrayOperatorLength(Program&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp >new file mode 100644 >index 00000000000..91f9dc04aec >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp >@@ -0,0 +1,124 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLSynthesizeConstructors.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class FindAllTypes : public Visitor { >+public: >+ ~FindAllTypes() = default; >+ >+ void visit(AST::PointerType& pointerType) override >+ { >+ m_unnamedTypes.append(pointerType); >+ Visitor::visit(pointerType); >+ } >+ >+ void visit(AST::ArrayReferenceType& arrayReferenceType) override >+ { >+ m_unnamedTypes.append(arrayReferenceType); >+ Visitor::visit(arrayReferenceType); >+ } >+ >+ void visit(AST::ArrayType& arrayType) override >+ { >+ m_unnamedTypes.append(arrayType); >+ Visitor::visit(arrayType); >+ } >+ >+ void visit(AST::EnumerationDefinition& enumerationDefinition) override >+ { >+ m_namedTypes.append(enumerationDefinition); >+ Visitor::visit(enumerationDefinition); >+ } >+ >+ void visit(AST::StructureDefinition& structureDefinition) override >+ { >+ m_namedTypes.append(structureDefinition); >+ Visitor::visit(structureDefinition); >+ } >+ >+ void visit(AST::NativeTypeDeclaration& nativeTypeDeclaration) override >+ { >+ m_namedTypes.append(nativeTypeDeclaration); >+ Visitor::visit(nativeTypeDeclaration); >+ } >+ >+ Vector<std::reference_wrapper<AST::UnnamedType>>&& takeUnnamedTypes() >+ { >+ return WTFMove(m_unnamedTypes); >+ } >+ >+ Vector<std::reference_wrapper<AST::NamedType>>&& takeNamedTypes() >+ { >+ return WTFMove(m_namedTypes); >+ } >+ >+private: >+ Vector<std::reference_wrapper<AST::UnnamedType>> m_unnamedTypes; >+ Vector<std::reference_wrapper<AST::NamedType>> m_namedTypes; >+}; >+ >+void synthesizeConstructors(Program& program) >+{ >+ FindAllTypes findAllTypes; >+ findAllTypes.Visitor::visit(program); >+ auto m_unnamedTypes = findAllTypes.takeUnnamedTypes(); >+ auto m_namedTypes = findAllTypes.takeNamedTypes(); >+ >+ for (auto& unnamedType : m_unnamedTypes) { >+ AST::VariableDeclaration variableDeclaration(Lexer::Token(unnamedType.get().origin()), AST::Qualifiers(), unnamedType.get().clone(), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration)); >+ AST::NativeFunctionDeclaration copyConstructor(Lexer::Token(unnamedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, unnamedType.get().clone(), String("operator cast", String::ConstructFromLiteral), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(copyConstructor)); >+ >+ AST::NativeFunctionDeclaration defaultConstructor(Lexer::Token(unnamedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, unnamedType.get().clone(), String("operator cast", String::ConstructFromLiteral), AST::VariableDeclarations(), WTF::nullopt, false); >+ program.append(WTFMove(defaultConstructor)); >+ } >+ >+ for (auto& namedType : m_namedTypes) { >+ AST::VariableDeclaration variableDeclaration(Lexer::Token(namedType.get().origin()), AST::Qualifiers(), AST::TypeReference::wrap(Lexer::Token(namedType.get().origin()), namedType.get()), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration)); >+ AST::NativeFunctionDeclaration copyConstructor(Lexer::Token(namedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(namedType.get().origin()), namedType.get()), String("operator cast", String::ConstructFromLiteral), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(copyConstructor)); >+ >+ AST::NativeFunctionDeclaration defaultConstructor(Lexer::Token(namedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(namedType.get().origin()), namedType.get()), String("operator cast", String::ConstructFromLiteral), AST::VariableDeclarations(), WTF::nullopt, false); >+ program.append(WTFMove(defaultConstructor)); >+ } >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.h >new file mode 100644 >index 00000000000..80020dd7c70 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.h >@@ -0,0 +1,42 @@ >+/* >+ * 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 { >+ >+class Program; >+ >+void synthesizeConstructors(Program&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp >new file mode 100644 >index 00000000000..3b2307f3337 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp >@@ -0,0 +1,78 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLSynthesizeEnumerationFunctions.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+void synthesizeEnumerationFunctions(Program& program) >+{ >+ for (auto& enumerationDefinition : program.enumerationDefinitions()) { >+ { >+ AST::VariableDeclaration variableDeclaration1(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), *enumerationDefinition), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclaration variableDeclaration2(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), *enumerationDefinition), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration1)); >+ parameters.append(WTFMove(variableDeclaration2)); >+ AST::NativeFunctionDeclaration nativeFunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), program.intrinsics().boolType()), String("operator==", String::ConstructFromLiteral), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(nativeFunctionDeclaration)); >+ } >+ >+ { >+ AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), *enumerationDefinition), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration)); >+ AST::NativeFunctionDeclaration nativeFunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type().clone(), String("operator.value", String::ConstructFromLiteral), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(nativeFunctionDeclaration)); >+ } >+ >+ { >+ AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), *enumerationDefinition), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration)); >+ AST::NativeFunctionDeclaration nativeFunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type().clone(), String("operator cast", String::ConstructFromLiteral), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(nativeFunctionDeclaration)); >+ } >+ >+ { >+ AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), enumerationDefinition->type().clone(), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration)); >+ AST::NativeFunctionDeclaration nativeFunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), *enumerationDefinition), String("operator cast", String::ConstructFromLiteral), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(nativeFunctionDeclaration)); >+ } >+ } >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.h >new file mode 100644 >index 00000000000..ac107872ef9 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.h >@@ -0,0 +1,42 @@ >+/* >+ * 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 { >+ >+class Program; >+ >+void synthesizeEnumerationFunctions(Program&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp >new file mode 100644 >index 00000000000..3a2302787da >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp >@@ -0,0 +1,87 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLSynthesizeStructureAccessors.h" >+ >+#include "WHLSLPointerType.h" >+#include "WHLSLProgram.h" >+#include "WHLSLReferenceType.h" >+#include "WHLSLTypeReference.h" >+#include "WHLSLVariableDeclaration.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+void synthesizeStructureAccessors(Program& program) >+{ >+ for (auto& structureDefinition : program.structureDefinitions()) { >+ for (auto& structureElement : structureDefinition->structureElements()) { >+ { >+ // The getter: operator.field >+ AST::VariableDeclaration variableDeclaration(Lexer::Token(structureElement.origin()), AST::Qualifiers(), AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), *structureDefinition), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration)); >+ AST::NativeFunctionDeclaration nativeFunctionDeclaration(Lexer::Token(structureElement.origin()), AST::AttributeBlock(), WTF::nullopt, structureElement.type().clone(), String::format("operator.%s", structureElement.name().utf8().data()), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(nativeFunctionDeclaration)); >+ } >+ >+ { >+ // The setter: operator.field= >+ AST::VariableDeclaration variableDeclaration1(Lexer::Token(structureElement.origin()), AST::Qualifiers(), AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), *structureDefinition), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclaration variableDeclaration2(Lexer::Token(structureElement.origin()), AST::Qualifiers(), structureElement.type().clone(), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration1)); >+ parameters.append(WTFMove(variableDeclaration2)); >+ AST::NativeFunctionDeclaration nativeFunctionDeclaration(Lexer::Token(structureElement.origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), *structureDefinition), String::format("operator.%s=", structureElement.name().utf8().data()), WTFMove(parameters), WTF::nullopt, false); >+ program.append(WTFMove(nativeFunctionDeclaration)); >+ } >+ >+ // The ander: operator&.field >+ auto createAnder = [&](AST::ReferenceType::AddressSpace addressSpace) -> AST::NativeFunctionDeclaration { >+ auto argumentType = std::make_unique<AST::PointerType>(Lexer::Token(structureElement.origin()), addressSpace, AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), *structureDefinition)); >+ AST::VariableDeclaration variableDeclaration(Lexer::Token(structureElement.origin()), AST::Qualifiers(), WTFMove(argumentType), String(), WTF::nullopt, nullptr); >+ AST::VariableDeclarations parameters; >+ parameters.append(WTFMove(variableDeclaration)); >+ auto returnType = std::make_unique<AST::PointerType>(Lexer::Token(structureElement.origin()), addressSpace, structureElement.type().clone()); >+ AST::NativeFunctionDeclaration nativeFunctionDeclaration(Lexer::Token(structureElement.origin()), AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), String::format("operator&.%s", structureElement.name().utf8().data()), WTFMove(parameters), WTF::nullopt, false); >+ return nativeFunctionDeclaration; >+ }; >+ program.append(createAnder(AST::ReferenceType::AddressSpace::Constant)); >+ program.append(createAnder(AST::ReferenceType::AddressSpace::Device)); >+ program.append(createAnder(AST::ReferenceType::AddressSpace::Threadgroup)); >+ program.append(createAnder(AST::ReferenceType::AddressSpace::Thread)); >+ } >+ } >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.h >new file mode 100644 >index 00000000000..4e9b9ff70c0 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.h >@@ -0,0 +1,42 @@ >+/* >+ * 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 { >+ >+class Program; >+ >+void synthesizeStructureAccessors(Program&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp >new file mode 100644 >index 00000000000..b38035dc9bf >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp >@@ -0,0 +1,585 @@ >+/* >+ * 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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLVisitor.h" >+ >+#include "WHLSLProgram.h" >+#include "WHLSLArrayReferenceType.h" >+#include "WHLSLArrayType.h" >+#include "WHLSLAssignmentExpression.h" >+#include "WHLSLBaseFunctionAttribute.h" >+#include "WHLSLBaseSemantic.h" >+#include "WHLSLBlock.h" >+#include "WHLSLBooleanLiteral.h" >+#include "WHLSLBreak.h" >+#include "WHLSLBuiltInSemantic.h" >+#include "WHLSLCallExpression.h" >+#include "WHLSLCommaExpression.h" >+#include "WHLSLConstantExpression.h" >+#include "WHLSLConstantExpressionEnumerationMemberReference.h" >+#include "WHLSLContinue.h" >+#include "WHLSLDereferenceExpression.h" >+#include "WHLSLDoWhileLoop.h" >+#include "WHLSLDotExpression.h" >+#include "WHLSLEffectfulExpressionStatement.h" >+#include "WHLSLEnumerationDefinition.h" >+#include "WHLSLEnumerationMember.h" >+#include "WHLSLExpression.h" >+#include "WHLSLFallthrough.h" >+#include "WHLSLFloatLiteral.h" >+#include "WHLSLForLoop.h" >+#include "WHLSLFunctionAttribute.h" >+#include "WHLSLFunctionDeclaration.h" >+#include "WHLSLFunctionDefinition.h" >+#include "WHLSLIfStatement.h" >+#include "WHLSLIndexExpression.h" >+#include "WHLSLIntegerLiteral.h" >+#include "WHLSLLogicalExpression.h" >+#include "WHLSLLogicalNotExpression.h" >+#include "WHLSLMakeArrayReferenceExpression.h" >+#include "WHLSLMakePointerExpression.h" >+#include "WHLSLNativeFunctionDeclaration.h" >+#include "WHLSLNativeTypeDeclaration.h" >+#include "WHLSLNode.h" >+#include "WHLSLNullLiteral.h" >+#include "WHLSLNumThreadsFunctionAttribute.h" >+#include "WHLSLPointerType.h" >+#include "WHLSLPropertyAccessExpression.h" >+#include "WHLSLQualifier.h" >+#include "WHLSLReadModifyWriteExpression.h" >+#include "WHLSLReferenceType.h" >+#include "WHLSLResourceSemantic.h" >+#include "WHLSLReturn.h" >+#include "WHLSLSemantic.h" >+#include "WHLSLSpecializationConstantSemantic.h" >+#include "WHLSLStageInOutSemantic.h" >+#include "WHLSLStatement.h" >+#include "WHLSLStructureDefinition.h" >+#include "WHLSLStructureElement.h" >+#include "WHLSLSwitchCase.h" >+#include "WHLSLSwitchStatement.h" >+#include "WHLSLTernaryExpression.h" >+#include "WHLSLTrap.h" >+#include "WHLSLType.h" >+#include "WHLSLTypeArgument.h" >+#include "WHLSLTypeDefinition.h" >+#include "WHLSLTypeReference.h" >+#include "WHLSLUnsignedIntegerLiteral.h" >+#include "WHLSLValue.h" >+#include "WHLSLVariableDeclaration.h" >+#include "WHLSLVariableDeclarationsStatement.h" >+#include "WHLSLVariableReference.h" >+#include "WHLSLWhileLoop.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+void Visitor::visit(Program& program) >+{ >+ for (auto& typeDefinition : program.typeDefinitions()) >+ visit(*typeDefinition); >+ for (auto& structureDefinition : program.structureDefinitions()) >+ visit(*structureDefinition); >+ for (auto& enumerationDefinition : program.enumerationDefinitions()) >+ visit(*enumerationDefinition); >+ for (auto& functionDefinition : program.functionDefinitions()) >+ visit(*functionDefinition); >+ for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) >+ visit(*nativeFunctionDeclaration); >+ for (auto& nativeTypeDeclaration : program.nativeTypeDeclarations()) >+ visit(*nativeTypeDeclaration); >+} >+ >+void Visitor::visitUnnamedType(AST::UnnamedType& unnamedType) >+{ >+ if (is<AST::TypeReference>(unnamedType)) >+ visit(downcast<AST::TypeReference>(unnamedType)); >+ else if (is<AST::PointerType>(unnamedType)) >+ visit(downcast<AST::PointerType>(unnamedType)); >+ else if (is<AST::ArrayReferenceType>(unnamedType)) >+ visit(downcast<AST::ArrayReferenceType>(unnamedType)); >+ else { >+ ASSERT(is<AST::ArrayType>(unnamedType)); >+ visit(downcast<AST::ArrayType>(unnamedType)); >+ } >+} >+ >+void Visitor::visitNamedType(AST::NamedType& namedType) >+{ >+ if (is<AST::TypeDefinition>(namedType)) >+ visit(downcast<AST::TypeDefinition>(namedType)); >+ else if (is<AST::StructureDefinition>(namedType)) >+ visit(downcast<AST::StructureDefinition>(namedType)); >+ else if (is<AST::EnumerationDefinition>(namedType)) >+ visit(downcast<AST::EnumerationDefinition>(namedType)); >+ else { >+ ASSERT(is<AST::NativeTypeDeclaration>(namedType)); >+ visit(downcast<AST::NativeTypeDeclaration>(namedType)); >+ } >+} >+ >+void Visitor::visit(AST::TypeDefinition& typeDefinition) >+{ >+ visitUnnamedType(typeDefinition.type()); >+} >+ >+void Visitor::visit(AST::StructureDefinition& structureDefinition) >+{ >+ for (auto& structureElement : structureDefinition.structureElements()) >+ visit(structureElement); >+} >+ >+void Visitor::visit(AST::EnumerationDefinition& enumerationDefinition) >+{ >+ visitUnnamedType(enumerationDefinition.type()); >+ for (auto& enumerationMember : enumerationDefinition.enumerationMembers()) >+ visit(enumerationMember); >+} >+ >+void Visitor::visit(AST::FunctionDefinition& functionDefinition) >+{ >+ visit(static_cast<AST::FunctionDeclaration&>(functionDefinition)); >+ visit(functionDefinition.block()); >+} >+ >+void Visitor::visit(AST::NativeFunctionDeclaration& nativeFunctionDeclaration) >+{ >+ visit(static_cast<AST::FunctionDeclaration&>(nativeFunctionDeclaration)); >+} >+ >+void Visitor::visit(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ for (auto& typeArgument : nativeTypeDeclaration.typeArguments()) >+ visit(typeArgument); >+} >+ >+void Visitor::visit(AST::TypeReference& typeReference) >+{ >+ for (auto& typeArgument : typeReference.typeArguments()) >+ visit(typeArgument); >+ if (typeReference.resolvedType() && is<AST::TypeDefinition>(*typeReference.resolvedType())) >+ visitUnnamedType(downcast<AST::TypeDefinition>(*typeReference.resolvedType()).type()); >+} >+ >+void Visitor::visit(AST::PointerType& pointerType) >+{ >+ visit(static_cast<AST::ReferenceType&>(pointerType)); >+} >+ >+void Visitor::visit(AST::ArrayReferenceType& arrayReferenceType) >+{ >+ visit(static_cast<AST::ReferenceType&>(arrayReferenceType)); >+} >+ >+void Visitor::visit(AST::ArrayType& arrayType) >+{ >+ visitUnnamedType(arrayType.type()); >+} >+ >+void Visitor::visit(AST::StructureElement& structureElement) >+{ >+ visitUnnamedType(structureElement.type()); >+ if (structureElement.semantic()) >+ visit(*structureElement.semantic()); >+} >+ >+void Visitor::visit(AST::EnumerationMember& enumerationMember) >+{ >+ if (enumerationMember.value()) >+ visit(*enumerationMember.value()); >+} >+ >+void Visitor::visit(AST::FunctionDeclaration& functionDeclaration) >+{ >+ visit(functionDeclaration.attributeBlock()); >+ visitUnnamedType(functionDeclaration.type()); >+ for (auto& parameter : functionDeclaration.parameters()) >+ visit(parameter); >+ if (functionDeclaration.semantic()) >+ visit(*functionDeclaration.semantic()); >+} >+ >+void Visitor::visit(AST::TypeArgument& typeArgument) >+{ >+ WTF::visit(WTF::makeVisitor([&](AST::ConstantExpression& constantExpression) { >+ visit(constantExpression); >+ }, [&](std::unique_ptr<AST::TypeReference>& typeReference) { >+ visit(*typeReference); >+ }), typeArgument); >+} >+ >+void Visitor::visit(AST::ReferenceType& referenceType) >+{ >+ visitUnnamedType(referenceType.elementType()); >+} >+ >+void Visitor::visit(AST::Semantic& semantic) >+{ >+ WTF::visit(WTF::makeVisitor([&](AST::BuiltInSemantic& builtInSemantic) { >+ visit(builtInSemantic); >+ }, [&](AST::ResourceSemantic& resourceSemantic) { >+ visit(resourceSemantic); >+ }, [&](AST::SpecializationConstantSemantic& specializationConstantSemantic) { >+ visit(specializationConstantSemantic); >+ }, [&](AST::StageInOutSemantic& stageInOutSemantic) { >+ visit(stageInOutSemantic); >+ }), semantic); >+} >+ >+void Visitor::visit(AST::ConstantExpression& constantExpression) >+{ >+ constantExpression.visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >+ visit(integerLiteral); >+ }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >+ visit(unsignedIntegerLiteral); >+ }, [&](AST::FloatLiteral& floatLiteral) { >+ visit(floatLiteral); >+ }, [&](AST::NullLiteral& nullLiteral) { >+ visit(nullLiteral); >+ }, [&](AST::BooleanLiteral& booleanLiteral) { >+ visit(booleanLiteral); >+ }, [&](AST::ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) { >+ visit(constantExpressionEnumerationMemberReference); >+ })); >+} >+ >+void Visitor::visit(AST::AttributeBlock& attributeBlock) >+{ >+ for (auto& functionAttribute : attributeBlock) >+ visit(functionAttribute); >+} >+ >+void Visitor::visit(AST::BuiltInSemantic&) >+{ >+} >+ >+void Visitor::visit(AST::ResourceSemantic&) >+{ >+} >+ >+void Visitor::visit(AST::SpecializationConstantSemantic&) >+{ >+} >+ >+void Visitor::visit(AST::StageInOutSemantic&) >+{ >+} >+ >+void Visitor::visit(AST::IntegerLiteral&) >+{ >+} >+ >+void Visitor::visit(AST::UnsignedIntegerLiteral&) >+{ >+} >+ >+void Visitor::visit(AST::FloatLiteral&) >+{ >+} >+ >+void Visitor::visit(AST::NullLiteral&) >+{ >+} >+ >+void Visitor::visit(AST::BooleanLiteral&) >+{ >+} >+ >+void Visitor::visit(AST::ConstantExpressionEnumerationMemberReference&) >+{ >+} >+ >+void Visitor::visit(AST::FunctionAttribute& functionAttribute) >+{ >+ WTF::visit(WTF::makeVisitor([&](AST::NumThreadsFunctionAttribute& numThreadsFunctionAttribute) { >+ visit(numThreadsFunctionAttribute); >+ }), functionAttribute); >+} >+ >+void Visitor::visit(AST::NumThreadsFunctionAttribute&) >+{ >+} >+ >+void Visitor::visit(AST::Block& block) >+{ >+ for (auto& statement : block.statements()) >+ visit(*statement); >+} >+ >+void Visitor::visit(AST::Statement& statement) >+{ >+ if (is<AST::Block>(statement)) >+ visit(downcast<AST::Block>(statement)); >+ else if (is<AST::Break>(statement)) >+ visit(downcast<AST::Break>(statement)); >+ else if (is<AST::Continue>(statement)) >+ visit(downcast<AST::Continue>(statement)); >+ else if (is<AST::DoWhileLoop>(statement)) >+ visit(downcast<AST::DoWhileLoop>(statement)); >+ else if (is<AST::EffectfulExpressionStatement>(statement)) >+ visit(downcast<AST::EffectfulExpressionStatement>(statement)); >+ else if (is<AST::Fallthrough>(statement)) >+ visit(downcast<AST::Fallthrough>(statement)); >+ else if (is<AST::ForLoop>(statement)) >+ visit(downcast<AST::ForLoop>(statement)); >+ else if (is<AST::IfStatement>(statement)) >+ visit(downcast<AST::IfStatement>(statement)); >+ else if (is<AST::Return>(statement)) >+ visit(downcast<AST::Return>(statement)); >+ else if (is<AST::SwitchCase>(statement)) >+ visit(downcast<AST::SwitchCase>(statement)); >+ else if (is<AST::SwitchStatement>(statement)) >+ visit(downcast<AST::SwitchStatement>(statement)); >+ else if (is<AST::Trap>(statement)) >+ visit(downcast<AST::Trap>(statement)); >+ else if (is<AST::VariableDeclarationsStatement>(statement)) >+ visit(downcast<AST::VariableDeclarationsStatement>(statement)); >+ else { >+ ASSERT(is<AST::WhileLoop>(statement)); >+ visit(downcast<AST::WhileLoop>(statement)); >+ } >+} >+ >+void Visitor::visit(AST::Break&) >+{ >+} >+ >+void Visitor::visit(AST::Continue&) >+{ >+} >+ >+void Visitor::visit(AST::DoWhileLoop& doWhileLoop) >+{ >+ visit(doWhileLoop.body()); >+ visit(doWhileLoop.conditional()); >+} >+ >+void Visitor::visit(AST::Expression& expression) >+{ >+ if (is<AST::AssignmentExpression>(expression)) >+ visit(downcast<AST::AssignmentExpression>(expression)); >+ else if (is<AST::BooleanLiteral>(expression)) >+ visit(downcast<AST::BooleanLiteral>(expression)); >+ else if (is<AST::CallExpression>(expression)) >+ visit(downcast<AST::CallExpression>(expression)); >+ else if (is<AST::CommaExpression>(expression)) >+ visit(downcast<AST::CommaExpression>(expression)); >+ else if (is<AST::DereferenceExpression>(expression)) >+ visit(downcast<AST::DereferenceExpression>(expression)); >+ else if (is<AST::FloatLiteral>(expression)) >+ visit(downcast<AST::FloatLiteral>(expression)); >+ else if (is<AST::IntegerLiteral>(expression)) >+ visit(downcast<AST::IntegerLiteral>(expression)); >+ else if (is<AST::LogicalExpression>(expression)) >+ visit(downcast<AST::LogicalExpression>(expression)); >+ else if (is<AST::LogicalNotExpression>(expression)) >+ visit(downcast<AST::LogicalNotExpression>(expression)); >+ else if (is<AST::MakeArrayReferenceExpression>(expression)) >+ visit(downcast<AST::MakeArrayReferenceExpression>(expression)); >+ else if (is<AST::MakePointerExpression>(expression)) >+ visit(downcast<AST::MakePointerExpression>(expression)); >+ else if (is<AST::NullLiteral>(expression)) >+ visit(downcast<AST::NullLiteral>(expression)); >+ else if (is<AST::DotExpression>(expression)) >+ visit(downcast<AST::DotExpression>(expression)); >+ else if (is<AST::IndexExpression>(expression)) >+ visit(downcast<AST::IndexExpression>(expression)); >+ else if (is<AST::ReadModifyWriteExpression>(expression)) >+ visit(downcast<AST::ReadModifyWriteExpression>(expression)); >+ else if (is<AST::TernaryExpression>(expression)) >+ visit(downcast<AST::TernaryExpression>(expression)); >+ else if (is<AST::UnsignedIntegerLiteral>(expression)) >+ visit(downcast<AST::UnsignedIntegerLiteral>(expression)); >+ else { >+ ASSERT(is<AST::VariableReference>(expression)); >+ visit(downcast<AST::VariableReference>(expression)); >+ } >+} >+ >+void Visitor::visit(AST::DotExpression& dotExpression) >+{ >+ visit(static_cast<AST::PropertyAccessExpression&>(dotExpression)); >+} >+ >+void Visitor::visit(AST::IndexExpression& indexExpression) >+{ >+ visit(indexExpression.indexExpression()); >+ visit(static_cast<AST::PropertyAccessExpression&>(indexExpression)); >+} >+ >+void Visitor::visit(AST::PropertyAccessExpression& expression) >+{ >+ visit(expression.base()); >+} >+ >+void Visitor::visit(AST::EffectfulExpressionStatement& effectfulExpressionStatement) >+{ >+ visit(effectfulExpressionStatement.effectfulExpression()); >+} >+ >+void Visitor::visit(AST::Fallthrough&) >+{ >+} >+ >+void Visitor::visit(AST::ForLoop& forLoop) >+{ >+ WTF::visit(WTF::makeVisitor([&](AST::VariableDeclarationsStatement& variableDeclarationsStatement) { >+ visit(variableDeclarationsStatement); >+ }, [&](std::unique_ptr<AST::Expression>& expression) { >+ visit(*expression); >+ }), forLoop.initialization()); >+ if (forLoop.condition()) >+ visit(*forLoop.condition()); >+ if (forLoop.increment()) >+ visit(*forLoop.increment()); >+ visit(forLoop.body()); >+} >+ >+void Visitor::visit(AST::IfStatement& ifStatement) >+{ >+ visit(ifStatement.conditional()); >+ visit(ifStatement.body()); >+ if (ifStatement.elseBody()) >+ visit(*ifStatement.elseBody()); >+} >+ >+void Visitor::visit(AST::Return& returnStatement) >+{ >+ if (returnStatement.value()) >+ visit(*returnStatement.value()); >+} >+ >+void Visitor::visit(AST::SwitchCase& switchCase) >+{ >+ if (switchCase.value()) >+ visit(*switchCase.value()); >+ visit(switchCase.block()); >+} >+ >+void Visitor::visit(AST::SwitchStatement& switchStatement) >+{ >+ visit(switchStatement.value()); >+ for (auto& switchCase : switchStatement.switchCases()) >+ visit(switchCase); >+} >+ >+void Visitor::visit(AST::Trap&) >+{ >+} >+ >+void Visitor::visit(AST::VariableDeclarationsStatement& variableDeclarationsStatement) >+{ >+ for (auto& variableDeclaration : variableDeclarationsStatement.variableDeclarations()) >+ visit(variableDeclaration); >+} >+ >+void Visitor::visit(AST::WhileLoop& whileLoop) >+{ >+ visit(whileLoop.conditional()); >+ visit(whileLoop.body()); >+} >+ >+void Visitor::visit(AST::VariableDeclaration& variableDeclaration) >+{ >+ visitUnnamedType(variableDeclaration.type()); >+ if (variableDeclaration.semantic()) >+ visit(*variableDeclaration.semantic()); >+ if (variableDeclaration.initializer()) >+ visit(*variableDeclaration.initializer()); >+} >+ >+void Visitor::visit(AST::AssignmentExpression& assignmentExpression) >+{ >+ visit(assignmentExpression.left()); >+ visit(assignmentExpression.right()); >+} >+ >+void Visitor::visit(AST::CallExpression& callExpression) >+{ >+ for (auto& argument : callExpression.arguments()) >+ visit(*argument); >+} >+ >+void Visitor::visit(AST::CommaExpression& commaExpression) >+{ >+ for (auto& expression : commaExpression.list()) >+ visit(*expression); >+} >+ >+void Visitor::visit(AST::DereferenceExpression& dereferenceExpression) >+{ >+ visit(dereferenceExpression.pointer()); >+} >+ >+void Visitor::visit(AST::LogicalExpression& logicalExpression) >+{ >+ visit(logicalExpression.left()); >+ visit(logicalExpression.right()); >+} >+ >+void Visitor::visit(AST::LogicalNotExpression& logicalNotExpression) >+{ >+ visit(logicalNotExpression.operand()); >+} >+ >+void Visitor::visit(AST::MakeArrayReferenceExpression& makeArrayReferenceExpression) >+{ >+ visit(makeArrayReferenceExpression.lValue()); >+} >+ >+void Visitor::visit(AST::MakePointerExpression& makePointerExpression) >+{ >+ visit(makePointerExpression.lValue()); >+} >+ >+void Visitor::visit(AST::ReadModifyWriteExpression& readModifyWriteExpression) >+{ >+ visit(readModifyWriteExpression.lValue()); >+ visit(readModifyWriteExpression.oldValue()); >+ visit(readModifyWriteExpression.newValue()); >+ visit(readModifyWriteExpression.newValueExpression()); >+ visit(readModifyWriteExpression.resultExpression()); >+} >+ >+void Visitor::visit(AST::TernaryExpression& ternaryExpression) >+{ >+ visit(ternaryExpression.predicate()); >+ visit(ternaryExpression.bodyExpression()); >+ visit(ternaryExpression.elseExpression()); >+} >+ >+void Visitor::visit(AST::VariableReference&) >+{ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h >index 516856e41d0..d022adcb9b3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h >@@ -27,543 +27,149 @@ > > #if ENABLE(WEBGPU) > >-#include "WHLSLProgram.h" >-#include "WHLSLAnonymousVariableDeclaration.h" >-#include "WHLSLArrayReferenceType.h" >-#include "WHLSLArrayType.h" >-#include "WHLSLAssignmentExpression.h" >-#include "WHLSLBaseFunctionAttribute.h" >-#include "WHLSLBaseSemantic.h" >-#include "WHLSLBlock.h" >-#include "WHLSLBooleanLiteral.h" >-#include "WHLSLBreak.h" >-#include "WHLSLBuiltInSemantic.h" >-#include "WHLSLCallExpression.h" >-#include "WHLSLCommaExpression.h" >-#include "WHLSLConstantExpression.h" >-#include "WHLSLConstantExpressionEnumerationMemberReference.h" >-#include "WHLSLContinue.h" >-#include "WHLSLDereferenceExpression.h" >-#include "WHLSLDoWhileLoop.h" >-#include "WHLSLDotExpression.h" >-#include "WHLSLEffectfulExpressionStatement.h" >-#include "WHLSLEnumerationDefinition.h" >-#include "WHLSLEnumerationMember.h" >-#include "WHLSLExpression.h" >-#include "WHLSLFallthrough.h" >-#include "WHLSLFloatLiteral.h" >-#include "WHLSLForLoop.h" > #include "WHLSLFunctionAttribute.h" >-#include "WHLSLFunctionDeclaration.h" >-#include "WHLSLFunctionDefinition.h" >-#include "WHLSLIfStatement.h" >-#include "WHLSLIndexExpression.h" >-#include "WHLSLIntegerLiteral.h" >-#include "WHLSLLogicalExpression.h" >-#include "WHLSLLogicalNotExpression.h" >-#include "WHLSLMakeArrayReferenceExpression.h" >-#include "WHLSLMakePointerExpression.h" >-#include "WHLSLNativeFunctionDeclaration.h" >-#include "WHLSLNativeTypeDeclaration.h" >-#include "WHLSLNode.h" >-#include "WHLSLNullLiteral.h" >-#include "WHLSLNumThreadsFunctionAttribute.h" >-#include "WHLSLParameter.h" >-#include "WHLSLPointerType.h" >-#include "WHLSLPropertyAccessExpression.h" >-#include "WHLSLQualifier.h" >-#include "WHLSLReadModifyWriteExpression.h" >-#include "WHLSLReferenceType.h" >-#include "WHLSLResourceSemantic.h" >-#include "WHLSLReturn.h" > #include "WHLSLSemantic.h" >-#include "WHLSLSpecializationConstantSemantic.h" >-#include "WHLSLStageInOutSemantic.h" >-#include "WHLSLStatement.h" >-#include "WHLSLStructureDefinition.h" >-#include "WHLSLStructureElement.h" >-#include "WHLSLSwitchCase.h" >-#include "WHLSLSwitchStatement.h" >-#include "WHLSLTernaryExpression.h" >-#include "WHLSLTrap.h" >-#include "WHLSLType.h" > #include "WHLSLTypeArgument.h" >-#include "WHLSLTypeDefinition.h" >-#include "WHLSLTypeReference.h" >-#include "WHLSLUnsignedIntegerLiteral.h" >-#include "WHLSLValue.h" >-#include "WHLSLVariableDeclaration.h" >-#include "WHLSLVariableDeclarationsStatement.h" >-#include "WHLSLVariableReference.h" >-#include "WHLSLWhileLoop.h" >- > > namespace WebCore { > > namespace WHLSL { > >-class Visitor { >- ~Visitor() = default; >- >- virtual void visit(Program& program) >- { >- for (auto& typeDefinition : program.typeDefinitions()) >- visit(typeDefinition); >- for (auto& structureDefinition : program.structureDefinitions()) >- visit(structureDefinition); >- for (auto& enumerationDefinition : program.enumerationDefinitions()) >- visit(enumerationDefinition); >- for (auto& functionDefinition : program.functionDefinitions()) >- visit(functionDefinition); >- for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) >- visit(nativeFunctionDeclaration); >- for (auto& nativeTypeDeclaration : program.nativeTypeDeclarations()) >- visit(nativeTypeDeclaration); >- } >- >- void visitType(AST::Type& type) >- { >- if (is<AST::TypeReference>(type)) >- visit(downcast<AST::TypeReference>(type)); >- else if (is<AST::PointerType>(type)) >- visit(downcast<AST::PointerType>(type)); >- else if (is<AST::ArrayReferenceType>(type)) >- visit(downcast<AST::ArrayReferenceType>(type)); >- else { >- ASSERT(is<AST::ArrayType>(type)); >- visit(downcast<AST::ArrayType>(type)); >- } >- } >- >- virtual void visit(AST::TypeDefinition& typeDefinition) >- { >- visitType(typeDefinition.type()); >- } >- >- virtual void visit(AST::StructureDefinition& structureDefinition) >- { >- for (auto& structureElement : structureDefinition.structureElements()) >- visit(structureElement); >- } >- >- virtual void visit(AST::EnumerationDefinition& enumerationDefinition) >- { >- visitType(enumerationDefinition.type()); >- for (auto& enumerationMember : enumerationDefinition.enumerationMembers()) >- visit(enumerationMember); >- } >- >- virtual void visit(AST::FunctionDefinition& functionDefinition) >- { >- visit(static_cast<AST::FunctionDeclaration&>(functionDefinition)); >- visit(functionDefinition.block()); >- } >- >- virtual void visit(AST::NativeFunctionDeclaration& nativeFunctionDeclaration) >- { >- visit(static_cast<AST::FunctionDeclaration&>(nativeFunctionDeclaration)); >- } >- >- virtual void visit(AST::NativeTypeDeclaration& nativeTypeDeclaration) >- { >- for (auto& typeArgument : nativeTypeDeclaration.typeArguments()) >- visit(typeArgument); >- } >- >- virtual void visit(AST::TypeReference& typeReference) >- { >- for (auto& typeArgument : typeReference.typeArguments()) >- visit(typeArgument); >- } >- >- virtual void visit(AST::PointerType& pointerType) >- { >- visit(static_cast<AST::ReferenceType&>(pointerType)); >- } >- >- virtual void visit(AST::ArrayReferenceType& arrayReferenceType) >- { >- visit(static_cast<AST::ReferenceType&>(arrayReferenceType)); >- } >- >- virtual void visit(AST::ArrayType& arrayType) >- { >- visitType(arrayType.type()); >- } >- >- virtual void visit(AST::StructureElement& structureElement) >- { >- visitType(structureElement.type()); >- if (structureElement.semantic()) >- visit(*structureElement.semantic()); >- } >- >- virtual void visit(AST::EnumerationMember& enumerationMember) >- { >- if (enumerationMember.value()) >- visit(*enumerationMember.value()); >- } >- >- virtual void visit(AST::FunctionDeclaration& functionDeclaration) >- { >- visit(functionDeclaration.attributeBlock()); >- visitType(functionDeclaration.type()); >- for (auto& parameter : functionDeclaration.parameters()) >- visit(parameter); >- if (functionDeclaration.semantic()) >- visit(*functionDeclaration.semantic()); >- } >- >- virtual void visit(AST::TypeArgument& typeArgument) >- { >- WTF::visit(WTF::makeVisitor([&](AST::ConstantExpression& constantExpression) { >- visit(constantExpression); >- }, [&](std::unique_ptr<AST::TypeReference>& typeReference) { >- visit(*typeReference); >- }), typeArgument); >- } >- >- virtual void visit(AST::ReferenceType& referenceType) >- { >- visitType(referenceType.elementType()); >- } >- >- virtual void visit(AST::Semantic& semantic) >- { >- WTF::visit(WTF::makeVisitor([&](AST::BuiltInSemantic& builtInSemantic) { >- visit(builtInSemantic); >- }, [&](AST::ResourceSemantic& resourceSemantic) { >- visit(resourceSemantic); >- }, [&](AST::SpecializationConstantSemantic& specializationConstantSemantic) { >- visit(specializationConstantSemantic); >- }, [&](AST::StageInOutSemantic& stageInOutSemantic) { >- visit(stageInOutSemantic); >- }), semantic); >- } >- >- virtual void visit(AST::ConstantExpression& constantExpression) >- { >- constantExpression.visit(WTF::makeVisitor([&](AST::IntegerLiteral& integerLiteral) { >- visit(integerLiteral); >- }, [&](AST::UnsignedIntegerLiteral& unsignedIntegerLiteral) { >- visit(unsignedIntegerLiteral); >- }, [&](AST::FloatLiteral& floatLiteral) { >- visit(floatLiteral); >- }, [&](AST::NullLiteral& nullLiteral) { >- visit(nullLiteral); >- }, [&](AST::BooleanLiteral& booleanLiteral) { >- visit(booleanLiteral); >- }, [&](AST::ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) { >- visit(constantExpressionEnumerationMemberReference); >- })); >- } >- >- virtual void visit(AST::AttributeBlock& attributeBlock) >- { >- for (auto& functionAttribute : attributeBlock) >- visit(functionAttribute); >- } >- >- virtual void visit(AST::Parameter& parameter) >- { >- visitType(parameter.type()); >- if (parameter.semantic()) >- visit(*parameter.semantic()); >- } >- >- virtual void visit(AST::BuiltInSemantic&) >- { >- } >- >- virtual void visit(AST::ResourceSemantic&) >- { >- } >- >- virtual void visit(AST::SpecializationConstantSemantic&) >- { >- } >- >- virtual void visit(AST::StageInOutSemantic&) >- { >- } >- >- virtual void visit(AST::IntegerLiteral&) >- { >- } >- >- virtual void visit(AST::UnsignedIntegerLiteral&) >- { >- } >- >- virtual void visit(AST::FloatLiteral&) >- { >- } >- >- virtual void visit(AST::NullLiteral&) >- { >- } >- >- virtual void visit(AST::BooleanLiteral&) >- { >- } >- >- virtual void visit(AST::ConstantExpressionEnumerationMemberReference&) >- { >- } >+class Program; >+ >+namespace AST { >+ >+class TypeDefinition; >+class StructureDefinition; >+class EnumerationDefinition; >+class FunctionDefinition; >+class NativeFunctionDeclaration; >+class NativeTypeDeclaration; >+class TypeReference; >+class PointerType; >+class ArrayReferenceType; >+class ArrayType; >+class StructureElement; >+class EnumerationMember; >+class FunctionDeclaration; >+class ReferenceType; >+class ConstantExpression; >+class BuiltInSemantic; >+class ResourceSemantic; >+class SpecializationConstantSemantic; >+class StageInOutSemantic; >+class IntegerLiteral; >+class UnsignedIntegerLiteral; >+class FloatLiteral; >+class NullLiteral; >+class BooleanLiteral; >+class ConstantExpressionEnumerationMemberReference; >+class NumThreadsFunctionAttribute; >+class Block; >+class Statement; >+class Break; >+class Continue; >+class DoWhileLoop; >+class Expression; >+class DotExpression; >+class IndexExpression; >+class PropertyAccessExpression; >+class EffectfulExpressionStatement; >+class Fallthrough; >+class ForLoop; >+class IfStatement; >+class Return; >+class SwitchCase; >+class SwitchStatement; >+class Trap; >+class VariableDeclarationsStatement; >+class WhileLoop; >+class VariableDeclaration; >+class AssignmentExpression; >+class CallExpression; >+class CommaExpression; >+class DereferenceExpression; >+class LogicalExpression; >+class LogicalNotExpression; >+class MakeArrayReferenceExpression; >+class MakePointerExpression; >+class ReadModifyWriteExpression; >+class TernaryExpression; >+class VariableReference; >+class UnnamedType; >+class NamedType; > >- virtual void visit(AST::FunctionAttribute& functionAttribute) >- { >- WTF::visit(WTF::makeVisitor([&](AST::NumThreadsFunctionAttribute& numThreadsFunctionAttribute) { >- visit(numThreadsFunctionAttribute); >- }), functionAttribute); >- } >- >- virtual void visit(AST::NumThreadsFunctionAttribute&) >- { >- } >- >- virtual void visit(AST::Block& block) >- { >- for (auto& statement : block.statements()) >- visit(*statement); >- } >- >- virtual void visit(AST::Statement& statement) >- { >- if (is<AST::Block>(statement)) >- visit(downcast<AST::Block>(statement)); >- else if (is<AST::Break>(statement)) >- visit(downcast<AST::Break>(statement)); >- else if (is<AST::Continue>(statement)) >- visit(downcast<AST::Continue>(statement)); >- else if (is<AST::DoWhileLoop>(statement)) >- visit(downcast<AST::DoWhileLoop>(statement)); >- else if (is<AST::EffectfulExpressionStatement>(statement)) >- visit(downcast<AST::EffectfulExpressionStatement>(statement)); >- else if (is<AST::Fallthrough>(statement)) >- visit(downcast<AST::Fallthrough>(statement)); >- else if (is<AST::ForLoop>(statement)) >- visit(downcast<AST::ForLoop>(statement)); >- else if (is<AST::IfStatement>(statement)) >- visit(downcast<AST::IfStatement>(statement)); >- else if (is<AST::Return>(statement)) >- visit(downcast<AST::Return>(statement)); >- else if (is<AST::SwitchCase>(statement)) >- visit(downcast<AST::SwitchCase>(statement)); >- else if (is<AST::SwitchStatement>(statement)) >- visit(downcast<AST::SwitchStatement>(statement)); >- else if (is<AST::Trap>(statement)) >- visit(downcast<AST::Trap>(statement)); >- else if (is<AST::VariableDeclarationsStatement>(statement)) >- visit(downcast<AST::VariableDeclarationsStatement>(statement)); >- else { >- ASSERT(is<AST::WhileLoop>(statement)); >- visit(downcast<AST::WhileLoop>(statement)); >- } >- } >- >- virtual void visit(AST::Break&) >- { >- } >- >- virtual void visit(AST::Continue&) >- { >- } >- >- virtual void visit(AST::DoWhileLoop& doWhileLoop) >- { >- visit(doWhileLoop.body()); >- visit(doWhileLoop.conditional()); >- } >- >- virtual void visit(AST::Expression& expression) >- { >- if (is<AST::AssignmentExpression>(expression)) >- visit(downcast<AST::AssignmentExpression>(expression)); >- else if (is<AST::BooleanLiteral>(expression)) >- visit(downcast<AST::BooleanLiteral>(expression)); >- else if (is<AST::CallExpression>(expression)) >- visit(downcast<AST::CallExpression>(expression)); >- else if (is<AST::CommaExpression>(expression)) >- visit(downcast<AST::CommaExpression>(expression)); >- else if (is<AST::DereferenceExpression>(expression)) >- visit(downcast<AST::DereferenceExpression>(expression)); >- else if (is<AST::FloatLiteral>(expression)) >- visit(downcast<AST::FloatLiteral>(expression)); >- else if (is<AST::IntegerLiteral>(expression)) >- visit(downcast<AST::IntegerLiteral>(expression)); >- else if (is<AST::LogicalExpression>(expression)) >- visit(downcast<AST::LogicalExpression>(expression)); >- else if (is<AST::LogicalNotExpression>(expression)) >- visit(downcast<AST::LogicalNotExpression>(expression)); >- else if (is<AST::MakeArrayReferenceExpression>(expression)) >- visit(downcast<AST::MakeArrayReferenceExpression>(expression)); >- else if (is<AST::MakePointerExpression>(expression)) >- visit(downcast<AST::MakePointerExpression>(expression)); >- else if (is<AST::NullLiteral>(expression)) >- visit(downcast<AST::NullLiteral>(expression)); >- else if (is<AST::PropertyAccessExpression>(expression)) >- visit(downcast<AST::PropertyAccessExpression>(expression)); >- else if (is<AST::ReadModifyWriteExpression>(expression)) >- visit(downcast<AST::ReadModifyWriteExpression>(expression)); >- else if (is<AST::TernaryExpression>(expression)) >- visit(downcast<AST::TernaryExpression>(expression)); >- else if (is<AST::UnsignedIntegerLiteral>(expression)) >- visit(downcast<AST::UnsignedIntegerLiteral>(expression)); >- else { >- ASSERT(is<AST::VariableReference>(expression)); >- visit(downcast<AST::VariableReference>(expression)); >- } >- } >- >- virtual void visit(AST::EffectfulExpressionStatement& effectfulExpressionStatement) >- { >- visit(effectfulExpressionStatement.effectfulExpression()); >- } >- >- virtual void visit(AST::Fallthrough&) >- { >- } >- >- virtual void visit(AST::ForLoop& forLoop) >- { >- WTF::visit(WTF::makeVisitor([&](AST::VariableDeclarationsStatement& variableDeclarationsStatement) { >- visit(variableDeclarationsStatement); >- }, [&](std::unique_ptr<AST::Expression>& expression) { >- visit(*expression); >- }), forLoop.initialization()); >- if (forLoop.condition()) >- visit(*forLoop.condition()); >- if (forLoop.increment()) >- visit(*forLoop.increment()); >- visit(forLoop.body()); >- } >- >- virtual void visit(AST::IfStatement& ifStatement) >- { >- visit(ifStatement.conditional()); >- visit(ifStatement.body()); >- if (ifStatement.elseBody()) >- visit(*ifStatement.elseBody()); >- } >- >- virtual void visit(AST::Return& returnStatement) >- { >- if (returnStatement.value()) >- visit(*returnStatement.value()); >- } >- >- virtual void visit(AST::SwitchCase& switchCase) >- { >- if (switchCase.value()) >- visit(*switchCase.value()); >- visit(switchCase.block()); >- } >- >- virtual void visit(AST::SwitchStatement& switchStatement) >- { >- visit(switchStatement.value()); >- for (auto& switchCase : switchStatement.switchCases()) >- visit(switchCase); >- } >- >- virtual void visit(AST::Trap&) >- { >- } >- >- virtual void visit(AST::VariableDeclarationsStatement& variableDeclarationsStatement) >- { >- for (auto& variableDeclaration : variableDeclarationsStatement.variableDeclarations()) >- visit(variableDeclaration); >- } >- >- virtual void visit(AST::WhileLoop& whileLoop) >- { >- visit(whileLoop.conditional()); >- visit(whileLoop.body()); >- } >- >- virtual void visit(AST::VariableDeclaration& variableDeclaration) >- { >- visitType(variableDeclaration.type()); >- if (variableDeclaration.semantic()) >- visit(*variableDeclaration.semantic()); >- if (variableDeclaration.initializer()) >- visit(*variableDeclaration.initializer()); >- } >- >- virtual void visit(AST::AssignmentExpression& assignmentExpression) >- { >- visit(assignmentExpression.left()); >- visit(assignmentExpression.right()); >- } >- >- virtual void visit(AST::CallExpression& callExpression) >- { >- for (auto& argument : callExpression.arguments()) >- visit(*argument); >- } >- >- virtual void visit(AST::CommaExpression& commaExpression) >- { >- for (auto& expression : commaExpression.list()) >- visit(*expression); >- } >- >- virtual void visit(AST::DereferenceExpression& dereferenceExpression) >- { >- visit(dereferenceExpression.pointer()); >- } >- >- virtual void visit(AST::LogicalExpression& logicalExpression) >- { >- visit(logicalExpression.left()); >- visit(logicalExpression.right()); >- } >- >- virtual void visit(AST::LogicalNotExpression& logicalNotExpression) >- { >- visit(logicalNotExpression.operand()); >- } >- >- virtual void visit(AST::MakeArrayReferenceExpression& makeArrayReferenceExpression) >- { >- visit(makeArrayReferenceExpression.lValue()); >- } >- >- virtual void visit(AST::MakePointerExpression& makePointerExpression) >- { >- visit(makePointerExpression.lValue()); >- } >- >- virtual void visit(AST::PropertyAccessExpression& propertyAccessExpression) >- { >- visit(propertyAccessExpression.base()); >- } >- >- virtual void visit(AST::ReadModifyWriteExpression& readModifyWriteExpression) >- { >- visit(readModifyWriteExpression.lValue()); >- visit(readModifyWriteExpression.oldValue()); >- visit(readModifyWriteExpression.newValue()); >- visit(readModifyWriteExpression.newValueExpression()); >- visit(readModifyWriteExpression.resultExpression()); >- } >- >- virtual void visit(AST::TernaryExpression& ternaryExpression) >- { >- visit(ternaryExpression.predicate()); >- visit(ternaryExpression.bodyExpression()); >- visit(ternaryExpression.elseExpression()); >- } >- >- virtual void visit(AST::VariableReference&) >- { >- } >+} > >- virtual void visit(AST::AnonymousVariableDeclaration&) >- { >- } >+class Visitor { >+public: >+ virtual ~Visitor() = default; >+ >+ void visitUnnamedType(AST::UnnamedType& unnamedType); >+ void visitNamedType(AST::NamedType& namedType); >+ >+ virtual void visit(Program& program); >+ virtual void visit(AST::TypeDefinition&); >+ virtual void visit(AST::StructureDefinition&); >+ virtual void visit(AST::EnumerationDefinition&); >+ virtual void visit(AST::FunctionDefinition&); >+ virtual void visit(AST::NativeFunctionDeclaration&); >+ virtual void visit(AST::NativeTypeDeclaration&); >+ virtual void visit(AST::TypeReference&); >+ virtual void visit(AST::PointerType&); >+ virtual void visit(AST::ArrayReferenceType&); >+ virtual void visit(AST::ArrayType&); >+ virtual void visit(AST::StructureElement&); >+ virtual void visit(AST::EnumerationMember&); >+ virtual void visit(AST::FunctionDeclaration&); >+ virtual void visit(AST::TypeArgument&); >+ virtual void visit(AST::ReferenceType&); >+ virtual void visit(AST::Semantic&); >+ virtual void visit(AST::ConstantExpression&); >+ virtual void visit(AST::AttributeBlock&); >+ virtual void visit(AST::BuiltInSemantic&); >+ virtual void visit(AST::ResourceSemantic&); >+ virtual void visit(AST::SpecializationConstantSemantic&); >+ virtual void visit(AST::StageInOutSemantic&); >+ virtual void visit(AST::IntegerLiteral&); >+ virtual void visit(AST::UnsignedIntegerLiteral&); >+ virtual void visit(AST::FloatLiteral&); >+ virtual void visit(AST::NullLiteral&); >+ virtual void visit(AST::BooleanLiteral&); >+ virtual void visit(AST::ConstantExpressionEnumerationMemberReference&); >+ virtual void visit(AST::FunctionAttribute&); >+ virtual void visit(AST::NumThreadsFunctionAttribute&); >+ virtual void visit(AST::Block&); >+ virtual void visit(AST::Statement&); >+ virtual void visit(AST::Break&); >+ virtual void visit(AST::Continue&); >+ virtual void visit(AST::DoWhileLoop&); >+ virtual void visit(AST::Expression&); >+ virtual void visit(AST::DotExpression&); >+ virtual void visit(AST::IndexExpression&); >+ virtual void visit(AST::PropertyAccessExpression&); >+ virtual void visit(AST::EffectfulExpressionStatement&); >+ virtual void visit(AST::Fallthrough&); >+ virtual void visit(AST::ForLoop&); >+ virtual void visit(AST::IfStatement&); >+ virtual void visit(AST::Return&); >+ virtual void visit(AST::SwitchCase&); >+ virtual void visit(AST::SwitchStatement&); >+ virtual void visit(AST::Trap&); >+ virtual void visit(AST::VariableDeclarationsStatement&); >+ virtual void visit(AST::WhileLoop&); >+ virtual void visit(AST::VariableDeclaration&); >+ virtual void visit(AST::AssignmentExpression&); >+ virtual void visit(AST::CallExpression&); >+ virtual void visit(AST::CommaExpression&); >+ virtual void visit(AST::DereferenceExpression&); >+ virtual void visit(AST::LogicalExpression&); >+ virtual void visit(AST::LogicalNotExpression&); >+ virtual void visit(AST::MakeArrayReferenceExpression&); >+ virtual void visit(AST::MakePointerExpression&); >+ virtual void visit(AST::ReadModifyWriteExpression&); >+ virtual void visit(AST::TernaryExpression&); >+ virtual void visit(AST::VariableReference&); > }; > > } >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 3c0e3647054..6a8ba1d2a56 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -306,8 +306,20 @@ Modules/webgpu/DOMWindowWebGPU.cpp > Modules/webgpu/WHLSL/WHLSLLexer.cpp > Modules/webgpu/WHLSL/WHLSLParser.cpp > Modules/webgpu/WHLSL/WHLSLPrepare.cpp >+Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >+Modules/webgpu/WHLSL/WHLSLChecker.cpp >+Modules/webgpu/WHLSL/WHLSLInferTypes.cpp > Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >+Modules/webgpu/WHLSL/WHLSLNameContext.cpp >+Modules/webgpu/WHLSL/WHLSLRecursiveTypeChecker.cpp >+Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp >+Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp >+Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp >+Modules/webgpu/WHLSL/WHLSLSynthesizeArrayOperatorLength.cpp >+Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp >+Modules/webgpu/WHLSL/WHLSLVisitor.cpp > Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp >+Modules/webgpu/WHLSL/WHLSLResolveOverloadImpl.cpp > Modules/webgpu/WebGPU.cpp > Modules/webgpu/WebGPUAdapter.cpp > Modules/webgpu/WebGPUBindGroupLayout.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 07c16ef1775..0e121e8e4b7 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -6403,9 +6403,20 @@ > 1C24EEA71C72A7B40080F8FC /* JSFontFaceSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSFontFaceSet.h; path = DerivedSources/WebCore/JSFontFaceSet.h; sourceTree = BUILT_PRODUCTS_DIR; }; > 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; }; > 1C3249101C6D6A3B007EDB32 /* FontVariantBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontVariantBuilder.cpp; sourceTree = "<group>"; }; >+ 1C33276C21CEDA42000DC9F2 /* WHLSLEnumerationMemberLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEnumerationMemberLiteral.h; sourceTree = "<group>"; }; >+ 1C33276E21CEFF74000DC9F2 /* WHLSLResolveOverloadImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLResolveOverloadImpl.h; sourceTree = "<group>"; }; >+ 1C33276F21CF0131000DC9F2 /* WHLSLInferTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLInferTypes.h; sourceTree = "<group>"; }; >+ 1C33277121CF0BE1000DC9F2 /* WHLSLNamedType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNamedType.h; sourceTree = "<group>"; }; >+ 1C33277221CF0D2E000DC9F2 /* WHLSLUnnamedType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLUnnamedType.h; sourceTree = "<group>"; }; >+ 1C33277421D5A706000DC9F2 /* WHLSLRecursiveTypeChecker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLRecursiveTypeChecker.h; sourceTree = "<group>"; }; >+ 1C33277521D5B0F8000DC9F2 /* WHLSLCheckDuplicateFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLCheckDuplicateFunctions.h; sourceTree = "<group>"; }; >+ 1C33277621D5C07E000DC9F2 /* WHLSLSynthesizeStructureAccessors.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSynthesizeStructureAccessors.h; sourceTree = "<group>"; }; >+ 1C33277721D5CA83000DC9F2 /* WHLSLSynthesizeEnumerationFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSynthesizeEnumerationFunctions.h; sourceTree = "<group>"; }; >+ 1C33277821D5CED4000DC9F2 /* WHLSLSynthesizeArrayOperatorLength.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSynthesizeArrayOperatorLength.h; sourceTree = "<group>"; }; > 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>"; }; >+ 1C7CC21D21CDE19800C1FA2C /* WHLSLNameContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNameContext.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>"; }; >@@ -13214,6 +13225,9 @@ > C11A9ECD21403A5C00CFB20A /* SwitchingGPUClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwitchingGPUClient.h; sourceTree = "<group>"; }; > 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>"; }; >+ C201334421DAC09500B60C27 /* WHLSLIntrinsics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLIntrinsics.h; sourceTree = "<group>"; }; >+ C201334621DAEE6E00B60C27 /* WHLSLIntrinsics.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLIntrinsics.cpp; sourceTree = "<group>"; }; >+ C201334721DB436300B60C27 /* WHLSLSynthesizeConstructors.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSynthesizeConstructors.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>"; }; >@@ -13245,7 +13259,6 @@ > C21BF70C21CD89CC00227979 /* WHLSLExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLExpression.h; sourceTree = "<group>"; }; > C21BF70D21CD89CD00227979 /* WHLSLReferenceType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLReferenceType.h; sourceTree = "<group>"; }; > C21BF70E21CD89CE00227979 /* WHLSLStageInOutSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStageInOutSemantic.h; sourceTree = "<group>"; }; >- C21BF70F21CD89CF00227979 /* WHLSLAnonymousVariableDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLAnonymousVariableDeclaration.h; sourceTree = "<group>"; }; > C21BF71021CD89D000227979 /* WHLSLVariableDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLVariableDeclaration.h; sourceTree = "<group>"; }; > C21BF71121CD89D100227979 /* WHLSLTypeArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLTypeArgument.h; sourceTree = "<group>"; }; > C21BF71221CD89D100227979 /* WHLSLStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStatement.h; sourceTree = "<group>"; }; >@@ -13253,7 +13266,6 @@ > C21BF71421CD89D300227979 /* WHLSLVariableDeclarationsStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLVariableDeclarationsStatement.h; sourceTree = "<group>"; }; > C21BF71521CD89D400227979 /* WHLSLLogicalNotExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLLogicalNotExpression.h; sourceTree = "<group>"; }; > C21BF71621CD89D500227979 /* WHLSLCallExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLCallExpression.h; sourceTree = "<group>"; }; >- C21BF71721CD89D600227979 /* WHLSLParameter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLParameter.h; sourceTree = "<group>"; }; > C21BF71821CD89D700227979 /* WHLSLDotExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLDotExpression.h; sourceTree = "<group>"; }; > C21BF71921CD89D700227979 /* WHLSLSwitchCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSwitchCase.h; sourceTree = "<group>"; }; > C21BF71A21CD89D800227979 /* WHLSLBreak.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBreak.h; sourceTree = "<group>"; }; >@@ -13299,15 +13311,27 @@ > 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; }; > C280B3FD1EF4608900D35135 /* FontFamilySpecificationNull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFamilySpecificationNull.cpp; sourceTree = "<group>"; }; >+ C286ED9E21DB5ABA00713C40 /* WHLSLResolveOverloadImpl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLResolveOverloadImpl.cpp; sourceTree = "<group>"; }; > C288C72721C8C6EF002DF5CA /* WHLSLVisitor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLVisitor.h; sourceTree = "<group>"; }; > C288C72921C8CA50002DF5CA /* WHLSLPrepare.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLPrepare.cpp; sourceTree = "<group>"; }; > C288C72A21C8CA50002DF5CA /* WHLSLPrepare.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLPrepare.h; sourceTree = "<group>"; }; >- C288C72B21C8CCC2002DF5CA /* WHLSLNameResolver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLNameResolver.cpp; sourceTree = "<group>"; }; > C288C72C21C8CCC2002DF5CA /* WHLSLNameResolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNameResolver.h; sourceTree = "<group>"; }; > C288C72D21C991DA002DF5CA /* WHLSLTypeArgument.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLTypeArgument.cpp; sourceTree = "<group>"; }; > C2AB0AF41E6B3C6C001348C5 /* FontSelectionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontSelectionAlgorithm.cpp; sourceTree = "<group>"; }; > C2AB0AF51E6B3C6C001348C5 /* FontSelectionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSelectionAlgorithm.h; sourceTree = "<group>"; }; > C2AB0B031E6DE92C001348C5 /* FontSelectionValueInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontSelectionValueInlines.h; sourceTree = "<group>"; }; >+ C2B5517021DB4B48004BE26E /* WHLSLChecker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLChecker.cpp; sourceTree = "<group>"; }; >+ C2B5517121DB4B48004BE26E /* WHLSLChecker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLChecker.h; sourceTree = "<group>"; }; >+ C2B5517321DB4BBD004BE26E /* WHLSLNameResolver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLNameResolver.cpp; sourceTree = "<group>"; }; >+ C2B5517421DB510F004BE26E /* WHLSLNameContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLNameContext.cpp; sourceTree = "<group>"; }; >+ C2B5517521DB5266004BE26E /* WHLSLInferTypes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLInferTypes.cpp; sourceTree = "<group>"; }; >+ C2B5517621DB5394004BE26E /* WHLSLRecursiveTypeChecker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLRecursiveTypeChecker.cpp; sourceTree = "<group>"; }; >+ C2B5517721DB540F004BE26E /* WHLSLCheckDuplicateFunctions.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLCheckDuplicateFunctions.cpp; sourceTree = "<group>"; }; >+ C2B5517821DB5575004BE26E /* WHLSLSynthesizeStructureAccessors.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLSynthesizeStructureAccessors.cpp; sourceTree = "<group>"; }; >+ C2B5517921DB558F004BE26E /* WHLSLSynthesizeEnumerationFunctions.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLSynthesizeEnumerationFunctions.cpp; sourceTree = "<group>"; }; >+ C2B5517A21DB559E004BE26E /* WHLSLSynthesizeArrayOperatorLength.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLSynthesizeArrayOperatorLength.cpp; sourceTree = "<group>"; }; >+ C2B5517B21DB55AF004BE26E /* WHLSLSynthesizeConstructors.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLSynthesizeConstructors.cpp; sourceTree = "<group>"; }; >+ C2B5517C21DB57ED004BE26E /* WHLSLVisitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLVisitor.cpp; sourceTree = "<group>"; }; > C2C2CF551EF3761A004281A8 /* FontFamilySpecificationNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFamilySpecificationNull.h; sourceTree = "<group>"; }; > C2E38EFB1E8396FD00CA3ADF /* CSSFontStyleValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontStyleValue.cpp; sourceTree = "<group>"; }; > C2E38EFC1E8396FD00CA3ADF /* CSSFontStyleValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontStyleValue.h; sourceTree = "<group>"; }; >@@ -25332,11 +25356,34 @@ > C21BF73721CD8A0200227979 /* WHLSLParser.cpp */, > C21BF73821CD8A0300227979 /* WHLSLParser.h */, > C21BF73A21CD8D7000227979 /* WHLSLProgram.h */, >- C288C72721C8C6EF002DF5CA /* WHLSLVisitor.h */, >- C288C72921C8CA50002DF5CA /* WHLSLPrepare.cpp */, >- C288C72A21C8CA50002DF5CA /* WHLSLPrepare.h */, >- C288C72B21C8CCC2002DF5CA /* WHLSLNameResolver.cpp */, >- C288C72C21C8CCC2002DF5CA /* WHLSLNameResolver.h */, >+ C288C72721C8C6EF002DF5CA /* WHLSLVisitor.h */, >+ C2B5517C21DB57ED004BE26E /* WHLSLVisitor.cpp */, >+ C288C72921C8CA50002DF5CA /* WHLSLPrepare.cpp */, >+ C288C72A21C8CA50002DF5CA /* WHLSLPrepare.h */, >+ C288C72C21C8CCC2002DF5CA /* WHLSLNameResolver.h */, >+ C2B5517321DB4BBD004BE26E /* WHLSLNameResolver.cpp */, >+ 1C7CC21D21CDE19800C1FA2C /* WHLSLNameContext.h */, >+ C2B5517421DB510F004BE26E /* WHLSLNameContext.cpp */, >+ 1C33276E21CEFF74000DC9F2 /* WHLSLResolveOverloadImpl.h */, >+ C286ED9E21DB5ABA00713C40 /* WHLSLResolveOverloadImpl.cpp */, >+ 1C33276F21CF0131000DC9F2 /* WHLSLInferTypes.h */, >+ C2B5517521DB5266004BE26E /* WHLSLInferTypes.cpp */, >+ 1C33277421D5A706000DC9F2 /* WHLSLRecursiveTypeChecker.h */, >+ C2B5517621DB5394004BE26E /* WHLSLRecursiveTypeChecker.cpp */, >+ 1C33277521D5B0F8000DC9F2 /* WHLSLCheckDuplicateFunctions.h */, >+ C2B5517721DB540F004BE26E /* WHLSLCheckDuplicateFunctions.cpp */, >+ 1C33277621D5C07E000DC9F2 /* WHLSLSynthesizeStructureAccessors.h */, >+ C2B5517821DB5575004BE26E /* WHLSLSynthesizeStructureAccessors.cpp */, >+ 1C33277721D5CA83000DC9F2 /* WHLSLSynthesizeEnumerationFunctions.h */, >+ C2B5517921DB558F004BE26E /* WHLSLSynthesizeEnumerationFunctions.cpp */, >+ 1C33277821D5CED4000DC9F2 /* WHLSLSynthesizeArrayOperatorLength.h */, >+ C2B5517A21DB559E004BE26E /* WHLSLSynthesizeArrayOperatorLength.cpp */, >+ C201334721DB436300B60C27 /* WHLSLSynthesizeConstructors.h */, >+ C2B5517B21DB55AF004BE26E /* WHLSLSynthesizeConstructors.cpp */, >+ C201334421DAC09500B60C27 /* WHLSLIntrinsics.h */, >+ C201334621DAEE6E00B60C27 /* WHLSLIntrinsics.cpp */, >+ C2B5517021DB4B48004BE26E /* WHLSLChecker.cpp */, >+ C2B5517121DB4B48004BE26E /* WHLSLChecker.h */, > ); > path = WHLSL; > sourceTree = "<group>"; >@@ -25344,7 +25391,6 @@ > C21BF6F121CD898D00227979 /* AST */ = { > isa = PBXGroup; > children = ( >- C21BF70F21CD89CF00227979 /* WHLSLAnonymousVariableDeclaration.h */, > C21BF72521CD89E200227979 /* WHLSLArrayReferenceType.h */, > C21BF70921CD89CA00227979 /* WHLSLArrayType.h */, > C21BF73021CD89ED00227979 /* WHLSLAssignmentExpression.h */, >@@ -25384,7 +25430,6 @@ > C21BF72421CD89E100227979 /* WHLSLNode.h */, > C21BF70721CD89C800227979 /* WHLSLNullLiteral.h */, > C21BF72121CD89DE00227979 /* WHLSLNumThreadsFunctionAttribute.h */, >- C21BF71721CD89D600227979 /* WHLSLParameter.h */, > C21BF72F21CD89EC00227979 /* WHLSLPointerType.h */, > C21BF72E21CD89EA00227979 /* WHLSLPropertyAccessExpression.h */, > C21BF70B21CD89CC00227979 /* WHLSLQualifier.h */, >@@ -25412,7 +25457,10 @@ > C21BF71421CD89D300227979 /* WHLSLVariableDeclarationsStatement.h */, > C21BF71321CD89D200227979 /* WHLSLVariableReference.h */, > C21BF70421CD89C600227979 /* WHLSLWhileLoop.h */, >- C288C72D21C991DA002DF5CA /* WHLSLTypeArgument.cpp */, >+ C288C72D21C991DA002DF5CA /* WHLSLTypeArgument.cpp */, >+ 1C33276C21CEDA42000DC9F2 /* WHLSLEnumerationMemberLiteral.h */, >+ 1C33277121CF0BE1000DC9F2 /* WHLSLNamedType.h */, >+ 1C33277221CF0D2E000DC9F2 /* WHLSLUnnamedType.h */, > ); > path = AST; > sourceTree = "<group>";
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 193007
:
358021
|
358022
|
358157
|
358164
|
358167
|
358169
|
358883
|
358908
|
358922
|
358928
|
358977