WebKit Bugzilla
Attachment 358011 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
patch.txt (text/plain), 92.13 KB, created by
Myles C. Maxfield
on 2018-12-21 18:56:41 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-12-21 18:56:41 PST
Size:
92.13 KB
patch
obsolete
>commit 0d0481c70d96b7d2ca2616fbc002af53f1573f87 >Author: Myles C. Maxfield <mmaxfield@apple.com> >Date: Fri Dec 21 18:56:07 2018 -0800 > > Visitor > >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index a973118f6e8..38d81efba76 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,194 @@ >+2018-12-21 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Add a Visitor class >+ https://bugs.webkit.org/show_bug.cgi?id=192826 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch exposes a bunch of the private members of WHLSL's AST nodes so that Visitor can recurse on constituent nodes. >+ It also writes the recursion in Visitor.h. This is a virtual base class that gets subclassed for compiler passes. >+ >+ I've split this part into its own patch to aid reviewing of the compiler. >+ >+ No new tests because it's not hooked up yet. >+ >+ * Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLArrayType.h: >+ (WebCore::WHLSL::AST::ArrayType::type): >+ * Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h: >+ (WebCore::WHLSL::AST::AssignmentExpression::left): >+ (WebCore::WHLSL::AST::AssignmentExpression::right): >+ * Modules/webgpu/WHLSL/AST/WHLSLBlock.h: >+ (WebCore::WHLSL::AST::Block::Block): >+ (WebCore::WHLSL::AST::Block::statements): >+ * Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLBreak.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h: >+ (WebCore::WHLSL::AST::CallExpression::arguments): >+ * Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.h: >+ (WebCore::WHLSL::AST::CommaExpression::list): >+ * Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h: >+ (WebCore::WHLSL::AST::ConstantExpression::ConstantExpression): >+ (WebCore::WHLSL::AST::ConstantExpression::visit): >+ * Modules/webgpu/WHLSL/AST/WHLSLContinue.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h: >+ (WebCore::WHLSL::AST::DereferenceExpression::pointer): >+ * Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h: >+ (WebCore::WHLSL::AST::DoWhileLoop::body): >+ (WebCore::WHLSL::AST::DoWhileLoop::conditional): >+ * Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h: >+ (WebCore::WHLSL::AST::EffectfulExpressionStatement::effectfulExpression): >+ * Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h: >+ (WebCore::WHLSL::AST::EnumerationDefinition::EnumerationDefinition): >+ (WebCore::WHLSL::AST::EnumerationDefinition::type): >+ (WebCore::WHLSL::AST::EnumerationDefinition::enumerationMembers): >+ (): Deleted. >+ * Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h: >+ (WebCore::WHLSL::AST::EnumerationMember::value): >+ * Modules/webgpu/WHLSL/AST/WHLSLExpression.h: >+ (WebCore::WHLSL::AST::Expression::isAssignmentExpression const): >+ (WebCore::WHLSL::AST::Expression::isBooleanLiteral const): >+ (WebCore::WHLSL::AST::Expression::isCallExpression const): >+ (WebCore::WHLSL::AST::Expression::isCommaExpression const): >+ (WebCore::WHLSL::AST::Expression::isDereferenceExpression const): >+ (WebCore::WHLSL::AST::Expression::isFloatLiteral const): >+ (WebCore::WHLSL::AST::Expression::isIntegerLiteral const): >+ (WebCore::WHLSL::AST::Expression::isLogicalExpression const): >+ (WebCore::WHLSL::AST::Expression::isLogicalNotExpression const): >+ (WebCore::WHLSL::AST::Expression::isMakeArrayReferenceExpression const): >+ (WebCore::WHLSL::AST::Expression::isMakePointerExpression const): >+ (WebCore::WHLSL::AST::Expression::isNullLiteral const): >+ (WebCore::WHLSL::AST::Expression::isPropertyAccessExpression const): >+ (WebCore::WHLSL::AST::Expression::isReadModifyWriteExpression const): >+ (WebCore::WHLSL::AST::Expression::isTernaryExpression const): >+ (WebCore::WHLSL::AST::Expression::isUnsignedIntegerLiteral const): >+ (WebCore::WHLSL::AST::Expression::isVariableReference const): >+ * Modules/webgpu/WHLSL/AST/WHLSLFallthrough.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLForLoop.h: >+ (WebCore::WHLSL::AST::ForLoop::initialization): >+ (WebCore::WHLSL::AST::ForLoop::condition): >+ (WebCore::WHLSL::AST::ForLoop::increment): >+ (WebCore::WHLSL::AST::ForLoop::body): >+ * Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h: >+ (WebCore::WHLSL::AST::FunctionDeclaration::attributeBlock): >+ (WebCore::WHLSL::AST::FunctionDeclaration::type): >+ (WebCore::WHLSL::AST::FunctionDeclaration::parameters): >+ (WebCore::WHLSL::AST::FunctionDeclaration::semantic): >+ * Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h: >+ (WebCore::WHLSL::AST::FunctionDefinition::block): >+ * Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h: >+ (WebCore::WHLSL::AST::IfStatement::conditional): >+ (WebCore::WHLSL::AST::IfStatement::body): >+ (WebCore::WHLSL::AST::IfStatement::elseBody): >+ * Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h: >+ (WebCore::WHLSL::AST::LogicalExpression::left): >+ (WebCore::WHLSL::AST::LogicalExpression::right): >+ * Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h: >+ (WebCore::WHLSL::AST::LogicalNotExpression::operand): >+ * Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h: >+ (WebCore::WHLSL::AST::MakeArrayReferenceExpression::lValue): >+ * Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h: >+ (WebCore::WHLSL::AST::MakePointerExpression::lValue): >+ * Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h: >+ (WebCore::WHLSL::AST::NativeTypeDeclaration::typeArguments): >+ * Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLParameter.h: >+ (WebCore::WHLSL::AST::Parameter::type): >+ (WebCore::WHLSL::AST::Parameter::semantic): >+ * Modules/webgpu/WHLSL/AST/WHLSLPointerType.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h: >+ (WebCore::WHLSL::AST::PropertyAccessExpression::base): >+ * Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h: >+ (WebCore::WHLSL::AST::ReadModifyWriteExpression::lValue): >+ (WebCore::WHLSL::AST::ReadModifyWriteExpression::oldValue): >+ (WebCore::WHLSL::AST::ReadModifyWriteExpression::newValue): >+ (WebCore::WHLSL::AST::ReadModifyWriteExpression::newValueExpression): >+ (WebCore::WHLSL::AST::ReadModifyWriteExpression::resultExpression): >+ * Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h: >+ (WebCore::WHLSL::AST::ReferenceType::elementType): >+ (WebCore::WHLSL::AST::ReferenceType::elementType const): >+ * Modules/webgpu/WHLSL/AST/WHLSLReturn.h: >+ (WebCore::WHLSL::AST::Return::value): >+ * Modules/webgpu/WHLSL/AST/WHLSLStatement.h: >+ (WebCore::WHLSL::AST::Statement::isBlock const): >+ (WebCore::WHLSL::AST::Statement::isBreak const): >+ (WebCore::WHLSL::AST::Statement::isContinue const): >+ (WebCore::WHLSL::AST::Statement::isDoWhileLoop const): >+ (WebCore::WHLSL::AST::Statement::isEffectfulExpressionStatement const): >+ (WebCore::WHLSL::AST::Statement::isFallthrough const): >+ (WebCore::WHLSL::AST::Statement::isForLoop const): >+ (WebCore::WHLSL::AST::Statement::isIfStatement const): >+ (WebCore::WHLSL::AST::Statement::isReturn const): >+ (WebCore::WHLSL::AST::Statement::isSwitchCase const): >+ (WebCore::WHLSL::AST::Statement::isSwitchStatement const): >+ (WebCore::WHLSL::AST::Statement::isTrap const): >+ (WebCore::WHLSL::AST::Statement::isVariableDeclarationsStatement const): >+ (WebCore::WHLSL::AST::Statement::isWhileLoop const): >+ * Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h: >+ (WebCore::WHLSL::AST::StructureDefinition::structureElements): >+ * Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h: >+ (WebCore::WHLSL::AST::StructureElement::type): >+ (WebCore::WHLSL::AST::StructureElement::semantic): >+ * Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h: >+ (WebCore::WHLSL::AST::SwitchCase::value): >+ (WebCore::WHLSL::AST::SwitchCase::block): >+ * Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h: >+ (WebCore::WHLSL::AST::SwitchStatement::value): >+ (WebCore::WHLSL::AST::SwitchStatement::switchCases): >+ * Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h: >+ (WebCore::WHLSL::AST::TernaryExpression::predicate): >+ (WebCore::WHLSL::AST::TernaryExpression::bodyExpression): >+ (WebCore::WHLSL::AST::TernaryExpression::elseExpression): >+ * Modules/webgpu/WHLSL/AST/WHLSLTrap.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLType.h: >+ (WebCore::WHLSL::AST::Type::isTypeReference const): >+ (WebCore::WHLSL::AST::Type::isPointerType const): >+ (WebCore::WHLSL::AST::Type::isArrayReferenceType const): >+ (WebCore::WHLSL::AST::Type::isArrayType const): >+ * Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h. >+ (WebCore::WHLSL::AST::clone): >+ * Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h: >+ (WebCore::WHLSL::AST::TypeDefinition::type): >+ * Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h: >+ (WebCore::WHLSL::AST::TypeReference::typeArguments): >+ (WebCore::WHLSL::AST::TypeReference::cloneTypeReference const): >+ * Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h: >+ (WebCore::WHLSL::AST::VariableDeclaration::type): >+ (WebCore::WHLSL::AST::VariableDeclaration::semantic): >+ (WebCore::WHLSL::AST::VariableDeclaration::initializer): >+ * Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.h: >+ (WebCore::WHLSL::AST::VariableDeclarationsStatement::variableDeclarations): >+ * Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h: >+ * Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h: >+ (WebCore::WHLSL::AST::WhileLoop::conditional): >+ (WebCore::WHLSL::AST::WhileLoop::body): >+ * Modules/webgpu/WHLSL/WHLSLNameResolver.cpp: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h. >+ (WebCore::WHLSL::resolveNamesInTypes): >+ * Modules/webgpu/WHLSL/WHLSLNameResolver.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h. >+ * Modules/webgpu/WHLSL/WHLSLParser.cpp: >+ (WebCore::WHLSL::Parser::parseTypeArgument): >+ (WebCore::WHLSL::Parser::parseEnumerationDefinition): >+ (WebCore::WHLSL::Parser::parseBlockBody): >+ * Modules/webgpu/WHLSL/WHLSLPrepare.cpp: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBreak.h. >+ (WebCore::WHLSL::prepare): >+ * Modules/webgpu/WHLSL/WHLSLPrepare.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h. >+ * Modules/webgpu/WHLSL/WHLSLProgram.h: >+ (WebCore::WHLSL::Program::typeDefinitions): >+ (WebCore::WHLSL::Program::structureDefinitions): >+ (WebCore::WHLSL::Program::enumerationDefinitions): >+ (WebCore::WHLSL::Program::functionDefinitions): >+ (WebCore::WHLSL::Program::nativeFunctionDeclarations): >+ (WebCore::WHLSL::Program::nativeTypeDeclarations): >+ * Modules/webgpu/WHLSL/WHLSLVisitor.h: Added. >+ (WebCore::WHLSL::Visitor::visit): >+ (WebCore::WHLSL::Visitor::visitType): >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ > 2018-12-21 Myles C. Maxfield <mmaxfield@apple.com> > > [WHLSL] Include the standard library >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h >index 0bd1b365f18..2d567f00e70 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.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/WHLSLArrayType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h >index 0dda2848af4..40b5f8df6fe 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.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/WHLSLAssignmentExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h >index 1e634cca7bf..eaa694f5985 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.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/WHLSLBlock.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBlock.h >index cc1726a31a0..c4d129fede3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBlock.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBlock.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/WHLSLBooleanLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.h >index ae90881bd77..200f364932b 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.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/WHLSLBreak.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBreak.h >index dc92521ae58..7475cc3f6fb 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBreak.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBreak.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/WHLSLCallExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h >index e1ba8563b41..64af713299c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.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/WHLSLCommaExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.h >index 6c7dc70ba20..b8d2ba38dbc 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.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/WHLSLConstantExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >index 8ca8b369d6a..a38b0d5b3a1 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h >@@ -44,87 +44,52 @@ namespace AST { > // FIXME: macOS Sierra doesn't seem to support putting Variants inside Variants, > // so this is a wrapper class to make sure that doesn't happen. As soon as we don't > // have to support Sierra, this can be migrated to a Variant proper. >-class ConstantExpression : public Variant< >- IntegerLiteral, >- UnsignedIntegerLiteral, >- FloatLiteral, >- NullLiteral, >- BooleanLiteral, >- ConstantExpressionEnumerationMemberReference >- > { >+class ConstantExpression { > public: > ConstantExpression(IntegerLiteral&& integerLiteral) >- : Variant< >- IntegerLiteral, >- UnsignedIntegerLiteral, >- FloatLiteral, >- NullLiteral, >- BooleanLiteral, >- ConstantExpressionEnumerationMemberReference >- >(WTFMove(integerLiteral)) >+ : m_variant(WTFMove(integerLiteral)) > { > } > > ConstantExpression(UnsignedIntegerLiteral&& unsignedIntegerLiteral) >- : Variant< >- IntegerLiteral, >- UnsignedIntegerLiteral, >- FloatLiteral, >- NullLiteral, >- BooleanLiteral, >- ConstantExpressionEnumerationMemberReference >- >(WTFMove(unsignedIntegerLiteral)) >+ : m_variant(WTFMove(unsignedIntegerLiteral)) > { > } > > ConstantExpression(FloatLiteral&& floatLiteral) >- : Variant< >- IntegerLiteral, >- UnsignedIntegerLiteral, >- FloatLiteral, >- NullLiteral, >- BooleanLiteral, >- ConstantExpressionEnumerationMemberReference >- >(WTFMove(floatLiteral)) >+ : m_variant(WTFMove(floatLiteral)) > { > } > > ConstantExpression(NullLiteral&& nullLiteral) >- : Variant< >- IntegerLiteral, >- UnsignedIntegerLiteral, >- FloatLiteral, >- NullLiteral, >- BooleanLiteral, >- ConstantExpressionEnumerationMemberReference >- >(WTFMove(nullLiteral)) >+ : m_variant(WTFMove(nullLiteral)) > { > } > > ConstantExpression(BooleanLiteral&& booleanLiteral) >- : Variant< >- IntegerLiteral, >- UnsignedIntegerLiteral, >- FloatLiteral, >- NullLiteral, >- BooleanLiteral, >- ConstantExpressionEnumerationMemberReference >- >(WTFMove(booleanLiteral)) >+ : m_variant(WTFMove(booleanLiteral)) > { > } > > ConstantExpression(ConstantExpressionEnumerationMemberReference&& constantExpressionEnumerationMemberReference) >- : Variant< >+ : m_variant(WTFMove(constantExpressionEnumerationMemberReference)) >+ { >+ } >+ >+ template<typename T> void visit(T&& t) >+ { >+ WTF::visit(WTFMove(t), m_variant); >+ } >+ >+private: >+ Variant< > IntegerLiteral, > UnsignedIntegerLiteral, > FloatLiteral, > NullLiteral, > BooleanLiteral, > ConstantExpressionEnumerationMemberReference >- >(WTFMove(constantExpressionEnumerationMemberReference)) >- { >- } >- >+ > m_variant; > }; > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLContinue.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLContinue.h >index e295a5a7787..3b06ec59d22 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLContinue.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLContinue.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/WHLSLDereferenceExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h >index 982433ba259..6c55de34a7f 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.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/WHLSLDoWhileLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h >index 6023d8dc7af..d26edf922ce 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.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/WHLSLEffectfulExpressionStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h >index 24d07512c38..d9ca99ad8e0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.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/WHLSLEnumerationDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h >index 9a670cebea0..7970b59e54a 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.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/WHLSLEnumerationMember.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h >index c8343ab4adb..9d9d854883e 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h >@@ -31,6 +31,7 @@ > #include "WHLSLLexer.h" > #include "WHLSLNode.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; > >+ Optional<ConstantExpression>& value() { return m_value; } >+ > private: > Lexer::Token m_origin; > String m_name; > Optional<ConstantExpression> m_value; > }; > >+typedef Vector<EnumerationMember> EnumerationMembers; >+ > } > > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h >index 8e314cf2082..e368383646d 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.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/WHLSLFallthrough.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFallthrough.h >index 1fc74d8f8d9..099157d4e6d 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFallthrough.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFallthrough.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/WHLSLFloatLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.h >index abf1dfb076c..cbf5469dbfa 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.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/WHLSLForLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLForLoop.h >index 1abde9c58e0..28fc1376dac 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLForLoop.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLForLoop.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/WHLSLFunctionDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h >index e6060aaa840..7a7e0a0656c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.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; } >+ 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); } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h >index 05f0b1f081a..a4907b0d298 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.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/WHLSLIfStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h >index 94b08b1a2af..1ef10e2e71d 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIfStatement.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/WHLSLIntegerLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.h >index acd25346c43..6854dd27f0c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.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/WHLSLLogicalExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h >index bfb0475d7b2..d996fa5f5d4 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.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/WHLSLLogicalNotExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h >index 993344f3b0d..2d4f0cb8619 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.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/WHLSLMakeArrayReferenceExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h >index 0b9ac24d249..9ab79983eff 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.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/WHLSLMakePointerExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h >index 146fe203bbb..2a6b8510e31 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.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/WHLSLNativeTypeDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >index 7adfe2ffbb7..320abc3c475 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.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/WHLSLNullLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.h >index 905f2b3fb7c..ee647cf9d39 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.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/WHLSLParameter.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLParameter.h >index aad7167b1cb..92586f8691f 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLParameter.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLParameter.h >@@ -57,6 +57,9 @@ public: > Parameter(const Parameter&) = delete; > Parameter(Parameter&&) = default; > >+ Type& type() { return *m_type; } >+ Optional<AST::Semantic>& semantic() { return m_semantic; } >+ > private: > Lexer::Token m_origin; > Qualifiers m_qualifiers; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h >index bf5fcbab83b..1529426a2ed 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.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/WHLSLPropertyAccessExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h >index 08d257e41ec..ba38a5c01ea 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.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/WHLSLReadModifyWriteExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h >index 9b27ee15686..a4c14ce1cf3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.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/WHLSLReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h >index f7b8857adf9..2257f9be240 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.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/WHLSLReturn.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h >index f4548edb60f..c5bfc9e4286 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.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/WHLSLStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h >index 2b9786e51a4..434d21a0432 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.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/WHLSLStructureDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h >index 5f657d5b092..87cc62f2356 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.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/WHLSLStructureElement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h >index 7893d59bc17..14be41c7298 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h >@@ -55,6 +55,9 @@ public: > StructureElement(const StructureElement&) = delete; > StructureElement(StructureElement&&) = default; > >+ Type& type() { return *m_type; } >+ Optional<Semantic>& semantic() { return m_semantic; } >+ > private: > Lexer::Token m_origin; > Qualifiers m_qualifiers; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h >index 93cefc72e00..19905bd1789 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h >@@ -52,6 +52,11 @@ public: > > SwitchCase(const SwitchCase&) = delete; > SwitchCase(SwitchCase&&) = default; >+ >+ bool isSwitchCase() const override { return true; } >+ >+ Optional<ConstantExpression>& value() { return m_value; } >+ Block& block() { return m_block; } > > private: > 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/WHLSLSwitchStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h >index e214d78c5d6..46e676550dc 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.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/WHLSLTernaryExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h >index defcf622e8e..904cc4c489c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.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/WHLSLTrap.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTrap.h >index 6ad009b9362..dba2f12f817 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTrap.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTrap.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/WHLSLType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h >index 12135e6a734..cf4cbc88790 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h >@@ -28,6 +28,7 @@ > #if ENABLE(WEBGPU) > > #include "WHLSLNode.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/WHLSLTypeArgument.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp >new file mode 100644 >index 00000000000..7e5801e3b56 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.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/WHLSLTypeArgument.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h >index 1591ae9772f..e385d50d5ef 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.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/WHLSLTypeDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h >index aa48b029462..f73629e29b1 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.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/WHLSLTypeReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h >index 7f484df7ca8..49441d8b5c7 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.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/WHLSLUnsignedIntegerLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.h >index 89b3003e8c6..58d6e23075e 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.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/WHLSLVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >index 69f88c72c95..ff0368193bd 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h >@@ -61,6 +61,10 @@ public: > > Lexer::Token origin() const { return m_origin; } > >+ Type& type() { return *m_type; } >+ 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/WHLSLVariableDeclarationsStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.h >index 018bfc99ccb..f8dafc251fb 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.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/WHLSLVariableReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h >index 8231a403af0..2ae828d5295 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.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/WHLSLWhileLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h >index 795dfdd6b7f..1d4ae759779 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.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 bbc9e160e48..bc6e73e6a1f 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp >@@ -383,7 +383,7 @@ auto Parser::parseTypeArgument() -> Expected<AST::TypeArgument, Error> { > auto result = consumeType(Lexer::Token::Type::Identifier); > if (!result) > return Unexpected<Error>(result.error()); >- return AST::TypeArgument(result->stringView.toString()); >+ return AST::TypeArgument(std::make_unique<AST::TypeReference>(Lexer::Token(*result), result->stringView.toString(), AST::TypeArguments())); > } > > auto Parser::parseTypeArguments() -> Expected<AST::TypeArguments, Error> { >@@ -863,7 +863,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)) { >@@ -1219,7 +1219,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..0eb64decd4d >--- /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 { >+ >+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 WTF::nullopt; >+ success = static_cast<bool>(parser.parse(program, source, WHLSL::Parser::Mode::User)); >+ if (!success) >+ return WTF::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..094926724f6 >--- /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. >+}; >+ >+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 9e60b276748..5630fe69ee4 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..516856e41d0 >--- /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 "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&) >+ { >+ } >+ >+ 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 531867a5db2..3c0e3647054 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -305,6 +305,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/WHLSLTypeArgument.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 4e11328b1a0..07c16ef1775 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -13299,6 +13299,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 /* 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>"; }; >@@ -25326,6 +25332,11 @@ > C21BF73721CD8A0200227979 /* WHLSLParser.cpp */, > C21BF73821CD8A0300227979 /* WHLSLParser.h */, > C21BF73A21CD8D7000227979 /* WHLSLProgram.h */, >+ C288C72721C8C6EF002DF5CA /* WHLSLVisitor.h */, >+ C288C72921C8CA50002DF5CA /* WHLSLPrepare.cpp */, >+ C288C72A21C8CA50002DF5CA /* WHLSLPrepare.h */, >+ C288C72B21C8CCC2002DF5CA /* WHLSLNameResolver.cpp */, >+ C288C72C21C8CCC2002DF5CA /* WHLSLNameResolver.h */, > ); > path = WHLSL; > sourceTree = "<group>"; >@@ -25401,6 +25412,7 @@ > C21BF71421CD89D300227979 /* WHLSLVariableDeclarationsStatement.h */, > C21BF71321CD89D200227979 /* WHLSLVariableReference.h */, > C21BF70421CD89C600227979 /* WHLSLWhileLoop.h */, >+ C288C72D21C991DA002DF5CA /* WHLSLTypeArgument.cpp */, > ); > 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 192826
:
357603
|
357930
|
358011
|
358882
|
358911