WebKit Bugzilla
Attachment 357603 Details for
Bug 192826
: [WHLSL] Add a Visitor class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
file2.txt (text/plain), 79.52 KB, created by
Myles C. Maxfield
on 2018-12-18 13:21:46 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-12-18 13:21:46 PST
Size:
79.52 KB
patch
obsolete
>commit eae42cca711be2b7795777e3687bbe6685108f90 >Author: Myles C. Maxfield <mmaxfield@apple.com> >Date: Tue Dec 18 12:14:01 2018 -0800 > > Visitor > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTArrayReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTArrayReferenceType.h >index 2397868353f..7c7e9cdf99e 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTArrayReferenceType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTArrayReferenceType.h >@@ -49,9 +49,11 @@ public: > ArrayReferenceType(const ArrayReferenceType&) = delete; > ArrayReferenceType(ArrayReferenceType&&) = default; > >+ bool isArrayReferenceType() const override { return false; } >+ > std::unique_ptr<Type> clone() const override > { >- return std::make_unique<ArrayReferenceType>(Lexer::Token(origin()), String(addressSpace()), elementType()->clone()); >+ return std::make_unique<ArrayReferenceType>(Lexer::Token(origin()), String(addressSpace()), elementType().clone()); > } > > private: >@@ -63,4 +65,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(ArrayReferenceType, isArrayReferenceType()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTArrayType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTArrayType.h >index bf388fb8f6b..807952ecc6f 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTArrayType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTArrayType.h >@@ -54,6 +54,10 @@ public: > > unsigned numElements() const { return m_numElements; } > >+ bool isArrayType() const override { return false; } >+ >+ Type& type() { return *m_elementType; } >+ > std::unique_ptr<Type> clone() const override > { > return std::make_unique<ArrayType>(Lexer::Token(m_origin), m_elementType->clone(), m_numElements); >@@ -71,4 +75,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(ArrayType, isArrayType()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTAssignmentExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTAssignmentExpression.h >index c66c6dc35ec..37797c27121 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTAssignmentExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTAssignmentExpression.h >@@ -50,6 +50,11 @@ public: > AssignmentExpression(const AssignmentExpression&) = delete; > AssignmentExpression(AssignmentExpression&&) = default; > >+ bool isAssignmentExpression() const override { return true; } >+ >+ Expression& left() { return *m_left; } >+ Expression& right() { return *m_right; } >+ > private: > std::unique_ptr<Expression> m_left; > std::unique_ptr<Expression> m_right; >@@ -61,4 +66,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(AssignmentExpression, isAssignmentExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBlock.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBlock.h >index 8b73f7f04c4..11c918c2afc 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBlock.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBlock.h >@@ -39,7 +39,7 @@ namespace AST { > > class Block : public Statement { > public: >- Block(Lexer::Token&& origin, Vector<std::unique_ptr<Statement>>&& statements) >+ Block(Lexer::Token&& origin, Statements&& statements) > : Statement(WTFMove(origin)) > , m_statements(WTFMove(statements)) > { >@@ -50,8 +50,12 @@ public: > Block(const Block&) = delete; > Block(Block&&) = default; > >+ Statements& statements() { return m_statements; } >+ >+ bool isBlock() const override { return true; } >+ > private: >- Vector<std::unique_ptr<Statement>> m_statements; >+ Statements m_statements; > }; > > } >@@ -60,4 +64,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Block, isBlock()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBooleanLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBooleanLiteral.h >index 0c3ba78652e..2c424adace1 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBooleanLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBooleanLiteral.h >@@ -51,6 +51,8 @@ public: > > bool value() const { return m_value; } > >+ bool isBooleanLiteral() const override { return true; } >+ > private: > bool m_value; > }; >@@ -61,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(BooleanLiteral, isBooleanLiteral()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBreak.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBreak.h >index 7c2b10ac727..d3d459d66b2 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBreak.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTBreak.h >@@ -47,6 +47,8 @@ public: > > Break(const Break&) = delete; > Break(Break&&) = default; >+ >+ bool isBreak() const override { return true; } > > private: > }; >@@ -57,4 +59,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Break, isBreak()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTCallExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTCallExpression.h >index 68af89ead85..c681eb70fa9 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTCallExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTCallExpression.h >@@ -50,6 +50,10 @@ public: > CallExpression(const CallExpression&) = delete; > CallExpression(CallExpression&&) = default; > >+ bool isCallExpression() const override { return true; } >+ >+ Vector<std::unique_ptr<Expression>>& arguments() { return m_arguments; } >+ > private: > String m_name; > Vector<std::unique_ptr<Expression>> m_arguments; >@@ -61,4 +65,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(CallExpression, isCallExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTCommaExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTCommaExpression.h >index 77bf3dcf50b..5413c95f9ff 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTCommaExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTCommaExpression.h >@@ -50,6 +50,10 @@ public: > CommaExpression(const CommaExpression&) = delete; > CommaExpression(CommaExpression&&) = default; > >+ bool isCommaExpression() const override { return true; } >+ >+ Vector<std::unique_ptr<Expression>>& list() { return m_list; } >+ > private: > Vector<std::unique_ptr<Expression>> m_list; > }; >@@ -60,4 +64,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(CommaExpression, isCommaExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTContinue.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTContinue.h >index 1681024e813..09741e8491d 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTContinue.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTContinue.h >@@ -47,6 +47,8 @@ public: > > Continue(const Continue&) = delete; > Continue(Continue&&) = default; >+ >+ bool isContinue() const override { return true; } > > private: > }; >@@ -57,4 +59,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Continue, isContinue()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTDereferenceExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTDereferenceExpression.h >index 2d2f1717805..cae4051054a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTDereferenceExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTDereferenceExpression.h >@@ -49,6 +49,10 @@ public: > DereferenceExpression(const DereferenceExpression&) = delete; > DereferenceExpression(DereferenceExpression&&) = default; > >+ bool isDereferenceExpression() const override { return true; } >+ >+ Expression& pointer() { return *m_pointer; } >+ > private: > std::unique_ptr<Expression> m_pointer; > }; >@@ -59,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(DereferenceExpression, isDereferenceExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTDoWhileLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTDoWhileLoop.h >index 6cc69c27fea..9f880c4ea44 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTDoWhileLoop.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTDoWhileLoop.h >@@ -50,6 +50,11 @@ public: > > DoWhileLoop(const DoWhileLoop&) = delete; > DoWhileLoop(DoWhileLoop&&) = default; >+ >+ bool isDoWhileLoop() const override { return true; } >+ >+ Statement& body() { return *m_body; } >+ Expression& conditional() { return *m_conditional; } > > private: > std::unique_ptr<Statement> m_body; >@@ -62,4 +67,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(DoWhileLoop, isDoWhileLoop()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEffectfulExpressionStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEffectfulExpressionStatement.h >index fd9aa730804..08321b6827a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEffectfulExpressionStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEffectfulExpressionStatement.h >@@ -50,6 +50,10 @@ public: > EffectfulExpressionStatement(const EffectfulExpressionStatement&) = delete; > EffectfulExpressionStatement(EffectfulExpressionStatement&&) = default; > >+ bool isEffectfulExpressionStatement() const override { return true; } >+ >+ Expression& effectfulExpression() { return *m_effectfulExpression; } >+ > private: > std::unique_ptr<Expression> m_effectfulExpression; > }; >@@ -60,4 +64,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(EffectfulExpressionStatement, isEffectfulExpressionStatement()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEnumerationDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEnumerationDefinition.h >index d607f662076..0b088a3428a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEnumerationDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEnumerationDefinition.h >@@ -39,9 +39,9 @@ namespace WHLSL { > > namespace AST { > >-class EnumerationDefinition : public Type { >+class EnumerationDefinition : public Node { > public: >- EnumerationDefinition(Lexer::Token&& origin, String&& name, std::unique_ptr<Type>&& type, Vector<EnumerationMember> members) >+ EnumerationDefinition(Lexer::Token&& origin, String&& name, std::unique_ptr<Type>&& type, EnumerationMembers&& members) > : m_origin(WTFMove(origin)) > , m_name(WTFMove(name)) > , m_type(WTFMove(type)) >@@ -54,17 +54,14 @@ public: > EnumerationDefinition(const EnumerationDefinition&) = delete; > EnumerationDefinition(EnumerationDefinition&&) = default; > >- std::unique_ptr<Type> clone() const override >- { >- ASSERT_NOT_REACHED(); >- return nullptr; >- } >+ Type& type() { return *m_type; } >+ EnumerationMembers& enumerationMembers() { return m_members; } > > private: > Lexer::Token m_origin; > String m_name; > std::unique_ptr<Type> m_type; >- Vector<EnumerationMember> m_members; >+ EnumerationMembers m_members; > }; > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEnumerationMember.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEnumerationMember.h >index 1ec91eabe9f..ba0d84e5061 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEnumerationMember.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTEnumerationMember.h >@@ -31,6 +31,7 @@ > #include "WHLSLASTNode.h" > #include "WHLSLLexer.h" > #include <wtf/Optional.h> >+#include <wtf/Vector.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -53,12 +54,16 @@ public: > EnumerationMember(const EnumerationMember&) = delete; > EnumerationMember(EnumerationMember&&) = default; > >+ std::optional<ConstantExpression>& value() { return m_value; } >+ > private: > Lexer::Token m_origin; > String m_name; > std::optional<ConstantExpression> m_value; > }; > >+typedef Vector<EnumerationMember> EnumerationMembers; >+ > } > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTExpression.h >index 82680321a31..0e1d6dd1c6e 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTExpression.h >@@ -50,6 +50,24 @@ public: > > Lexer::Token origin() const { return m_origin; } > >+ virtual bool isAssignmentExpression() const { return false; } >+ virtual bool isBooleanLiteral() const { return false; } >+ virtual bool isCallExpression() const { return false; } >+ virtual bool isCommaExpression() const { return false; } >+ virtual bool isDereferenceExpression() const { return false; } >+ virtual bool isFloatLiteral() const { return false; } >+ virtual bool isIntegerLiteral() const { return false; } >+ virtual bool isLogicalExpression() const { return false; } >+ virtual bool isLogicalNotExpression() const { return false; } >+ virtual bool isMakeArrayReferenceExpression() const { return false; } >+ virtual bool isMakePointerExpression() const { return false; } >+ virtual bool isNullLiteral() const { return false; } >+ virtual bool isPropertyAccessExpression() const { return false; } >+ virtual bool isReadModifyWriteExpression() const { return false; } >+ virtual bool isTernaryExpression() const { return false; } >+ virtual bool isUnsignedIntegerLiteral() const { return false; } >+ virtual bool isVariableReference() const { return false; } >+ > private: > Lexer::Token m_origin; > }; >@@ -60,4 +78,9 @@ private: > > } > >+#define SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(ToValueTypeName, predicate) \ >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \ >+ static bool isType(const WebCore::WHLSL::AST::Expression& expression) { return expression.predicate; } \ >+SPECIALIZE_TYPE_TRAITS_END() >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFallthrough.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFallthrough.h >index f7e3bb50186..573b569236e 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFallthrough.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFallthrough.h >@@ -47,6 +47,8 @@ public: > > Fallthrough(const Fallthrough&) = delete; > Fallthrough(Fallthrough&&) = default; >+ >+ bool isFallthrough() const override { return true; } > > private: > }; >@@ -57,4 +59,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Fallthrough, isFallthrough()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFloatLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFloatLiteral.h >index e450bd27289..9e839435c1a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFloatLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFloatLiteral.h >@@ -51,6 +51,8 @@ public: > > float value() const { return m_value; } > >+ bool isFloatLiteral() const override { return true; } >+ > private: > float m_value; > }; >@@ -61,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(FloatLiteral, isFloatLiteral()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTForLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTForLoop.h >index 22606384764..36f2c329bc3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTForLoop.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTForLoop.h >@@ -57,6 +57,13 @@ public: > > ForLoop(const ForLoop&) = delete; > ForLoop(ForLoop&&) = default; >+ >+ bool isForLoop() const override { return true; } >+ >+ Variant<VariableDeclarationsStatement, std::unique_ptr<Expression>>& initialization() { return m_initialization; } >+ Expression* condition() { return m_condition.get(); } >+ Expression* increment() { return m_increment.get(); } >+ Statement& body() { return *m_body; } > > private: > Variant<VariableDeclarationsStatement, std::unique_ptr<Expression>> m_initialization; >@@ -71,4 +78,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(ForLoop, isForLoop()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFunctionDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFunctionDeclaration.h >index ff78c4d8b9a..24fbdc8151b 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFunctionDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFunctionDeclaration.h >@@ -65,6 +65,11 @@ public: > FunctionDeclaration(const FunctionDeclaration&) = delete; > FunctionDeclaration(FunctionDeclaration&&) = default; > >+ AttributeBlock& attributeBlock() { return m_attributeBlock; } >+ AST::Type& type() { return *m_type; } >+ Parameters& parameters() { return m_parameters; } >+ std::optional<AST::Semantic>& semantic() { return m_semantic; } >+ > Lexer::Token&& takeOrigin() { return WTFMove(m_origin); } > AttributeBlock&& takeAttributeBlock() { return WTFMove(m_attributeBlock); } > std::optional<EntryPointType>&& takeEntryPointType() { return WTFMove(m_entryPointType); } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFunctionDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFunctionDefinition.h >index 8d7209a6c7f..5e07df6ccb5 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFunctionDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTFunctionDefinition.h >@@ -50,6 +50,7 @@ public: > FunctionDefinition(const FunctionDefinition&) = delete; > FunctionDefinition(FunctionDefinition&&) = default; > >+ Block& block() { return m_block; } > bool restricted() const { return m_restricted; } > > private: >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTIfStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTIfStatement.h >index 18131e443b3..f3848c95d69 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTIfStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTIfStatement.h >@@ -51,11 +51,17 @@ public: > > IfStatement(const IfStatement&) = delete; > IfStatement(IfStatement&&) = default; >+ >+ bool isIfStatement() const override { return true; } >+ >+ Expression& conditional() { return *m_conditional; } >+ Statement& body() { return *m_body; } >+ Statement* elseBody() { return m_elseBody.get(); } > > private: > std::unique_ptr<Expression> m_conditional; > std::unique_ptr<Statement> m_body; >- std::unique_ptr<Statement> m_elseBody; >+ std::unique_ptr<Statement> m_elseBody; // nullable > }; > > } >@@ -64,4 +70,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(IfStatement, isIfStatement()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTIntegerLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTIntegerLiteral.h >index d6b51d18fce..c0eebf452aa 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTIntegerLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTIntegerLiteral.h >@@ -51,6 +51,8 @@ public: > > int value() const { return m_value; } > >+ bool isIntegerLiteral() const override { return true; } >+ > private: > int m_value; > }; >@@ -61,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(IntegerLiteral, isIntegerLiteral()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTLogicalExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTLogicalExpression.h >index 77beb1e3b91..b665844c353 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTLogicalExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTLogicalExpression.h >@@ -58,6 +58,11 @@ public: > > Type type() const { return m_type; } > >+ bool isLogicalExpression() const override { return true; } >+ >+ Expression& left() { return *m_left; } >+ Expression& right() { return *m_right; } >+ > private: > Type m_type; > std::unique_ptr<Expression> m_left; >@@ -70,4 +75,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(LogicalExpression, isLogicalExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTLogicalNotExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTLogicalNotExpression.h >index 8c93d885761..007676afa6f 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTLogicalNotExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTLogicalNotExpression.h >@@ -49,6 +49,10 @@ public: > LogicalNotExpression(const LogicalNotExpression&) = delete; > LogicalNotExpression(LogicalNotExpression&&) = default; > >+ bool isLogicalNotExpression() const override { return true; } >+ >+ Expression& operand() { return *m_operand; } >+ > private: > std::unique_ptr<Expression> m_operand; > }; >@@ -59,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(LogicalNotExpression, isLogicalNotExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTMakeArrayReferenceExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTMakeArrayReferenceExpression.h >index 10f8206e88a..e3083175fc5 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTMakeArrayReferenceExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTMakeArrayReferenceExpression.h >@@ -49,6 +49,10 @@ public: > MakeArrayReferenceExpression(const MakeArrayReferenceExpression&) = delete; > MakeArrayReferenceExpression(MakeArrayReferenceExpression&&) = default; > >+ bool isMakeArrayReferenceExpression() const override { return true; } >+ >+ Expression& lValue() { return *m_lValue; } >+ > private: > std::unique_ptr<Expression> m_lValue; > }; >@@ -59,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(MakeArrayReferenceExpression, isMakeArrayReferenceExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTMakePointerExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTMakePointerExpression.h >index 69fa9240e10..60ebc59595a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTMakePointerExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTMakePointerExpression.h >@@ -49,6 +49,10 @@ public: > MakePointerExpression(const MakePointerExpression&) = delete; > MakePointerExpression(MakePointerExpression&&) = default; > >+ bool isMakePointerExpression() const override { return true; } >+ >+ Expression& lValue() { return *m_lValue; } >+ > private: > std::unique_ptr<Expression> m_lValue; > }; >@@ -59,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(MakePointerExpression, isMakePointerExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTNativeTypeDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTNativeTypeDeclaration.h >index 83f954393c5..828f0437aee 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTNativeTypeDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTNativeTypeDeclaration.h >@@ -52,6 +52,8 @@ public: > NativeTypeDeclaration(const NativeTypeDeclaration&) = delete; > NativeTypeDeclaration(NativeTypeDeclaration&&) = default; > >+ TypeArguments& typeArguments() { return m_typeArguments; } >+ > std::unique_ptr<Type> clone() const override > { > ASSERT_NOT_REACHED(); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTNullLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTNullLiteral.h >index 5ba7f687e83..4bdf4011d87 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTNullLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTNullLiteral.h >@@ -48,6 +48,8 @@ public: > explicit NullLiteral(const NullLiteral&) = default; > NullLiteral(NullLiteral&&) = default; > >+ bool isNullLiteral() const override { return true; } >+ > private: > }; > >@@ -57,4 +59,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(NullLiteral, isNullLiteral()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTParameter.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTParameter.h >index 6b919fa5753..8091b7febbf 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTParameter.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTParameter.h >@@ -57,6 +57,9 @@ public: > Parameter(const Parameter&) = delete; > Parameter(Parameter&&) = default; > >+ Type& type() { return *m_type; } >+ std::optional<AST::Semantic>& semantic() { return m_semantic; } >+ > private: > Lexer::Token m_origin; > Qualifiers m_qualifiers; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTPointerType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTPointerType.h >index 4d4bf5cacf5..0e564930c5b 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTPointerType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTPointerType.h >@@ -49,9 +49,11 @@ public: > PointerType(const PointerType&) = delete; > PointerType(PointerType&&) = default; > >+ bool isPointerType() const override { return false; } >+ > std::unique_ptr<Type> clone() const override > { >- return std::make_unique<PointerType>(Lexer::Token(origin()), String(addressSpace()), elementType()->clone()); >+ return std::make_unique<PointerType>(Lexer::Token(origin()), String(addressSpace()), elementType().clone()); > } > > private: >@@ -63,4 +65,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(PointerType, isPointerType()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTPropertyAccessExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTPropertyAccessExpression.h >index f12b3b28a21..8ef7e84f186 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTPropertyAccessExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTPropertyAccessExpression.h >@@ -49,6 +49,10 @@ public: > PropertyAccessExpression(const PropertyAccessExpression&) = delete; > PropertyAccessExpression(PropertyAccessExpression&&) = default; > >+ bool isPropertyAccessExpression() const override { return true; } >+ >+ Expression& base() { return *m_base; } >+ > private: > std::unique_ptr<Expression> m_base; > }; >@@ -59,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(PropertyAccessExpression, isPropertyAccessExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReadModifyWriteExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReadModifyWriteExpression.h >index 3f27e6a3c2c..2987c8a7dca 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReadModifyWriteExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReadModifyWriteExpression.h >@@ -84,6 +84,14 @@ public: > return std::make_unique<VariableReference>(VariableReference::wrap(m_newValue)); > } > >+ bool isReadModifyWriteExpression() const override { return true; } >+ >+ Expression& lValue() { return *m_lValue; } >+ AnonymousVariableDeclaration& oldValue() { return m_oldValue; } >+ AnonymousVariableDeclaration& newValue() { return m_newValue; } >+ Expression& newValueExpression() { return *m_newValueExpression; } >+ Expression& resultExpression() { return *m_resultExpression; } >+ > private: > std::unique_ptr<Expression> m_lValue; > AnonymousVariableDeclaration m_oldValue; >@@ -98,4 +106,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(ReadModifyWriteExpression, isReadModifyWriteExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReferenceType.h >index 701bbb1ba57..9c6fae93659 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReferenceType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReferenceType.h >@@ -50,11 +50,13 @@ 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 std::unique_ptr<Type>& elementType() const { return m_elementType; } >+ const Type& elementType() const { return *m_elementType; } > > private: > Lexer::Token m_origin; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReturn.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReturn.h >index 10d786fcec6..72f6f574be0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReturn.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTReturn.h >@@ -49,9 +49,13 @@ public: > > Return(const Return&) = delete; > Return(Return&&) = default; >+ >+ bool isReturn() const override { return true; } >+ >+ Expression* value() { return m_value.get(); } > > private: >- std::unique_ptr<Expression> m_value; >+ std::unique_ptr<Expression> m_value; // nullable > }; > > } >@@ -60,4 +64,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Return, isReturn()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStatement.h >index 2686edff4d6..403baa02c13 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStatement.h >@@ -48,14 +48,36 @@ public: > Statement(const Statement&) = delete; > Statement(Statement&&) = default; > >+ virtual bool isBlock() const { return false; } >+ virtual bool isBreak() const { return false; } >+ virtual bool isContinue() const { return false; } >+ virtual bool isDoWhileLoop() const { return false; } >+ virtual bool isEffectfulExpressionStatement() const { return false; } >+ virtual bool isFallthrough() const { return false; } >+ virtual bool isForLoop() const { return false; } >+ virtual bool isIfStatement() const { return false; } >+ virtual bool isReturn() const { return false; } >+ virtual bool isSwitchCase() const { return false; } >+ virtual bool isSwitchStatement() const { return false; } >+ virtual bool isTrap() const { return false; } >+ virtual bool isVariableDeclarationsStatement() const { return false; } >+ virtual bool isWhileLoop() const { return false; } >+ > private: > Lexer::Token m_origin; > }; > >+typedef Vector<std::unique_ptr<Statement>> Statements; >+ > } > > } > > } > >+#define SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(ToValueTypeName, predicate) \ >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \ >+ static bool isType(const WebCore::WHLSL::AST::Statement& statement) { return statement.predicate; } \ >+SPECIALIZE_TYPE_TRAITS_END() >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStructureDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStructureDefinition.h >index 0a8f4a4cc3b..092d914676b 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStructureDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStructureDefinition.h >@@ -53,6 +53,8 @@ public: > StructureDefinition(const StructureDefinition&) = delete; > StructureDefinition(StructureDefinition&&) = default; > >+ StructureElements& structureElements() { return m_structureElements; } >+ > std::unique_ptr<Type> clone() const override > { > ASSERT_NOT_REACHED(); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStructureElement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStructureElement.h >index fc59990f120..5e6dbd754d8 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStructureElement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTStructureElement.h >@@ -55,6 +55,9 @@ public: > StructureElement(const StructureElement&) = delete; > StructureElement(StructureElement&&) = default; > >+ Type& type() { return *m_type; } >+ std::optional<Semantic>& semantic() { return m_semantic; } >+ > private: > Lexer::Token m_origin; > Qualifiers m_qualifiers; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTSwitchCase.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTSwitchCase.h >index b44d0ecf74e..bf5b614ab9e 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTSwitchCase.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTSwitchCase.h >@@ -52,6 +52,11 @@ public: > > SwitchCase(const SwitchCase&) = delete; > SwitchCase(SwitchCase&&) = default; >+ >+ bool isSwitchCase() const override { return true; } >+ >+ std::optional<ConstantExpression>& value() { return m_value; } >+ Block& block() { return m_block; } > > private: > std::optional<ConstantExpression> m_value; >@@ -64,4 +69,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(SwitchCase, isSwitchCase()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTSwitchStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTSwitchStatement.h >index 736ef116848..7f9a69d9d11 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTSwitchStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTSwitchStatement.h >@@ -51,6 +51,11 @@ public: > > SwitchStatement(const SwitchStatement&) = delete; > SwitchStatement(SwitchStatement&&) = default; >+ >+ bool isSwitchStatement() const override { return true; } >+ >+ Expression& value() { return *m_value; } >+ Vector<SwitchCase>& switchCases() { return m_switchCases; } > > private: > std::unique_ptr<Expression> m_value; >@@ -63,4 +68,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(SwitchStatement, isSwitchStatement()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTernaryExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTernaryExpression.h >index cbfb5968a6d..af97e6880a5 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTernaryExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTernaryExpression.h >@@ -51,6 +51,12 @@ public: > TernaryExpression(const TernaryExpression&) = delete; > TernaryExpression(TernaryExpression&&) = default; > >+ bool isTernaryExpression() const override { return true; } >+ >+ Expression& predicate() { return *m_predicate; } >+ Expression& bodyExpression() { return *m_bodyExpression; } >+ Expression& elseExpression() { return *m_elseExpression; } >+ > private: > std::unique_ptr<Expression> m_predicate; > std::unique_ptr<Expression> m_bodyExpression; >@@ -63,4 +69,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(TernaryExpression, isTernaryExpression()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTrap.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTrap.h >index 577714b2596..3eaa5a46542 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTrap.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTrap.h >@@ -47,6 +47,8 @@ public: > > Trap(const Trap&) = delete; > Trap(Trap&&) = default; >+ >+ bool isTrap() const override { return true; } > > private: > }; >@@ -57,4 +59,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Trap, isTrap()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTType.h >index df6ecec669b..0d8ff6398a5 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTType.h >@@ -28,6 +28,7 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLASTNode.h" >+#include <wtf/TypeCasts.h> > > namespace WebCore { > >@@ -44,6 +45,11 @@ 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; > > private: >@@ -55,4 +61,9 @@ private: > > } > >+#define SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(ToValueTypeName, predicate) \ >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \ >+ static bool isType(const WebCore::WHLSL::AST::Type& type) { return type.predicate; } \ >+SPECIALIZE_TYPE_TRAITS_END() >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeArgument.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeArgument.cpp >new file mode 100644 >index 00000000000..7e5801e3b56 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeArgument.cpp >@@ -0,0 +1,64 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLLexer.h" >+ >+#include <wtf/Optional.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+namespace AST { >+ >+TypeArguments clone(const TypeArguments& typeArguments) >+{ >+ TypeArguments result; >+ for (const auto& typeArgument : typeArguments) >+ result.append(clone(typeArgument)); >+ return result; >+} >+ >+TypeArgument clone(const TypeArgument& typeArgument) >+{ >+ return WTF::visit(WTF::makeVisitor([](const ConstantExpression& constantExpression) -> TypeArgument { >+ return constantExpression; >+ }, [](const std::unique_ptr<TypeReference>& typeReference) -> TypeArgument { >+ return typeReference->cloneTypeReference(); >+ }), typeArgument); >+} >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeArgument.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeArgument.h >index a416896ad4a..3d728bf5ebf 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeArgument.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeArgument.h >@@ -31,7 +31,6 @@ > #include "WHLSLLexer.h" > #include <wtf/Variant.h> > #include <wtf/Vector.h> >-#include <wtf/text/StringView.h> > > namespace WebCore { > >@@ -39,9 +38,14 @@ namespace WHLSL { > > namespace AST { > >-typedef Variant<ConstantExpression, String> TypeArgument; >+class TypeReference; >+ >+typedef Variant<ConstantExpression, std::unique_ptr<TypeReference>> TypeArgument; > typedef Vector<TypeArgument> TypeArguments; > >+TypeArgument clone(const TypeArgument&); >+TypeArguments clone(const TypeArguments&); >+ > } > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeDefinition.h >index f72c6b6a03d..6fb05cafbe6 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeDefinition.h >@@ -52,6 +52,8 @@ public: > TypeDefinition(const TypeDefinition&) = delete; > TypeDefinition(TypeDefinition&&) = default; > >+ AST::Type& type() { return *m_type; } >+ > std::unique_ptr<Type> clone() const override > { > ASSERT_NOT_REACHED(); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeReference.h >index 6bbab389950..00111adb073 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeReference.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTTypeReference.h >@@ -52,9 +52,18 @@ public: > TypeReference(const TypeReference&) = delete; > TypeReference(TypeReference&&) = default; > >+ bool isTypeReference() const override { return true; } >+ >+ TypeArguments& typeArguments() { return m_typeArguments; } >+ >+ std::unique_ptr<TypeReference> cloneTypeReference() const >+ { >+ return std::make_unique<TypeReference>(Lexer::Token(m_origin), String(m_name), AST::clone(m_typeArguments)); >+ } >+ > std::unique_ptr<Type> clone() const override > { >- return std::make_unique<TypeReference>(Lexer::Token(m_origin), String(m_name), TypeArguments(m_typeArguments)); >+ return cloneTypeReference(); > } > > private: >@@ -69,4 +78,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(TypeReference, isTypeReference()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTUnsignedIntegerLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTUnsignedIntegerLiteral.h >index 67b9c22793a..a5c2ecd5ae0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTUnsignedIntegerLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTUnsignedIntegerLiteral.h >@@ -51,6 +51,8 @@ public: > > unsigned value() const { return m_value; } > >+ bool isUnsignedIntegerLiteral() const override { return true; } >+ > private: > unsigned m_value; > }; >@@ -61,4 +63,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(UnsignedIntegerLiteral, isUnsignedIntegerLiteral()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableDeclaration.h >index 1a9c81ace34..8b19095eb32 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableDeclaration.h >@@ -61,6 +61,10 @@ public: > > Lexer::Token origin() const { return m_origin; } > >+ Type& type() { return *m_type; } >+ std::optional<Semantic>& semantic() { return m_semantic; } >+ Expression* initializer() { return m_initializer.get(); } >+ > private: > Lexer::Token m_origin; > Qualifiers m_qualifiers; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableDeclarationsStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableDeclarationsStatement.h >index 30be3f45b98..20fc9d0ba00 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableDeclarationsStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableDeclarationsStatement.h >@@ -50,9 +50,13 @@ public: > > VariableDeclarationsStatement(const VariableDeclarationsStatement&) = delete; > VariableDeclarationsStatement(VariableDeclarationsStatement&&) = default; >+ >+ bool isVariableDeclarationsStatement() const override { return true; } >+ >+ Vector<VariableDeclaration>& variableDeclarations() { return m_variableDeclarations; } > > private: >- Vector<VariableDeclaration>&& m_variableDeclarations; >+ Vector<VariableDeclaration> m_variableDeclarations; > }; > > } >@@ -61,4 +65,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(VariableDeclarationsStatement, isVariableDeclarationsStatement()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableReference.h >index 33b6fc61d5f..74d6fa6d8ea 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableReference.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTVariableReference.h >@@ -66,6 +66,8 @@ public: > return result; > } > >+ bool isVariableReference() const override { return true; } >+ > private: > VariableReference(Lexer::Token&& origin) > : Expression(WTFMove(origin)) >@@ -82,4 +84,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(VariableReference, isVariableReference()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTWhileLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTWhileLoop.h >index 8aea2c1b2d9..f34053e2929 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTWhileLoop.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLASTWhileLoop.h >@@ -50,6 +50,11 @@ public: > > WhileLoop(const WhileLoop&) = delete; > WhileLoop(WhileLoop&&) = default; >+ >+ bool isWhileLoop() const override { return true; } >+ >+ Expression& conditional() { return *m_conditional; } >+ Statement& body() { return *m_body; } > > private: > std::unique_ptr<Expression> m_conditional; >@@ -62,4 +67,6 @@ private: > > } > >+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(WhileLoop, isWhileLoop()) >+ > #endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >new file mode 100644 >index 00000000000..780d5c5425a >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >@@ -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. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLNameResolver.h" >+ >+#include "WHLSLVisitor.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class NameResolver : public Visitor { >+ ~NameResolver() = default; >+}; >+ >+void resolveNamesInTypes(Program&) >+{ >+ >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >new file mode 100644 >index 00000000000..47d4d6a5793 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.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) >+ >+#include "WHLSLProgram.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+void resolveNamesInTypes(Program& program); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >index b20f374a524..6cf4139b147 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >@@ -23,8 +23,6 @@ > * THE POSSIBILITY OF SUCH DAMAGE. > */ > >-#pragma once >- > #if ENABLE(WEBGPU) > > #include "config.h" >@@ -414,7 +412,7 @@ auto Parser::parseTypeArgument() -> Expected<AST::TypeArgument, Error> { > auto result = consumeType(Lexer::Token::Type::Identifier); > if (!result) > return Unexpected<Error>(result.error()); >- return { result->stringView.toString() }; >+ return { std::make_unique<AST::TypeReference>(Lexer::Token(*result), result->stringView.toString(), AST::TypeArguments()) }; > } > > auto Parser::parseTypeArguments() -> Expected<AST::TypeArguments, Error> { >@@ -895,7 +893,7 @@ auto Parser::parseEnumerationDefinition() -> Expected<AST::EnumerationDefinition > if (!firstEnumerationMember) > return Unexpected<Error>(firstEnumerationMember.error()); > >- Vector<AST::EnumerationMember> members; >+ AST::EnumerationMembers members; > members.append(WTFMove(*firstEnumerationMember)); > > while (tryType(Lexer::Token::Type::Comma)) { >@@ -1251,7 +1249,7 @@ auto Parser::parseBlock() -> Expected<AST::Block, Error> { > > AST::Block Parser::parseBlockBody(Lexer::Token&& origin) > { >- Vector<std::unique_ptr<AST::Statement>> statements; >+ AST::Statements statements; > while (true) { > auto statement = backtrackingScope<Expected<std::unique_ptr<AST::Statement>, Error>>([&]() { > return parseStatement(); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp >new file mode 100644 >index 00000000000..ab8d746c26f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp >@@ -0,0 +1,62 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#if ENABLE(WEBGPU) >+ >+#include "config.h" >+#include "WHLSLPrepare.h" >+ >+#include "WHLSLNameResolver.h" >+#include "WHLSLParser.h" >+#include "WHLSLProgram.h" >+#include "WHLSLStandardLibrary.h" >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+std::optional<PreparationResult> prepare(StringView source) >+{ >+ Program program; >+ >+ Parser parser; >+ auto standardLibrary = String::fromUTF8(WHLSLStandardLibrary, sizeof(WHLSLStandardLibrary)); >+ bool success = static_cast<bool>(parser.parse(program, standardLibrary, WHLSL::Parser::Mode::StandardLibrary)); >+ if (!success) >+ return std::nullopt; >+ success = static_cast<bool>(parser.parse(program, source, WHLSL::Parser::Mode::User)); >+ if (!success) >+ return std::nullopt; >+ >+ resolveNamesInTypes(program); >+ >+ return PreparationResult(); >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h >new file mode 100644 >index 00000000000..54ccd647c75 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.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 <wtf/Optional.h> >+#include <wtf/text/StringView.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+struct PreparationResult >+{ >+ // Metal shading language code >+ // Mapping of attribute IDs >+ // etc. >+}; >+ >+std::optional<PreparationResult> prepare(StringView source); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >index 65e613a9fb3..ea67dd924b4 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h >@@ -69,6 +69,13 @@ public: > m_nativeTypeDeclarations.append(WTFMove(nativeTypeDeclaration)); > } > >+ 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; } >+ > private: > Vector<AST::TypeDefinition> m_typeDefinitions; > Vector<AST::StructureDefinition> m_structureDefinitions; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h >new file mode 100644 >index 00000000000..c733bb912e6 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h >@@ -0,0 +1,573 @@ >+/* >+ * 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" >+#include "WHLSLASTAnonymousVariableDeclaration.h" >+#include "WHLSLASTArrayReferenceType.h" >+#include "WHLSLASTArrayType.h" >+#include "WHLSLASTAssignmentExpression.h" >+#include "WHLSLASTBaseFunctionAttribute.h" >+#include "WHLSLASTBaseSemantic.h" >+#include "WHLSLASTBlock.h" >+#include "WHLSLASTBooleanLiteral.h" >+#include "WHLSLASTBreak.h" >+#include "WHLSLASTBuiltInSemantic.h" >+#include "WHLSLASTCallExpression.h" >+#include "WHLSLASTCommaExpression.h" >+#include "WHLSLASTConstantExpression.h" >+#include "WHLSLASTConstantExpressionEnumerationMemberReference.h" >+#include "WHLSLASTContinue.h" >+#include "WHLSLASTDereferenceExpression.h" >+#include "WHLSLASTDoWhileLoop.h" >+#include "WHLSLASTDotExpression.h" >+#include "WHLSLASTEffectfulExpressionStatement.h" >+#include "WHLSLASTEnumerationDefinition.h" >+#include "WHLSLASTEnumerationMember.h" >+#include "WHLSLASTExpression.h" >+#include "WHLSLASTFallthrough.h" >+#include "WHLSLASTFloatLiteral.h" >+#include "WHLSLASTForLoop.h" >+#include "WHLSLASTFunctionAttribute.h" >+#include "WHLSLASTFunctionDeclaration.h" >+#include "WHLSLASTFunctionDefinition.h" >+#include "WHLSLASTIfStatement.h" >+#include "WHLSLASTIndexExpression.h" >+#include "WHLSLASTIntegerLiteral.h" >+#include "WHLSLASTLogicalExpression.h" >+#include "WHLSLASTLogicalNotExpression.h" >+#include "WHLSLASTMakeArrayReferenceExpression.h" >+#include "WHLSLASTMakePointerExpression.h" >+#include "WHLSLASTNativeFunctionDeclaration.h" >+#include "WHLSLASTNativeTypeDeclaration.h" >+#include "WHLSLASTNode.h" >+#include "WHLSLASTNullLiteral.h" >+#include "WHLSLASTNumThreadsFunctionAttribute.h" >+#include "WHLSLASTParameter.h" >+#include "WHLSLASTPointerType.h" >+#include "WHLSLASTPropertyAccessExpression.h" >+#include "WHLSLASTQualifier.h" >+#include "WHLSLASTReadModifyWriteExpression.h" >+#include "WHLSLASTReferenceType.h" >+#include "WHLSLASTResourceSemantic.h" >+#include "WHLSLASTReturn.h" >+#include "WHLSLASTSemantic.h" >+#include "WHLSLASTSpecializationConstantSemantic.h" >+#include "WHLSLASTStageInOutSemantic.h" >+#include "WHLSLASTStatement.h" >+#include "WHLSLASTStructureDefinition.h" >+#include "WHLSLASTStructureElement.h" >+#include "WHLSLASTSwitchCase.h" >+#include "WHLSLASTSwitchStatement.h" >+#include "WHLSLASTTernaryExpression.h" >+#include "WHLSLASTTrap.h" >+#include "WHLSLASTType.h" >+#include "WHLSLASTTypeArgument.h" >+#include "WHLSLASTTypeDefinition.h" >+#include "WHLSLASTTypeReference.h" >+#include "WHLSLASTUnsignedIntegerLiteral.h" >+#include "WHLSLASTValue.h" >+#include "WHLSLASTVariableDeclaration.h" >+#include "WHLSLASTVariableDeclarationsStatement.h" >+#include "WHLSLASTVariableReference.h" >+#include "WHLSLASTWhileLoop.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) >+ { >+ WTF::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); >+ }), constantExpression); >+ } >+ >+ 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&) >+ { >+ } >+ >+ 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&) >+ { >+ } >+}; >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 2e230f1c931..6df196d2417 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -303,6 +303,9 @@ Modules/websockets/WorkerThreadableWebSocketChannel.cpp > Modules/webgpu/DOMWindowWebGPU.cpp > Modules/webgpu/WHLSL/WHLSLLexer.cpp > Modules/webgpu/WHLSL/WHLSLParser.cpp >+Modules/webgpu/WHLSL/WHLSLPrepare.cpp >+Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >+Modules/webgpu/WHLSL/AST/WHLSLASTTypeArgument.cpp > Modules/webgpu/WebGPU.cpp > Modules/webgpu/WebGPUAdapter.cpp > Modules/webgpu/WebGPUBuffer.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index ea335ad63f4..58cc55c6bb6 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -13278,6 +13278,12 @@ > 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>"; }; >+ 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 /* WHLSLASTTypeArgument.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLASTTypeArgument.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>"; }; >@@ -25289,6 +25295,11 @@ > C2ECEB4D21B63CBB008F8DE9 /* WHLSLParser.h */, > C2ECEB5E21B64D6F008F8DE9 /* WHLSLProgram.h */, > C274F14321C335FF003410BD /* WHLSLStandardLibrary.txt */, >+ C288C72721C8C6EF002DF5CA /* WHLSLVisitor.h */, >+ C288C72921C8CA50002DF5CA /* WHLSLPrepare.cpp */, >+ C288C72A21C8CA50002DF5CA /* WHLSLPrepare.h */, >+ C288C72B21C8CCC2002DF5CA /* WHLSLNameResolver.cpp */, >+ C288C72C21C8CCC2002DF5CA /* WHLSLNameResolver.h */, > ); > path = WHLSL; > sourceTree = "<group>"; >@@ -25364,6 +25375,7 @@ > C22F76DF21C26F4700C5434E /* WHLSLASTVariableDeclarationsStatement.h */, > C22F76CC21C0A9A700C5434E /* WHLSLASTVariableReference.h */, > 1C80599221C1FDDA006B0906 /* WHLSLASTWhileLoop.h */, >+ C288C72D21C991DA002DF5CA /* WHLSLASTTypeArgument.cpp */, > ); > path = AST; > sourceTree = "<group>"; >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm >index ba94fcf2933..513f5a96e64 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm >@@ -31,9 +31,7 @@ > #import "GPUDevice.h" > #import "GPUShaderModuleDescriptor.h" > #import "Logging.h" >-#import "WHLSLParser.h" >-#import "WHLSLProgram.h" >-#import "WHLSLStandardLibrary.h" >+#import "WHLSLPrepare.h" > > #import <Metal/Metal.h> > #import <wtf/BlockObjCExceptions.h> >@@ -50,11 +48,7 @@ RefPtr<GPUShaderModule> GPUShaderModule::create(const GPUDevice& device, GPUShad > String code = descriptor.code; > > if (descriptor.isWHLSL) { >- WHLSL::Program program; >- WHLSL::Parser parser; >- auto standardLibrary = String::fromUTF8(WHLSLStandardLibrary, sizeof(WHLSLStandardLibrary)); >- if (parser.parse(program, standardLibrary, WHLSL::Parser::Mode::StandardLibrary) == std::nullopt >- && parser.parse(program, descriptor.code, WHLSL::Parser::Mode::User) == std::nullopt) >+ if (WHLSL::prepare(descriptor.code)) > code = ""; > else > return nullptr;
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 192826
:
357603
|
357930
|
358011
|
358882
|
358911