[WHLSL] Assorted cleanup
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jan 2019 19:21:50 +0000 (19:21 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jan 2019 19:21:50 +0000 (19:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193389

Reviewed by Dean Jackson.

This is a bunch of non-behavior-changing cleanup.

- The compiler uses UniqueRef all over the place, and UniqueRef has an implicit operator T&. Therefore,
  we don't need to static_cast<T&> everywhere.
- ConstantExpressionEnumerationMemberReference is the exact same thing as EnumerationMemberLiteral, so
  this patch deletes the longer-named class in favor of the shorter-named class.
- Because of the header dependency tree, this patch moves EntryPointType into its own file so it can be
  used by files that FunctionDeclaration depends on. Same thing for AddressSpace.
- EnumTypes have to have non-null base types. The parser will make sure this is always true.

No new tests because there is no behavior change.

* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h.
* Modules/webgpu/WHLSL/AST/WHLSLArrayType.h:
(WebCore::WHLSL::AST::ArrayType::type const):
(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/WHLSLBaseSemantic.h:
* Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp:
(WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.h:
* Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h:
(WebCore::WHLSL::AST::ConstantExpression::ConstantExpression):
(WebCore::WHLSL::AST::ConstantExpression::clone const):
(WebCore::WHLSL::AST::ConstantExpression::matches const):
* Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h: Removed.
* 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/WHLSLEntryPointType.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h.
* Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h:
(WebCore::WHLSL::AST::EnumerationDefinition::EnumerationDefinition):
(WebCore::WHLSL::AST::EnumerationDefinition::type):
* Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h:
(WebCore::WHLSL::AST::EnumerationMemberLiteral::EnumerationMemberLiteral):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::wrap):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::left const):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::right const):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::clone const):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationDefinition):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationDefinition const):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationMember):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationMember const):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::setEnumerationMember):
* Modules/webgpu/WHLSL/AST/WHLSLExpression.h:
(WebCore::WHLSL::AST::Expression::type):
(WebCore::WHLSL::AST::Expression::setType):
(WebCore::WHLSL::AST::Expression::addressSpace const):
(WebCore::WHLSL::AST::Expression::setAddressSpace):
* Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp:
(WebCore::WHLSL::AST::FloatLiteralType::conversionCost const):
* Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.h:
(WebCore::WHLSL::AST::FloatLiteralType::preferredType):
* Modules/webgpu/WHLSL/AST/WHLSLForLoop.h:
(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::type const):
(WebCore::WHLSL::AST::FunctionDeclaration::type):
* 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/WHLSLIndexExpression.h:
(WebCore::WHLSL::AST::IndexExpression::indexExpression):
* Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp:
(WebCore::WHLSL::AST::IntegerLiteralType::conversionCost const):
* Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.h:
(WebCore::WHLSL::AST::IntegerLiteralType::preferredType):
* 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/WHLSLPropertyAccessExpression.h:
(WebCore::WHLSL::AST::PropertyAccessExpression::base):
* Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h:
(WebCore::WHLSL::AST::ReadModifyWriteExpression::lValue):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::newValueExpression):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::resultExpression):
* Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h:
(WebCore::WHLSL::AST::ReferenceType::elementType const):
(WebCore::WHLSL::AST::ReferenceType::elementType):
* Modules/webgpu/WHLSL/AST/WHLSLResolvableType.h:
(WebCore::WHLSL::AST::ResolvableType::resolvedType const):
(WebCore::WHLSL::AST::ResolvableType::resolvedType):
* Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp:
(WebCore::WHLSL::AST::ResourceSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::ResourceSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.h:
* Modules/webgpu/WHLSL/AST/WHLSLReturn.h:
(WebCore::WHLSL::AST::Return::value):
* Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp:
(WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.h:
* Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp:
(WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.h:
* Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h:
(WebCore::WHLSL::AST::StructureElement::type):
* Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h:
(WebCore::WHLSL::AST::SwitchStatement::value):
* 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/WHLSLTypeDefinition.h:
(WebCore::WHLSL::AST::TypeDefinition::type):
* Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp:
(WebCore::WHLSL::AST::UnsignedIntegerLiteralType::conversionCost const):
* Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.h:
(WebCore::WHLSL::AST::UnsignedIntegerLiteralType::preferredType):
* Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h:
(WebCore::WHLSL::AST::VariableDeclaration::type):
(WebCore::WHLSL::AST::VariableDeclaration::initializer):
(WebCore::WHLSL::AST::VariableDeclaration::isAnonymous const):
* Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h:
(WebCore::WHLSL::AST::WhileLoop::conditional):
(WebCore::WHLSL::AST::WhileLoop::body):
* Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp:
(WebCore::WHLSL::checkDuplicateFunctions):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::commit):
(WebCore::WHLSL::inferTypesForTypeArguments):
(WebCore::WHLSL::inferTypesForCall):
* Modules/webgpu/WHLSL/WHLSLNameResolver.cpp:
(WebCore::WHLSL::NameResolver::visit):
(WebCore::WHLSL::resolveNamesInTypes):
(WebCore::WHLSL::resolveNamesInFunctions):
* Modules/webgpu/WHLSL/WHLSLNameResolver.h:
* Modules/webgpu/WHLSL/WHLSLParser.h:
* Modules/webgpu/WHLSL/WHLSLProgram.h:
(WebCore::WHLSL::Program::append):
* Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp:
(WebCore::WHLSL::synthesizeEnumerationFunctions):
* Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp:
(WebCore::WHLSL::synthesizeStructureAccessors):
* Modules/webgpu/WHLSL/WHLSLVisitor.cpp:
(WebCore::WHLSL::Visitor::visit):
* Modules/webgpu/WHLSL/WHLSLVisitor.h:
* WebCore.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239930 268f45cc-cd09-0410-ab3c-d52691b4dbfc

58 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h [deleted file]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEntryPointType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLForLoop.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResolvableType.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h
Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLInferTypes.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h
Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h
Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h
Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj

index 2870e6b..4946813 100644 (file)
@@ -1,3 +1,163 @@
+2019-01-14  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [WHLSL] Assorted cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=193389
+
+        Reviewed by Dean Jackson.
+
+        This is a bunch of non-behavior-changing cleanup.
+
+        - The compiler uses UniqueRef all over the place, and UniqueRef has an implicit operator T&. Therefore,
+          we don't need to static_cast<T&> everywhere.
+        - ConstantExpressionEnumerationMemberReference is the exact same thing as EnumerationMemberLiteral, so
+          this patch deletes the longer-named class in favor of the shorter-named class.
+        - Because of the header dependency tree, this patch moves EntryPointType into its own file so it can be
+          used by files that FunctionDeclaration depends on. Same thing for AddressSpace.
+        - EnumTypes have to have non-null base types. The parser will make sure this is always true.
+
+        No new tests because there is no behavior change.
+
+        * Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h.
+        * Modules/webgpu/WHLSL/AST/WHLSLArrayType.h:
+        (WebCore::WHLSL::AST::ArrayType::type const):
+        (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/WHLSLBaseSemantic.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp:
+        (WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h:
+        (WebCore::WHLSL::AST::ConstantExpression::ConstantExpression):
+        (WebCore::WHLSL::AST::ConstantExpression::clone const):
+        (WebCore::WHLSL::AST::ConstantExpression::matches const):
+        * Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h: Removed.
+        * 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/WHLSLEntryPointType.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h.
+        * Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h:
+        (WebCore::WHLSL::AST::EnumerationDefinition::EnumerationDefinition):
+        (WebCore::WHLSL::AST::EnumerationDefinition::type):
+        * Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h:
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::EnumerationMemberLiteral):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::wrap):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::left const):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::right const):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::clone const):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationDefinition):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationDefinition const):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationMember):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationMember const):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::setEnumerationMember):
+        * Modules/webgpu/WHLSL/AST/WHLSLExpression.h:
+        (WebCore::WHLSL::AST::Expression::type):
+        (WebCore::WHLSL::AST::Expression::setType):
+        (WebCore::WHLSL::AST::Expression::addressSpace const):
+        (WebCore::WHLSL::AST::Expression::setAddressSpace):
+        * Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp:
+        (WebCore::WHLSL::AST::FloatLiteralType::conversionCost const):
+        * Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.h:
+        (WebCore::WHLSL::AST::FloatLiteralType::preferredType):
+        * Modules/webgpu/WHLSL/AST/WHLSLForLoop.h:
+        (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::type const):
+        (WebCore::WHLSL::AST::FunctionDeclaration::type):
+        * 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/WHLSLIndexExpression.h:
+        (WebCore::WHLSL::AST::IndexExpression::indexExpression):
+        * Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp:
+        (WebCore::WHLSL::AST::IntegerLiteralType::conversionCost const):
+        * Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.h:
+        (WebCore::WHLSL::AST::IntegerLiteralType::preferredType):
+        * 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/WHLSLPropertyAccessExpression.h:
+        (WebCore::WHLSL::AST::PropertyAccessExpression::base):
+        * Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h:
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::lValue):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::newValueExpression):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::resultExpression):
+        * Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h:
+        (WebCore::WHLSL::AST::ReferenceType::elementType const):
+        (WebCore::WHLSL::AST::ReferenceType::elementType):
+        * Modules/webgpu/WHLSL/AST/WHLSLResolvableType.h:
+        (WebCore::WHLSL::AST::ResolvableType::resolvedType const):
+        (WebCore::WHLSL::AST::ResolvableType::resolvedType):
+        * Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp:
+        (WebCore::WHLSL::AST::ResourceSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::ResourceSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLReturn.h:
+        (WebCore::WHLSL::AST::Return::value):
+        * Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp:
+        (WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp:
+        (WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h:
+        (WebCore::WHLSL::AST::StructureElement::type):
+        * Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h:
+        (WebCore::WHLSL::AST::SwitchStatement::value):
+        * 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/WHLSLTypeDefinition.h:
+        (WebCore::WHLSL::AST::TypeDefinition::type):
+        * Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp:
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteralType::conversionCost const):
+        * Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.h:
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteralType::preferredType):
+        * Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h:
+        (WebCore::WHLSL::AST::VariableDeclaration::type):
+        (WebCore::WHLSL::AST::VariableDeclaration::initializer):
+        (WebCore::WHLSL::AST::VariableDeclaration::isAnonymous const):
+        * Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h:
+        (WebCore::WHLSL::AST::WhileLoop::conditional):
+        (WebCore::WHLSL::AST::WhileLoop::body):
+        * Modules/webgpu/WHLSL/WHLSLCheckDuplicateFunctions.cpp:
+        (WebCore::WHLSL::checkDuplicateFunctions):
+        * Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
+        (WebCore::WHLSL::commit):
+        (WebCore::WHLSL::inferTypesForTypeArguments):
+        (WebCore::WHLSL::inferTypesForCall):
+        * Modules/webgpu/WHLSL/WHLSLNameResolver.cpp:
+        (WebCore::WHLSL::NameResolver::visit):
+        (WebCore::WHLSL::resolveNamesInTypes):
+        (WebCore::WHLSL::resolveNamesInFunctions):
+        * Modules/webgpu/WHLSL/WHLSLNameResolver.h:
+        * Modules/webgpu/WHLSL/WHLSLParser.h:
+        * Modules/webgpu/WHLSL/WHLSLProgram.h:
+        (WebCore::WHLSL::Program::append):
+        * Modules/webgpu/WHLSL/WHLSLSynthesizeEnumerationFunctions.cpp:
+        (WebCore::WHLSL::synthesizeEnumerationFunctions):
+        * Modules/webgpu/WHLSL/WHLSLSynthesizeStructureAccessors.cpp:
+        (WebCore::WHLSL::synthesizeStructureAccessors):
+        * Modules/webgpu/WHLSL/WHLSLVisitor.cpp:
+        (WebCore::WHLSL::Visitor::visit):
+        * Modules/webgpu/WHLSL/WHLSLVisitor.h:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2019-01-14  Zan Dobersek  <zdobersek@igalia.com>
 
         DOMCacheStorage: use-after-move in doSequentialMatch()
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h
new file mode 100644 (file)
index 0000000..4a6d7c4
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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 <cstdint>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+enum class AddressSpace : uint8_t {
+    Constant,
+    Device,
+    Threadgroup,
+    Thread
+};
+
+}
+
+}
+
+}
+
+#endif
index 89794b8..a3ff645 100644 (file)
@@ -55,8 +55,8 @@ public:
 
     bool isArrayType() const override { return true; }
 
-    const UnnamedType& type() const { return static_cast<const UnnamedType&>(m_elementType); }
-    UnnamedType& type() { return static_cast<UnnamedType&>(m_elementType); }
+    const UnnamedType& type() const { return m_elementType; }
+    UnnamedType& type() { return m_elementType; }
     unsigned numElements() const { return m_numElements; }
 
     UniqueRef<UnnamedType> clone() const override
index 79eb1ae..b121fb6 100644 (file)
@@ -53,8 +53,8 @@ public:
 
     bool isAssignmentExpression() const override { return true; }
 
-    Expression& left() { return static_cast<Expression&>(m_left); }
-    Expression& right() { return static_cast<Expression&>(m_right); }
+    Expression& left() { return m_left; }
+    Expression& right() { return m_right; }
 
 private:
     UniqueRef<Expression> m_left;
index fe99da2..dd2a665 100644 (file)
 
 #if ENABLE(WEBGPU)
 
+#include "WHLSLEntryPointType.h"
 #include "WHLSLLexer.h"
 #include "WHLSLNode.h"
+#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -59,7 +61,7 @@ public:
         Input,
         Output
     };
-    virtual bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const = 0;
+    virtual bool isAcceptableForShaderItemDirection(ShaderItemDirection, const Optional<EntryPointType>&) const = 0;
 
 private:
     Lexer::Token m_origin;
index 414bd45..8e95e39 100644 (file)
@@ -73,10 +73,10 @@ bool BuiltInSemantic::isAcceptableType(const UnnamedType& unnamedType, const Int
     }
 }
 
-bool BuiltInSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const FunctionDefinition& functionDefinition) const
+bool BuiltInSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const Optional<EntryPointType>& entryPointType) const
 {
-    switch (*functionDefinition.entryPointType()) {
-    case FunctionDeclaration::EntryPointType::Vertex:
+    switch (*entryPointType) {
+    case EntryPointType::Vertex:
         switch (direction) {
         case ShaderItemDirection::Input:
             switch (m_variable) {
@@ -95,7 +95,7 @@ bool BuiltInSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection dir
                 return false;
             }
         }
-    case FunctionDeclaration::EntryPointType::Fragment:
+    case EntryPointType::Fragment:
         switch (direction) {
         case ShaderItemDirection::Input:
             switch (m_variable) {
@@ -117,7 +117,7 @@ bool BuiltInSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection dir
                 return false;
             }
         }
-    case FunctionDeclaration::EntryPointType::Compute:
+    case EntryPointType::Compute:
         switch (direction) {
         case ShaderItemDirection::Input:
             switch (m_variable) {
index ebde1d0..43b6986 100644 (file)
@@ -81,7 +81,7 @@ public:
     }
 
     bool isAcceptableType(const UnnamedType&, const Intrinsics&) const override;
-    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const override;
+    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const Optional<EntryPointType>&) const override;
 
 private:
     Variable m_variable;
index df68c2a..3d1ae1c 100644 (file)
@@ -28,7 +28,7 @@
 #if ENABLE(WEBGPU)
 
 #include "WHLSLBooleanLiteral.h"
-#include "WHLSLConstantExpressionEnumerationMemberReference.h"
+#include "WHLSLEnumerationMemberLiteral.h"
 #include "WHLSLFloatLiteral.h"
 #include "WHLSLIntegerLiteral.h"
 #include "WHLSLNullLiteral.h"
@@ -71,8 +71,8 @@ public:
     {
     }
 
-    ConstantExpression(ConstantExpressionEnumerationMemberReference&& constantExpressionEnumerationMemberReference)
-        : m_variant(WTFMove(constantExpressionEnumerationMemberReference))
+    ConstantExpression(EnumerationMemberLiteral&& enumerationMemberLiteral)
+        : m_variant(WTFMove(enumerationMemberLiteral))
     {
     }
 
@@ -110,8 +110,8 @@ public:
             return nullLiteral.clone();
         }, [&](const BooleanLiteral& booleanLiteral) -> ConstantExpression {
             return booleanLiteral.clone();
-        }, [&](const ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) -> ConstantExpression {
-            return constantExpressionEnumerationMemberReference.clone();
+        }, [&](const EnumerationMemberLiteral& enumerationMemberLiteral) -> ConstantExpression {
+            return enumerationMemberLiteral.clone();
         }), m_variant);
     }
 
@@ -133,10 +133,10 @@ public:
                 result = booleanLiteral.value() == otherBooleanLiteral.value();
             } else
                 result = false;
-        }, [&](const ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) {
-            if (WTF::holds_alternative<ConstantExpressionEnumerationMemberReference>(other.m_variant)) {
-                const auto& otherMemberReference = WTF::get<ConstantExpressionEnumerationMemberReference>(other.m_variant);
-                result = constantExpressionEnumerationMemberReference.enumerationMember() == otherMemberReference.enumerationMember();
+        }, [&](const EnumerationMemberLiteral& enumerationMemberLiteral) {
+            if (WTF::holds_alternative<EnumerationMemberLiteral>(other.m_variant)) {
+                const auto& otherMemberReference = WTF::get<EnumerationMemberLiteral>(other.m_variant);
+                result = enumerationMemberLiteral.enumerationMember() == otherMemberReference.enumerationMember();
             } else
                 result = false;
         }));
@@ -154,7 +154,7 @@ public:
             result = false;
         }, [&](const BooleanLiteral&) {
             result = false;
-        }, [&](const ConstantExpressionEnumerationMemberReference&) {
+        }, [&](const EnumerationMemberLiteral&) {
             result = false;
         }));
 
@@ -169,7 +169,7 @@ private:
         FloatLiteral,
         NullLiteral,
         BooleanLiteral,
-        ConstantExpressionEnumerationMemberReference
+        EnumerationMemberLiteral
         > m_variant;
 };
 
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h
deleted file mode 100644 (file)
index 5857d94..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(WEBGPU)
-
-#include "WHLSLLexer.h"
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-namespace WHLSL {
-
-namespace AST {
-
-class EnumerationDefinition;
-class EnumerationMember;
-
-class ConstantExpressionEnumerationMemberReference : public Expression {
-public:
-    ConstantExpressionEnumerationMemberReference(Lexer::Token&& origin, String&& left, String&& right)
-        : Expression(WTFMove(origin))
-        , m_left(WTFMove(left))
-        , m_right(WTFMove(right))
-    {
-    }
-
-    virtual ~ConstantExpressionEnumerationMemberReference() = default;
-
-    explicit ConstantExpressionEnumerationMemberReference(const ConstantExpressionEnumerationMemberReference&) = default;
-    ConstantExpressionEnumerationMemberReference(ConstantExpressionEnumerationMemberReference&&) = default;
-
-    ConstantExpressionEnumerationMemberReference& operator=(const ConstantExpressionEnumerationMemberReference&) = delete;
-    ConstantExpressionEnumerationMemberReference& operator=(ConstantExpressionEnumerationMemberReference&&) = default;
-
-    const String& left() const { return m_left; }
-    const String& right() const { return m_right; }
-
-    ConstantExpressionEnumerationMemberReference clone() const
-    {
-        auto result = ConstantExpressionEnumerationMemberReference(Lexer::Token(origin()), String(m_left), String(m_right));
-        result.m_enumerationMember = m_enumerationMember;
-        return result;
-    }
-
-    EnumerationDefinition* enumerationDefinition()
-    {
-        return m_enumerationDefinition;
-    }
-
-    EnumerationDefinition* enumerationDefinition() const
-    {
-        return m_enumerationDefinition;
-    }
-
-    EnumerationMember* enumerationMember()
-    {
-        return m_enumerationMember;
-    }
-
-    EnumerationMember* enumerationMember() const
-    {
-        return m_enumerationMember;
-    }
-
-    void setEnumerationMember(EnumerationDefinition& enumerationDefinition, EnumerationMember& enumerationMember)
-    {
-        m_enumerationDefinition = &enumerationDefinition;
-        m_enumerationMember = &enumerationMember;
-    }
-
-private:
-    String m_left;
-    String m_right;
-    EnumerationDefinition* m_enumerationDefinition { nullptr };
-    EnumerationMember* m_enumerationMember { nullptr };
-};
-
-} // namespace AST
-
-}
-
-}
-
-#endif
index 545912a..e12122e 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     bool isDereferenceExpression() const override { return true; }
 
-    Expression& pointer() { return static_cast<Expression&>(m_pointer); }
+    Expression& pointer() { return m_pointer; }
 
 private:
     UniqueRef<Expression> m_pointer;
index 0147837..1d921f6 100644 (file)
@@ -54,8 +54,8 @@ public:
 
     bool isDoWhileLoop() const override { return true; }
 
-    Statement& body() { return static_cast<Statement&>(m_body); }
-    Expression& conditional() { return static_cast<Expression&>(m_conditional); }
+    Statement& body() { return m_body; }
+    Expression& conditional() { return m_conditional; }
 
 private:
     UniqueRef<Statement> m_body;
index 54d083a..70aea4b 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     bool isEffectfulExpressionStatement() const override { return true; }
 
-    Expression& effectfulExpression() { return static_cast<Expression&>(m_effectfulExpression); }
+    Expression& effectfulExpression() { return m_effectfulExpression; }
 
 private:
     UniqueRef<Expression> m_effectfulExpression;
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEntryPointType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEntryPointType.h
new file mode 100644 (file)
index 0000000..e288770
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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 <cstdint>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+enum class EntryPointType : uint8_t {
+    Vertex,
+    Fragment,
+    Compute,
+    // FIXME: Add an entry point type for testing
+};
+
+}
+
+}
+
+}
+
+#endif
index 55089a1..0bcea95 100644 (file)
@@ -46,7 +46,7 @@ namespace AST {
 
 class EnumerationDefinition : public NamedType {
 public:
-    EnumerationDefinition(Lexer::Token&& origin, String&& name, Optional<UniqueRef<UnnamedType>>&& type)
+    EnumerationDefinition(Lexer::Token&& origin, String&& name, UniqueRef<UnnamedType>&& type)
         : NamedType(WTFMove(origin), WTFMove(name))
         , m_type(WTFMove(type))
     {
@@ -59,7 +59,7 @@ public:
 
     bool isEnumerationDefinition() const override { return true; }
 
-    UnnamedType* type() { return m_type ? &static_cast<UnnamedType&>(*m_type) : nullptr; }
+    UnnamedType& type() { return m_type; }
 
     bool add(EnumerationMember&& member)
     {
@@ -84,7 +84,7 @@ public:
     }
 
 private:
-    Optional<UniqueRef<UnnamedType>> m_type;
+    UniqueRef<UnnamedType> m_type;
     HashMap<String, std::unique_ptr<EnumerationMember>> m_members;
 };
 
index ba64303..ee745e5 100644 (file)
@@ -27,9 +27,8 @@
 
 #if ENABLE(WEBGPU)
 
-#include "WHLSLEnumerationMember.h"
-#include "WHLSLExpression.h"
 #include "WHLSLLexer.h"
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -37,25 +36,77 @@ namespace WHLSL {
 
 namespace AST {
 
+class EnumerationDefinition;
+class EnumerationMember;
+
 class EnumerationMemberLiteral : public Expression {
 public:
-    EnumerationMemberLiteral(Lexer::Token&& origin, EnumerationMember& enumerationMember)
+    EnumerationMemberLiteral(Lexer::Token&& origin, String&& left, String&& right)
         : Expression(WTFMove(origin))
-        , m_enumerationMember(enumerationMember)
+        , m_left(WTFMove(left))
+        , m_right(WTFMove(right))
     {
     }
 
     virtual ~EnumerationMemberLiteral() = default;
 
-    EnumerationMemberLiteral(const EnumerationMemberLiteral&) = delete;
+    explicit EnumerationMemberLiteral(const EnumerationMemberLiteral&) = default;
     EnumerationMemberLiteral(EnumerationMemberLiteral&&) = default;
 
+    EnumerationMemberLiteral& operator=(const EnumerationMemberLiteral&) = delete;
+    EnumerationMemberLiteral& operator=(EnumerationMemberLiteral&&) = default;
+
     bool isEnumerationMemberLiteral() const override { return true; }
 
-    EnumerationMember& enumerationMember() { return m_enumerationMember; }
+    static EnumerationMemberLiteral wrap(Lexer::Token&& origin, String&& left, String&& right, EnumerationDefinition& enumerationDefinition, EnumerationMember& enumerationMember)
+    {
+        EnumerationMemberLiteral result(WTFMove(origin), WTFMove(left), WTFMove(right));
+        result.m_enumerationDefinition = &enumerationDefinition;
+        result.m_enumerationMember = &enumerationMember;
+        return result;
+    }
+
+    const String& left() const { return m_left; }
+    const String& right() const { return m_right; }
+
+    EnumerationMemberLiteral clone() const
+    {
+        auto result = EnumerationMemberLiteral(Lexer::Token(origin()), String(m_left), String(m_right));
+        result.m_enumerationMember = m_enumerationMember;
+        return result;
+    }
+
+    EnumerationDefinition* enumerationDefinition()
+    {
+        return m_enumerationDefinition;
+    }
+
+    EnumerationDefinition* enumerationDefinition() const
+    {
+        return m_enumerationDefinition;
+    }
+
+    EnumerationMember* enumerationMember()
+    {
+        return m_enumerationMember;
+    }
+
+    EnumerationMember* enumerationMember() const
+    {
+        return m_enumerationMember;
+    }
+
+    void setEnumerationMember(EnumerationDefinition& enumerationDefinition, EnumerationMember& enumerationMember)
+    {
+        m_enumerationDefinition = &enumerationDefinition;
+        m_enumerationMember = &enumerationMember;
+    }
 
 private:
-    EnumerationMember& m_enumerationMember;
+    String m_left;
+    String m_right;
+    EnumerationDefinition* m_enumerationDefinition { nullptr };
+    EnumerationMember* m_enumerationMember { nullptr };
 };
 
 } // namespace AST
index 741300d..583a62e 100644 (file)
 
 #if ENABLE(WEBGPU)
 
+#include "WHLSLAddressSpace.h"
 #include "WHLSLLexer.h"
+#include "WHLSLUnnamedType.h"
 #include "WHLSLValue.h"
+#include <wtf/Optional.h>
+#include <wtf/UniqueRef.h>
 
 namespace WebCore {
 
@@ -53,6 +57,22 @@ public:
 
     const Lexer::Token& origin() const { return m_origin; }
 
+    UnnamedType* type() { return m_type ? &*m_type : nullptr; }
+
+    void setType(UniqueRef<UnnamedType>&& type)
+    {
+        ASSERT(!m_type);
+        m_type = WTFMove(type);
+    }
+
+    const Optional<AddressSpace>& addressSpace() const { return m_addressSpace; }
+
+    void setAddressSpace(Optional<AddressSpace>& addressSpace)
+    {
+        ASSERT(!m_addressSpace);
+        m_addressSpace = addressSpace;
+    }
+
     virtual bool isAssignmentExpression() const { return false; }
     virtual bool isBooleanLiteral() const { return false; }
     virtual bool isCallExpression() const { return false; }
@@ -76,6 +96,8 @@ public:
 
 private:
     Lexer::Token m_origin;
+    Optional<UniqueRef<UnnamedType>> m_type;
+    Optional<AddressSpace> m_addressSpace;
 };
 
 } // namespace AST
index 81c9dde..0b67126 100644 (file)
@@ -67,7 +67,7 @@ bool FloatLiteralType::canResolve(const Type& type) const
 
 unsigned FloatLiteralType::conversionCost(const UnnamedType& unnamedType) const
 {
-    if (matches(unnamedType, static_cast<const TypeReference&>(m_preferredType)))
+    if (matches(unnamedType, m_preferredType))
         return 0;
     return 1;
 }
index 5680643..bc9f037 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     bool isFloatLiteralType() const override { return true; }
 
-    TypeReference& preferredType() { return static_cast<TypeReference&>(m_preferredType); }
+    TypeReference& preferredType() { return m_preferredType; }
 
     bool canResolve(const Type&) const override;
     unsigned conversionCost(const UnnamedType&) const override;
index 713edc9..3cdc418 100644 (file)
@@ -63,9 +63,9 @@ public:
     bool isForLoop() const override { return true; }
 
     Variant<VariableDeclarationsStatement, UniqueRef<Expression>>& initialization() { return m_initialization; }
-    Expression* condition() { return m_condition ? &static_cast<Expression&>(*m_condition) : nullptr; }
-    Expression* increment() { return m_increment ? &static_cast<Expression&>(*m_increment) : nullptr; }
-    Statement& body() { return static_cast<Statement&>(m_body); }
+    Expression* condition() { return m_condition ? &*m_condition : nullptr; }
+    Expression* increment() { return m_increment ? &*m_increment : nullptr; }
+    Statement& body() { return m_body; }
 
 private:
     Variant<VariableDeclarationsStatement, UniqueRef<Expression>> m_initialization;
index 190bbb8..5082858 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(WEBGPU)
 
+#include "WHLSLEntryPointType.h"
 #include "WHLSLFunctionAttribute.h"
 #include "WHLSLLexer.h"
 #include "WHLSLNode.h"
@@ -44,13 +45,6 @@ namespace AST {
 
 class FunctionDeclaration : public Node {
 public:
-    enum class EntryPointType : uint8_t {
-        Vertex,
-        Fragment,
-        Compute,
-        // FIXME: Add an entry point type for testing
-    };
-
     FunctionDeclaration(Lexer::Token&& origin, AttributeBlock&& attributeBlock, Optional<EntryPointType> entryPointType, UniqueRef<UnnamedType>&& type, String&& name, VariableDeclarations&& parameters, Optional<Semantic>&& semantic, bool isOperator)
         : m_origin(WTFMove(origin))
         , m_attributeBlock(WTFMove(attributeBlock))
@@ -73,8 +67,8 @@ public:
 
     AttributeBlock& attributeBlock() { return m_attributeBlock; }
     const Optional<EntryPointType>& entryPointType() const { return m_entryPointType; }
-    const UnnamedType& type() const { return static_cast<const UnnamedType&>(m_type); }
-    UnnamedType& type() { return static_cast<UnnamedType&>(m_type); }
+    const UnnamedType& type() const { return m_type; }
+    UnnamedType& type() { return m_type; }
     const String& name() const { return m_name; }
     bool isCast() const { return m_name == "operator cast"; }
     const VariableDeclarations& parameters() const { return m_parameters; }
index 9b7cf4b..bf6f656 100644 (file)
@@ -56,9 +56,9 @@ public:
 
     bool isIfStatement() const override { return true; }
 
-    Expression& conditional() { return static_cast<Expression&>(m_conditional); }
-    Statement& body() { return static_cast<Statement&>(m_body); }
-    Statement* elseBody() { return m_elseBody ? &static_cast<Statement&>(*m_elseBody) : nullptr; }
+    Expression& conditional() { return m_conditional; }
+    Statement& body() { return m_body; }
+    Statement* elseBody() { return m_elseBody ? &*m_elseBody : nullptr; }
 
 private:
     UniqueRef<Expression> m_conditional;
index 25ba6e7..347bcfe 100644 (file)
@@ -67,7 +67,7 @@ public:
         return "operator[]="_str;
     }
 
-    Expression& indexExpression() { return static_cast<Expression&>(m_index); }
+    Expression& indexExpression() { return m_index; }
 
 private:
     UniqueRef<Expression> m_index;
index e87acda..4fc6863 100644 (file)
@@ -68,7 +68,7 @@ bool IntegerLiteralType::canResolve(const Type& type) const
 
 unsigned IntegerLiteralType::conversionCost(const UnnamedType& unnamedType) const
 {
-    if (matches(unnamedType, static_cast<const TypeReference&>(m_preferredType)))
+    if (matches(unnamedType, m_preferredType))
         return 0;
     return 1;
 }
index 426f0fe..55617b6 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     bool isIntegerLiteralType() const override { return true; }
 
-    TypeReference& preferredType() { return static_cast<TypeReference&>(m_preferredType); }
+    TypeReference& preferredType() { return m_preferredType; }
 
     bool canResolve(const Type&) const override;
     unsigned conversionCost(const UnnamedType&) const override;
index ad35e88..fbfc935 100644 (file)
@@ -61,8 +61,8 @@ public:
 
     bool isLogicalExpression() const override { return true; }
 
-    Expression& left() { return static_cast<Expression&>(m_left); }
-    Expression& right() { return static_cast<Expression&>(m_right); }
+    Expression& left() { return m_left; }
+    Expression& right() { return m_right; }
 
 private:
     Type m_type;
index 1a972be..1497632 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     bool isLogicalNotExpression() const override { return true; }
 
-    Expression& operand() { return static_cast<Expression&>(m_operand); }
+    Expression& operand() { return m_operand; }
 
 private:
     UniqueRef<Expression> m_operand;
index bc01953..6316f54 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     bool isMakeArrayReferenceExpression() const override { return true; }
 
-    Expression& lValue() { return static_cast<Expression&>(m_lValue); }
+    Expression& lValue() { return m_lValue; }
 
 private:
     UniqueRef<Expression> m_lValue;
index 048a444..7b052b6 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     bool isMakePointerExpression() const override { return true; }
 
-    Expression& lValue() { return static_cast<Expression&>(m_lValue); }
+    Expression& lValue() { return m_lValue; }
 
 private:
     UniqueRef<Expression> m_lValue;
index e28755e..2ec34e1 100644 (file)
@@ -73,7 +73,7 @@ public:
         m_possibleAndOverloads = overloads;
     }
 
-    Expression& base() { return static_cast<Expression&>(m_base); }
+    Expression& base() { return m_base; }
 
 private:
     UniqueRef<Expression> m_base;
index f29b293..79d8d0f 100644 (file)
@@ -85,11 +85,11 @@ public:
 
     bool isReadModifyWriteExpression() const override { return true; }
 
-    Expression& lValue() { return static_cast<Expression&>(m_lValue); }
+    Expression& lValue() { return m_lValue; }
     VariableDeclaration& oldValue() { return m_oldValue; }
     VariableDeclaration& newValue() { return m_newValue; }
-    Expression* newValueExpression() { return m_newValueExpression ? &static_cast<Expression&>(*m_newValueExpression) : nullptr; }
-    Expression* resultExpression() { return m_resultExpression ? &static_cast<Expression&>(*m_resultExpression) : nullptr; }
+    Expression* newValueExpression() { return m_newValueExpression ? &*m_newValueExpression : nullptr; }
+    Expression* resultExpression() { return m_resultExpression ? &*m_resultExpression : nullptr; }
 
 private:
     template<class U, class... Args> friend UniqueRef<U> WTF::makeUniqueRef(Args&&...);
index 64c84bc..8811ac9 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(WEBGPU)
 
+#include "WHLSLAddressSpace.h"
 #include "WHLSLLexer.h"
 #include "WHLSLUnnamedType.h"
 #include <wtf/UniqueRef.h>
@@ -40,13 +41,6 @@ namespace AST {
 
 class ReferenceType : public UnnamedType {
 public:
-    enum class AddressSpace : uint8_t {
-        Constant,
-        Device,
-        Threadgroup,
-        Thread
-    };
-
     ReferenceType(Lexer::Token&& origin, AddressSpace addressSpace, UniqueRef<UnnamedType>&& elementType)
         : UnnamedType(WTFMove(origin))
         , m_addressSpace(addressSpace)
@@ -62,8 +56,8 @@ public:
     bool isReferenceType() const override { return false; }
 
     AddressSpace addressSpace() const { return m_addressSpace; }
-    const UnnamedType& elementType() const { return static_cast<const UnnamedType&>(m_elementType); }
-    UnnamedType& elementType() { return static_cast<UnnamedType&>(m_elementType); }
+    const UnnamedType& elementType() const { return m_elementType; }
+    UnnamedType& elementType() { return m_elementType; }
 
 private:
     AddressSpace m_addressSpace;
index cd71bd4..f01f866 100644 (file)
@@ -58,8 +58,8 @@ public:
     virtual bool canResolve(const Type&) const = 0;
     virtual unsigned conversionCost(const UnnamedType&) const = 0;
 
-    const UnnamedType* resolvedType() const { return m_resolvedType ? &static_cast<const UnnamedType&>(*m_resolvedType) : nullptr; }
-    UnnamedType* resolvedType() { return m_resolvedType ? &static_cast<UnnamedType&>(*m_resolvedType) : nullptr; }
+    const UnnamedType* resolvedType() const { return m_resolvedType ? &*m_resolvedType : nullptr; }
+    UnnamedType* resolvedType() { return m_resolvedType ? &*m_resolvedType : nullptr; }
 
     void resolve(UniqueRef<UnnamedType>&& type)
     {
index 8440960..be1a873 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(WEBGPU)
 
+#include "WHLSLAddressSpace.h"
 #include "WHLSLArrayType.h"
 #include "WHLSLInferTypes.h"
 #include "WHLSLIntrinsics.h"
@@ -46,7 +47,7 @@ bool ResourceSemantic::isAcceptableType(const UnnamedType& unnamedType, const In
     case Mode::UnorderedAccessView:
         if (is<ReferenceType>(unnamedType)) {
             auto& referenceType = downcast<ReferenceType>(unnamedType);
-            return referenceType.addressSpace() == ReferenceType::AddressSpace::Constant || referenceType.addressSpace() == ReferenceType::AddressSpace::Device;
+            return referenceType.addressSpace() == AddressSpace::Constant || referenceType.addressSpace() == AddressSpace::Device;
         }
         if (is<ArrayType>(unnamedType))
             return true;
@@ -59,7 +60,7 @@ bool ResourceSemantic::isAcceptableType(const UnnamedType& unnamedType, const In
         return false;
     case Mode::Texture:
         if (is<ReferenceType>(unnamedType))
-            return downcast<ReferenceType>(unnamedType).addressSpace() == ReferenceType::AddressSpace::Constant;
+            return downcast<ReferenceType>(unnamedType).addressSpace() == AddressSpace::Constant;
         if (is<ArrayType>(unnamedType))
             return true;
         if (is<TypeReference>(unnamedType)) {
@@ -71,14 +72,14 @@ bool ResourceSemantic::isAcceptableType(const UnnamedType& unnamedType, const In
         return false;
     case Mode::Buffer:
         if (is<ReferenceType>(unnamedType))
-            return downcast<ReferenceType>(unnamedType).addressSpace() == ReferenceType::AddressSpace::Constant;
+            return downcast<ReferenceType>(unnamedType).addressSpace() == AddressSpace::Constant;
         return is<ArrayType>(unnamedType);
     case Mode::Sampler:
         return matches(unnamedType, intrinsics.samplerType());
     }
 }
 
-bool ResourceSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const FunctionDefinition&) const
+bool ResourceSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const Optional<EntryPointType>&) const
 {
     return direction == ShaderItemDirection::Input;
 }
index 4b02be0..e7ca064 100644 (file)
@@ -73,7 +73,7 @@ public:
     }
 
     bool isAcceptableType(const UnnamedType&, const Intrinsics&) const override;
-    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const override;
+    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const Optional<EntryPointType>&) const override;
 
 private:
     Mode m_mode;
index 77eb246..f9d209d 100644 (file)
@@ -54,7 +54,7 @@ public:
 
     bool isReturn() const override { return true; }
 
-    Expression* value() { return m_value ? &static_cast<Expression&>(*m_value) : nullptr; }
+    Expression* value() { return m_value ? &*m_value : nullptr; }
 
     FunctionDefinition* function() { return m_function; }
     void setFunction(FunctionDefinition* functionDefinition) { m_function = functionDefinition; }
index 421c793..7b47809 100644 (file)
@@ -48,7 +48,7 @@ bool SpecializationConstantSemantic::isAcceptableType(const UnnamedType& unnamed
     return downcast<NativeTypeDeclaration>(*typeReference.resolvedType()).isNumber();
 }
 
-bool SpecializationConstantSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const FunctionDefinition&) const
+bool SpecializationConstantSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const Optional<EntryPointType>&) const
 {
     return direction == ShaderItemDirection::Input;
 }
index d62abbc..656315a 100644 (file)
@@ -59,7 +59,7 @@ public:
     }
 
     bool isAcceptableType(const UnnamedType&, const Intrinsics&) const override;
-    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const override;
+    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const Optional<EntryPointType>&) const override;
 
 private:
 };
index 22572c8..bca315a 100644 (file)
@@ -59,14 +59,14 @@ bool StageInOutSemantic::isAcceptableType(const UnnamedType& unnamedType, const
         || nativeTypeDeclaration.isMatrix();
 }
 
-bool StageInOutSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const FunctionDefinition& functionDefinition) const
+bool StageInOutSemantic::isAcceptableForShaderItemDirection(ShaderItemDirection direction, const Optional<EntryPointType>& entryPointType) const
 {
-    switch (*functionDefinition.entryPointType()) {
-    case FunctionDeclaration::EntryPointType::Vertex:
+    switch (*entryPointType) {
+    case EntryPointType::Vertex:
         return true;
-    case FunctionDeclaration::EntryPointType::Fragment:
+    case EntryPointType::Fragment:
         return direction == ShaderItemDirection::Input;
-    case FunctionDeclaration::EntryPointType::Compute:
+    case EntryPointType::Compute:
         return false;
     }
 }
index 4ae8532..61764c9 100644 (file)
@@ -62,7 +62,7 @@ public:
     }
 
     bool isAcceptableType(const UnnamedType&, const Intrinsics&) const override;
-    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const override;
+    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const Optional<EntryPointType>&) const override;
 
 private:
     unsigned m_index;
index 4cd64e2..8472f5c 100644 (file)
@@ -57,7 +57,7 @@ public:
     StructureElement(StructureElement&&) = default;
 
     const Lexer::Token& origin() const { return m_origin; }
-    UnnamedType& type() { return static_cast<UnnamedType&>(m_type); }
+    UnnamedType& type() { return m_type; }
     const String& name() { return m_name; }
     Optional<Semantic>& semantic() { return m_semantic; }
 
index 6b19d70..7c160ba 100644 (file)
@@ -55,7 +55,7 @@ public:
 
     bool isSwitchStatement() const override { return true; }
 
-    Expression& value() { return static_cast<Expression&>(m_value); }
+    Expression& value() { return m_value; }
     Vector<SwitchCase>& switchCases() { return m_switchCases; }
 
 private:
index b41d12b..fe5614d 100644 (file)
@@ -54,9 +54,9 @@ public:
 
     bool isTernaryExpression() const override { return true; }
 
-    Expression& predicate() { return static_cast<Expression&>(m_predicate); }
-    Expression& bodyExpression() { return static_cast<Expression&>(m_bodyExpression); }
-    Expression& elseExpression() { return static_cast<Expression&>(m_elseExpression); }
+    Expression& predicate() { return m_predicate; }
+    Expression& bodyExpression() { return m_bodyExpression; }
+    Expression& elseExpression() { return m_elseExpression; }
 
 private:
     UniqueRef<Expression> m_predicate;
index 2e3ff36..ad87a00 100644 (file)
@@ -55,7 +55,7 @@ public:
 
     bool isTypeDefinition() const override { return true; }
 
-    UnnamedType& type() { return static_cast<UnnamedType&>(m_type); }
+    UnnamedType& type() { return m_type; }
 
     const Type& unifyNode() const override
     {
index 01f3197..7fdf8cb 100644 (file)
@@ -71,7 +71,7 @@ bool UnsignedIntegerLiteralType::canResolve(const Type& type) const
 
 unsigned UnsignedIntegerLiteralType::conversionCost(const UnnamedType& unnamedType) const
 {
-    if (matches(unnamedType, static_cast<const TypeReference&>(m_preferredType)))
+    if (matches(unnamedType, m_preferredType))
         return 0;
     return 1;
 }
index 362efa9..95fbff6 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     bool isUnsignedIntegerLiteralType() const override { return true; }
 
-    TypeReference& preferredType() { return static_cast<TypeReference&>(m_preferredType); }
+    TypeReference& preferredType() { return m_preferredType; }
 
     bool canResolve(const Type&) const override;
     unsigned conversionCost(const UnnamedType&) const override;
index b449460..19824f9 100644 (file)
@@ -65,9 +65,10 @@ public:
     String& name() { return m_name; }
 
     const Optional<UniqueRef<UnnamedType>>& type() const { return m_type; } // Anonymous variables inside ReadModifyWriteExpressions have their type set by the type checker.
-    UnnamedType* type() { return m_type ? &static_cast<UnnamedType&>(*m_type) : nullptr; }
+    UnnamedType* type() { return m_type ? &*m_type : nullptr; }
     Optional<Semantic>& semantic() { return m_semantic; }
-    Expression* initializer() { return m_initializer ? &static_cast<Expression&>(*m_initializer) : nullptr; }
+    Expression* initializer() { return m_initializer ? &*m_initializer : nullptr; }
+    bool isAnonymous() const { return m_name.isNull(); }
 
 private:
     Lexer::Token m_origin;
index a7e8682..a6c7b5e 100644 (file)
@@ -54,8 +54,8 @@ public:
 
     bool isWhileLoop() const override { return true; }
 
-    Expression& conditional() { return static_cast<Expression&>(m_conditional); }
-    Statement& body() { return static_cast<Statement&>(m_body); }
+    Expression& conditional() { return m_conditional; }
+    Statement& body() { return m_body; }
 
 private:
     UniqueRef<Expression> m_conditional;
index 57b462e..8d5f68f 100644 (file)
@@ -41,9 +41,9 @@ bool checkDuplicateFunctions(const Program& program)
 {
     Vector<std::reference_wrapper<const AST::FunctionDeclaration>> functions;
     for (auto& functionDefinition : program.functionDefinitions())
-        functions.append(static_cast<const AST::FunctionDefinition&>(functionDefinition));
+        functions.append(functionDefinition);
     for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations())
-        functions.append(static_cast<const AST::NativeFunctionDeclaration&>(nativeFunctionDeclaration));
+        functions.append(nativeFunctionDeclaration);
 
     std::sort(functions.begin(), functions.end(), [](const AST::FunctionDeclaration& a, const AST::FunctionDeclaration& b) -> bool {
         if (a.name().length() < b.name().length())
@@ -99,7 +99,7 @@ bool checkDuplicateFunctions(const Program& program)
             && functions[i].get().parameters().size() == 2
             && is<AST::ReferenceType>(static_cast<const AST::UnnamedType&>(*functions[i].get().parameters()[0].type()))
             && is<AST::ReferenceType>(static_cast<const AST::UnnamedType&>(*functions[i].get().parameters()[1].type()))
-            && matches(static_cast<const AST::UnnamedType&>(*functions[i].get().parameters()[0].type()), static_cast<const AST::UnnamedType&>(*functions[i].get().parameters()[1].type())))
+            && matches(*functions[i].get().parameters()[0].type(), *functions[i].get().parameters()[1].type()))
             return false;
     }
     return true;
index 20e0ef0..7cbdb6a 100644 (file)
@@ -159,16 +159,19 @@ Optional<UniqueRef<AST::UnnamedType>> commit(AST::ResolvableType& resolvableType
 {
     ASSERT(!resolvableType.resolvedType());
     if (is<AST::FloatLiteralType>(resolvableType)) {
-        resolvableType.resolve(downcast<AST::FloatLiteralType>(resolvableType).preferredType().clone());
-        return downcast<AST::FloatLiteralType>(resolvableType).preferredType().clone();
+        auto& floatLiteralType = downcast<AST::FloatLiteralType>(resolvableType);
+        resolvableType.resolve(floatLiteralType.preferredType().clone());
+        return floatLiteralType.preferredType().clone();
     }
     if (is<AST::IntegerLiteralType>(resolvableType)) {
-        resolvableType.resolve(downcast<AST::IntegerLiteralType>(resolvableType).preferredType().clone());
-        return downcast<AST::IntegerLiteralType>(resolvableType).preferredType().clone();
+        auto& integerLiteralType = downcast<AST::IntegerLiteralType>(resolvableType);
+        resolvableType.resolve(integerLiteralType.preferredType().clone());
+        return integerLiteralType.preferredType().clone();
     }
     if (is<AST::UnsignedIntegerLiteralType>(resolvableType)) {
-        resolvableType.resolve(downcast<AST::UnsignedIntegerLiteralType>(resolvableType).preferredType().clone());
-        return downcast<AST::UnsignedIntegerLiteralType>(resolvableType).preferredType().clone();
+        auto& unsignedIntegerLiteralType = downcast<AST::UnsignedIntegerLiteralType>(resolvableType);
+        resolvableType.resolve(unsignedIntegerLiteralType.preferredType().clone());
+        return unsignedIntegerLiteralType.preferredType().clone();
     }
     if (is<AST::NullLiteralType>(resolvableType)) {
         // FIXME: Trying to match nullptr and nullptr fails.
@@ -199,7 +202,7 @@ bool inferTypesForTypeArguments(AST::NamedType& possibleType, AST::TypeArguments
             WTF::visit(WTF::makeVisitor([&](AST::ConstantExpression& constantExpression) {
                 expression = &constantExpression;
             }, [&](UniqueRef<AST::TypeReference>& theTypeReference) {
-                typeReference = &static_cast<AST::TypeReference&>(theTypeReference);
+                typeReference = &theTypeReference;
             }), typeArgument);
         };
 
@@ -224,7 +227,7 @@ bool inferTypesForCall(AST::FunctionDeclaration& possibleFunction, Vector<std::r
         return false;
     for (size_t i = 0; i < possibleFunction.parameters().size(); ++i) {
         auto success = WTF::visit(WTF::makeVisitor([&](UniqueRef<AST::UnnamedType>& unnamedType) -> bool {
-            return matches(*possibleFunction.parameters()[i].type(), static_cast<AST::UnnamedType&>(unnamedType));
+            return matches(*possibleFunction.parameters()[i].type(), unnamedType);
         }, [&](Ref<ResolvableTypeReference>& resolvableTypeReference) -> bool {
             return resolvableTypeReference->resolvableType().canResolve(*possibleFunction.parameters()[i].type());
         }), argumentTypes[i].get());
index 48fa930..2e0edef 100644 (file)
@@ -103,7 +103,7 @@ void NameResolver::visit(AST::IfStatement& ifStatement)
     NameResolver(nameContext).checkErrorAndVisit(ifStatement.body());
     if (ifStatement.elseBody()) {
         NameContext nameContext(&m_nameContext);
-        NameResolver(nameContext).checkErrorAndVisit(static_cast<AST::Statement&>(*ifStatement.elseBody()));
+        NameResolver(nameContext).checkErrorAndVisit(*ifStatement.elseBody());
     }
 }
 
@@ -167,17 +167,20 @@ void NameResolver::visit(AST::PropertyAccessExpression& propertyAccessExpression
 void NameResolver::visit(AST::DotExpression& dotExpression)
 {
     if (is<AST::VariableReference>(dotExpression.base())) {
-        if (auto enumerationTypes = m_nameContext.getTypes(downcast<AST::VariableReference>(dotExpression.base()).name())) {
+        auto baseName = downcast<AST::VariableReference>(dotExpression.base()).name();
+        if (auto enumerationTypes = m_nameContext.getTypes(baseName)) {
             ASSERT(enumerationTypes->size() == 1);
             AST::NamedType& type = (*enumerationTypes)[0];
             if (is<AST::EnumerationDefinition>(type)) {
                 AST::EnumerationDefinition& enumerationDefinition = downcast<AST::EnumerationDefinition>(type);
-                if (auto* member = enumerationDefinition.memberByName(dotExpression.fieldName())) {
+                auto memberName = dotExpression.fieldName();
+                if (auto* member = enumerationDefinition.memberByName(memberName)) {
                     static_assert(sizeof(AST::EnumerationMemberLiteral) <= sizeof(AST::DotExpression), "Dot expressions need to be able to become EnumerationMemberLiterals without updating backreferences");
                     Lexer::Token origin = dotExpression.origin();
                     // FIXME: Perhaps do this with variants or a Rewriter instead.
                     dotExpression.~DotExpression();
-                    new (&dotExpression) AST::EnumerationMemberLiteral(WTFMove(origin), *member);
+                    auto enumerationMemberLiteral = AST::EnumerationMemberLiteral::wrap(WTFMove(origin), WTFMove(baseName), WTFMove(memberName), enumerationDefinition, *member);
+                    new (&dotExpression) AST::EnumerationMemberLiteral(WTFMove(enumerationMemberLiteral));
                     return;
                 }
                 setError();
@@ -212,15 +215,18 @@ void NameResolver::visit(AST::CallExpression& callExpression)
     checkErrorAndVisit(callExpression);
 }
 
-void NameResolver::visit(AST::ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference)
+void NameResolver::visit(AST::EnumerationMemberLiteral& enumerationMemberLiteral)
 {
-    if (auto enumerationTypes = m_nameContext.getTypes(constantExpressionEnumerationMemberReference.left())) {
+    if (enumerationMemberLiteral.enumerationMember())
+        return;
+
+    if (auto enumerationTypes = m_nameContext.getTypes(enumerationMemberLiteral.left())) {
         ASSERT(enumerationTypes->size() == 1);
         AST::NamedType& type = (*enumerationTypes)[0];
         if (is<AST::EnumerationDefinition>(type)) {
             AST::EnumerationDefinition& enumerationDefinition = downcast<AST::EnumerationDefinition>(type);
-            if (auto* member = enumerationDefinition.memberByName(constantExpressionEnumerationMemberReference.right())) {
-                constantExpressionEnumerationMemberReference.setEnumerationMember(enumerationDefinition, *member);
+            if (auto* member = enumerationDefinition.memberByName(enumerationMemberLiteral.right())) {
+                enumerationMemberLiteral.setEnumerationMember(enumerationDefinition, *member);
                 return;
             }
         }
@@ -234,22 +240,22 @@ void NameResolver::visit(AST::ConstantExpressionEnumerationMemberReference& cons
 bool resolveNamesInTypes(Program& program, NameResolver& nameResolver)
 {
     for (auto& typeDefinition : program.typeDefinitions()) {
-        nameResolver.checkErrorAndVisit(static_cast<AST::TypeDefinition&>(typeDefinition));
+        nameResolver.checkErrorAndVisit(typeDefinition);
         if (nameResolver.error())
             return false;
     }
     for (auto& structureDefinition : program.structureDefinitions()) {
-        nameResolver.checkErrorAndVisit(static_cast<AST::StructureDefinition&>(structureDefinition));
+        nameResolver.checkErrorAndVisit(structureDefinition);
         if (nameResolver.error())
             return false;
     }
     for (auto& enumerationDefinition : program.enumerationDefinitions()) {
-        nameResolver.checkErrorAndVisit(static_cast<AST::EnumerationDefinition&>(enumerationDefinition));
+        nameResolver.checkErrorAndVisit(enumerationDefinition);
         if (nameResolver.error())
             return false;
     }
     for (auto& nativeTypeDeclaration : program.nativeTypeDeclarations()) {
-        nameResolver.checkErrorAndVisit(static_cast<AST::NativeTypeDeclaration&>(nativeTypeDeclaration));
+        nameResolver.checkErrorAndVisit(nativeTypeDeclaration);
         if (nameResolver.error())
             return false;
     }
@@ -259,14 +265,14 @@ bool resolveNamesInTypes(Program& program, NameResolver& nameResolver)
 bool resolveNamesInFunctions(Program& program, NameResolver& nameResolver)
 {
     for (auto& functionDefinition : program.functionDefinitions()) {
-        nameResolver.setCurrentFunctionDefinition(&static_cast<AST::FunctionDefinition&>(functionDefinition));
-        nameResolver.checkErrorAndVisit(static_cast<AST::FunctionDefinition&>(functionDefinition));
+        nameResolver.setCurrentFunctionDefinition(&functionDefinition);
+        nameResolver.checkErrorAndVisit(functionDefinition);
         if (nameResolver.error())
             return false;
     }
     nameResolver.setCurrentFunctionDefinition(nullptr);
     for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) {
-        nameResolver.checkErrorAndVisit(static_cast<AST::FunctionDeclaration&>(nativeFunctionDeclaration));
+        nameResolver.checkErrorAndVisit(nativeFunctionDeclaration);
         if (nameResolver.error())
             return false;
     }
index c72e08e..65189e2 100644 (file)
@@ -62,7 +62,7 @@ private:
     void visit(AST::PropertyAccessExpression&) override;
     void visit(AST::DotExpression&) override;
     void visit(AST::CallExpression&) override;
-    void visit(AST::ConstantExpressionEnumerationMemberReference&) override;
+    void visit(AST::EnumerationMemberLiteral&) override;
 
     NameContext m_nameContext;
     AST::FunctionDefinition* m_currentFunction { nullptr };
index 3cf66ce..5671c45 100644 (file)
@@ -39,7 +39,6 @@
 #include "WHLSLCallExpression.h"
 #include "WHLSLCommaExpression.h"
 #include "WHLSLConstantExpression.h"
-#include "WHLSLConstantExpressionEnumerationMemberReference.h"
 #include "WHLSLContinue.h"
 #include "WHLSLDereferenceExpression.h"
 #include "WHLSLDoWhileLoop.h"
index c93a767..81510d3 100644 (file)
@@ -49,39 +49,39 @@ public:
     bool append(AST::TypeDefinition&& typeDefinition)
     {
         m_typeDefinitions.append(makeUniqueRef<AST::TypeDefinition>(WTFMove(typeDefinition)));
-        return m_nameContext.add(static_cast<AST::TypeDefinition&>(m_typeDefinitions.last()));
+        return m_nameContext.add(m_typeDefinitions.last());
     }
 
     bool append(AST::StructureDefinition&& structureDefinition)
     {
         m_structureDefinitions.append(makeUniqueRef<AST::StructureDefinition>(WTFMove(structureDefinition)));
-        return m_nameContext.add(static_cast<AST::StructureDefinition&>(m_structureDefinitions.last()));
+        return m_nameContext.add(m_structureDefinitions.last());
     }
 
     bool append(AST::EnumerationDefinition&& enumerationDefinition)
     {
         m_enumerationDefinitions.append(makeUniqueRef<AST::EnumerationDefinition>(WTFMove(enumerationDefinition)));
-        return m_nameContext.add(static_cast<AST::EnumerationDefinition&>(m_enumerationDefinitions.last()));
+        return m_nameContext.add(m_enumerationDefinitions.last());
     }
 
     bool append(AST::FunctionDefinition&& functionDefinition)
     {
         m_functionDefinitions.append(makeUniqueRef<AST::FunctionDefinition>(WTFMove(functionDefinition)));
-        return m_nameContext.add(static_cast<AST::FunctionDefinition&>(m_functionDefinitions.last()));
+        return m_nameContext.add(m_functionDefinitions.last());
     }
 
     bool append(AST::NativeFunctionDeclaration&& nativeFunctionDeclaration)
     {
         m_nativeFunctionDeclarations.append(makeUniqueRef<AST::NativeFunctionDeclaration>(WTFMove(nativeFunctionDeclaration)));
-        m_intrinsics.add(static_cast<AST::NativeFunctionDeclaration&>(m_nativeFunctionDeclarations.last()));
-        return m_nameContext.add(static_cast<AST::NativeFunctionDeclaration&>(m_nativeFunctionDeclarations.last()));
+        m_intrinsics.add(m_nativeFunctionDeclarations.last());
+        return m_nameContext.add(m_nativeFunctionDeclarations.last());
     }
 
     bool append(AST::NativeTypeDeclaration&& nativeTypeDeclaration)
     {
         m_nativeTypeDeclarations.append(makeUniqueRef<AST::NativeTypeDeclaration>(WTFMove(nativeTypeDeclaration)));
-        m_intrinsics.add(static_cast<AST::NativeTypeDeclaration&>(m_nativeTypeDeclarations.last()));
-        return m_nameContext.add(static_cast<AST::NativeTypeDeclaration&>(m_nativeTypeDeclarations.last()));
+        m_intrinsics.add(m_nativeTypeDeclarations.last());
+        return m_nameContext.add(m_nativeTypeDeclarations.last());
     }
 
     NameContext& nameContext() { return m_nameContext; }
index 63fefb4..8345483 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(WEBGPU)
 
+#include "WHLSLAddressSpace.h"
 #include "WHLSLProgram.h"
 #include "WHLSLTypeReference.h"
 
@@ -41,8 +42,8 @@ void synthesizeEnumerationFunctions(Program& program)
     bool isRestricted = false;
     for (auto& enumerationDefinition : program.enumerationDefinitions()) {
         {
-            AST::VariableDeclaration variableDeclaration1(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), static_cast<AST::EnumerationDefinition&>(enumerationDefinition)) }, String(), WTF::nullopt, WTF::nullopt);
-            AST::VariableDeclaration variableDeclaration2(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), static_cast<AST::EnumerationDefinition&>(enumerationDefinition)) }, String(), WTF::nullopt, WTF::nullopt);
+            AST::VariableDeclaration variableDeclaration1(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), enumerationDefinition) }, String(), WTF::nullopt, WTF::nullopt);
+            AST::VariableDeclaration variableDeclaration2(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), enumerationDefinition) }, String(), WTF::nullopt, WTF::nullopt);
             AST::VariableDeclarations parameters;
             parameters.append(WTFMove(variableDeclaration1));
             parameters.append(WTFMove(variableDeclaration2));
@@ -50,31 +51,28 @@ void synthesizeEnumerationFunctions(Program& program)
             program.append(WTFMove(nativeFunctionDeclaration));
         }
 
-        if (enumerationDefinition->type()) {
-            // FIXME: Handle a null base type.
-            {
-                AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), static_cast<AST::EnumerationDefinition&>(enumerationDefinition)) }, String(), WTF::nullopt, WTF::nullopt);
-                AST::VariableDeclarations parameters;
-                parameters.append(WTFMove(variableDeclaration));
-                AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type()->clone(), "operator.value"_str, WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
-                program.append(WTFMove(nativeFunctionDeclaration));
-            }
+        {
+            AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), enumerationDefinition) }, String(), WTF::nullopt, WTF::nullopt);
+            AST::VariableDeclarations parameters;
+            parameters.append(WTFMove(variableDeclaration));
+            AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type().clone(), "operator.value"_str, WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
+            program.append(WTFMove(nativeFunctionDeclaration));
+        }
 
-            {
-                AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), static_cast<AST::EnumerationDefinition&>(enumerationDefinition)) }, String(), WTF::nullopt, WTF::nullopt);
-                AST::VariableDeclarations parameters;
-                parameters.append(WTFMove(variableDeclaration));
-                AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type()->clone(), "operator cast"_str, WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
-                program.append(WTFMove(nativeFunctionDeclaration));
-            }
+        {
+            AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), enumerationDefinition) }, String(), WTF::nullopt, WTF::nullopt);
+            AST::VariableDeclarations parameters;
+            parameters.append(WTFMove(variableDeclaration));
+            AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, enumerationDefinition->type().clone(), "operator cast"_str, WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
+            program.append(WTFMove(nativeFunctionDeclaration));
+        }
 
-            {
-                AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), enumerationDefinition->type()->clone(), String(), WTF::nullopt, WTF::nullopt);
-                AST::VariableDeclarations parameters;
-                parameters.append(WTFMove(variableDeclaration));
-                AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), static_cast<AST::EnumerationDefinition&>(enumerationDefinition)) }, "operator cast"_str, WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
-                program.append(WTFMove(nativeFunctionDeclaration));
-            }
+        {
+            AST::VariableDeclaration variableDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::Qualifiers(), enumerationDefinition->type().clone(), String(), WTF::nullopt, WTF::nullopt);
+            AST::VariableDeclarations parameters;
+            parameters.append(WTFMove(variableDeclaration));
+            AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(enumerationDefinition->origin()), AST::AttributeBlock(), WTF::nullopt, { AST::TypeReference::wrap(Lexer::Token(enumerationDefinition->origin()), enumerationDefinition) }, "operator cast"_str, WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
+            program.append(WTFMove(nativeFunctionDeclaration));
         }
     }
 }
index b3422dd..b99dc77 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(WEBGPU)
 
+#include "WHLSLAddressSpace.h"
 #include "WHLSLPointerType.h"
 #include "WHLSLProgram.h"
 #include "WHLSLReferenceType.h"
@@ -46,7 +47,7 @@ void synthesizeStructureAccessors(Program& program)
         for (auto& structureElement : structureDefinition->structureElements()) {
             {
                 // The getter: operator.field
-                AST::VariableDeclaration variableDeclaration(Lexer::Token(structureElement.origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), static_cast<AST::StructureDefinition&>(structureDefinition)) }, String(), WTF::nullopt, WTF::nullopt);
+                AST::VariableDeclaration variableDeclaration(Lexer::Token(structureElement.origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), structureDefinition) }, String(), WTF::nullopt, WTF::nullopt);
                 AST::VariableDeclarations parameters;
                 parameters.append(WTFMove(variableDeclaration));
                 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(structureElement.origin()), AST::AttributeBlock(), WTF::nullopt, structureElement.type().clone(), String::format("operator.%s", structureElement.name().utf8().data()), WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
@@ -55,18 +56,18 @@ void synthesizeStructureAccessors(Program& program)
 
             {
                 // The setter: operator.field=
-                AST::VariableDeclaration variableDeclaration1(Lexer::Token(structureElement.origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), static_cast<AST::StructureDefinition&>(structureDefinition)) }, String(), WTF::nullopt, WTF::nullopt);
+                AST::VariableDeclaration variableDeclaration1(Lexer::Token(structureElement.origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), structureDefinition) }, String(), WTF::nullopt, WTF::nullopt);
                 AST::VariableDeclaration variableDeclaration2(Lexer::Token(structureElement.origin()), AST::Qualifiers(), { structureElement.type().clone() }, String(), WTF::nullopt, WTF::nullopt);
                 AST::VariableDeclarations parameters;
                 parameters.append(WTFMove(variableDeclaration1));
                 parameters.append(WTFMove(variableDeclaration2));
-                AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(structureElement.origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), static_cast<AST::StructureDefinition&>(structureDefinition)), String::format("operator.%s=", structureElement.name().utf8().data()), WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
+                AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(structureElement.origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), structureDefinition), String::format("operator.%s=", structureElement.name().utf8().data()), WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
                 program.append(WTFMove(nativeFunctionDeclaration));
             }
 
             // The ander: operator&.field
-            auto createAnder = [&](AST::ReferenceType::AddressSpace addressSpace) -> AST::NativeFunctionDeclaration {
-                auto argumentType = makeUniqueRef<AST::PointerType>(Lexer::Token(structureElement.origin()), addressSpace, AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), static_cast<AST::StructureDefinition&>(structureDefinition)));
+            auto createAnder = [&](AST::AddressSpace addressSpace) -> AST::NativeFunctionDeclaration {
+                auto argumentType = makeUniqueRef<AST::PointerType>(Lexer::Token(structureElement.origin()), addressSpace, AST::TypeReference::wrap(Lexer::Token(structureElement.origin()), structureDefinition));
                 AST::VariableDeclaration variableDeclaration(Lexer::Token(structureElement.origin()), AST::Qualifiers(), { WTFMove(argumentType) }, String(), WTF::nullopt, WTF::nullopt);
                 AST::VariableDeclarations parameters;
                 parameters.append(WTFMove(variableDeclaration));
@@ -74,10 +75,10 @@ void synthesizeStructureAccessors(Program& program)
                 AST::NativeFunctionDeclaration nativeFunctionDeclaration(AST::FunctionDeclaration(Lexer::Token(structureElement.origin()), AST::AttributeBlock(), WTF::nullopt, WTFMove(returnType), String::format("operator&.%s", structureElement.name().utf8().data()), WTFMove(parameters), WTF::nullopt, isOperator), isRestricted);
                 return nativeFunctionDeclaration;
             };
-            program.append(createAnder(AST::ReferenceType::AddressSpace::Constant));
-            program.append(createAnder(AST::ReferenceType::AddressSpace::Device));
-            program.append(createAnder(AST::ReferenceType::AddressSpace::Threadgroup));
-            program.append(createAnder(AST::ReferenceType::AddressSpace::Thread));
+            program.append(createAnder(AST::AddressSpace::Constant));
+            program.append(createAnder(AST::AddressSpace::Device));
+            program.append(createAnder(AST::AddressSpace::Threadgroup));
+            program.append(createAnder(AST::AddressSpace::Thread));
         }
     }
 }
index 7fd3675..52d2e8f 100644 (file)
@@ -40,7 +40,6 @@
 #include "WHLSLCallExpression.h"
 #include "WHLSLCommaExpression.h"
 #include "WHLSLConstantExpression.h"
-#include "WHLSLConstantExpressionEnumerationMemberReference.h"
 #include "WHLSLContinue.h"
 #include "WHLSLDereferenceExpression.h"
 #include "WHLSLDoWhileLoop.h"
@@ -48,6 +47,7 @@
 #include "WHLSLEffectfulExpressionStatement.h"
 #include "WHLSLEnumerationDefinition.h"
 #include "WHLSLEnumerationMember.h"
+#include "WHLSLEnumerationMemberLiteral.h"
 #include "WHLSLExpression.h"
 #include "WHLSLFallthrough.h"
 #include "WHLSLFloatLiteral.h"
@@ -104,17 +104,17 @@ void Visitor::visit(Program& program)
 {
     // These visiting functions might add new global statements, so don't use foreach syntax.
     for (size_t i = 0; i < program.typeDefinitions().size(); ++i)
-        checkErrorAndVisit(static_cast<AST::TypeDefinition&>(program.typeDefinitions()[i]));
+        checkErrorAndVisit(program.typeDefinitions()[i]);
     for (size_t i = 0; i < program.structureDefinitions().size(); ++i)
-        checkErrorAndVisit(static_cast<AST::StructureDefinition&>(program.structureDefinitions()[i]));
+        checkErrorAndVisit(program.structureDefinitions()[i]);
     for (size_t i = 0; i < program.enumerationDefinitions().size(); ++i)
-        checkErrorAndVisit(static_cast<AST::EnumerationDefinition&>(program.enumerationDefinitions()[i]));
+        checkErrorAndVisit(program.enumerationDefinitions()[i]);
     for (size_t i = 0; i < program.functionDefinitions().size(); ++i)
-        checkErrorAndVisit(static_cast<AST::FunctionDefinition&>(program.functionDefinitions()[i]));
+        checkErrorAndVisit(program.functionDefinitions()[i]);
     for (size_t i = 0; i < program.nativeFunctionDeclarations().size(); ++i)
-        checkErrorAndVisit(static_cast<AST::NativeFunctionDeclaration&>(program.nativeFunctionDeclarations()[i]));
+        checkErrorAndVisit(program.nativeFunctionDeclarations()[i]);
     for (size_t i = 0; i < program.nativeTypeDeclarations().size(); ++i)
-        checkErrorAndVisit(static_cast<AST::NativeTypeDeclaration&>(program.nativeTypeDeclarations()[i]));
+        checkErrorAndVisit(program.nativeTypeDeclarations()[i]);
 }
 
 void Visitor::visit(AST::UnnamedType& unnamedType)
@@ -158,8 +158,7 @@ void Visitor::visit(AST::StructureDefinition& structureDefinition)
 
 void Visitor::visit(AST::EnumerationDefinition& enumerationDefinition)
 {
-    if (enumerationDefinition.type())
-        checkErrorAndVisit(static_cast<AST::UnnamedType&>(*enumerationDefinition.type()));
+    checkErrorAndVisit(enumerationDefinition.type());
     for (auto& enumerationMember : enumerationDefinition.enumerationMembers())
         checkErrorAndVisit(enumerationMember);
 }
@@ -234,7 +233,7 @@ void Visitor::visit(AST::TypeArgument& typeArgument)
     WTF::visit(WTF::makeVisitor([&](AST::ConstantExpression& constantExpression) {
         checkErrorAndVisit(constantExpression);
     }, [&](UniqueRef<AST::TypeReference>& typeReference) {
-        checkErrorAndVisit(static_cast<AST::TypeReference&>(typeReference));
+        checkErrorAndVisit(typeReference);
     }), typeArgument);
 }
 
@@ -268,8 +267,8 @@ void Visitor::visit(AST::ConstantExpression& constantExpression)
         checkErrorAndVisit(nullLiteral);
     }, [&](AST::BooleanLiteral& booleanLiteral) {
         checkErrorAndVisit(booleanLiteral);
-    }, [&](AST::ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) {
-        checkErrorAndVisit(constantExpressionEnumerationMemberReference);
+    }, [&](AST::EnumerationMemberLiteral& enumerationMemberLiteral) {
+        checkErrorAndVisit(enumerationMemberLiteral);
     }));
 }
 
@@ -346,7 +345,7 @@ void Visitor::visit(AST::NullLiteralType& nullLiteralType)
         checkErrorAndVisit(*nullLiteralType.resolvedType());
 }
 
-void Visitor::visit(AST::ConstantExpressionEnumerationMemberReference&)
+void Visitor::visit(AST::EnumerationMemberLiteral&)
 {
 }
 
@@ -364,7 +363,7 @@ void Visitor::visit(AST::NumThreadsFunctionAttribute&)
 void Visitor::visit(AST::Block& block)
 {
     for (auto& statement : block.statements())
-        checkErrorAndVisit(static_cast<AST::Statement&>(statement));
+        checkErrorAndVisit(statement);
 }
 
 void Visitor::visit(AST::Statement& statement)
@@ -451,6 +450,8 @@ void Visitor::visit(AST::Expression& expression)
         checkErrorAndVisit(downcast<AST::TernaryExpression>(expression));
     else if (is<AST::UnsignedIntegerLiteral>(expression))
         checkErrorAndVisit(downcast<AST::UnsignedIntegerLiteral>(expression));
+    else if (is<AST::EnumerationMemberLiteral>(expression))
+        checkErrorAndVisit(downcast<AST::EnumerationMemberLiteral>(expression));
     else {
         ASSERT(is<AST::VariableReference>(expression));
         checkErrorAndVisit(downcast<AST::VariableReference>(expression));
@@ -487,7 +488,7 @@ void Visitor::visit(AST::ForLoop& forLoop)
     WTF::visit(WTF::makeVisitor([&](AST::VariableDeclarationsStatement& variableDeclarationsStatement) {
         checkErrorAndVisit(variableDeclarationsStatement);
     }, [&](UniqueRef<AST::Expression>& expression) {
-        checkErrorAndVisit(static_cast<AST::Expression&>(expression));
+        checkErrorAndVisit(expression);
     }), forLoop.initialization());
     if (forLoop.condition())
         checkErrorAndVisit(*forLoop.condition());
@@ -501,7 +502,7 @@ void Visitor::visit(AST::IfStatement& ifStatement)
     checkErrorAndVisit(ifStatement.conditional());
     checkErrorAndVisit(ifStatement.body());
     if (ifStatement.elseBody())
-        checkErrorAndVisit(static_cast<AST::Statement&>(*ifStatement.elseBody()));
+        checkErrorAndVisit(*ifStatement.elseBody());
 }
 
 void Visitor::visit(AST::Return& returnStatement)
@@ -559,7 +560,7 @@ void Visitor::visit(AST::AssignmentExpression& assignmentExpression)
 void Visitor::visit(AST::CallExpression& callExpression)
 {
     for (auto& argument : callExpression.arguments())
-        checkErrorAndVisit(static_cast<AST::Expression&>(argument));
+        checkErrorAndVisit(argument);
     if (callExpression.castReturnType())
         checkErrorAndVisit(callExpression.castReturnType()->get());
 }
@@ -567,7 +568,7 @@ void Visitor::visit(AST::CallExpression& callExpression)
 void Visitor::visit(AST::CommaExpression& commaExpression)
 {
     for (auto& expression : commaExpression.list())
-        checkErrorAndVisit(static_cast<AST::Expression&>(expression));
+        checkErrorAndVisit(expression);
 }
 
 void Visitor::visit(AST::DereferenceExpression& dereferenceExpression)
index a6ae293..a5e4c96 100644 (file)
@@ -63,7 +63,7 @@ class UnsignedIntegerLiteral;
 class FloatLiteral;
 class NullLiteral;
 class BooleanLiteral;
-class ConstantExpressionEnumerationMemberReference;
+class EnumerationMemberLiteral;
 class NumThreadsFunctionAttribute;
 class Block;
 class Statement;
@@ -141,7 +141,7 @@ public:
     virtual void visit(AST::UnsignedIntegerLiteralType&);
     virtual void visit(AST::FloatLiteralType&);
     virtual void visit(AST::NullLiteralType&);
-    virtual void visit(AST::ConstantExpressionEnumerationMemberReference&);
+    virtual void visit(AST::EnumerationMemberLiteral&);
     virtual void visit(AST::FunctionAttribute&);
     virtual void visit(AST::NumThreadsFunctionAttribute&);
     virtual void visit(AST::Block&);
index 6493844..f2f515a 100644 (file)
                1C24EEA71C72A7B40080F8FC /* JSFontFaceSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSFontFaceSet.h; path = DerivedSources/WebCore/JSFontFaceSet.h; sourceTree = BUILT_PRODUCTS_DIR; };
                1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
                1C3249101C6D6A3B007EDB32 /* FontVariantBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontVariantBuilder.cpp; sourceTree = "<group>"; };
-               1C33276C21CEDA42000DC9F2 /* WHLSLEnumerationMemberLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEnumerationMemberLiteral.h; sourceTree = "<group>"; };
                1C33277121CF0BE1000DC9F2 /* WHLSLNamedType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNamedType.h; sourceTree = "<group>"; };
                1C33277221CF0D2E000DC9F2 /* WHLSLUnnamedType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLUnnamedType.h; sourceTree = "<group>"; };
                1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = "<group>"; };
                1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; };
                1C81B9570E97330800266E07 /* InspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorController.cpp; sourceTree = "<group>"; };
                1C81B9580E97330800266E07 /* InspectorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorClient.h; sourceTree = "<group>"; };
+               1C840B7D21EBE0B800D0500D /* WHLSLEntryPointType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEntryPointType.h; sourceTree = "<group>"; };
+               1C840B9021EC30F900D0500D /* WHLSLAddressSpace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLAddressSpace.h; sourceTree = "<group>"; };
                1C904DF90BA9D2C80081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
                1CA19E030DC255950065A994 /* EventLoopMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventLoopMac.mm; sourceTree = "<group>"; };
                1CA19E150DC255CA0065A994 /* EventLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventLoop.h; sourceTree = "<group>"; };
                C21BF6FF21CD89C200227979 /* WHLSLIfStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLIfStatement.h; sourceTree = "<group>"; };
                C21BF70021CD89C200227979 /* WHLSLFallthrough.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFallthrough.h; sourceTree = "<group>"; };
                C21BF70121CD89C400227979 /* WHLSLDereferenceExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLDereferenceExpression.h; sourceTree = "<group>"; };
-               C21BF70221CD89C400227979 /* WHLSLConstantExpressionEnumerationMemberReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLConstantExpressionEnumerationMemberReference.h; sourceTree = "<group>"; };
+               C21BF70221CD89C400227979 /* WHLSLEnumerationMemberLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEnumerationMemberLiteral.h; sourceTree = "<group>"; };
                C21BF70321CD89C500227979 /* WHLSLReturn.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLReturn.h; sourceTree = "<group>"; };
                C21BF70421CD89C600227979 /* WHLSLWhileLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLWhileLoop.h; sourceTree = "<group>"; };
                C21BF70521CD89C700227979 /* WHLSLFunctionAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFunctionAttribute.h; sourceTree = "<group>"; };
                C21BF73A21CD8D7000227979 /* WHLSLProgram.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLProgram.h; sourceTree = "<group>"; };
                C21BF74221CD963B00227979 /* WHLSLStandardLibrary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WHLSLStandardLibrary.h; path = DerivedSources/WebCore/WHLSLStandardLibrary.h; sourceTree = BUILT_PRODUCTS_DIR; };
                C21BF74521CD969800227979 /* WHLSLStandardLibrary.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = WHLSLStandardLibrary.txt; sourceTree = "<group>"; };
+               C21DF2E71D9E4E9900F5B24C /* CSSFontVariationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontVariationValue.cpp; sourceTree = "<group>"; };
+               C21DF2E81D9E4E9900F5B24C /* CSSFontVariationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontVariationValue.h; sourceTree = "<group>"; };
+               C234A98521E886A9003C984D /* WHLSLVisitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLVisitor.cpp; sourceTree = "<group>"; };
+               C234A98721E886AD003C984D /* WHLSLVisitor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLVisitor.h; sourceTree = "<group>"; };
                C234A98A21E8883E003C984D /* WHLSLNameResolver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLNameResolver.cpp; sourceTree = "<group>"; };
                C234A98C21E8883E003C984D /* WHLSLNameResolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNameResolver.h; sourceTree = "<group>"; };
                C234A98D21E88884003C984D /* WHLSLNameContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLNameContext.cpp; sourceTree = "<group>"; };
                C234A9B521E92C23003C984D /* WHLSLSynthesizeStructureAccessors.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSynthesizeStructureAccessors.h; sourceTree = "<group>"; };
                C234A9B621E92CC0003C984D /* WHLSLIntrinsics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLIntrinsics.h; sourceTree = "<group>"; };
                C234A9B721E92CC1003C984D /* WHLSLIntrinsics.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLIntrinsics.cpp; sourceTree = "<group>"; };
-               C21DF2E71D9E4E9900F5B24C /* CSSFontVariationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontVariationValue.cpp; sourceTree = "<group>"; };
-               C21DF2E81D9E4E9900F5B24C /* CSSFontVariationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontVariationValue.h; sourceTree = "<group>"; };
-               C234A98521E886A9003C984D /* WHLSLVisitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLVisitor.cpp; sourceTree = "<group>"; };
-               C234A98721E886AD003C984D /* WHLSLVisitor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLVisitor.h; sourceTree = "<group>"; };
                C2458E611FE8979E00594759 /* FontCacheCoreText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontCacheCoreText.h; sourceTree = "<group>"; };
                C26017A11C72DC9900F74A16 /* CSSFontFaceSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontFaceSet.cpp; sourceTree = "<group>"; };
                C26017A21C72DC9900F74A16 /* CSSFontFaceSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFaceSet.h; sourceTree = "<group>"; };
                C21BF6F121CD898D00227979 /* AST */ = {
                        isa = PBXGroup;
                        children = (
+                               1C840B9021EC30F900D0500D /* WHLSLAddressSpace.h */,
                                C21BF72521CD89E200227979 /* WHLSLArrayReferenceType.h */,
                                C21BF70921CD89CA00227979 /* WHLSLArrayType.h */,
                                C21BF73021CD89ED00227979 /* WHLSLAssignmentExpression.h */,
                                C21BF71621CD89D500227979 /* WHLSLCallExpression.h */,
                                C21BF70621CD89C700227979 /* WHLSLCommaExpression.h */,
                                C21BF73321CD89F000227979 /* WHLSLConstantExpression.h */,
-                               C21BF70221CD89C400227979 /* WHLSLConstantExpressionEnumerationMemberReference.h */,
                                C21BF6F521CD89B500227979 /* WHLSLContinue.h */,
                                C21BF70121CD89C400227979 /* WHLSLDereferenceExpression.h */,
                                C21BF71821CD89D700227979 /* WHLSLDotExpression.h */,
                                C21BF6FB21CD89BE00227979 /* WHLSLDoWhileLoop.h */,
                                C21BF72821CD89E500227979 /* WHLSLEffectfulExpressionStatement.h */,
+                               1C840B7D21EBE0B800D0500D /* WHLSLEntryPointType.h */,
                                C21BF72021CD89DD00227979 /* WHLSLEnumerationDefinition.h */,
                                C21BF72621CD89E300227979 /* WHLSLEnumerationMember.h */,
-                               1C33276C21CEDA42000DC9F2 /* WHLSLEnumerationMemberLiteral.h */,
+                               C21BF70221CD89C400227979 /* WHLSLEnumerationMemberLiteral.h */,
                                C21BF70C21CD89CC00227979 /* WHLSLExpression.h */,
                                C21BF70021CD89C200227979 /* WHLSLFallthrough.h */,
                                C21BF73521CD89F200227979 /* WHLSLFloatLiteral.h */,