[WHLSL] Implement parser AST nodes
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2019 22:17:58 +0000 (22:17 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2019 22:17:58 +0000 (22:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192991

Reviewed by Alex Christensen.

This patch creates all the AST nodes which will be the result of running the parser.
This patch used to be a part of the "create a WHLSL parser" patch but I split them
out in order to aid reviewing.

The classes were mechanically created to match the result of the parser. There are
nodes for things like ForLoops, LogicalNotExpressions, DereferenceExpressions,
StructureDefinitions, and things like that. The classes don't actually have any logic
in them - they are currently just containers to hold the structure of the parsed
program. Some of these nodes (like constexprs) are just Variants of the various things
they can in the form of.

No new tests because the parser doesn't exist to create the new AST nodes yet.

* Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h: Added.
(WebCore::WHLSL::AST::ArrayReferenceType::ArrayReferenceType):
* Modules/webgpu/WHLSL/AST/WHLSLArrayType.h: Added.
(WebCore::WHLSL::AST::ArrayType::ArrayType):
(WebCore::WHLSL::AST::ArrayType::type const):
(WebCore::WHLSL::AST::ArrayType::type):
(WebCore::WHLSL::AST::ArrayType::numElements const):
* Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h: Added.
(WebCore::WHLSL::AST::AssignmentExpression::AssignmentExpression):
(WebCore::WHLSL::AST::AssignmentExpression::left):
(WebCore::WHLSL::AST::AssignmentExpression::right):
* Modules/webgpu/WHLSL/AST/WHLSLBaseFunctionAttribute.h: Added.
(WebCore::WHLSL::AST::BaseFunctionAttribute::BaseFunctionAttribute):
* Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h: Added.
(WebCore::WHLSL::AST::BaseSemantic::BaseSemantic):
* Modules/webgpu/WHLSL/AST/WHLSLBlock.h: Added.
(WebCore::WHLSL::AST::Block::Block):
(WebCore::WHLSL::AST::Block::statements):
* Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.h: Added.
(WebCore::WHLSL::AST::BooleanLiteral::BooleanLiteral):
(WebCore::WHLSL::AST::BooleanLiteral::value const):
(WebCore::WHLSL::AST::BooleanLiteral::clone const):
* Modules/webgpu/WHLSL/AST/WHLSLBreak.h: Added.
(WebCore::WHLSL::AST::Break::Break):
* Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp: Added.
(WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.h: Added.
(WebCore::WHLSL::AST::BuiltInSemantic::BuiltInSemantic):
(WebCore::WHLSL::AST::BuiltInSemantic::variable const):
(WebCore::WHLSL::AST::BuiltInSemantic::operator== const):
(WebCore::WHLSL::AST::BuiltInSemantic::operator!= const):
* Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h: Added.
(WebCore::WHLSL::AST::CallExpression::CallExpression):
(WebCore::WHLSL::AST::CallExpression::arguments):
(WebCore::WHLSL::AST::CallExpression::name):
(WebCore::WHLSL::AST::CallExpression::setCastData):
(WebCore::WHLSL::AST::CallExpression::isCast):
(WebCore::WHLSL::AST::CallExpression::castReturnType):
(WebCore::WHLSL::AST::CallExpression::hasOverloads const):
(WebCore::WHLSL::AST::CallExpression::overloads):
(WebCore::WHLSL::AST::CallExpression::setOverloads):
(WebCore::WHLSL::AST::CallExpression::setFunction):
* Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.h: Added.
(WebCore::WHLSL::AST::CommaExpression::CommaExpression):
(WebCore::WHLSL::AST::CommaExpression::list):
* Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h: Added.
(WebCore::WHLSL::AST::ConstantExpression::ConstantExpression):
(WebCore::WHLSL::AST::ConstantExpression::integerLiteral):
(WebCore::WHLSL::AST::ConstantExpression::visit):
(WebCore::WHLSL::AST::ConstantExpression::visit const):
(WebCore::WHLSL::AST::ConstantExpression::clone const):
(WebCore::WHLSL::AST::ConstantExpression::matches const):
* Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h: Added.
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::ConstantExpressionEnumerationMemberReference):
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::left const):
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::right const):
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::clone const):
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::enumerationDefinition):
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::enumerationDefinition const):
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::enumerationMember):
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::enumerationMember const):
(WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::setEnumerationMember):
* Modules/webgpu/WHLSL/AST/WHLSLContinue.h: Added.
(WebCore::WHLSL::AST::Continue::Continue):
* Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h: Added.
(WebCore::WHLSL::AST::DereferenceExpression::DereferenceExpression):
(WebCore::WHLSL::AST::DereferenceExpression::pointer):
* Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h: Added.
(WebCore::WHLSL::AST::DoWhileLoop::DoWhileLoop):
(WebCore::WHLSL::AST::DoWhileLoop::body):
(WebCore::WHLSL::AST::DoWhileLoop::conditional):
* Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h: Added.
(WebCore::WHLSL::AST::DotExpression::DotExpression):
(WebCore::WHLSL::AST::DotExpression::fieldName):
* Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h: Added.
(WebCore::WHLSL::AST::EffectfulExpressionStatement::EffectfulExpressionStatement):
(WebCore::WHLSL::AST::EffectfulExpressionStatement::effectfulExpression):
* Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h: Added.
(WebCore::WHLSL::AST::EnumerationDefinition::EnumerationDefinition):
(WebCore::WHLSL::AST::EnumerationDefinition::type):
(WebCore::WHLSL::AST::EnumerationDefinition::add):
(WebCore::WHLSL::AST::EnumerationDefinition::memberByName):
(WebCore::WHLSL::AST::EnumerationDefinition::enumerationMembers):
* Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h: Added.
(WebCore::WHLSL::AST::EnumerationMember::EnumerationMember):
(WebCore::WHLSL::AST::EnumerationMember::origin const):
(WebCore::WHLSL::AST::EnumerationMember::name):
(WebCore::WHLSL::AST::EnumerationMember::value):
(WebCore::WHLSL::AST::EnumerationMember::setValue):
* Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h: Added.
(WebCore::WHLSL::AST::EnumerationMemberLiteral::EnumerationMemberLiteral):
(WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationMember):
* Modules/webgpu/WHLSL/AST/WHLSLExpression.h: Added.
(WebCore::WHLSL::AST::Expression::Expression):
(WebCore::WHLSL::AST::Expression::origin const):
(WebCore::WHLSL::AST::Expression::isAssignmentExpression const):
(WebCore::WHLSL::AST::Expression::isBooleanLiteral const):
(WebCore::WHLSL::AST::Expression::isCallExpression const):
(WebCore::WHLSL::AST::Expression::isCommaExpression const):
(WebCore::WHLSL::AST::Expression::isDereferenceExpression const):
(WebCore::WHLSL::AST::Expression::isDotExpression const):
(WebCore::WHLSL::AST::Expression::isFloatLiteral const):
(WebCore::WHLSL::AST::Expression::isIndexExpression const):
(WebCore::WHLSL::AST::Expression::isIntegerLiteral const):
(WebCore::WHLSL::AST::Expression::isLogicalExpression const):
(WebCore::WHLSL::AST::Expression::isLogicalNotExpression const):
(WebCore::WHLSL::AST::Expression::isMakeArrayReferenceExpression const):
(WebCore::WHLSL::AST::Expression::isMakePointerExpression const):
(WebCore::WHLSL::AST::Expression::isNullLiteral const):
(WebCore::WHLSL::AST::Expression::isPropertyAccessExpression const):
(WebCore::WHLSL::AST::Expression::isReadModifyWriteExpression const):
(WebCore::WHLSL::AST::Expression::isTernaryExpression const):
(WebCore::WHLSL::AST::Expression::isUnsignedIntegerLiteral const):
(WebCore::WHLSL::AST::Expression::isVariableReference const):
(WebCore::WHLSL::AST::Expression::isEnumerationMemberLiteral const):
* Modules/webgpu/WHLSL/AST/WHLSLFallthrough.h: Added.
(WebCore::WHLSL::AST::Fallthrough::Fallthrough):
* Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.h: Added.
(WebCore::WHLSL::AST::FloatLiteral::FloatLiteral):
(WebCore::WHLSL::AST::FloatLiteral::type):
(WebCore::WHLSL::AST::FloatLiteral::value const):
(WebCore::WHLSL::AST::FloatLiteral::clone const):
* Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp: Added.
(WebCore::WHLSL::AST::FloatLiteralType::FloatLiteralType):
(WebCore::WHLSL::AST::FloatLiteralType::canResolve const):
(WebCore::WHLSL::AST::FloatLiteralType::conversionCost const):
* Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.h: Added.
(WebCore::WHLSL::AST::FloatLiteralType::preferredType):
* Modules/webgpu/WHLSL/AST/WHLSLForLoop.h: Added.
(WebCore::WHLSL::AST::ForLoop::ForLoop):
(WebCore::WHLSL::AST::ForLoop::~ForLoop):
(WebCore::WHLSL::AST::ForLoop::initialization):
(WebCore::WHLSL::AST::ForLoop::condition):
(WebCore::WHLSL::AST::ForLoop::increment):
(WebCore::WHLSL::AST::ForLoop::body):
* Modules/webgpu/WHLSL/AST/WHLSLFunctionAttribute.h: Added.
* Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h: Added.
(WebCore::WHLSL::AST::FunctionDeclaration::FunctionDeclaration):
(WebCore::WHLSL::AST::FunctionDeclaration::isFunctionDefinition const):
(WebCore::WHLSL::AST::FunctionDeclaration::isNativeFunctionDeclaration const):
(WebCore::WHLSL::AST::FunctionDeclaration::attributeBlock):
(WebCore::WHLSL::AST::FunctionDeclaration::entryPointType const):
(WebCore::WHLSL::AST::FunctionDeclaration::type const):
(WebCore::WHLSL::AST::FunctionDeclaration::type):
(WebCore::WHLSL::AST::FunctionDeclaration::name const):
(WebCore::WHLSL::AST::FunctionDeclaration::isCast const):
(WebCore::WHLSL::AST::FunctionDeclaration::parameters const):
(WebCore::WHLSL::AST::FunctionDeclaration::parameters):
(WebCore::WHLSL::AST::FunctionDeclaration::semantic):
(WebCore::WHLSL::AST::FunctionDeclaration::isOperator const):
* Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h: Added.
(WebCore::WHLSL::AST::FunctionDefinition::FunctionDefinition):
(WebCore::WHLSL::AST::FunctionDefinition::block):
(WebCore::WHLSL::AST::FunctionDefinition::restricted const):
* Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h: Added.
(WebCore::WHLSL::AST::IfStatement::IfStatement):
(WebCore::WHLSL::AST::IfStatement::conditional):
(WebCore::WHLSL::AST::IfStatement::body):
(WebCore::WHLSL::AST::IfStatement::elseBody):
* Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h: Added.
(WebCore::WHLSL::AST::IndexExpression::IndexExpression):
(WebCore::WHLSL::AST::IndexExpression::indexExpression):
* Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.cpp: Added.
(WebCore::WHLSL::AST::IntegerLiteral::valueForSelectedType const):
* Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.h: Added.
(WebCore::WHLSL::AST::IntegerLiteral::IntegerLiteral):
(WebCore::WHLSL::AST::IntegerLiteral::type):
(WebCore::WHLSL::AST::IntegerLiteral::value const):
(WebCore::WHLSL::AST::IntegerLiteral::clone const):
* Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp: Added.
(WebCore::WHLSL::AST::IntegerLiteralType::IntegerLiteralType):
(WebCore::WHLSL::AST::IntegerLiteralType::canResolve const):
(WebCore::WHLSL::AST::IntegerLiteralType::conversionCost const):
* Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.h: Added.
(WebCore::WHLSL::AST::IntegerLiteralType::preferredType):
* Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h: Added.
(WebCore::WHLSL::AST::LogicalExpression::LogicalExpression):
(WebCore::WHLSL::AST::LogicalExpression::type const):
(WebCore::WHLSL::AST::LogicalExpression::left):
(WebCore::WHLSL::AST::LogicalExpression::right):
* Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h: Added.
(WebCore::WHLSL::AST::LogicalNotExpression::LogicalNotExpression):
(WebCore::WHLSL::AST::LogicalNotExpression::operand):
* Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h: Added.
(WebCore::WHLSL::AST::MakeArrayReferenceExpression::MakeArrayReferenceExpression):
(WebCore::WHLSL::AST::MakeArrayReferenceExpression::lValue):
* Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h: Added.
(WebCore::WHLSL::AST::MakePointerExpression::MakePointerExpression):
(WebCore::WHLSL::AST::MakePointerExpression::lValue):
* Modules/webgpu/WHLSL/AST/WHLSLNamedType.h: Added.
(WebCore::WHLSL::AST::NamedType::NamedType):
(WebCore::WHLSL::AST::NamedType::origin const):
(WebCore::WHLSL::AST::NamedType::name):
(WebCore::WHLSL::AST::NamedType::isTypeDefinition const):
(WebCore::WHLSL::AST::NamedType::isStructureDefinition const):
(WebCore::WHLSL::AST::NamedType::isEnumerationDefinition const):
(WebCore::WHLSL::AST::NamedType::isNativeTypeDeclaration const):
(WebCore::WHLSL::AST::NamedType::unifyNode const):
(WebCore::WHLSL::AST::NamedType::unifyNode):
* Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h: Added.
(WebCore::WHLSL::AST::NativeFunctionDeclaration::NativeFunctionDeclaration):
(WebCore::WHLSL::AST::NativeFunctionDeclaration::restricted const):
* Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h: Added.
(WebCore::WHLSL::AST::NativeTypeDeclaration::NativeTypeDeclaration):
(WebCore::WHLSL::AST::NativeTypeDeclaration::name const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::name):
(WebCore::WHLSL::AST::NativeTypeDeclaration::typeArguments):
(WebCore::WHLSL::AST::NativeTypeDeclaration::isInt const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::isNumber const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::isFloating const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::isVector const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::isMatrix const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::isTexture const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::isSigned const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::std::function<bool const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::std::function<int64_t const):
(WebCore::WHLSL::AST::NativeTypeDeclaration::iterateAllValues):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setIsInt):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setIsNumber):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setIsFloating):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setIsVector):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setIsMatrix):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setIsTexture):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setIsSigned):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setCanRepresentInteger):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setCanRepresentUnsignedInteger):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setCanRepresentFloat):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setSuccessor):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setFormatValueFromInteger):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setFormatValueFromUnsignedInteger):
(WebCore::WHLSL::AST::NativeTypeDeclaration::setIterateAllValues):
* Modules/webgpu/WHLSL/AST/WHLSLNode.h: Added.
* Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.h: Added.
(WebCore::WHLSL::AST::NullLiteral::NullLiteral):
(WebCore::WHLSL::AST::NullLiteral::type):
(WebCore::WHLSL::AST::NullLiteral::clone const):
* Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.cpp: Added.
(WebCore::WHLSL::AST::NullLiteralType::canResolve const):
(WebCore::WHLSL::AST::NullLiteralType::conversionCost const):
* Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.h: Added.
* Modules/webgpu/WHLSL/AST/WHLSLNumThreadsFunctionAttribute.h: Added.
(WebCore::WHLSL::AST::NumThreadsFunctionAttribute::NumThreadsFunctionAttribute):
(WebCore::WHLSL::AST::NumThreadsFunctionAttribute::width const):
(WebCore::WHLSL::AST::NumThreadsFunctionAttribute::height const):
(WebCore::WHLSL::AST::NumThreadsFunctionAttribute::depth const):
* Modules/webgpu/WHLSL/AST/WHLSLPointerType.h: Added.
(WebCore::WHLSL::AST::PointerType::PointerType):
* Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h: Added.
(WebCore::WHLSL::AST::PropertyAccessExpression::PropertyAccessExpression):
(WebCore::WHLSL::AST::PropertyAccessExpression::possibleGetOverloads):
(WebCore::WHLSL::AST::PropertyAccessExpression::possibleSetOverloads):
(WebCore::WHLSL::AST::PropertyAccessExpression::possibleAndOverloads):
(WebCore::WHLSL::AST::PropertyAccessExpression::setPossibleGetOverloads):
(WebCore::WHLSL::AST::PropertyAccessExpression::setPossibleSetOverloads):
(WebCore::WHLSL::AST::PropertyAccessExpression::setPossibleAndOverloads):
(WebCore::WHLSL::AST::PropertyAccessExpression::base):
* Modules/webgpu/WHLSL/AST/WHLSLQualifier.h: Added.
* Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h: Added.
(WebCore::WHLSL::AST::ReadModifyWriteExpression::create):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::setNewValueExpression):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::setResultExpression):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::oldVariableReference):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::newVariableReference):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::lValue):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::oldValue):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::newValue):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::newValueExpression):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::resultExpression):
(WebCore::WHLSL::AST::ReadModifyWriteExpression::ReadModifyWriteExpression):
* Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h: Added.
(WebCore::WHLSL::AST::ReferenceType::ReferenceType):
(WebCore::WHLSL::AST::ReferenceType::addressSpace const):
(WebCore::WHLSL::AST::ReferenceType::elementType const):
(WebCore::WHLSL::AST::ReferenceType::elementType):
* Modules/webgpu/WHLSL/AST/WHLSLResolvableType.h: Added.
(WebCore::WHLSL::AST::ResolvableType::isFloatLiteralType const):
(WebCore::WHLSL::AST::ResolvableType::isIntegerLiteralType const):
(WebCore::WHLSL::AST::ResolvableType::isNullLiteralType const):
(WebCore::WHLSL::AST::ResolvableType::isUnsignedIntegerLiteralType const):
(WebCore::WHLSL::AST::ResolvableType::resolvedType const):
(WebCore::WHLSL::AST::ResolvableType::resolvedType):
(WebCore::WHLSL::AST::ResolvableType::resolve):
* Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp: Added.
(WebCore::WHLSL::AST::ResourceSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::ResourceSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.h: Added.
(WebCore::WHLSL::AST::ResourceSemantic::ResourceSemantic):
(WebCore::WHLSL::AST::ResourceSemantic::mode const):
(WebCore::WHLSL::AST::ResourceSemantic::index const):
(WebCore::WHLSL::AST::ResourceSemantic::space const):
(WebCore::WHLSL::AST::ResourceSemantic::operator== const):
(WebCore::WHLSL::AST::ResourceSemantic::operator!= const):
* Modules/webgpu/WHLSL/AST/WHLSLReturn.h: Added.
(WebCore::WHLSL::AST::Return::Return):
(WebCore::WHLSL::AST::Return::value):
(WebCore::WHLSL::AST::Return::function):
(WebCore::WHLSL::AST::Return::setFunction):
* Modules/webgpu/WHLSL/AST/WHLSLSemantic.h: Added.
* Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp: Added.
(WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.h: Added.
(WebCore::WHLSL::AST::SpecializationConstantSemantic::SpecializationConstantSemantic):
(WebCore::WHLSL::AST::SpecializationConstantSemantic::operator== const):
(WebCore::WHLSL::AST::SpecializationConstantSemantic::operator!= const):
* Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp: Added.
(WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableType const):
(WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableForShaderItemDirection const):
* Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.h: Added.
(WebCore::WHLSL::AST::StageInOutSemantic::StageInOutSemantic):
(WebCore::WHLSL::AST::StageInOutSemantic::index const):
(WebCore::WHLSL::AST::StageInOutSemantic::operator== const):
(WebCore::WHLSL::AST::StageInOutSemantic::operator!= const):
* Modules/webgpu/WHLSL/AST/WHLSLStatement.h: Added.
(WebCore::WHLSL::AST::Statement::Statement):
(WebCore::WHLSL::AST::Statement::isBlock const):
(WebCore::WHLSL::AST::Statement::isBreak const):
(WebCore::WHLSL::AST::Statement::isContinue const):
(WebCore::WHLSL::AST::Statement::isDoWhileLoop const):
(WebCore::WHLSL::AST::Statement::isEffectfulExpressionStatement const):
(WebCore::WHLSL::AST::Statement::isFallthrough const):
(WebCore::WHLSL::AST::Statement::isForLoop const):
(WebCore::WHLSL::AST::Statement::isIfStatement const):
(WebCore::WHLSL::AST::Statement::isReturn const):
(WebCore::WHLSL::AST::Statement::isSwitchCase const):
(WebCore::WHLSL::AST::Statement::isSwitchStatement const):
(WebCore::WHLSL::AST::Statement::isTrap const):
(WebCore::WHLSL::AST::Statement::isVariableDeclarationsStatement const):
(WebCore::WHLSL::AST::Statement::isWhileLoop const):
* Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h: Added.
(WebCore::WHLSL::AST::StructureDefinition::StructureDefinition):
(WebCore::WHLSL::AST::StructureDefinition::structureElements):
* Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h: Added.
(WebCore::WHLSL::AST::StructureElement::StructureElement):
(WebCore::WHLSL::AST::StructureElement::origin const):
(WebCore::WHLSL::AST::StructureElement::type):
(WebCore::WHLSL::AST::StructureElement::name):
(WebCore::WHLSL::AST::StructureElement::semantic):
* Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h: Added.
(WebCore::WHLSL::AST::SwitchCase::SwitchCase):
(WebCore::WHLSL::AST::SwitchCase::value):
(WebCore::WHLSL::AST::SwitchCase::block):
* Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h: Added.
(WebCore::WHLSL::AST::SwitchStatement::SwitchStatement):
(WebCore::WHLSL::AST::SwitchStatement::value):
(WebCore::WHLSL::AST::SwitchStatement::switchCases):
* Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h: Added.
(WebCore::WHLSL::AST::TernaryExpression::TernaryExpression):
(WebCore::WHLSL::AST::TernaryExpression::predicate):
(WebCore::WHLSL::AST::TernaryExpression::bodyExpression):
(WebCore::WHLSL::AST::TernaryExpression::elseExpression):
* Modules/webgpu/WHLSL/AST/WHLSLTrap.h: Added.
(WebCore::WHLSL::AST::Trap::Trap):
* Modules/webgpu/WHLSL/AST/WHLSLType.h: Added.
(WebCore::WHLSL::AST::Type::isNamedType const):
(WebCore::WHLSL::AST::Type::isUnnamedType const):
(WebCore::WHLSL::AST::Type::isResolvableType const):
* Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp: Added.
(WebCore::WHLSL::AST::clone):
* Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h: Added.
* Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h: Added.
(WebCore::WHLSL::AST::TypeDefinition::TypeDefinition):
(WebCore::WHLSL::AST::TypeDefinition::type):
* Modules/webgpu/WHLSL/AST/WHLSLTypeReference.cpp: Added.
(WebCore::WHLSL::AST::TypeReference::wrap):
* Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h: Added.
(WebCore::WHLSL::AST::TypeReference::TypeReference):
(WebCore::WHLSL::AST::TypeReference::name):
(WebCore::WHLSL::AST::TypeReference::typeArguments):
(WebCore::WHLSL::AST::TypeReference::resolvedType const):
(WebCore::WHLSL::AST::TypeReference::setResolvedType):
(WebCore::WHLSL::AST::TypeReference::cloneTypeReference const):
* Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h: Added.
(WebCore::WHLSL::AST::UnnamedType::UnnamedType):
(WebCore::WHLSL::AST::UnnamedType::isTypeReference const):
(WebCore::WHLSL::AST::UnnamedType::isPointerType const):
(WebCore::WHLSL::AST::UnnamedType::isArrayReferenceType const):
(WebCore::WHLSL::AST::UnnamedType::isArrayType const):
(WebCore::WHLSL::AST::UnnamedType::isReferenceType const):
(WebCore::WHLSL::AST::UnnamedType::unifyNode const):
(WebCore::WHLSL::AST::UnnamedType::unifyNode):
(WebCore::WHLSL::AST::UnnamedType::origin const):
* Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.cpp: Added.
(WebCore::WHLSL::AST::UnsignedIntegerLiteral::valueForSelectedType const):
* Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.h: Added.
(WebCore::WHLSL::AST::UnsignedIntegerLiteral::UnsignedIntegerLiteral):
(WebCore::WHLSL::AST::UnsignedIntegerLiteral::type):
(WebCore::WHLSL::AST::UnsignedIntegerLiteral::value const):
(WebCore::WHLSL::AST::UnsignedIntegerLiteral::clone const):
* Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp: Added.
(WebCore::WHLSL::AST::UnsignedIntegerLiteralType::UnsignedIntegerLiteralType):
(WebCore::WHLSL::AST::UnsignedIntegerLiteralType::canResolve const):
(WebCore::WHLSL::AST::UnsignedIntegerLiteralType::conversionCost const):
* Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.h: Added.
(WebCore::WHLSL::AST::UnsignedIntegerLiteralType::preferredType):
* Modules/webgpu/WHLSL/AST/WHLSLValue.h: Added.
(WebCore::WHLSL::AST::Value::Value):
* Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h: Added.
(WebCore::WHLSL::AST::VariableDeclaration::VariableDeclaration):
(WebCore::WHLSL::AST::VariableDeclaration::origin const):
(WebCore::WHLSL::AST::VariableDeclaration::name):
(WebCore::WHLSL::AST::VariableDeclaration::type const):
(WebCore::WHLSL::AST::VariableDeclaration::type):
(WebCore::WHLSL::AST::VariableDeclaration::semantic):
(WebCore::WHLSL::AST::VariableDeclaration::initializer):
* Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.h: Added.
(WebCore::WHLSL::AST::VariableDeclarationsStatement::VariableDeclarationsStatement):
(WebCore::WHLSL::AST::VariableDeclarationsStatement::variableDeclarations):
* Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h: Added.
(WebCore::WHLSL::AST::VariableReference::VariableReference):
(WebCore::WHLSL::AST::VariableReference::wrap):
(WebCore::WHLSL::AST::VariableReference::name):
(WebCore::WHLSL::AST::VariableReference::variable):
(WebCore::WHLSL::AST::VariableReference::setVariable):
* Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h: Added.
(WebCore::WHLSL::AST::WhileLoop::WhileLoop):
(WebCore::WHLSL::AST::WhileLoop::conditional):
(WebCore::WHLSL::AST::WhileLoop::body):
* Modules/webgpu/WHLSL/WHLSLLexer.cpp:
* Modules/webgpu/WHLSL/WHLSLParser.cpp: Added.
* Modules/webgpu/WHLSL/WHLSLParser.h: Added.
* Modules/webgpu/WHLSL/WHLSLProgram.h: Added.
(WebCore::WHLSL::Program::append):
(WebCore::WHLSL::Program::nameContext):
(WebCore::WHLSL::Program::intrinsics):
(WebCore::WHLSL::Program::typeDefinitions):
(WebCore::WHLSL::Program::structureDefinitions):
(WebCore::WHLSL::Program::enumerationDefinitions):
(WebCore::WHLSL::Program::functionDefinitions const):
(WebCore::WHLSL::Program::functionDefinitions):
(WebCore::WHLSL::Program::nativeFunctionDeclarations const):
(WebCore::WHLSL::Program::nativeFunctionDeclarations):
(WebCore::WHLSL::Program::nativeTypeDeclarations):

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

93 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseFunctionAttribute.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBlock.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBreak.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLContinue.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFallthrough.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLForLoop.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionAttribute.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNamedType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNode.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNumThreadsFunctionAttribute.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLQualifier.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResolvableType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSemantic.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTrap.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLValue.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h [new file with mode: 0644]
Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h [new file with mode: 0644]
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj

index 93be2a8..ee2b684 100644 (file)
@@ -1,3 +1,458 @@
+2019-01-10  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [WHLSL] Implement parser AST nodes
+        https://bugs.webkit.org/show_bug.cgi?id=192991
+
+        Reviewed by Alex Christensen.
+
+        This patch creates all the AST nodes which will be the result of running the parser.
+        This patch used to be a part of the "create a WHLSL parser" patch but I split them
+        out in order to aid reviewing.
+
+        The classes were mechanically created to match the result of the parser. There are
+        nodes for things like ForLoops, LogicalNotExpressions, DereferenceExpressions,
+        StructureDefinitions, and things like that. The classes don't actually have any logic
+        in them - they are currently just containers to hold the structure of the parsed
+        program. Some of these nodes (like constexprs) are just Variants of the various things
+        they can in the form of.
+
+        No new tests because the parser doesn't exist to create the new AST nodes yet.
+
+        * Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h: Added.
+        (WebCore::WHLSL::AST::ArrayReferenceType::ArrayReferenceType):
+        * Modules/webgpu/WHLSL/AST/WHLSLArrayType.h: Added.
+        (WebCore::WHLSL::AST::ArrayType::ArrayType):
+        (WebCore::WHLSL::AST::ArrayType::type const):
+        (WebCore::WHLSL::AST::ArrayType::type):
+        (WebCore::WHLSL::AST::ArrayType::numElements const):
+        * Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h: Added.
+        (WebCore::WHLSL::AST::AssignmentExpression::AssignmentExpression):
+        (WebCore::WHLSL::AST::AssignmentExpression::left):
+        (WebCore::WHLSL::AST::AssignmentExpression::right):
+        * Modules/webgpu/WHLSL/AST/WHLSLBaseFunctionAttribute.h: Added.
+        (WebCore::WHLSL::AST::BaseFunctionAttribute::BaseFunctionAttribute):
+        * Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h: Added.
+        (WebCore::WHLSL::AST::BaseSemantic::BaseSemantic):
+        * Modules/webgpu/WHLSL/AST/WHLSLBlock.h: Added.
+        (WebCore::WHLSL::AST::Block::Block):
+        (WebCore::WHLSL::AST::Block::statements):
+        * Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.h: Added.
+        (WebCore::WHLSL::AST::BooleanLiteral::BooleanLiteral):
+        (WebCore::WHLSL::AST::BooleanLiteral::value const):
+        (WebCore::WHLSL::AST::BooleanLiteral::clone const):
+        * Modules/webgpu/WHLSL/AST/WHLSLBreak.h: Added.
+        (WebCore::WHLSL::AST::Break::Break):
+        * Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp: Added.
+        (WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::BuiltInSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.h: Added.
+        (WebCore::WHLSL::AST::BuiltInSemantic::BuiltInSemantic):
+        (WebCore::WHLSL::AST::BuiltInSemantic::variable const):
+        (WebCore::WHLSL::AST::BuiltInSemantic::operator== const):
+        (WebCore::WHLSL::AST::BuiltInSemantic::operator!= const):
+        * Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h: Added.
+        (WebCore::WHLSL::AST::CallExpression::CallExpression):
+        (WebCore::WHLSL::AST::CallExpression::arguments):
+        (WebCore::WHLSL::AST::CallExpression::name):
+        (WebCore::WHLSL::AST::CallExpression::setCastData):
+        (WebCore::WHLSL::AST::CallExpression::isCast):
+        (WebCore::WHLSL::AST::CallExpression::castReturnType):
+        (WebCore::WHLSL::AST::CallExpression::hasOverloads const):
+        (WebCore::WHLSL::AST::CallExpression::overloads):
+        (WebCore::WHLSL::AST::CallExpression::setOverloads):
+        (WebCore::WHLSL::AST::CallExpression::setFunction):
+        * Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.h: Added.
+        (WebCore::WHLSL::AST::CommaExpression::CommaExpression):
+        (WebCore::WHLSL::AST::CommaExpression::list):
+        * Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h: Added.
+        (WebCore::WHLSL::AST::ConstantExpression::ConstantExpression):
+        (WebCore::WHLSL::AST::ConstantExpression::integerLiteral):
+        (WebCore::WHLSL::AST::ConstantExpression::visit):
+        (WebCore::WHLSL::AST::ConstantExpression::visit const):
+        (WebCore::WHLSL::AST::ConstantExpression::clone const):
+        (WebCore::WHLSL::AST::ConstantExpression::matches const):
+        * Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h: Added.
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::ConstantExpressionEnumerationMemberReference):
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::left const):
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::right const):
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::clone const):
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::enumerationDefinition):
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::enumerationDefinition const):
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::enumerationMember):
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::enumerationMember const):
+        (WebCore::WHLSL::AST::ConstantExpressionEnumerationMemberReference::setEnumerationMember):
+        * Modules/webgpu/WHLSL/AST/WHLSLContinue.h: Added.
+        (WebCore::WHLSL::AST::Continue::Continue):
+        * Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h: Added.
+        (WebCore::WHLSL::AST::DereferenceExpression::DereferenceExpression):
+        (WebCore::WHLSL::AST::DereferenceExpression::pointer):
+        * Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h: Added.
+        (WebCore::WHLSL::AST::DoWhileLoop::DoWhileLoop):
+        (WebCore::WHLSL::AST::DoWhileLoop::body):
+        (WebCore::WHLSL::AST::DoWhileLoop::conditional):
+        * Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h: Added.
+        (WebCore::WHLSL::AST::DotExpression::DotExpression):
+        (WebCore::WHLSL::AST::DotExpression::fieldName):
+        * Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h: Added.
+        (WebCore::WHLSL::AST::EffectfulExpressionStatement::EffectfulExpressionStatement):
+        (WebCore::WHLSL::AST::EffectfulExpressionStatement::effectfulExpression):
+        * Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h: Added.
+        (WebCore::WHLSL::AST::EnumerationDefinition::EnumerationDefinition):
+        (WebCore::WHLSL::AST::EnumerationDefinition::type):
+        (WebCore::WHLSL::AST::EnumerationDefinition::add):
+        (WebCore::WHLSL::AST::EnumerationDefinition::memberByName):
+        (WebCore::WHLSL::AST::EnumerationDefinition::enumerationMembers):
+        * Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h: Added.
+        (WebCore::WHLSL::AST::EnumerationMember::EnumerationMember):
+        (WebCore::WHLSL::AST::EnumerationMember::origin const):
+        (WebCore::WHLSL::AST::EnumerationMember::name):
+        (WebCore::WHLSL::AST::EnumerationMember::value):
+        (WebCore::WHLSL::AST::EnumerationMember::setValue):
+        * Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h: Added.
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::EnumerationMemberLiteral):
+        (WebCore::WHLSL::AST::EnumerationMemberLiteral::enumerationMember):
+        * Modules/webgpu/WHLSL/AST/WHLSLExpression.h: Added.
+        (WebCore::WHLSL::AST::Expression::Expression):
+        (WebCore::WHLSL::AST::Expression::origin const):
+        (WebCore::WHLSL::AST::Expression::isAssignmentExpression const):
+        (WebCore::WHLSL::AST::Expression::isBooleanLiteral const):
+        (WebCore::WHLSL::AST::Expression::isCallExpression const):
+        (WebCore::WHLSL::AST::Expression::isCommaExpression const):
+        (WebCore::WHLSL::AST::Expression::isDereferenceExpression const):
+        (WebCore::WHLSL::AST::Expression::isDotExpression const):
+        (WebCore::WHLSL::AST::Expression::isFloatLiteral const):
+        (WebCore::WHLSL::AST::Expression::isIndexExpression const):
+        (WebCore::WHLSL::AST::Expression::isIntegerLiteral const):
+        (WebCore::WHLSL::AST::Expression::isLogicalExpression const):
+        (WebCore::WHLSL::AST::Expression::isLogicalNotExpression const):
+        (WebCore::WHLSL::AST::Expression::isMakeArrayReferenceExpression const):
+        (WebCore::WHLSL::AST::Expression::isMakePointerExpression const):
+        (WebCore::WHLSL::AST::Expression::isNullLiteral const):
+        (WebCore::WHLSL::AST::Expression::isPropertyAccessExpression const):
+        (WebCore::WHLSL::AST::Expression::isReadModifyWriteExpression const):
+        (WebCore::WHLSL::AST::Expression::isTernaryExpression const):
+        (WebCore::WHLSL::AST::Expression::isUnsignedIntegerLiteral const):
+        (WebCore::WHLSL::AST::Expression::isVariableReference const):
+        (WebCore::WHLSL::AST::Expression::isEnumerationMemberLiteral const):
+        * Modules/webgpu/WHLSL/AST/WHLSLFallthrough.h: Added.
+        (WebCore::WHLSL::AST::Fallthrough::Fallthrough):
+        * Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.h: Added.
+        (WebCore::WHLSL::AST::FloatLiteral::FloatLiteral):
+        (WebCore::WHLSL::AST::FloatLiteral::type):
+        (WebCore::WHLSL::AST::FloatLiteral::value const):
+        (WebCore::WHLSL::AST::FloatLiteral::clone const):
+        * Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp: Added.
+        (WebCore::WHLSL::AST::FloatLiteralType::FloatLiteralType):
+        (WebCore::WHLSL::AST::FloatLiteralType::canResolve const):
+        (WebCore::WHLSL::AST::FloatLiteralType::conversionCost const):
+        * Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.h: Added.
+        (WebCore::WHLSL::AST::FloatLiteralType::preferredType):
+        * Modules/webgpu/WHLSL/AST/WHLSLForLoop.h: Added.
+        (WebCore::WHLSL::AST::ForLoop::ForLoop):
+        (WebCore::WHLSL::AST::ForLoop::~ForLoop):
+        (WebCore::WHLSL::AST::ForLoop::initialization):
+        (WebCore::WHLSL::AST::ForLoop::condition):
+        (WebCore::WHLSL::AST::ForLoop::increment):
+        (WebCore::WHLSL::AST::ForLoop::body):
+        * Modules/webgpu/WHLSL/AST/WHLSLFunctionAttribute.h: Added.
+        * Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h: Added.
+        (WebCore::WHLSL::AST::FunctionDeclaration::FunctionDeclaration):
+        (WebCore::WHLSL::AST::FunctionDeclaration::isFunctionDefinition const):
+        (WebCore::WHLSL::AST::FunctionDeclaration::isNativeFunctionDeclaration const):
+        (WebCore::WHLSL::AST::FunctionDeclaration::attributeBlock):
+        (WebCore::WHLSL::AST::FunctionDeclaration::entryPointType const):
+        (WebCore::WHLSL::AST::FunctionDeclaration::type const):
+        (WebCore::WHLSL::AST::FunctionDeclaration::type):
+        (WebCore::WHLSL::AST::FunctionDeclaration::name const):
+        (WebCore::WHLSL::AST::FunctionDeclaration::isCast const):
+        (WebCore::WHLSL::AST::FunctionDeclaration::parameters const):
+        (WebCore::WHLSL::AST::FunctionDeclaration::parameters):
+        (WebCore::WHLSL::AST::FunctionDeclaration::semantic):
+        (WebCore::WHLSL::AST::FunctionDeclaration::isOperator const):
+        * Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h: Added.
+        (WebCore::WHLSL::AST::FunctionDefinition::FunctionDefinition):
+        (WebCore::WHLSL::AST::FunctionDefinition::block):
+        (WebCore::WHLSL::AST::FunctionDefinition::restricted const):
+        * Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h: Added.
+        (WebCore::WHLSL::AST::IfStatement::IfStatement):
+        (WebCore::WHLSL::AST::IfStatement::conditional):
+        (WebCore::WHLSL::AST::IfStatement::body):
+        (WebCore::WHLSL::AST::IfStatement::elseBody):
+        * Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h: Added.
+        (WebCore::WHLSL::AST::IndexExpression::IndexExpression):
+        (WebCore::WHLSL::AST::IndexExpression::indexExpression):
+        * Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.cpp: Added.
+        (WebCore::WHLSL::AST::IntegerLiteral::valueForSelectedType const):
+        * Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.h: Added.
+        (WebCore::WHLSL::AST::IntegerLiteral::IntegerLiteral):
+        (WebCore::WHLSL::AST::IntegerLiteral::type):
+        (WebCore::WHLSL::AST::IntegerLiteral::value const):
+        (WebCore::WHLSL::AST::IntegerLiteral::clone const):
+        * Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp: Added.
+        (WebCore::WHLSL::AST::IntegerLiteralType::IntegerLiteralType):
+        (WebCore::WHLSL::AST::IntegerLiteralType::canResolve const):
+        (WebCore::WHLSL::AST::IntegerLiteralType::conversionCost const):
+        * Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.h: Added.
+        (WebCore::WHLSL::AST::IntegerLiteralType::preferredType):
+        * Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h: Added.
+        (WebCore::WHLSL::AST::LogicalExpression::LogicalExpression):
+        (WebCore::WHLSL::AST::LogicalExpression::type const):
+        (WebCore::WHLSL::AST::LogicalExpression::left):
+        (WebCore::WHLSL::AST::LogicalExpression::right):
+        * Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h: Added.
+        (WebCore::WHLSL::AST::LogicalNotExpression::LogicalNotExpression):
+        (WebCore::WHLSL::AST::LogicalNotExpression::operand):
+        * Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h: Added.
+        (WebCore::WHLSL::AST::MakeArrayReferenceExpression::MakeArrayReferenceExpression):
+        (WebCore::WHLSL::AST::MakeArrayReferenceExpression::lValue):
+        * Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h: Added.
+        (WebCore::WHLSL::AST::MakePointerExpression::MakePointerExpression):
+        (WebCore::WHLSL::AST::MakePointerExpression::lValue):
+        * Modules/webgpu/WHLSL/AST/WHLSLNamedType.h: Added.
+        (WebCore::WHLSL::AST::NamedType::NamedType):
+        (WebCore::WHLSL::AST::NamedType::origin const):
+        (WebCore::WHLSL::AST::NamedType::name):
+        (WebCore::WHLSL::AST::NamedType::isTypeDefinition const):
+        (WebCore::WHLSL::AST::NamedType::isStructureDefinition const):
+        (WebCore::WHLSL::AST::NamedType::isEnumerationDefinition const):
+        (WebCore::WHLSL::AST::NamedType::isNativeTypeDeclaration const):
+        (WebCore::WHLSL::AST::NamedType::unifyNode const):
+        (WebCore::WHLSL::AST::NamedType::unifyNode):
+        * Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h: Added.
+        (WebCore::WHLSL::AST::NativeFunctionDeclaration::NativeFunctionDeclaration):
+        (WebCore::WHLSL::AST::NativeFunctionDeclaration::restricted const):
+        * Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h: Added.
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::NativeTypeDeclaration):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::name const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::name):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::typeArguments):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::isInt const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::isNumber const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::isFloating const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::isVector const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::isMatrix const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::isTexture const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::isSigned const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::std::function<bool const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::std::function<int64_t const):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::iterateAllValues):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsInt):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsNumber):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsFloating):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsVector):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsMatrix):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsTexture):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsSigned):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setCanRepresentInteger):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setCanRepresentUnsignedInteger):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setCanRepresentFloat):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setSuccessor):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setFormatValueFromInteger):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setFormatValueFromUnsignedInteger):
+        (WebCore::WHLSL::AST::NativeTypeDeclaration::setIterateAllValues):
+        * Modules/webgpu/WHLSL/AST/WHLSLNode.h: Added.
+        * Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.h: Added.
+        (WebCore::WHLSL::AST::NullLiteral::NullLiteral):
+        (WebCore::WHLSL::AST::NullLiteral::type):
+        (WebCore::WHLSL::AST::NullLiteral::clone const):
+        * Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.cpp: Added.
+        (WebCore::WHLSL::AST::NullLiteralType::canResolve const):
+        (WebCore::WHLSL::AST::NullLiteralType::conversionCost const):
+        * Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.h: Added.
+        * Modules/webgpu/WHLSL/AST/WHLSLNumThreadsFunctionAttribute.h: Added.
+        (WebCore::WHLSL::AST::NumThreadsFunctionAttribute::NumThreadsFunctionAttribute):
+        (WebCore::WHLSL::AST::NumThreadsFunctionAttribute::width const):
+        (WebCore::WHLSL::AST::NumThreadsFunctionAttribute::height const):
+        (WebCore::WHLSL::AST::NumThreadsFunctionAttribute::depth const):
+        * Modules/webgpu/WHLSL/AST/WHLSLPointerType.h: Added.
+        (WebCore::WHLSL::AST::PointerType::PointerType):
+        * Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h: Added.
+        (WebCore::WHLSL::AST::PropertyAccessExpression::PropertyAccessExpression):
+        (WebCore::WHLSL::AST::PropertyAccessExpression::possibleGetOverloads):
+        (WebCore::WHLSL::AST::PropertyAccessExpression::possibleSetOverloads):
+        (WebCore::WHLSL::AST::PropertyAccessExpression::possibleAndOverloads):
+        (WebCore::WHLSL::AST::PropertyAccessExpression::setPossibleGetOverloads):
+        (WebCore::WHLSL::AST::PropertyAccessExpression::setPossibleSetOverloads):
+        (WebCore::WHLSL::AST::PropertyAccessExpression::setPossibleAndOverloads):
+        (WebCore::WHLSL::AST::PropertyAccessExpression::base):
+        * Modules/webgpu/WHLSL/AST/WHLSLQualifier.h: Added.
+        * Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h: Added.
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::create):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::setNewValueExpression):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::setResultExpression):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::oldVariableReference):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::newVariableReference):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::lValue):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::oldValue):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::newValue):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::newValueExpression):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::resultExpression):
+        (WebCore::WHLSL::AST::ReadModifyWriteExpression::ReadModifyWriteExpression):
+        * Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h: Added.
+        (WebCore::WHLSL::AST::ReferenceType::ReferenceType):
+        (WebCore::WHLSL::AST::ReferenceType::addressSpace const):
+        (WebCore::WHLSL::AST::ReferenceType::elementType const):
+        (WebCore::WHLSL::AST::ReferenceType::elementType):
+        * Modules/webgpu/WHLSL/AST/WHLSLResolvableType.h: Added.
+        (WebCore::WHLSL::AST::ResolvableType::isFloatLiteralType const):
+        (WebCore::WHLSL::AST::ResolvableType::isIntegerLiteralType const):
+        (WebCore::WHLSL::AST::ResolvableType::isNullLiteralType const):
+        (WebCore::WHLSL::AST::ResolvableType::isUnsignedIntegerLiteralType const):
+        (WebCore::WHLSL::AST::ResolvableType::resolvedType const):
+        (WebCore::WHLSL::AST::ResolvableType::resolvedType):
+        (WebCore::WHLSL::AST::ResolvableType::resolve):
+        * Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp: Added.
+        (WebCore::WHLSL::AST::ResourceSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::ResourceSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.h: Added.
+        (WebCore::WHLSL::AST::ResourceSemantic::ResourceSemantic):
+        (WebCore::WHLSL::AST::ResourceSemantic::mode const):
+        (WebCore::WHLSL::AST::ResourceSemantic::index const):
+        (WebCore::WHLSL::AST::ResourceSemantic::space const):
+        (WebCore::WHLSL::AST::ResourceSemantic::operator== const):
+        (WebCore::WHLSL::AST::ResourceSemantic::operator!= const):
+        * Modules/webgpu/WHLSL/AST/WHLSLReturn.h: Added.
+        (WebCore::WHLSL::AST::Return::Return):
+        (WebCore::WHLSL::AST::Return::value):
+        (WebCore::WHLSL::AST::Return::function):
+        (WebCore::WHLSL::AST::Return::setFunction):
+        * Modules/webgpu/WHLSL/AST/WHLSLSemantic.h: Added.
+        * Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp: Added.
+        (WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::SpecializationConstantSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.h: Added.
+        (WebCore::WHLSL::AST::SpecializationConstantSemantic::SpecializationConstantSemantic):
+        (WebCore::WHLSL::AST::SpecializationConstantSemantic::operator== const):
+        (WebCore::WHLSL::AST::SpecializationConstantSemantic::operator!= const):
+        * Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp: Added.
+        (WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableType const):
+        (WebCore::WHLSL::AST::StageInOutSemantic::isAcceptableForShaderItemDirection const):
+        * Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.h: Added.
+        (WebCore::WHLSL::AST::StageInOutSemantic::StageInOutSemantic):
+        (WebCore::WHLSL::AST::StageInOutSemantic::index const):
+        (WebCore::WHLSL::AST::StageInOutSemantic::operator== const):
+        (WebCore::WHLSL::AST::StageInOutSemantic::operator!= const):
+        * Modules/webgpu/WHLSL/AST/WHLSLStatement.h: Added.
+        (WebCore::WHLSL::AST::Statement::Statement):
+        (WebCore::WHLSL::AST::Statement::isBlock const):
+        (WebCore::WHLSL::AST::Statement::isBreak const):
+        (WebCore::WHLSL::AST::Statement::isContinue const):
+        (WebCore::WHLSL::AST::Statement::isDoWhileLoop const):
+        (WebCore::WHLSL::AST::Statement::isEffectfulExpressionStatement const):
+        (WebCore::WHLSL::AST::Statement::isFallthrough const):
+        (WebCore::WHLSL::AST::Statement::isForLoop const):
+        (WebCore::WHLSL::AST::Statement::isIfStatement const):
+        (WebCore::WHLSL::AST::Statement::isReturn const):
+        (WebCore::WHLSL::AST::Statement::isSwitchCase const):
+        (WebCore::WHLSL::AST::Statement::isSwitchStatement const):
+        (WebCore::WHLSL::AST::Statement::isTrap const):
+        (WebCore::WHLSL::AST::Statement::isVariableDeclarationsStatement const):
+        (WebCore::WHLSL::AST::Statement::isWhileLoop const):
+        * Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h: Added.
+        (WebCore::WHLSL::AST::StructureDefinition::StructureDefinition):
+        (WebCore::WHLSL::AST::StructureDefinition::structureElements):
+        * Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h: Added.
+        (WebCore::WHLSL::AST::StructureElement::StructureElement):
+        (WebCore::WHLSL::AST::StructureElement::origin const):
+        (WebCore::WHLSL::AST::StructureElement::type):
+        (WebCore::WHLSL::AST::StructureElement::name):
+        (WebCore::WHLSL::AST::StructureElement::semantic):
+        * Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h: Added.
+        (WebCore::WHLSL::AST::SwitchCase::SwitchCase):
+        (WebCore::WHLSL::AST::SwitchCase::value):
+        (WebCore::WHLSL::AST::SwitchCase::block):
+        * Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h: Added.
+        (WebCore::WHLSL::AST::SwitchStatement::SwitchStatement):
+        (WebCore::WHLSL::AST::SwitchStatement::value):
+        (WebCore::WHLSL::AST::SwitchStatement::switchCases):
+        * Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h: Added.
+        (WebCore::WHLSL::AST::TernaryExpression::TernaryExpression):
+        (WebCore::WHLSL::AST::TernaryExpression::predicate):
+        (WebCore::WHLSL::AST::TernaryExpression::bodyExpression):
+        (WebCore::WHLSL::AST::TernaryExpression::elseExpression):
+        * Modules/webgpu/WHLSL/AST/WHLSLTrap.h: Added.
+        (WebCore::WHLSL::AST::Trap::Trap):
+        * Modules/webgpu/WHLSL/AST/WHLSLType.h: Added.
+        (WebCore::WHLSL::AST::Type::isNamedType const):
+        (WebCore::WHLSL::AST::Type::isUnnamedType const):
+        (WebCore::WHLSL::AST::Type::isResolvableType const):
+        * Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp: Added.
+        (WebCore::WHLSL::AST::clone):
+        * Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h: Added.
+        * Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h: Added.
+        (WebCore::WHLSL::AST::TypeDefinition::TypeDefinition):
+        (WebCore::WHLSL::AST::TypeDefinition::type):
+        * Modules/webgpu/WHLSL/AST/WHLSLTypeReference.cpp: Added.
+        (WebCore::WHLSL::AST::TypeReference::wrap):
+        * Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h: Added.
+        (WebCore::WHLSL::AST::TypeReference::TypeReference):
+        (WebCore::WHLSL::AST::TypeReference::name):
+        (WebCore::WHLSL::AST::TypeReference::typeArguments):
+        (WebCore::WHLSL::AST::TypeReference::resolvedType const):
+        (WebCore::WHLSL::AST::TypeReference::setResolvedType):
+        (WebCore::WHLSL::AST::TypeReference::cloneTypeReference const):
+        * Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h: Added.
+        (WebCore::WHLSL::AST::UnnamedType::UnnamedType):
+        (WebCore::WHLSL::AST::UnnamedType::isTypeReference const):
+        (WebCore::WHLSL::AST::UnnamedType::isPointerType const):
+        (WebCore::WHLSL::AST::UnnamedType::isArrayReferenceType const):
+        (WebCore::WHLSL::AST::UnnamedType::isArrayType const):
+        (WebCore::WHLSL::AST::UnnamedType::isReferenceType const):
+        (WebCore::WHLSL::AST::UnnamedType::unifyNode const):
+        (WebCore::WHLSL::AST::UnnamedType::unifyNode):
+        (WebCore::WHLSL::AST::UnnamedType::origin const):
+        * Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.cpp: Added.
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteral::valueForSelectedType const):
+        * Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.h: Added.
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteral::UnsignedIntegerLiteral):
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteral::type):
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteral::value const):
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteral::clone const):
+        * Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp: Added.
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteralType::UnsignedIntegerLiteralType):
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteralType::canResolve const):
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteralType::conversionCost const):
+        * Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.h: Added.
+        (WebCore::WHLSL::AST::UnsignedIntegerLiteralType::preferredType):
+        * Modules/webgpu/WHLSL/AST/WHLSLValue.h: Added.
+        (WebCore::WHLSL::AST::Value::Value):
+        * Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h: Added.
+        (WebCore::WHLSL::AST::VariableDeclaration::VariableDeclaration):
+        (WebCore::WHLSL::AST::VariableDeclaration::origin const):
+        (WebCore::WHLSL::AST::VariableDeclaration::name):
+        (WebCore::WHLSL::AST::VariableDeclaration::type const):
+        (WebCore::WHLSL::AST::VariableDeclaration::type):
+        (WebCore::WHLSL::AST::VariableDeclaration::semantic):
+        (WebCore::WHLSL::AST::VariableDeclaration::initializer):
+        * Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.h: Added.
+        (WebCore::WHLSL::AST::VariableDeclarationsStatement::VariableDeclarationsStatement):
+        (WebCore::WHLSL::AST::VariableDeclarationsStatement::variableDeclarations):
+        * Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h: Added.
+        (WebCore::WHLSL::AST::VariableReference::VariableReference):
+        (WebCore::WHLSL::AST::VariableReference::wrap):
+        (WebCore::WHLSL::AST::VariableReference::name):
+        (WebCore::WHLSL::AST::VariableReference::variable):
+        (WebCore::WHLSL::AST::VariableReference::setVariable):
+        * Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h: Added.
+        (WebCore::WHLSL::AST::WhileLoop::WhileLoop):
+        (WebCore::WHLSL::AST::WhileLoop::conditional):
+        (WebCore::WHLSL::AST::WhileLoop::body):
+        * Modules/webgpu/WHLSL/WHLSLLexer.cpp:
+        * Modules/webgpu/WHLSL/WHLSLParser.cpp: Added.
+        * Modules/webgpu/WHLSL/WHLSLParser.h: Added.
+        * Modules/webgpu/WHLSL/WHLSLProgram.h: Added.
+        (WebCore::WHLSL::Program::append):
+        (WebCore::WHLSL::Program::nameContext):
+        (WebCore::WHLSL::Program::intrinsics):
+        (WebCore::WHLSL::Program::typeDefinitions):
+        (WebCore::WHLSL::Program::structureDefinitions):
+        (WebCore::WHLSL::Program::enumerationDefinitions):
+        (WebCore::WHLSL::Program::functionDefinitions const):
+        (WebCore::WHLSL::Program::functionDefinitions):
+        (WebCore::WHLSL::Program::nativeFunctionDeclarations const):
+        (WebCore::WHLSL::Program::nativeFunctionDeclarations):
+        (WebCore::WHLSL::Program::nativeTypeDeclarations):
+
 2019-01-10  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Bindings generator emits incorrect code when using VoidCallback as an IDL dictionary attribute
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h
new file mode 100644 (file)
index 0000000..8e3dc88
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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 "WHLSLReferenceType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class ArrayReferenceType : public ReferenceType {
+public:
+    ArrayReferenceType(Lexer::Token&& origin, AddressSpace addressSpace, UniqueRef<UnnamedType>&& elementType)
+        : ReferenceType(WTFMove(origin), addressSpace, WTFMove(elementType))
+    {
+    }
+
+    virtual ~ArrayReferenceType() = default;
+
+    ArrayReferenceType(const ArrayReferenceType&) = delete;
+    ArrayReferenceType(ArrayReferenceType&&) = default;
+
+    bool isArrayReferenceType() const override { return true; }
+
+    UniqueRef<UnnamedType> clone() const override
+    {
+        return makeUniqueRef<ArrayReferenceType>(Lexer::Token(origin()), addressSpace(), elementType().clone());
+    }
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(ArrayReferenceType, isArrayReferenceType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h
new file mode 100644 (file)
index 0000000..89794b8
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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 "WHLSLTypeArgument.h"
+#include "WHLSLUnnamedType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class ArrayType : public UnnamedType {
+public:
+    ArrayType(Lexer::Token&& origin, UniqueRef<UnnamedType>&& elementType, unsigned numElements)
+        : UnnamedType(WTFMove(origin))
+        , m_elementType(WTFMove(elementType))
+        , m_numElements(numElements)
+    {
+    }
+
+    virtual ~ArrayType() = default;
+
+    ArrayType(const ArrayType&) = delete;
+    ArrayType(ArrayType&&) = default;
+
+    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); }
+    unsigned numElements() const { return m_numElements; }
+
+    UniqueRef<UnnamedType> clone() const override
+    {
+        return makeUniqueRef<ArrayType>(Lexer::Token(origin()), m_elementType->clone(), m_numElements);
+    }
+
+private:
+    UniqueRef<UnnamedType> m_elementType;
+    unsigned m_numElements;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(ArrayType, isArrayType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAssignmentExpression.h
new file mode 100644 (file)
index 0000000..79eb1ae
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class AssignmentExpression : public Expression {
+public:
+    AssignmentExpression(Lexer::Token&& origin, UniqueRef<Expression>&& left, UniqueRef<Expression>&& right)
+        : Expression(WTFMove(origin))
+        , m_left(WTFMove(left))
+        , m_right(WTFMove(right))
+    {
+    }
+
+    virtual ~AssignmentExpression() = default;
+
+    AssignmentExpression(const AssignmentExpression&) = delete;
+    AssignmentExpression(AssignmentExpression&&) = default;
+
+    bool isAssignmentExpression() const override { return true; }
+
+    Expression& left() { return static_cast<Expression&>(m_left); }
+    Expression& right() { return static_cast<Expression&>(m_right); }
+
+private:
+    UniqueRef<Expression> m_left;
+    UniqueRef<Expression> m_right;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(AssignmentExpression, isAssignmentExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseFunctionAttribute.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseFunctionAttribute.h
new file mode 100644 (file)
index 0000000..2731ed1
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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 "WHLSLNode.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class BaseFunctionAttribute : public Node {
+public:
+    BaseFunctionAttribute(Lexer::Token&& origin)
+        : m_origin(WTFMove(origin))
+    {
+    }
+
+    virtual ~BaseFunctionAttribute() = default;
+
+    BaseFunctionAttribute(const BaseFunctionAttribute&) = delete;
+    BaseFunctionAttribute(BaseFunctionAttribute&&) = default;
+
+private:
+    Lexer::Token m_origin;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBaseSemantic.h
new file mode 100644 (file)
index 0000000..fe99da2
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 "WHLSLNode.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+class Intrinsics;
+
+namespace AST {
+
+class FunctionDefinition;
+class UnnamedType;
+
+class BaseSemantic : public Node {
+public:
+    BaseSemantic(Lexer::Token&& origin)
+        : m_origin(WTFMove(origin))
+    {
+    }
+
+    virtual ~BaseSemantic() = default;
+
+    BaseSemantic(const BaseSemantic&) = delete;
+    BaseSemantic(BaseSemantic&&) = default;
+
+    virtual bool isAcceptableType(const UnnamedType&, const Intrinsics&) const = 0;
+
+    enum class ShaderItemDirection : uint8_t {
+        Input,
+        Output
+    };
+    virtual bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const = 0;
+
+private:
+    Lexer::Token m_origin;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBlock.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBlock.h
new file mode 100644 (file)
index 0000000..e42a178
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 "WHLSLStatement.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Block : public Statement {
+public:
+    Block(Lexer::Token&& origin, Statements&& statements)
+        : Statement(WTFMove(origin))
+        , m_statements(WTFMove(statements))
+    {
+    }
+
+    virtual ~Block() = default;
+
+    Block(const Block&) = delete;
+    Block(Block&&) = default;
+
+    Statements& statements() { return m_statements; }
+
+    bool isBlock() const override { return true; }
+
+private:
+    Statements m_statements;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Block, isBlock())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBooleanLiteral.h
new file mode 100644 (file)
index 0000000..123d945
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class BooleanLiteral : public Expression {
+public:
+    BooleanLiteral(Lexer::Token&& origin, bool value)
+        : Expression(WTFMove(origin))
+        , m_value(value)
+    {
+    }
+
+    virtual ~BooleanLiteral() = default;
+
+    BooleanLiteral(const BooleanLiteral&) = delete;
+    BooleanLiteral(BooleanLiteral&&) = default;
+
+    BooleanLiteral& operator=(const BooleanLiteral&) = delete;
+    BooleanLiteral& operator=(BooleanLiteral&&) = default;
+
+    bool value() const { return m_value; }
+
+    bool isBooleanLiteral() const override { return true; }
+
+    BooleanLiteral clone() const
+    {
+        return BooleanLiteral(Lexer::Token(origin()), m_value);
+    }
+
+private:
+    bool m_value;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(BooleanLiteral, isBooleanLiteral())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBreak.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBreak.h
new file mode 100644 (file)
index 0000000..965c00f
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 "WHLSLStatement.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Break : public Statement {
+public:
+    Break(Lexer::Token&& origin)
+        : Statement(WTFMove(origin))
+    {
+    }
+
+    virtual ~Break() = default;
+
+    Break(const Break&) = delete;
+    Break(Break&&) = default;
+
+    bool isBreak() const override { return true; }
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Break, isBreak())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp
new file mode 100644 (file)
index 0000000..ae3c78e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLBuiltInSemantic.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLFunctionDefinition.h"
+#include "WHLSLTypeReference.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.h
new file mode 100644 (file)
index 0000000..ebde1d0
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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 "WHLSLBaseSemantic.h"
+#include "WHLSLLexer.h"
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class BuiltInSemantic : public BaseSemantic {
+public:
+    enum class Variable : uint8_t {
+        SVInstanceID,
+        SVVertexID,
+        PSize,
+        SVPosition,
+        SVIsFrontFace,
+        SVSampleIndex,
+        SVInnerCoverage,
+        SVTarget,
+        SVDepth,
+        SVCoverage,
+        SVDispatchThreadID,
+        SVGroupID,
+        SVGroupIndex,
+        SVGroupThreadID
+    };
+
+    BuiltInSemantic(Lexer::Token&& origin, Variable variable, Optional<unsigned>&& targetIndex = WTF::nullopt)
+        : BaseSemantic(WTFMove(origin))
+        , m_variable(variable)
+        , m_targetIndex(WTFMove(targetIndex))
+    {
+    }
+
+    virtual ~BuiltInSemantic() = default;
+
+    BuiltInSemantic(const BuiltInSemantic&) = delete;
+    BuiltInSemantic(BuiltInSemantic&&) = default;
+
+    Variable variable() const { return m_variable; }
+
+    bool operator==(const BuiltInSemantic& other) const
+    {
+        return m_variable == other.m_variable && m_targetIndex == other.m_targetIndex;
+    }
+
+    bool operator!=(const BuiltInSemantic& other) const
+    {
+        return !(*this == other);
+    }
+
+    bool isAcceptableType(const UnnamedType&, const Intrinsics&) const override;
+    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const override;
+
+private:
+    Variable m_variable;
+    Optional<unsigned> m_targetIndex;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h
new file mode 100644 (file)
index 0000000..0446ada
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLFunctionDeclaration.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class NamedType;
+
+class CallExpression : public Expression {
+public:
+    CallExpression(Lexer::Token&& origin, String&& name, Vector<UniqueRef<Expression>>&& arguments)
+        : Expression(WTFMove(origin))
+        , m_name(WTFMove(name))
+        , m_arguments(WTFMove(arguments))
+    {
+    }
+
+    virtual ~CallExpression() = default;
+
+    CallExpression(const CallExpression&) = delete;
+    CallExpression(CallExpression&&) = default;
+
+    bool isCallExpression() const override { return true; }
+
+    Vector<UniqueRef<Expression>>& arguments() { return m_arguments; }
+
+    String& name() { return m_name; }
+
+    void setCastData(NamedType& namedType)
+    {
+        m_castReturnType = { namedType };
+    }
+
+    bool isCast() { return static_cast<bool>(m_castReturnType); }
+    Optional<std::reference_wrapper<NamedType>>& castReturnType() { return m_castReturnType; }
+    bool hasOverloads() const { return static_cast<bool>(m_overloads); }
+    Optional<Vector<std::reference_wrapper<FunctionDeclaration>, 1>>& overloads() { return m_overloads; }
+    void setOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads)
+    {
+        assert(!hasOverloads());
+        m_overloads = overloads;
+    }
+
+    void setFunction(FunctionDeclaration& functionDeclaration)
+    {
+        assert(!m_function);
+        m_function = &functionDeclaration;
+    }
+
+private:
+    String m_name;
+    Vector<UniqueRef<Expression>> m_arguments;
+    Optional<Vector<std::reference_wrapper<FunctionDeclaration>, 1>> m_overloads;
+    FunctionDeclaration* m_function { nullptr };
+    Optional<std::reference_wrapper<NamedType>> m_castReturnType { WTF::nullopt };
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(CallExpression, isCallExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCommaExpression.h
new file mode 100644 (file)
index 0000000..9702c28
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class CommaExpression : public Expression {
+public:
+    CommaExpression(Lexer::Token&& origin, Vector<UniqueRef<Expression>>&& list)
+        : Expression(WTFMove(origin))
+        , m_list(WTFMove(list))
+    {
+    }
+
+    virtual ~CommaExpression() = default;
+
+    CommaExpression(const CommaExpression&) = delete;
+    CommaExpression(CommaExpression&&) = default;
+
+    bool isCommaExpression() const override { return true; }
+
+    Vector<UniqueRef<Expression>>& list() { return m_list; }
+
+private:
+    Vector<UniqueRef<Expression>> m_list;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(CommaExpression, isCommaExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpression.h
new file mode 100644 (file)
index 0000000..df68c2a
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * 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 "WHLSLBooleanLiteral.h"
+#include "WHLSLConstantExpressionEnumerationMemberReference.h"
+#include "WHLSLFloatLiteral.h"
+#include "WHLSLIntegerLiteral.h"
+#include "WHLSLNullLiteral.h"
+#include "WHLSLUnsignedIntegerLiteral.h"
+#include <wtf/Variant.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+// FIXME: macOS Sierra doesn't seem to support putting Variants inside Variants,
+// so this is a wrapper class to make sure that doesn't happen. As soon as we don't
+// have to support Sierra, this can be migrated to a Variant proper.
+class ConstantExpression {
+public:
+    ConstantExpression(IntegerLiteral&& integerLiteral)
+        : m_variant(WTFMove(integerLiteral))
+    {
+    }
+
+    ConstantExpression(UnsignedIntegerLiteral&& unsignedIntegerLiteral)
+        : m_variant(WTFMove(unsignedIntegerLiteral))
+    {
+    }
+
+    ConstantExpression(FloatLiteral&& floatLiteral)
+        : m_variant(WTFMove(floatLiteral))
+    {
+    }
+
+    ConstantExpression(NullLiteral&& nullLiteral)
+        : m_variant(WTFMove(nullLiteral))
+    {
+    }
+
+    ConstantExpression(BooleanLiteral&& booleanLiteral)
+        : m_variant(WTFMove(booleanLiteral))
+    {
+    }
+
+    ConstantExpression(ConstantExpressionEnumerationMemberReference&& constantExpressionEnumerationMemberReference)
+        : m_variant(WTFMove(constantExpressionEnumerationMemberReference))
+    {
+    }
+
+    ConstantExpression(const ConstantExpression&) = delete;
+    ConstantExpression(ConstantExpression&&) = default;
+
+    ConstantExpression& operator=(const ConstantExpression&) = delete;
+    ConstantExpression& operator=(ConstantExpression&&) = default;
+
+    IntegerLiteral& integerLiteral()
+    {
+        ASSERT(WTF::holds_alternative<IntegerLiteral>(m_variant));
+        return WTF::get<IntegerLiteral>(m_variant);
+    }
+
+    template<typename T> void visit(T&& t)
+    {
+        WTF::visit(WTFMove(t), m_variant);
+    }
+
+    template<typename T> void visit(T&& t) const
+    {
+        WTF::visit(WTFMove(t), m_variant);
+    }
+
+    ConstantExpression clone() const
+    {
+        return WTF::visit(WTF::makeVisitor([&](const IntegerLiteral& integerLiteral) -> ConstantExpression {
+            return integerLiteral.clone();
+        }, [&](const UnsignedIntegerLiteral& unsignedIntegerLiteral) -> ConstantExpression {
+            return unsignedIntegerLiteral.clone();
+        }, [&](const FloatLiteral& floatLiteral) -> ConstantExpression {
+            return floatLiteral.clone();
+        }, [&](const NullLiteral& nullLiteral) -> ConstantExpression {
+            return nullLiteral.clone();
+        }, [&](const BooleanLiteral& booleanLiteral) -> ConstantExpression {
+            return booleanLiteral.clone();
+        }, [&](const ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) -> ConstantExpression {
+            return constantExpressionEnumerationMemberReference.clone();
+        }), m_variant);
+    }
+
+    bool matches(const ConstantExpression& other) const
+    {
+        Optional<bool> result;
+        double value;
+        visit(WTF::makeVisitor([&](const IntegerLiteral& integerLiteral) {
+            value = integerLiteral.value();
+        }, [&](const UnsignedIntegerLiteral& unsignedIntegerLiteral) {
+            value = unsignedIntegerLiteral.value();
+        }, [&](const FloatLiteral& floatLiteral) {
+            value = floatLiteral.value();
+        }, [&](const NullLiteral&) {
+            result = WTF::holds_alternative<NullLiteral>(other.m_variant);
+        }, [&](const BooleanLiteral& booleanLiteral) {
+            if (WTF::holds_alternative<BooleanLiteral>(other.m_variant)) {
+                const auto& otherBooleanLiteral = WTF::get<BooleanLiteral>(other.m_variant);
+                result = booleanLiteral.value() == otherBooleanLiteral.value();
+            } else
+                result = false;
+        }, [&](const ConstantExpressionEnumerationMemberReference& constantExpressionEnumerationMemberReference) {
+            if (WTF::holds_alternative<ConstantExpressionEnumerationMemberReference>(other.m_variant)) {
+                const auto& otherMemberReference = WTF::get<ConstantExpressionEnumerationMemberReference>(other.m_variant);
+                result = constantExpressionEnumerationMemberReference.enumerationMember() == otherMemberReference.enumerationMember();
+            } else
+                result = false;
+        }));
+
+        if (result)
+            return *result;
+
+        other.visit(WTF::makeVisitor([&](const IntegerLiteral& integerLiteral) {
+            result = value == integerLiteral.value();
+        }, [&](const UnsignedIntegerLiteral& unsignedIntegerLiteral) {
+            result = value == unsignedIntegerLiteral.value();
+        }, [&](const FloatLiteral& floatLiteral) {
+            result = value == floatLiteral.value();
+        }, [&](const NullLiteral&) {
+            result = false;
+        }, [&](const BooleanLiteral&) {
+            result = false;
+        }, [&](const ConstantExpressionEnumerationMemberReference&) {
+            result = false;
+        }));
+
+        ASSERT(result);
+        return *result;
+    }
+
+private:
+    Variant<
+        IntegerLiteral,
+        UnsignedIntegerLiteral,
+        FloatLiteral,
+        NullLiteral,
+        BooleanLiteral,
+        ConstantExpressionEnumerationMemberReference
+        > m_variant;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLConstantExpressionEnumerationMemberReference.h
new file mode 100644 (file)
index 0000000..5857d94
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLContinue.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLContinue.h
new file mode 100644 (file)
index 0000000..db9e7b6
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 "WHLSLStatement.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Continue : public Statement {
+public:
+    Continue(Lexer::Token&& origin)
+        : Statement(WTFMove(origin))
+    {
+    }
+
+    virtual ~Continue() = default;
+
+    Continue(const Continue&) = delete;
+    Continue(Continue&&) = default;
+
+    bool isContinue() const override { return true; }
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Continue, isContinue())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDereferenceExpression.h
new file mode 100644 (file)
index 0000000..545912a
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class DereferenceExpression : public Expression {
+public:
+    DereferenceExpression(Lexer::Token&& origin, UniqueRef<Expression>&& pointer)
+        : Expression(WTFMove(origin))
+        , m_pointer(WTFMove(pointer))
+    {
+    }
+
+    virtual ~DereferenceExpression() = default;
+
+    DereferenceExpression(const DereferenceExpression&) = delete;
+    DereferenceExpression(DereferenceExpression&&) = default;
+
+    bool isDereferenceExpression() const override { return true; }
+
+    Expression& pointer() { return static_cast<Expression&>(m_pointer); }
+
+private:
+    UniqueRef<Expression> m_pointer;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(DereferenceExpression, isDereferenceExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDoWhileLoop.h
new file mode 100644 (file)
index 0000000..0147837
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLStatement.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class DoWhileLoop : public Statement {
+public:
+    DoWhileLoop(Lexer::Token&& origin, UniqueRef<Statement>&& body, UniqueRef<Expression>&& conditional)
+        : Statement(WTFMove(origin))
+        , m_body(WTFMove(body))
+        , m_conditional(WTFMove(conditional))
+    {
+    }
+
+    virtual ~DoWhileLoop() = default;
+
+    DoWhileLoop(const DoWhileLoop&) = delete;
+    DoWhileLoop(DoWhileLoop&&) = default;
+
+    bool isDoWhileLoop() const override { return true; }
+
+    Statement& body() { return static_cast<Statement&>(m_body); }
+    Expression& conditional() { return static_cast<Expression&>(m_conditional); }
+
+private:
+    UniqueRef<Statement> m_body;
+    UniqueRef<Expression> m_conditional;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(DoWhileLoop, isDoWhileLoop())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLDotExpression.h
new file mode 100644 (file)
index 0000000..d2c19db
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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 "WHLSLPropertyAccessExpression.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class DotExpression : public PropertyAccessExpression {
+public:
+    DotExpression(Lexer::Token&& origin, UniqueRef<Expression>&& base, String&& fieldName)
+        : PropertyAccessExpression(WTFMove(origin), WTFMove(base))
+        , m_fieldName(WTFMove(fieldName))
+    {
+    }
+
+    virtual ~DotExpression() = default;
+
+    DotExpression(const DotExpression&) = delete;
+    DotExpression(DotExpression&&) = default;
+
+    bool isDotExpression() const override { return true; }
+
+    String getFunctionName() const override
+    {
+        return String::format("operator.%s", m_fieldName.utf8().data());
+    }
+
+    String setFunctionName() const override
+    {
+        return String::format("operator.%s=", m_fieldName.utf8().data());
+    }
+
+    String andFunctionName() const override
+    {
+        return String::format("operator&.%s", m_fieldName.utf8().data());
+    }
+
+    String& fieldName() { return m_fieldName; }
+
+private:
+    String m_fieldName;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(DotExpression, isDotExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEffectfulExpressionStatement.h
new file mode 100644 (file)
index 0000000..54d083a
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLStatement.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class EffectfulExpressionStatement : public Statement {
+public:
+    EffectfulExpressionStatement(UniqueRef<Expression>&& effectfulExpression)
+        : Statement(Lexer::Token(effectfulExpression->origin()))
+        , m_effectfulExpression(WTFMove(effectfulExpression))
+    {
+    }
+
+    virtual ~EffectfulExpressionStatement() = default;
+
+    EffectfulExpressionStatement(const EffectfulExpressionStatement&) = delete;
+    EffectfulExpressionStatement(EffectfulExpressionStatement&&) = default;
+
+    bool isEffectfulExpressionStatement() const override { return true; }
+
+    Expression& effectfulExpression() { return static_cast<Expression&>(m_effectfulExpression); }
+
+private:
+    UniqueRef<Expression> m_effectfulExpression;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(EffectfulExpressionStatement, isEffectfulExpressionStatement())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h
new file mode 100644 (file)
index 0000000..55089a1
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * 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 "WHLSLEnumerationMember.h"
+#include "WHLSLLexer.h"
+#include "WHLSLNamedType.h"
+#include "WHLSLUnnamedType.h"
+#include <memory>
+#include <wtf/HashMap.h>
+#include <wtf/UniqueRef.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class EnumerationDefinition : public NamedType {
+public:
+    EnumerationDefinition(Lexer::Token&& origin, String&& name, Optional<UniqueRef<UnnamedType>>&& type)
+        : NamedType(WTFMove(origin), WTFMove(name))
+        , m_type(WTFMove(type))
+    {
+    }
+
+    virtual ~EnumerationDefinition() = default;
+
+    EnumerationDefinition(const EnumerationDefinition&) = delete;
+    EnumerationDefinition(EnumerationDefinition&&) = default;
+
+    bool isEnumerationDefinition() const override { return true; }
+
+    UnnamedType* type() { return m_type ? &static_cast<UnnamedType&>(*m_type) : nullptr; }
+
+    bool add(EnumerationMember&& member)
+    {
+        auto result = m_members.add(member.name(), std::make_unique<EnumerationMember>(WTFMove(member)));
+        return !result.isNewEntry;
+    }
+
+    EnumerationMember* memberByName(const String& name)
+    {
+        auto iterator = m_members.find(name);
+        if (iterator == m_members.end())
+            return nullptr;
+        return iterator->value.get();
+    }
+
+    Vector<std::reference_wrapper<EnumerationMember>> enumerationMembers()
+    {
+        Vector<std::reference_wrapper<EnumerationMember>> result;
+        for (auto& pair : m_members)
+            result.append(*pair.value);
+        return result;
+    }
+
+private:
+    Optional<UniqueRef<UnnamedType>> m_type;
+    HashMap<String, std::unique_ptr<EnumerationMember>> m_members;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(EnumerationDefinition, isEnumerationDefinition())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMember.h
new file mode 100644 (file)
index 0000000..8b61a72
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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 "WHLSLConstantExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLNode.h"
+#include <wtf/Optional.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class EnumerationMember : public Node {
+public:
+    EnumerationMember(Lexer::Token&& origin, String&& name, Optional<ConstantExpression>&& value = WTF::nullopt)
+        : m_origin(WTFMove(origin))
+        , m_name(WTFMove(name))
+        , m_value(WTFMove(value))
+    {
+    }
+
+    virtual ~EnumerationMember() = default;
+
+    EnumerationMember(const EnumerationMember&) = delete;
+    EnumerationMember(EnumerationMember&&) = default;
+
+    const Lexer::Token& origin() const { return m_origin; }
+    String& name() { return m_name; }
+    Optional<ConstantExpression>& value() { return m_value; }
+
+    void setValue(ConstantExpression&& value)
+    {
+        ASSERT(!m_value);
+        m_value = WTFMove(value);
+    }
+
+private:
+    Lexer::Token m_origin;
+    String m_name;
+    Optional<ConstantExpression> m_value;
+};
+
+using EnumerationMembers = Vector<EnumerationMember>;
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLEnumerationMemberLiteral.h
new file mode 100644 (file)
index 0000000..ba64303
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 "WHLSLEnumerationMember.h"
+#include "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class EnumerationMemberLiteral : public Expression {
+public:
+    EnumerationMemberLiteral(Lexer::Token&& origin, EnumerationMember& enumerationMember)
+        : Expression(WTFMove(origin))
+        , m_enumerationMember(enumerationMember)
+    {
+    }
+
+    virtual ~EnumerationMemberLiteral() = default;
+
+    EnumerationMemberLiteral(const EnumerationMemberLiteral&) = delete;
+    EnumerationMemberLiteral(EnumerationMemberLiteral&&) = default;
+
+    bool isEnumerationMemberLiteral() const override { return true; }
+
+    EnumerationMember& enumerationMember() { return m_enumerationMember; }
+
+private:
+    EnumerationMember& m_enumerationMember;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(EnumerationMemberLiteral, isEnumerationMemberLiteral())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLExpression.h
new file mode 100644 (file)
index 0000000..741300d
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * 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 "WHLSLValue.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Expression : public Value {
+public:
+    Expression(Lexer::Token&& origin)
+        : m_origin(WTFMove(origin))
+    {
+    }
+
+    virtual ~Expression() = default;
+
+    explicit Expression(const Expression&) = default;
+    Expression(Expression&&) = default;
+
+    Expression& operator=(const Expression&) = default;
+    Expression& operator=(Expression&&) = default;
+
+    const Lexer::Token& origin() const { return m_origin; }
+
+    virtual bool isAssignmentExpression() const { return false; }
+    virtual bool isBooleanLiteral() const { return false; }
+    virtual bool isCallExpression() const { return false; }
+    virtual bool isCommaExpression() const { return false; }
+    virtual bool isDereferenceExpression() const { return false; }
+    virtual bool isDotExpression() const { return false; }
+    virtual bool isFloatLiteral() const { return false; }
+    virtual bool isIndexExpression() const { return false; }
+    virtual bool isIntegerLiteral() const { return false; }
+    virtual bool isLogicalExpression() const { return false; }
+    virtual bool isLogicalNotExpression() const { return false; }
+    virtual bool isMakeArrayReferenceExpression() const { return false; }
+    virtual bool isMakePointerExpression() const { return false; }
+    virtual bool isNullLiteral() const { return false; }
+    virtual bool isPropertyAccessExpression() const { return false; }
+    virtual bool isReadModifyWriteExpression() const { return false; }
+    virtual bool isTernaryExpression() const { return false; }
+    virtual bool isUnsignedIntegerLiteral() const { return false; }
+    virtual bool isVariableReference() const { return false; }
+    virtual bool isEnumerationMemberLiteral() const { return false; }
+
+private:
+    Lexer::Token m_origin;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#define SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \
+    static bool isType(const WebCore::WHLSL::AST::Expression& expression) { return expression.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFallthrough.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFallthrough.h
new file mode 100644 (file)
index 0000000..36bcf41
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 "WHLSLStatement.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Fallthrough : public Statement {
+public:
+    Fallthrough(Lexer::Token&& origin)
+        : Statement(WTFMove(origin))
+    {
+    }
+
+    virtual ~Fallthrough() = default;
+
+    Fallthrough(const Fallthrough&) = delete;
+    Fallthrough(Fallthrough&&) = default;
+
+    bool isFallthrough() const override { return true; }
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Fallthrough, isFallthrough())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteral.h
new file mode 100644 (file)
index 0000000..f1fb13f
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLFloatLiteralType.h"
+#include "WHLSLLexer.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class FloatLiteral : public Expression {
+public:
+    FloatLiteral(Lexer::Token&& origin, float value)
+        : Expression(Lexer::Token(origin))
+        , m_type(WTFMove(origin), value)
+        , m_value(value)
+    {
+    }
+
+    virtual ~FloatLiteral() = default;
+
+    FloatLiteral(const FloatLiteral&) = delete;
+    FloatLiteral(FloatLiteral&&) = default;
+
+    FloatLiteral& operator=(const FloatLiteral&) = delete;
+    FloatLiteral& operator=(FloatLiteral&&) = default;
+
+    FloatLiteralType& type() { return m_type; }
+    float value() const { return m_value; }
+
+    bool isFloatLiteral() const override { return true; }
+
+    FloatLiteral clone() const
+    {
+        FloatLiteral result(Lexer::Token(origin()), m_value);
+        if (result.m_type.resolvedType())
+            result.m_type.resolve(result.m_type.resolvedType()->clone());
+        return result;
+    }
+
+private:
+    FloatLiteralType m_type;
+    float m_value;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(FloatLiteral, isFloatLiteral())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp
new file mode 100644 (file)
index 0000000..4680932
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLFloatLiteralType.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLTypeReference.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+FloatLiteralType::FloatLiteralType(Lexer::Token&& origin, float value)
+    : m_value(value)
+    , m_preferredType(makeUniqueRef<TypeReference>(WTFMove(origin), String("float", String::ConstructFromLiteral), TypeArguments()))
+{
+}
+
+FloatLiteralType::~FloatLiteralType() = default;
+
+bool FloatLiteralType::canResolve(const Type&) const
+{
+    // FIXME: Implement this
+    return true;
+}
+
+unsigned FloatLiteralType::conversionCost(const UnnamedType&) const
+{
+    // FIXME: Implement this
+    return 0;
+}
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.h
new file mode 100644 (file)
index 0000000..f3a4432
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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 "WHLSLResolvableType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class TypeReference;
+
+class FloatLiteralType : public ResolvableType {
+public:
+    FloatLiteralType(Lexer::Token&& origin, float value);
+
+    virtual ~FloatLiteralType();
+
+    FloatLiteralType(const FloatLiteralType&) = delete;
+    FloatLiteralType(FloatLiteralType&&) = default;
+
+    FloatLiteralType& operator=(const FloatLiteralType&) = delete;
+    FloatLiteralType& operator=(FloatLiteralType&&) = default;
+
+    bool isFloatLiteralType() const override { return true; }
+
+    TypeReference& preferredType() { return static_cast<TypeReference&>(m_preferredType); }
+
+    bool canResolve(const Type&) const override;
+    unsigned conversionCost(const UnnamedType&) const override;
+
+    float value() const { return m_value; }
+
+private:
+    float m_value;
+    // This is a unique_ptr to resolve a circular dependency between
+    // ConstantExpression -> LiteralType -> TypeReference -> TypeArguments -> ConstantExpression
+    UniqueRef<TypeReference> m_preferredType;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_RESOLVABLE_TYPE(FloatLiteralType, isFloatLiteralType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLForLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLForLoop.h
new file mode 100644 (file)
index 0000000..713edc9
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLStatement.h"
+#include "WHLSLVariableDeclarationsStatement.h"
+#include <memory>
+#include <wtf/UniqueRef.h>
+#include <wtf/Variant.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class ForLoop : public Statement {
+public:
+    ForLoop(Lexer::Token&& origin, Variant<VariableDeclarationsStatement, UniqueRef<Expression>>&& initialization, Optional<UniqueRef<Expression>>&& condition, Optional<UniqueRef<Expression>>&& increment, UniqueRef<Statement>&& body)
+        : Statement(WTFMove(origin))
+        , m_initialization(WTFMove(initialization))
+        , m_condition(WTFMove(condition))
+        , m_increment(WTFMove(increment))
+        , m_body(WTFMove(body))
+    {
+    }
+
+    virtual ~ForLoop()
+    {
+    }
+
+    ForLoop(const ForLoop&) = delete;
+    ForLoop(ForLoop&&) = default;
+
+    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); }
+
+private:
+    Variant<VariableDeclarationsStatement, UniqueRef<Expression>> m_initialization;
+    Optional<UniqueRef<Expression>> m_condition;
+    Optional<UniqueRef<Expression>> m_increment;
+    UniqueRef<Statement> m_body;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(ForLoop, isForLoop())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionAttribute.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionAttribute.h
new file mode 100644 (file)
index 0000000..32b0b0c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 "WHLSLNumThreadsFunctionAttribute.h"
+#include <wtf/Variant.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+using FunctionAttribute = Variant<NumThreadsFunctionAttribute>;
+using AttributeBlock = Vector<FunctionAttribute>;
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDeclaration.h
new file mode 100644 (file)
index 0000000..190bbb8
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * 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 "WHLSLFunctionAttribute.h"
+#include "WHLSLLexer.h"
+#include "WHLSLNode.h"
+#include "WHLSLSemantic.h"
+#include "WHLSLUnnamedType.h"
+#include "WHLSLVariableDeclaration.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+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))
+        , m_entryPointType(entryPointType)
+        , m_type(WTFMove(type))
+        , m_name(WTFMove(name))
+        , m_parameters(WTFMove(parameters))
+        , m_semantic(WTFMove(semantic))
+        , m_isOperator(WTFMove(isOperator))
+    {
+    }
+
+    virtual ~FunctionDeclaration() = default;
+
+    FunctionDeclaration(const FunctionDeclaration&) = delete;
+    FunctionDeclaration(FunctionDeclaration&&) = default;
+
+    virtual bool isFunctionDefinition() const { return false; }
+    virtual bool isNativeFunctionDeclaration() const { return false; }
+
+    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 String& name() const { return m_name; }
+    bool isCast() const { return m_name == "operator cast"; }
+    const VariableDeclarations& parameters() const { return m_parameters; }
+    VariableDeclarations& parameters() { return m_parameters; }
+    Optional<Semantic>& semantic() { return m_semantic; }
+    bool isOperator() const { return m_isOperator; }
+
+private:
+    Lexer::Token m_origin;
+    AttributeBlock m_attributeBlock;
+    Optional<EntryPointType> m_entryPointType;
+    UniqueRef<UnnamedType> m_type;
+    String m_name;
+    VariableDeclarations m_parameters;
+    Optional<Semantic> m_semantic;
+    bool m_isOperator;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#define SPECIALIZE_TYPE_TRAITS_WHLSL_FUNCTION_DECLARATION(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \
+    static bool isType(const WebCore::WHLSL::AST::FunctionDeclaration& type) { return type.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLFunctionDefinition.h
new file mode 100644 (file)
index 0000000..ce58b6a
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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 "WHLSLBlock.h"
+#include "WHLSLFunctionDeclaration.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class FunctionDefinition : public FunctionDeclaration {
+public:
+    FunctionDefinition(FunctionDeclaration&& functionDeclaration, Block&& block, bool restricted)
+        : FunctionDeclaration(WTFMove(functionDeclaration))
+        , m_block(WTFMove(block))
+        , m_restricted(restricted)
+    {
+    }
+
+    virtual ~FunctionDefinition() = default;
+
+    FunctionDefinition(const FunctionDefinition&) = delete;
+    FunctionDefinition(FunctionDefinition&&) = default;
+
+    bool isFunctionDefinition() const override { return true; }
+
+    Block& block() { return m_block; }
+    bool restricted() const { return m_restricted; }
+
+private:
+    Block m_block;
+    bool m_restricted;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_FUNCTION_DECLARATION(FunctionDefinition, isFunctionDefinition())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIfStatement.h
new file mode 100644 (file)
index 0000000..9b7cf4b
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLStatement.h"
+#include <memory>
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class IfStatement : public Statement {
+public:
+    IfStatement(Lexer::Token&& origin, UniqueRef<Expression>&& conditional, UniqueRef<Statement>&& body, Optional<UniqueRef<Statement>>&& elseBody)
+        : Statement(WTFMove(origin))
+        , m_conditional(WTFMove(conditional))
+        , m_body(WTFMove(body))
+        , m_elseBody(WTFMove(elseBody))
+    {
+    }
+
+    virtual ~IfStatement() = default;
+
+    IfStatement(const IfStatement&) = delete;
+    IfStatement(IfStatement&&) = default;
+
+    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; }
+
+private:
+    UniqueRef<Expression> m_conditional;
+    UniqueRef<Statement> m_body;
+    Optional<UniqueRef<Statement>> m_elseBody;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(IfStatement, isIfStatement())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIndexExpression.h
new file mode 100644 (file)
index 0000000..ab89774
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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 "WHLSLPropertyAccessExpression.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class IndexExpression : public PropertyAccessExpression {
+public:
+    IndexExpression(Lexer::Token&& origin, UniqueRef<Expression>&& base, UniqueRef<Expression>&& index)
+        : PropertyAccessExpression(WTFMove(origin), WTFMove(base))
+        , m_index(WTFMove(index))
+    {
+    }
+
+    virtual ~IndexExpression() = default;
+
+    IndexExpression(const IndexExpression&) = delete;
+    IndexExpression(IndexExpression&&) = default;
+
+    bool isIndexExpression() const override { return true; }
+
+    String getFunctionName() const override
+    {
+        return String("operator[]", String::ConstructFromLiteral);
+    }
+
+    String setFunctionName() const override
+    {
+        return String("operator&[]", String::ConstructFromLiteral);
+    }
+
+    String andFunctionName() const override
+    {
+        return String("operator[]=", String::ConstructFromLiteral);
+    }
+
+    Expression& indexExpression() { return static_cast<Expression&>(m_index); }
+
+private:
+    UniqueRef<Expression> m_index;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(IndexExpression, isIndexExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.cpp
new file mode 100644 (file)
index 0000000..3cf685a
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLIntegerLiteral.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLNativeTypeDeclaration.h"
+#include "WHLSLTypeReference.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+int64_t IntegerLiteral::valueForSelectedType() const
+{
+    ASSERT(m_type.resolvedType());
+    auto& typeReference = downcast<TypeReference>(*m_type.resolvedType());
+    ASSERT(typeReference.resolvedType());
+    auto& nativeTypeDeclaration = downcast<NativeTypeDeclaration>(*typeReference.resolvedType());
+    return nativeTypeDeclaration.formatValueFromInteger()(m_value);
+}
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.h
new file mode 100644 (file)
index 0000000..129aebd
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLIntegerLiteralType.h"
+#include "WHLSLLexer.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class IntegerLiteral : public Expression {
+public:
+    IntegerLiteral(Lexer::Token&& origin, int value)
+        : Expression(Lexer::Token(origin))
+        , m_type(WTFMove(origin), value)
+        , m_value(value)
+    {
+    }
+
+    virtual ~IntegerLiteral() = default;
+
+    IntegerLiteral(const IntegerLiteral&) = delete;
+    IntegerLiteral(IntegerLiteral&&) = default;
+
+    IntegerLiteral& operator=(const IntegerLiteral&) = delete;
+    IntegerLiteral& operator=(IntegerLiteral&&) = default;
+
+    IntegerLiteralType& type() { return m_type; }
+    int value() const { return m_value; }
+
+    bool isIntegerLiteral() const override { return true; }
+
+    IntegerLiteral clone() const
+    {
+        IntegerLiteral result(Lexer::Token(origin()), m_value);
+        if (result.m_type.resolvedType())
+            result.m_type.resolve(result.m_type.resolvedType()->clone());
+        return result;
+    }
+
+    int64_t valueForSelectedType() const;
+
+private:
+    IntegerLiteralType m_type;
+    int m_value;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(IntegerLiteral, isIntegerLiteral())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp
new file mode 100644 (file)
index 0000000..5b451ee
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLIntegerLiteralType.h"
+
+#if ENABLE(WEBGPU)
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+IntegerLiteralType::IntegerLiteralType(Lexer::Token&& origin, int value)
+    : m_value(value)
+    , m_preferredType(makeUniqueRef<TypeReference>(WTFMove(origin), String("int", String::ConstructFromLiteral), TypeArguments()))
+{
+}
+
+IntegerLiteralType::~IntegerLiteralType() = default;
+
+bool IntegerLiteralType::canResolve(const Type&) const
+{
+    // FIXME: Implement this
+    return true;
+}
+
+unsigned IntegerLiteralType::conversionCost(const UnnamedType&) const
+{
+    // FIXME: Implement this
+    return 0;
+}
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.h
new file mode 100644 (file)
index 0000000..4e7d0ec
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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 "WHLSLResolvableType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class TypeReference;
+
+class IntegerLiteralType : public ResolvableType {
+public:
+    IntegerLiteralType(Lexer::Token&& origin, int value);
+
+    virtual ~IntegerLiteralType();
+
+    IntegerLiteralType(const IntegerLiteralType&) = delete;
+    IntegerLiteralType(IntegerLiteralType&&) = default;
+
+    IntegerLiteralType& operator=(const IntegerLiteralType&) = delete;
+    IntegerLiteralType& operator=(IntegerLiteralType&&) = default;
+
+    bool isIntegerLiteralType() const override { return true; }
+
+    TypeReference& preferredType() { return static_cast<TypeReference&>(m_preferredType); }
+
+    bool canResolve(const Type&) const override;
+    unsigned conversionCost(const UnnamedType&) const override;
+
+    int value() const { return m_value; }
+
+private:
+    int m_value;
+    // This is a unique_ptr to resolve a circular dependency between
+    // ConstantExpression -> LiteralType -> TypeReference -> TypeArguments -> ConstantExpression
+    UniqueRef<TypeReference> m_preferredType;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_RESOLVABLE_TYPE(IntegerLiteralType, isIntegerLiteralType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalExpression.h
new file mode 100644 (file)
index 0000000..ad35e88
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class LogicalExpression : public Expression {
+public:
+    enum class Type : uint8_t {
+        And,
+        Or
+    };
+
+    LogicalExpression(Lexer::Token&& origin, Type type, UniqueRef<Expression>&& left, UniqueRef<Expression>&& right)
+        : Expression(WTFMove(origin))
+        , m_type(type)
+        , m_left(WTFMove(left))
+        , m_right(WTFMove(right))
+    {
+    }
+
+    virtual ~LogicalExpression() = default;
+
+    LogicalExpression(const LogicalExpression&) = delete;
+    LogicalExpression(LogicalExpression&&) = default;
+
+    Type type() const { return m_type; }
+
+    bool isLogicalExpression() const override { return true; }
+
+    Expression& left() { return static_cast<Expression&>(m_left); }
+    Expression& right() { return static_cast<Expression&>(m_right); }
+
+private:
+    Type m_type;
+    UniqueRef<Expression> m_left;
+    UniqueRef<Expression> m_right;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(LogicalExpression, isLogicalExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLLogicalNotExpression.h
new file mode 100644 (file)
index 0000000..1a972be
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class LogicalNotExpression : public Expression {
+public:
+    LogicalNotExpression(Lexer::Token&& origin, UniqueRef<Expression>&& operand)
+        : Expression(WTFMove(origin))
+        , m_operand(WTFMove(operand))
+    {
+    }
+
+    virtual ~LogicalNotExpression() = default;
+
+    LogicalNotExpression(const LogicalNotExpression&) = delete;
+    LogicalNotExpression(LogicalNotExpression&&) = default;
+
+    bool isLogicalNotExpression() const override { return true; }
+
+    Expression& operand() { return static_cast<Expression&>(m_operand); }
+
+private:
+    UniqueRef<Expression> m_operand;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(LogicalNotExpression, isLogicalNotExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakeArrayReferenceExpression.h
new file mode 100644 (file)
index 0000000..bc01953
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class MakeArrayReferenceExpression : public Expression {
+public:
+    MakeArrayReferenceExpression(Lexer::Token&& origin, UniqueRef<Expression>&& lValue)
+        : Expression(WTFMove(origin))
+        , m_lValue(WTFMove(lValue))
+    {
+    }
+
+    virtual ~MakeArrayReferenceExpression() = default;
+
+    MakeArrayReferenceExpression(const MakeArrayReferenceExpression&) = delete;
+    MakeArrayReferenceExpression(MakeArrayReferenceExpression&&) = default;
+
+    bool isMakeArrayReferenceExpression() const override { return true; }
+
+    Expression& lValue() { return static_cast<Expression&>(m_lValue); }
+
+private:
+    UniqueRef<Expression> m_lValue;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(MakeArrayReferenceExpression, isMakeArrayReferenceExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLMakePointerExpression.h
new file mode 100644 (file)
index 0000000..048a444
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class MakePointerExpression : public Expression {
+public:
+    MakePointerExpression(Lexer::Token&& origin, UniqueRef<Expression>&& lValue)
+        : Expression(WTFMove(origin))
+        , m_lValue(WTFMove(lValue))
+    {
+    }
+
+    virtual ~MakePointerExpression() = default;
+
+    MakePointerExpression(const MakePointerExpression&) = delete;
+    MakePointerExpression(MakePointerExpression&&) = default;
+
+    bool isMakePointerExpression() const override { return true; }
+
+    Expression& lValue() { return static_cast<Expression&>(m_lValue); }
+
+private:
+    UniqueRef<Expression> m_lValue;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(MakePointerExpression, isMakePointerExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNamedType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNamedType.h
new file mode 100644 (file)
index 0000000..8aa7c5e
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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 "WHLSLNode.h"
+#include "WHLSLType.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class NamedType : public Type {
+public:
+    NamedType(Lexer::Token&& origin, String&& name)
+        : m_origin(WTFMove(origin))
+        , m_name(WTFMove(name))
+    {
+    }
+
+    virtual ~NamedType() = default;
+
+    NamedType(const NamedType&) = delete;
+    NamedType(NamedType&&) = default;
+
+    const Lexer::Token& origin() const { return m_origin; }
+    String& name() { return m_name; }
+
+    bool isNamedType() const override { return true; }
+    virtual bool isTypeDefinition() const { return false; }
+    virtual bool isStructureDefinition() const { return false; }
+    virtual bool isEnumerationDefinition() const { return false; }
+    virtual bool isNativeTypeDeclaration() const { return false; }
+
+    virtual const Type& unifyNode() const { return *this; }
+    virtual Type& unifyNode() { return *this; }
+
+private:
+    Lexer::Token m_origin;
+    String m_name;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#define SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \
+    static bool isType(const WebCore::WHLSL::AST::NamedType& type) { return type.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(NamedType, isNamedType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeFunctionDeclaration.h
new file mode 100644 (file)
index 0000000..d81a38c
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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 "WHLSLFunctionDeclaration.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class NativeFunctionDeclaration : public FunctionDeclaration {
+public:
+    NativeFunctionDeclaration(FunctionDeclaration&& functionDeclaration, bool restricted)
+        : FunctionDeclaration(WTFMove(functionDeclaration))
+        , m_restricted(restricted)
+    {
+    }
+
+    virtual ~NativeFunctionDeclaration() = default;
+
+    NativeFunctionDeclaration(const NativeFunctionDeclaration&) = delete;
+    NativeFunctionDeclaration(NativeFunctionDeclaration&&) = default;
+
+    bool isNativeFunctionDeclaration() const override { return true; }
+
+    bool restricted() const { return m_restricted; }
+
+private:
+    bool m_restricted;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_FUNCTION_DECLARATION(NativeFunctionDeclaration, isNativeFunctionDeclaration())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h
new file mode 100644 (file)
index 0000000..3dbc504
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * 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 "WHLSLNamedType.h"
+#include "WHLSLTypeArgument.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class NativeTypeDeclaration : public NamedType {
+public:
+    NativeTypeDeclaration(Lexer::Token&& origin, String&& name, TypeArguments&& typeArguments)
+        : NamedType(WTFMove(origin), WTFMove(name))
+        , m_typeArguments(WTFMove(typeArguments))
+    {
+    }
+
+    virtual ~NativeTypeDeclaration() = default;
+
+    NativeTypeDeclaration(const NativeTypeDeclaration&) = delete;
+    NativeTypeDeclaration(NativeTypeDeclaration&&) = default;
+
+    bool isNativeTypeDeclaration() const override { return true; }
+
+    const String& name() const { return m_name; }
+    String& name() { return m_name; }
+    TypeArguments& typeArguments() { return m_typeArguments; }
+
+    bool isInt() const { return m_isInt; }
+    bool isNumber() const { return m_isNumber; }
+    bool isFloating() const { return m_isFloating; }
+    bool isVector() const { return m_isVector; }
+    bool isMatrix() const { return m_isMatrix; }
+    bool isTexture() const { return m_isTexture; }
+    bool isSigned() const { return m_isSigned; }
+    const std::function<bool(int)>& canRepresentInteger() const { return m_canRepresentInteger; }
+    const std::function<bool(unsigned)>& canRepresentUnsignedInteger() const { return m_canRepresentUnsignedInteger; }
+    const std::function<bool(float)>& canRepresentFloat() const { return m_canRepresentFloat; }
+    const std::function<int64_t(int64_t)>& successor() const { return m_successor; }
+    const std::function<int64_t(int)>& formatValueFromInteger() const { return m_formatValueFromInteger; }
+    const std::function<int64_t(unsigned)>& formatValueFromUnsignedInteger() const { return m_formatValueFromUnsignedInteger; }
+    void iterateAllValues(const std::function<bool(int64_t)>& callback) { m_iterateAllValues(callback); }
+
+    void setIsInt() { m_isInt = true; }
+    void setIsNumber() { m_isNumber = true; }
+    void setIsFloating() { m_isFloating = true; }
+    void setIsVector() { m_isVector = true; }
+    void setIsMatrix() { m_isMatrix = true; }
+    void setIsTexture() { m_isTexture = true; }
+    void setIsSigned() { m_isSigned = true; }
+    void setCanRepresentInteger(std::function<bool(int)>&& canRepresent) { m_canRepresentInteger = WTFMove(canRepresent); }
+    void setCanRepresentUnsignedInteger(std::function<bool(unsigned)>&& canRepresent) { m_canRepresentUnsignedInteger = WTFMove(canRepresent); }
+    void setCanRepresentFloat(std::function<bool(float)>&& canRepresent) { m_canRepresentFloat = WTFMove(canRepresent); }
+    void setSuccessor(std::function<int64_t(int64_t)>&& successor) { m_successor = WTFMove(successor); }
+    void setFormatValueFromInteger(std::function<int64_t(int)>&& formatValue) { m_formatValueFromInteger = WTFMove(formatValue); }
+    void setFormatValueFromUnsignedInteger(std::function<int64_t(unsigned)>&& formatValue) { m_formatValueFromUnsignedInteger = WTFMove(formatValue); }
+    void setIterateAllValues(std::function<void(const std::function<bool(int64_t)>&)>&& iterateAllValues) { m_iterateAllValues = WTFMove(iterateAllValues); }
+
+private:
+    String m_name;
+    TypeArguments m_typeArguments;
+    std::function<bool(int)> m_canRepresentInteger;
+    std::function<bool(unsigned)> m_canRepresentUnsignedInteger;
+    std::function<bool(float)> m_canRepresentFloat;
+    std::function<int64_t(int64_t)> m_successor;
+    std::function<int64_t(int)> m_formatValueFromInteger;
+    std::function<int64_t(unsigned)> m_formatValueFromUnsignedInteger;
+    std::function<void(const std::function<bool(int64_t)>&)> m_iterateAllValues;
+    bool m_isInt { false };
+    bool m_isNumber { false };
+    bool m_isFloating { false };
+    bool m_isVector { false };
+    bool m_isMatrix { false };
+    bool m_isTexture { false };
+    bool m_isSigned { false };
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(NativeTypeDeclaration, isNativeTypeDeclaration())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNode.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNode.h
new file mode 100644 (file)
index 0000000..9429b78
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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)
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Node {
+public:
+    Node() = default;
+
+    virtual ~Node() = default;
+
+    explicit Node(const Node&) = default;
+    Node(Node&&) = default;
+
+    Node& operator=(const Node&) = default;
+    Node& operator=(Node&&) = default;
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteral.h
new file mode 100644 (file)
index 0000000..5eb0150
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLNullLiteralType.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class NullLiteral : public Expression {
+public:
+    NullLiteral(Lexer::Token&& origin)
+        : Expression(WTFMove(origin))
+    {
+    }
+
+    virtual ~NullLiteral() = default;
+
+    NullLiteral(const NullLiteral&) = delete;
+    NullLiteral(NullLiteral&&) = default;
+
+    NullLiteral& operator=(const NullLiteral&) = delete;
+    NullLiteral& operator=(NullLiteral&&) = default;
+
+    NullLiteralType& type() { return m_type; }
+
+    bool isNullLiteral() const override { return true; }
+
+    NullLiteral clone() const
+    {
+        auto result = NullLiteral(Lexer::Token(origin()));
+        if (result.m_type.resolvedType())
+            result.m_type.resolve(result.m_type.resolvedType()->clone());
+        return result;
+    }
+
+private:
+    NullLiteralType m_type;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(NullLiteral, isNullLiteral())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.cpp
new file mode 100644 (file)
index 0000000..15d0905
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLNullLiteralType.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLReferenceType.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+bool NullLiteralType::canResolve(const Type& type) const
+{
+    if (!is<UnnamedType>(type))
+        return false;
+    auto& unnamedType = downcast<UnnamedType>(type);
+    if (!is<ReferenceType>(unnamedType))
+        return false;
+    return true;
+}
+
+unsigned NullLiteralType::conversionCost(const UnnamedType&) const
+{
+    return 0;
+}
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.h
new file mode 100644 (file)
index 0000000..f6568fa
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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 "WHLSLResolvableType.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class NullLiteralType : public ResolvableType {
+public:
+    NullLiteralType() = default;
+
+    virtual ~NullLiteralType() = default;
+
+    NullLiteralType(const NullLiteralType&) = delete;
+    NullLiteralType(NullLiteralType&&) = default;
+
+    NullLiteralType& operator=(const NullLiteralType&) = delete;
+    NullLiteralType& operator=(NullLiteralType&&) = default;
+
+    bool isNullLiteralType() const override { return true; }
+
+    bool canResolve(const Type&) const override;
+    unsigned conversionCost(const UnnamedType&) const override;
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_RESOLVABLE_TYPE(NullLiteralType, isNullLiteralType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNumThreadsFunctionAttribute.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNumThreadsFunctionAttribute.h
new file mode 100644 (file)
index 0000000..38e298f
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 "WHLSLBaseFunctionAttribute.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class NumThreadsFunctionAttribute : public BaseFunctionAttribute {
+public:
+    NumThreadsFunctionAttribute(Lexer::Token&& origin, unsigned width, unsigned height, unsigned depth)
+        : BaseFunctionAttribute(WTFMove(origin))
+        , m_width(width)
+        , m_height(height)
+        , m_depth(depth)
+    {
+    }
+
+    virtual ~NumThreadsFunctionAttribute() = default;
+
+    NumThreadsFunctionAttribute(const NumThreadsFunctionAttribute&) = delete;
+    NumThreadsFunctionAttribute(NumThreadsFunctionAttribute&&) = default;
+
+    unsigned width() const { return m_width; }
+    unsigned height() const { return m_height; }
+    unsigned depth() const { return m_depth; }
+
+private:
+    unsigned m_width;
+    unsigned m_height;
+    unsigned m_depth;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h
new file mode 100644 (file)
index 0000000..ae692d0
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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 "WHLSLReferenceType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class PointerType : public ReferenceType {
+public:
+    PointerType(Lexer::Token&& origin, AddressSpace addressSpace, UniqueRef<UnnamedType> elementType)
+        : ReferenceType(WTFMove(origin), addressSpace, WTFMove(elementType))
+    {
+    }
+
+    virtual ~PointerType() = default;
+
+    PointerType(const PointerType&) = delete;
+    PointerType(PointerType&&) = default;
+
+    bool isPointerType() const override { return true; }
+
+    UniqueRef<UnnamedType> clone() const override
+    {
+        return makeUniqueRef<PointerType>(Lexer::Token(origin()), addressSpace(), elementType().clone());
+    }
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(PointerType, isPointerType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPropertyAccessExpression.h
new file mode 100644 (file)
index 0000000..e28755e
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class PropertyAccessExpression : public Expression {
+public:
+    PropertyAccessExpression(Lexer::Token&& origin, UniqueRef<Expression>&& base)
+        : Expression(WTFMove(origin))
+        , m_base(WTFMove(base))
+    {
+    }
+
+    virtual ~PropertyAccessExpression() = default;
+
+    PropertyAccessExpression(const PropertyAccessExpression&) = delete;
+    PropertyAccessExpression(PropertyAccessExpression&&) = default;
+
+    bool isPropertyAccessExpression() const override { return true; }
+
+    virtual String getFunctionName() const = 0;
+    virtual String setFunctionName() const = 0;
+    virtual String andFunctionName() const = 0;
+
+    Vector<std::reference_wrapper<FunctionDeclaration>, 1>& possibleGetOverloads() { return m_possibleGetOverloads; }
+    Vector<std::reference_wrapper<FunctionDeclaration>, 1>& possibleSetOverloads() { return m_possibleSetOverloads; }
+    Vector<std::reference_wrapper<FunctionDeclaration>, 1>& possibleAndOverloads() { return m_possibleAndOverloads; }
+
+    void setPossibleGetOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads)
+    {
+        m_possibleGetOverloads = overloads;
+    }
+    void setPossibleSetOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads)
+    {
+        m_possibleSetOverloads = overloads;
+    }
+    void setPossibleAndOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads)
+    {
+        m_possibleAndOverloads = overloads;
+    }
+
+    Expression& base() { return static_cast<Expression&>(m_base); }
+
+private:
+    UniqueRef<Expression> m_base;
+    Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleGetOverloads;
+    Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleSetOverloads;
+    Vector<std::reference_wrapper<FunctionDeclaration>, 1> m_possibleAndOverloads;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(PropertyAccessExpression, isPropertyAccessExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLQualifier.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLQualifier.h
new file mode 100644 (file)
index 0000000..295d6dd
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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 "WHLSLType.h"
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+enum class Qualifier : uint8_t {
+    Nointerpolation,
+    Noperspective,
+    Uniform,
+    Centroid,
+    Sample
+};
+
+using Qualifiers = Vector<Qualifier>;
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReadModifyWriteExpression.h
new file mode 100644 (file)
index 0000000..f29b293
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLVariableDeclaration.h"
+#include "WHLSLVariableReference.h"
+#include <memory>
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+/*
+ *  1. Evaluate m_lValue
+ *  2. Assign the result to m_oldValue
+ *  3. Evaluate m_newValueExpression
+ *  4. Assign the result to m_newValue
+ *  5. Assign the result to m_lValue
+ *  6. Evaluate m_resultExpression
+ *  7. Return the result
+ */
+class ReadModifyWriteExpression : public Expression {
+public:
+    static UniqueRef<ReadModifyWriteExpression> create(Lexer::Token&& origin, UniqueRef<Expression> lValue)
+    {
+        return makeUniqueRef<ReadModifyWriteExpression>(WTFMove(origin), WTFMove(lValue));
+    }
+
+    virtual ~ReadModifyWriteExpression() = default;
+
+    ReadModifyWriteExpression(const ReadModifyWriteExpression&) = delete;
+    ReadModifyWriteExpression(ReadModifyWriteExpression&&) = default;
+
+    void setNewValueExpression(UniqueRef<Expression>&& newValueExpression)
+    {
+        m_newValueExpression = WTFMove(newValueExpression);
+    }
+
+    void setResultExpression(UniqueRef<Expression>&& resultExpression)
+    {
+        m_resultExpression = WTFMove(resultExpression);
+    }
+
+    UniqueRef<VariableReference> oldVariableReference()
+    {
+        // The only reason we don't get use-after-frees is the fact that every instance of ReadModifyWriteExpression is allocated on the heap.
+        return makeUniqueRef<VariableReference>(VariableReference::wrap(m_oldValue));
+    }
+
+    UniqueRef<VariableReference> newVariableReference()
+    {
+        // The only reason we don't get use-after-frees is the fact that every instance of ReadModifyWriteExpression is allocated on the heap.
+        return makeUniqueRef<VariableReference>(VariableReference::wrap(m_newValue));
+    }
+
+    bool isReadModifyWriteExpression() const override { return true; }
+
+    Expression& lValue() { return static_cast<Expression&>(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; }
+
+private:
+    template<class U, class... Args> friend UniqueRef<U> WTF::makeUniqueRef(Args&&...);
+
+    ReadModifyWriteExpression(Lexer::Token&& origin, UniqueRef<Expression> lValue)
+        : Expression(Lexer::Token(origin))
+        , m_lValue(WTFMove(lValue))
+        , m_oldValue(Lexer::Token(origin), Qualifiers(), WTF::nullopt, String(), WTF::nullopt, WTF::nullopt)
+        , m_newValue(WTFMove(origin), Qualifiers(), WTF::nullopt, String(), WTF::nullopt, WTF::nullopt)
+    {
+    }
+
+    UniqueRef<Expression> m_lValue;
+    VariableDeclaration m_oldValue;
+    VariableDeclaration m_newValue;
+    Optional<UniqueRef<Expression>> m_newValueExpression;
+    Optional<UniqueRef<Expression>> m_resultExpression;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(ReadModifyWriteExpression, isReadModifyWriteExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h
new file mode 100644 (file)
index 0000000..64c84bc
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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 "WHLSLUnnamedType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+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)
+        , m_elementType(WTFMove(elementType))
+    {
+    }
+
+    virtual ~ReferenceType() = default;
+
+    ReferenceType(const ReferenceType&) = delete;
+    ReferenceType(ReferenceType&&) = default;
+
+    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); }
+
+private:
+    AddressSpace m_addressSpace;
+    UniqueRef<UnnamedType> m_elementType;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(ReferenceType, isReferenceType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResolvableType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResolvableType.h
new file mode 100644 (file)
index 0000000..cd71bd4
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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 "WHLSLType.h"
+#include "WHLSLUnnamedType.h"
+#include <memory>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class ResolvableType : public Type {
+public:
+    ResolvableType() = default;
+
+    virtual ~ResolvableType() = default;
+
+    ResolvableType(const ResolvableType&) = delete;
+    ResolvableType(ResolvableType&&) = default;
+
+    ResolvableType& operator=(const ResolvableType&) = delete;
+    ResolvableType& operator=(ResolvableType&&) = default;
+
+    bool isResolvableType() const override { return true; }
+    virtual bool isFloatLiteralType() const { return false; }
+    virtual bool isIntegerLiteralType() const { return false; }
+    virtual bool isNullLiteralType() const { return false; }
+    virtual bool isUnsignedIntegerLiteralType() const { return false; }
+
+    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; }
+
+    void resolve(UniqueRef<UnnamedType>&& type)
+    {
+        m_resolvedType = WTFMove(type);
+    }
+
+private:
+    Optional<UniqueRef<UnnamedType>> m_resolvedType;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#define SPECIALIZE_TYPE_TRAITS_WHLSL_RESOLVABLE_TYPE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \
+    static bool isType(const WebCore::WHLSL::AST::ResolvableType& type) { return type.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(ResolvableType, isResolvableType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp
new file mode 100644 (file)
index 0000000..6365888
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLResourceSemantic.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLArrayType.h"
+#include "WHLSLReferenceType.h"
+#include "WHLSLTypeReference.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.h
new file mode 100644 (file)
index 0000000..4b02be0
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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 "WHLSLBaseSemantic.h"
+#include "WHLSLLexer.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class ResourceSemantic : public BaseSemantic {
+public:
+    enum class Mode : uint8_t {
+        UnorderedAccessView,
+        Texture,
+        Buffer,
+        Sampler
+    };
+
+    ResourceSemantic(Lexer::Token&& origin, Mode mode, unsigned index, unsigned space)
+        : BaseSemantic(WTFMove(origin))
+        , m_mode(mode)
+        , m_index(index)
+        , m_space(space)
+    {
+    }
+
+    virtual ~ResourceSemantic() = default;
+
+    ResourceSemantic(const ResourceSemantic&) = delete;
+    ResourceSemantic(ResourceSemantic&&) = default;
+
+    Mode mode() const { return m_mode; }
+    unsigned index() const { return m_index; }
+    unsigned space() const { return m_space; }
+
+    bool operator==(const ResourceSemantic& other) const
+    {
+        return m_mode == other.m_mode && m_index == other.m_index && m_space == other.m_space;
+    }
+
+    bool operator!=(const ResourceSemantic& other) const
+    {
+        return !(*this == other);
+    }
+
+    bool isAcceptableType(const UnnamedType&, const Intrinsics&) const override;
+    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const override;
+
+private:
+    Mode m_mode;
+    unsigned m_index;
+    unsigned m_space;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReturn.h
new file mode 100644 (file)
index 0000000..77eb246
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLStatement.h"
+#include <memory>
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Return : public Statement {
+public:
+    Return(Lexer::Token&& origin, Optional<UniqueRef<Expression>>&& value)
+        : Statement(WTFMove(origin))
+        , m_value(WTFMove(value))
+    {
+    }
+
+    virtual ~Return() = default;
+
+    Return(const Return&) = delete;
+    Return(Return&&) = default;
+
+    bool isReturn() const override { return true; }
+
+    Expression* value() { return m_value ? &static_cast<Expression&>(*m_value) : nullptr; }
+
+    FunctionDefinition* function() { return m_function; }
+    void setFunction(FunctionDefinition* functionDefinition) { m_function = functionDefinition; }
+
+private:
+    Optional<UniqueRef<Expression>> m_value;
+    FunctionDefinition* m_function;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Return, isReturn())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSemantic.h
new file mode 100644 (file)
index 0000000..94cb806
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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 "WHLSLBuiltInSemantic.h"
+#include "WHLSLResourceSemantic.h"
+#include "WHLSLSpecializationConstantSemantic.h"
+#include "WHLSLStageInOutSemantic.h"
+#include <wtf/Variant.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+using Semantic = Variant<BuiltInSemantic, ResourceSemantic, SpecializationConstantSemantic, StageInOutSemantic>;
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp
new file mode 100644 (file)
index 0000000..a57dccc
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLSpecializationConstantSemantic.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLTypeReference.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.h
new file mode 100644 (file)
index 0000000..d62abbc
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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 "WHLSLBaseSemantic.h"
+#include "WHLSLLexer.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class SpecializationConstantSemantic : public BaseSemantic {
+public:
+    SpecializationConstantSemantic(Lexer::Token&& origin)
+        : BaseSemantic(WTFMove(origin))
+    {
+    }
+
+    virtual ~SpecializationConstantSemantic() = default;
+
+    SpecializationConstantSemantic(const SpecializationConstantSemantic&) = delete;
+    SpecializationConstantSemantic(SpecializationConstantSemantic&&) = default;
+
+    bool operator==(const SpecializationConstantSemantic&) const
+    {
+        return true;
+    }
+
+    bool operator!=(const SpecializationConstantSemantic&) const
+    {
+        return false;
+    }
+
+    bool isAcceptableType(const UnnamedType&, const Intrinsics&) const override;
+    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const override;
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp
new file mode 100644 (file)
index 0000000..5553552
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLStageInOutSemantic.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLArrayType.h"
+#include "WHLSLEnumerationDefinition.h"
+#include "WHLSLFunctionDefinition.h"
+#include "WHLSLTypeReference.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.h
new file mode 100644 (file)
index 0000000..4ae8532
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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 "WHLSLBaseSemantic.h"
+#include "WHLSLLexer.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class StageInOutSemantic : public BaseSemantic {
+public:
+    StageInOutSemantic(Lexer::Token&& origin, unsigned index)
+        : BaseSemantic(WTFMove(origin))
+        , m_index(index)
+    {
+    }
+
+    virtual ~StageInOutSemantic() = default;
+
+    StageInOutSemantic(const StageInOutSemantic&) = delete;
+    StageInOutSemantic(StageInOutSemantic&&) = default;
+
+    unsigned index() const { return m_index; }
+
+    bool operator==(const StageInOutSemantic& other) const
+    {
+        return m_index == other.m_index;
+    }
+
+    bool operator!=(const StageInOutSemantic& other) const
+    {
+        return !(*this == other);
+    }
+
+    bool isAcceptableType(const UnnamedType&, const Intrinsics&) const override;
+    bool isAcceptableForShaderItemDirection(ShaderItemDirection, const FunctionDefinition&) const override;
+
+private:
+    unsigned m_index;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h
new file mode 100644 (file)
index 0000000..b56c19c
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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 "WHLSLValue.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Statement : public Value {
+public:
+    Statement(Lexer::Token&& origin)
+        : m_origin(WTFMove(origin))
+    {
+    }
+
+    virtual ~Statement() = default;
+
+    Statement(const Statement&) = delete;
+    Statement(Statement&&) = default;
+
+    virtual bool isBlock() const { return false; }
+    virtual bool isBreak() const { return false; }
+    virtual bool isContinue() const { return false; }
+    virtual bool isDoWhileLoop() const { return false; }
+    virtual bool isEffectfulExpressionStatement() const { return false; }
+    virtual bool isFallthrough() const { return false; }
+    virtual bool isForLoop() const { return false; }
+    virtual bool isIfStatement() const { return false; }
+    virtual bool isReturn() const { return false; }
+    virtual bool isSwitchCase() const { return false; }
+    virtual bool isSwitchStatement() const { return false; }
+    virtual bool isTrap() const { return false; }
+    virtual bool isVariableDeclarationsStatement() const { return false; }
+    virtual bool isWhileLoop() const { return false; }
+
+private:
+    Lexer::Token m_origin;
+};
+
+using Statements = Vector<UniqueRef<Statement>>;
+
+} // namespace AST
+
+}
+
+}
+
+#define SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \
+    static bool isType(const WebCore::WHLSL::AST::Statement& statement) { return statement.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureDefinition.h
new file mode 100644 (file)
index 0000000..456c6e1
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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 "WHLSLNamedType.h"
+#include "WHLSLStructureElement.h"
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class StructureDefinition : public NamedType {
+public:
+    StructureDefinition(Lexer::Token&& origin, String&& name, StructureElements&& structureElements)
+        : NamedType(WTFMove(origin), WTFMove(name))
+        , m_structureElements(WTFMove(structureElements))
+    {
+    }
+
+    virtual ~StructureDefinition() = default;
+
+    StructureDefinition(const StructureDefinition&) = delete;
+    StructureDefinition(StructureDefinition&&) = default;
+
+    bool isStructureDefinition() const override { return true; }
+
+    StructureElements& structureElements() { return m_structureElements; }
+
+private:
+    StructureElements m_structureElements;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(StructureDefinition, isStructureDefinition())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStructureElement.h
new file mode 100644 (file)
index 0000000..4cd64e2
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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 "WHLSLNode.h"
+#include "WHLSLQualifier.h"
+#include "WHLSLSemantic.h"
+#include "WHLSLType.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class StructureElement : public Node {
+public:
+    StructureElement(Lexer::Token&& origin, Qualifiers&& qualifiers, UniqueRef<UnnamedType>&& type, String&& name, Optional<Semantic> semantic)
+        : m_origin(WTFMove(origin))
+        , m_qualifiers(WTFMove(qualifiers))
+        , m_type(WTFMove(type))
+        , m_name(WTFMove(name))
+        , m_semantic(WTFMove(semantic))
+    {
+    }
+
+    virtual ~StructureElement() = default;
+
+    StructureElement(const StructureElement&) = delete;
+    StructureElement(StructureElement&&) = default;
+
+    const Lexer::Token& origin() const { return m_origin; }
+    UnnamedType& type() { return static_cast<UnnamedType&>(m_type); }
+    const String& name() { return m_name; }
+    Optional<Semantic>& semantic() { return m_semantic; }
+
+private:
+    Lexer::Token m_origin;
+    Qualifiers m_qualifiers;
+    UniqueRef<UnnamedType> m_type;
+    String m_name;
+    Optional<Semantic> m_semantic;
+};
+
+using StructureElements = Vector<StructureElement>;
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchCase.h
new file mode 100644 (file)
index 0000000..fe9f8a8
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 "WHLSLBlock.h"
+#include "WHLSLConstantExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLStatement.h"
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class SwitchCase : public Statement {
+public:
+    SwitchCase(Lexer::Token&& origin, Optional<ConstantExpression>&& value, Block&& block)
+        : Statement(WTFMove(origin))
+        , m_value(WTFMove(value))
+        , m_block(WTFMove(block))
+    {
+    }
+
+    virtual ~SwitchCase() = default;
+
+    SwitchCase(const SwitchCase&) = delete;
+    SwitchCase(SwitchCase&&) = default;
+
+    bool isSwitchCase() const override { return true; }
+
+    Optional<ConstantExpression>& value() { return m_value; }
+    Block& block() { return m_block; }
+
+private:
+    Optional<ConstantExpression> m_value;
+    Block m_block;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(SwitchCase, isSwitchCase())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLSwitchStatement.h
new file mode 100644 (file)
index 0000000..6b19d70
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLStatement.h"
+#include "WHLSLSwitchCase.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class SwitchStatement : public Statement {
+public:
+    SwitchStatement(Lexer::Token&& origin, UniqueRef<Expression>&& value, Vector<SwitchCase>&& switchCases)
+        : Statement(WTFMove(origin))
+        , m_value(WTFMove(value))
+        , m_switchCases(WTFMove(switchCases))
+    {
+    }
+
+    virtual ~SwitchStatement() = default;
+
+    SwitchStatement(const SwitchStatement&) = delete;
+    SwitchStatement(SwitchStatement&&) = default;
+
+    bool isSwitchStatement() const override { return true; }
+
+    Expression& value() { return static_cast<Expression&>(m_value); }
+    Vector<SwitchCase>& switchCases() { return m_switchCases; }
+
+private:
+    UniqueRef<Expression> m_value;
+    Vector<SwitchCase> m_switchCases;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(SwitchStatement, isSwitchStatement())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTernaryExpression.h
new file mode 100644 (file)
index 0000000..b41d12b
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class TernaryExpression : public Expression {
+public:
+    TernaryExpression(Lexer::Token&& origin, UniqueRef<Expression>&& predicate, UniqueRef<Expression>&& bodyExpression, UniqueRef<Expression>&& elseExpression)
+        : Expression(WTFMove(origin))
+        , m_predicate(WTFMove(predicate))
+        , m_bodyExpression(WTFMove(bodyExpression))
+        , m_elseExpression(WTFMove(elseExpression))
+    {
+    }
+
+    virtual ~TernaryExpression() = default;
+
+    TernaryExpression(const TernaryExpression&) = delete;
+    TernaryExpression(TernaryExpression&&) = default;
+
+    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); }
+
+private:
+    UniqueRef<Expression> m_predicate;
+    UniqueRef<Expression> m_bodyExpression;
+    UniqueRef<Expression> m_elseExpression;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(TernaryExpression, isTernaryExpression())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTrap.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTrap.h
new file mode 100644 (file)
index 0000000..d280e71
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 "WHLSLStatement.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Trap : public Statement {
+public:
+    Trap(Lexer::Token&& origin)
+        : Statement(WTFMove(origin))
+    {
+    }
+
+    virtual ~Trap() = default;
+
+    Trap(const Trap&) = delete;
+    Trap(Trap&&) = default;
+
+    bool isTrap() const override { return true; }
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(Trap, isTrap())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLType.h
new file mode 100644 (file)
index 0000000..c59e496
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 "WHLSLNode.h"
+#include <wtf/TypeCasts.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Type : public Node {
+public:
+    Type() = default;
+
+    virtual ~Type() = default;
+
+    explicit Type(const Type&) = delete;
+    Type(Type&&) = default;
+
+    Type& operator=(const Type&) = delete;
+    Type& operator=(Type&&) = default;
+
+    virtual bool isNamedType() const { return false; }
+    virtual bool isUnnamedType() const { return false; }
+    virtual bool isResolvableType() const { return false; }
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+#define SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \
+    static bool isType(const WebCore::WHLSL::AST::Type& type) { return type.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp
new file mode 100644 (file)
index 0000000..23ef910
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLTypeArgument.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLConstantExpression.h"
+#include "WHLSLTypeReference.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/Variant.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+TypeArguments clone(const TypeArguments& typeArguments)
+{
+    TypeArguments result;
+    for (const auto& typeArgument : typeArguments)
+        result.append(clone(typeArgument));
+    return result;
+}
+
+TypeArgument clone(const TypeArgument& typeArgument)
+{
+    return WTF::visit(WTF::makeVisitor([](const ConstantExpression& constantExpression) -> TypeArgument {
+        return constantExpression.clone();
+    }, [](const UniqueRef<TypeReference>& typeReference) -> TypeArgument {
+        return typeReference->cloneTypeReference();
+    }), typeArgument);
+}
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.h
new file mode 100644 (file)
index 0000000..0e6709d
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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 "WHLSLConstantExpression.h"
+#include "WHLSLLexer.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/Variant.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class TypeReference;
+
+using TypeArgument = Variant<ConstantExpression, UniqueRef<TypeReference>>;
+using TypeArguments = Vector<TypeArgument>;
+
+TypeArgument clone(const TypeArgument&);
+TypeArguments clone(const TypeArguments&);
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeDefinition.h
new file mode 100644 (file)
index 0000000..2e3ff36
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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 "WHLSLNamedType.h"
+#include "WHLSLNode.h"
+#include "WHLSLUnnamedType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class TypeDefinition : public NamedType {
+public:
+    TypeDefinition(Lexer::Token&& origin, String&& name, UniqueRef<UnnamedType>&& type)
+        : NamedType(WTFMove(origin), WTFMove(name))
+        , m_type(WTFMove(type))
+    {
+    }
+
+    virtual ~TypeDefinition() = default;
+
+    TypeDefinition(const TypeDefinition&) = delete;
+    TypeDefinition(TypeDefinition&&) = default;
+
+    bool isTypeDefinition() const override { return true; }
+
+    UnnamedType& type() { return static_cast<UnnamedType&>(m_type); }
+
+    const Type& unifyNode() const override
+    {
+        return m_type->unifyNode();
+    }
+
+    Type& unifyNode() override
+    {
+        return m_type->unifyNode();
+    }
+
+private:
+    UniqueRef<UnnamedType> m_type;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_NAMED_TYPE(TypeDefinition, isTypeDefinition())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.cpp
new file mode 100644 (file)
index 0000000..a2d8fe4
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLTypeReference.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLNativeTypeDeclaration.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+UniqueRef<TypeReference> TypeReference::wrap(Lexer::Token&& origin, NamedType& resolvedType)
+{
+    TypeArguments typeArguments;
+    if (is<NativeTypeDeclaration>(resolvedType))
+        typeArguments = AST::clone(downcast<NativeTypeDeclaration>(resolvedType).typeArguments());
+    auto result = makeUniqueRef<TypeReference>(WTFMove(origin), String(resolvedType.name()), WTFMove(typeArguments));
+    result->setResolvedType(resolvedType);
+    return result;
+}
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h
new file mode 100644 (file)
index 0000000..bb69f03
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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 "WHLSLNamedType.h"
+#include "WHLSLTypeArgument.h"
+#include "WHLSLUnnamedType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class NamedType;
+
+class TypeReference : public UnnamedType {
+public:
+    TypeReference(Lexer::Token&& origin, String&& name, TypeArguments&& typeArguments)
+        : UnnamedType(WTFMove(origin))
+        , m_name(WTFMove(name))
+        , m_typeArguments(WTFMove(typeArguments))
+    {
+    }
+
+    virtual ~TypeReference() = default;
+
+    TypeReference(const TypeReference&) = delete;
+    TypeReference(TypeReference&&) = default;
+
+    static UniqueRef<TypeReference> wrap(Lexer::Token&& origin, NamedType& resolvedType);
+
+    bool isTypeReference() const override { return true; }
+
+    String& name() { return m_name; }
+    TypeArguments& typeArguments() { return m_typeArguments; }
+    NamedType* resolvedType() const { return m_resolvedType; }
+
+    const Type& unifyNode() const override
+    {
+        ASSERT(m_resolvedType);
+        return m_resolvedType->unifyNode();
+    }
+
+    Type& unifyNode() override
+    {
+        ASSERT(m_resolvedType);
+        return m_resolvedType->unifyNode();
+    }
+
+    void setResolvedType(NamedType& resolvedType)
+    {
+        m_resolvedType = &resolvedType;
+    }
+
+    UniqueRef<TypeReference> cloneTypeReference() const
+    {
+        return makeUniqueRef<TypeReference>(Lexer::Token(origin()), String(m_name), AST::clone(m_typeArguments));
+    }
+
+    UniqueRef<UnnamedType> clone() const override
+    {
+        return cloneTypeReference();
+    }
+
+private:
+    String m_name;
+    TypeArguments m_typeArguments;
+    NamedType* m_resolvedType { nullptr };
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(TypeReference, isTypeReference())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h
new file mode 100644 (file)
index 0000000..8c7c517
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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 "WHLSLNode.h"
+#include "WHLSLType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class UnnamedType : public Type {
+public:
+    UnnamedType(Lexer::Token&& origin)
+        : m_origin(WTFMove(origin))
+    {
+    }
+
+    virtual ~UnnamedType() = default;
+
+    UnnamedType(const UnnamedType&) = delete;
+    UnnamedType(UnnamedType&&) = default;
+
+    bool isUnnamedType() const override { return true; }
+    virtual bool isTypeReference() const { return false; }
+    virtual bool isPointerType() const { return false; }
+    virtual bool isArrayReferenceType() const { return false; }
+    virtual bool isArrayType() const { return false; }
+    virtual bool isReferenceType() const { return false; }
+
+    virtual const Type& unifyNode() const { return *this; }
+    virtual Type& unifyNode() { return *this; }
+
+    virtual UniqueRef<UnnamedType> clone() const = 0;
+
+    const Lexer::Token& origin() const { return m_origin; }
+
+private:
+    Lexer::Token m_origin;
+};
+
+} // namespace AST
+
+}
+
+}
+
+#define SPECIALIZE_TYPE_TRAITS_WHLSL_UNNAMED_TYPE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WHLSL::AST::ToValueTypeName) \
+    static bool isType(const WebCore::WHLSL::AST::UnnamedType& type) { return type.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_TYPE(UnnamedType, isUnnamedType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.cpp
new file mode 100644 (file)
index 0000000..c8f5419
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLUnsignedIntegerLiteral.h"
+
+#if ENABLE(WEBGPU)
+
+#include "WHLSLNativeTypeDeclaration.h"
+#include "WHLSLTypeReference.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+int64_t UnsignedIntegerLiteral::valueForSelectedType() const
+{
+    ASSERT(m_type.resolvedType());
+    auto& typeReference = downcast<TypeReference>(*m_type.resolvedType());
+    ASSERT(typeReference.resolvedType());
+    auto& nativeTypeDeclaration = downcast<NativeTypeDeclaration>(*typeReference.resolvedType());
+    return nativeTypeDeclaration.formatValueFromUnsignedInteger()(m_value);
+}
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.h
new file mode 100644 (file)
index 0000000..47b9e25
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLUnsignedIntegerLiteralType.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class UnsignedIntegerLiteral : public Expression {
+public:
+    UnsignedIntegerLiteral(Lexer::Token&& origin, unsigned value)
+        : Expression(Lexer::Token(origin))
+        , m_type(WTFMove(origin), value)
+        , m_value(value)
+    {
+    }
+
+    virtual ~UnsignedIntegerLiteral() = default;
+
+    UnsignedIntegerLiteral(const UnsignedIntegerLiteral&) = delete;
+    UnsignedIntegerLiteral(UnsignedIntegerLiteral&&) = default;
+
+    UnsignedIntegerLiteral& operator=(const UnsignedIntegerLiteral&) = delete;
+    UnsignedIntegerLiteral& operator=(UnsignedIntegerLiteral&&) = default;
+
+    UnsignedIntegerLiteralType& type() { return m_type; }
+    unsigned value() const { return m_value; }
+
+    bool isUnsignedIntegerLiteral() const override { return true; }
+
+    UnsignedIntegerLiteral clone() const
+    {
+        UnsignedIntegerLiteral result(Lexer::Token(origin()), m_value);
+        if (result.m_type.resolvedType())
+            result.m_type.resolve(result.m_type.resolvedType()->clone());
+        return result;
+    }
+
+    int64_t valueForSelectedType() const;
+
+private:
+    UnsignedIntegerLiteralType m_type;
+    unsigned m_value;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(UnsignedIntegerLiteral, isUnsignedIntegerLiteral())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp
new file mode 100644 (file)
index 0000000..eedacf6
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLUnsignedIntegerLiteralType.h"
+
+#if ENABLE(WEBGPU)
+
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+UnsignedIntegerLiteralType::UnsignedIntegerLiteralType(Lexer::Token&& origin, unsigned value)
+    : m_value(value)
+    , m_preferredType(makeUniqueRef<TypeReference>(WTFMove(origin), String("uint", String::ConstructFromLiteral), TypeArguments()))
+{
+}
+
+UnsignedIntegerLiteralType::~UnsignedIntegerLiteralType() = default;
+
+bool UnsignedIntegerLiteralType::canResolve(const Type&) const
+{
+    // FIXME: Implement this
+    return true;
+}
+
+unsigned UnsignedIntegerLiteralType::conversionCost(const UnnamedType&) const
+{
+    // FIXME: Implement this
+    return 0;
+}
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.h
new file mode 100644 (file)
index 0000000..52a3b77
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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 "WHLSLResolvableType.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class TypeReference;
+
+class UnsignedIntegerLiteralType : public ResolvableType {
+public:
+    UnsignedIntegerLiteralType(Lexer::Token&& origin, unsigned value);
+
+    virtual ~UnsignedIntegerLiteralType();
+
+    UnsignedIntegerLiteralType(const UnsignedIntegerLiteralType&) = delete;
+    UnsignedIntegerLiteralType(UnsignedIntegerLiteralType&&) = default;
+
+    UnsignedIntegerLiteralType& operator=(const UnsignedIntegerLiteralType&) = delete;
+    UnsignedIntegerLiteralType& operator=(UnsignedIntegerLiteralType&&) = default;
+
+    bool isUnsignedIntegerLiteralType() const override { return true; }
+
+    TypeReference& preferredType() { return static_cast<TypeReference&>(m_preferredType); }
+
+    bool canResolve(const Type&) const override;
+    unsigned conversionCost(const UnnamedType&) const override;
+
+    unsigned value() const { return m_value; }
+
+private:
+    unsigned m_value;
+    // This is a unique_ptr to resolve a circular dependency between
+    // ConstantExpression -> LiteralType -> TypeReference -> TypeArguments -> ConstantExpression
+    UniqueRef<TypeReference> m_preferredType;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_RESOLVABLE_TYPE(UnsignedIntegerLiteralType, isUnsignedIntegerLiteralType())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLValue.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLValue.h
new file mode 100644 (file)
index 0000000..ffd9c8e
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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 "WHLSLNode.h"
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class Value : public Node {
+public:
+    Value()
+    {
+    }
+
+    virtual ~Value() = default;
+
+    explicit Value(const Value&) = default;
+    Value(Value&&) = default;
+
+    Value& operator=(const Value&) = default;
+    Value& operator=(Value&&) = default;
+
+private:
+};
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h
new file mode 100644 (file)
index 0000000..b449460
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLQualifier.h"
+#include "WHLSLSemantic.h"
+#include "WHLSLType.h"
+#include "WHLSLValue.h"
+#include <memory>
+#include <wtf/UniqueRef.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class VariableDeclaration : public Value {
+public:
+    VariableDeclaration(Lexer::Token&& origin, Qualifiers&& qualifiers, Optional<UniqueRef<UnnamedType>>&& type, String&& name, Optional<Semantic>&& semantic, Optional<UniqueRef<Expression>>&& initializer)
+        : m_origin(WTFMove(origin))
+        , m_qualifiers(WTFMove(qualifiers))
+        , m_type(WTFMove(type))
+        , m_name(WTFMove(name))
+        , m_semantic(WTFMove(semantic))
+        , m_initializer(WTFMove(initializer))
+    {
+    }
+
+    virtual ~VariableDeclaration() = default;
+
+    VariableDeclaration(const VariableDeclaration&) = delete;
+    VariableDeclaration(VariableDeclaration&&) = default;
+
+    const Lexer::Token& origin() const { return m_origin; }
+    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; }
+    Optional<Semantic>& semantic() { return m_semantic; }
+    Expression* initializer() { return m_initializer ? &static_cast<Expression&>(*m_initializer) : nullptr; }
+
+private:
+    Lexer::Token m_origin;
+    Qualifiers m_qualifiers;
+    Optional<UniqueRef<UnnamedType>> m_type;
+    String m_name;
+    Optional<Semantic> m_semantic;
+    Optional<UniqueRef<Expression>> m_initializer;
+};
+
+using VariableDeclarations = Vector<VariableDeclaration>;
+
+} // namespace AST
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableDeclarationsStatement.h
new file mode 100644 (file)
index 0000000..e8e1fc7
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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 "WHLSLStatement.h"
+#include "WHLSLVariableDeclaration.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class VariableDeclarationsStatement : public Statement {
+public:
+    VariableDeclarationsStatement(Lexer::Token&& origin, Vector<VariableDeclaration>&& variableDeclarations)
+        : Statement(WTFMove(origin))
+        , m_variableDeclarations(WTFMove(variableDeclarations))
+    {
+    }
+
+    virtual ~VariableDeclarationsStatement() = default;
+
+    VariableDeclarationsStatement(const VariableDeclarationsStatement&) = delete;
+    VariableDeclarationsStatement(VariableDeclarationsStatement&&) = default;
+
+    bool isVariableDeclarationsStatement() const override { return true; }
+
+    Vector<VariableDeclaration>& variableDeclarations() { return m_variableDeclarations; }
+
+private:
+    Vector<VariableDeclaration> m_variableDeclarations;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(VariableDeclarationsStatement, isVariableDeclarationsStatement())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLVariableReference.h
new file mode 100644 (file)
index 0000000..5052fdf
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLVariableDeclaration.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class VariableReference : public Expression {
+public:
+    VariableReference(Lexer::Token&& origin, String&& name)
+        : Expression(WTFMove(origin))
+        , m_name(WTFMove(name))
+    {
+    }
+
+    virtual ~VariableReference() = default;
+
+    VariableReference(const VariableReference&) = delete;
+    VariableReference(VariableReference&&) = default;
+
+    static VariableReference wrap(VariableDeclaration& variableDeclaration)
+    {
+        VariableReference result(Lexer::Token(variableDeclaration.origin()));
+        result.m_variable = &variableDeclaration;
+        return result;
+    }
+
+    bool isVariableReference() const override { return true; }
+
+    String& name() { return m_name; }
+
+    VariableDeclaration* variable() { return m_variable; }
+
+    void setVariable(VariableDeclaration& variableDeclaration)
+    {
+        m_variable = &variableDeclaration;
+    }
+
+private:
+    VariableReference(Lexer::Token&& origin)
+        : Expression(WTFMove(origin))
+    {
+    }
+
+    String m_name;
+    VariableDeclaration* m_variable;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_EXPRESSION(VariableReference, isVariableReference())
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h
new file mode 100644 (file)
index 0000000..a7e8682
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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 "WHLSLExpression.h"
+#include "WHLSLLexer.h"
+#include "WHLSLStatement.h"
+#include <wtf/UniqueRef.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+namespace AST {
+
+class WhileLoop : public Statement {
+public:
+    WhileLoop(Lexer::Token&& origin, UniqueRef<Expression>&& conditional, UniqueRef<Statement>&& body)
+        : Statement(WTFMove(origin))
+        , m_conditional(WTFMove(conditional))
+        , m_body(WTFMove(body))
+    {
+    }
+
+    virtual ~WhileLoop() = default;
+
+    WhileLoop(const WhileLoop&) = delete;
+    WhileLoop(WhileLoop&&) = default;
+
+    bool isWhileLoop() const override { return true; }
+
+    Expression& conditional() { return static_cast<Expression&>(m_conditional); }
+    Statement& body() { return static_cast<Statement&>(m_body); }
+
+private:
+    UniqueRef<Expression> m_conditional;
+    UniqueRef<Statement> m_body;
+};
+
+} // namespace AST
+
+}
+
+}
+
+SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(WhileLoop, isWhileLoop())
+
+#endif
index 3b1934e..e9aeae7 100644 (file)
@@ -23,8 +23,6 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#pragma once
-
 #include "config.h"
 #include "WHLSLLexer.h"
 
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp
new file mode 100644 (file)
index 0000000..b2d7905
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WHLSLParser.h"
+
+#if ENABLE(WEBGPU)
+
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h
new file mode 100644 (file)
index 0000000..3cf66ce
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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 "WHLSLArrayReferenceType.h"
+#include "WHLSLArrayType.h"
+#include "WHLSLAssignmentExpression.h"
+#include "WHLSLBaseFunctionAttribute.h"
+#include "WHLSLBaseSemantic.h"
+#include "WHLSLBlock.h"
+#include "WHLSLBooleanLiteral.h"
+#include "WHLSLBreak.h"
+#include "WHLSLBuiltInSemantic.h"
+#include "WHLSLCallExpression.h"
+#include "WHLSLCommaExpression.h"
+#include "WHLSLConstantExpression.h"
+#include "WHLSLConstantExpressionEnumerationMemberReference.h"
+#include "WHLSLContinue.h"
+#include "WHLSLDereferenceExpression.h"
+#include "WHLSLDoWhileLoop.h"
+#include "WHLSLDotExpression.h"
+#include "WHLSLEffectfulExpressionStatement.h"
+#include "WHLSLEnumerationDefinition.h"
+#include "WHLSLEnumerationMember.h"
+#include "WHLSLExpression.h"
+#include "WHLSLFallthrough.h"
+#include "WHLSLFloatLiteral.h"
+#include "WHLSLForLoop.h"
+#include "WHLSLFunctionAttribute.h"
+#include "WHLSLFunctionDeclaration.h"
+#include "WHLSLFunctionDefinition.h"
+#include "WHLSLIfStatement.h"
+#include "WHLSLIndexExpression.h"
+#include "WHLSLIntegerLiteral.h"
+#include "WHLSLLexer.h"
+#include "WHLSLLogicalExpression.h"
+#include "WHLSLLogicalNotExpression.h"
+#include "WHLSLMakeArrayReferenceExpression.h"
+#include "WHLSLMakePointerExpression.h"
+#include "WHLSLNativeFunctionDeclaration.h"
+#include "WHLSLNativeTypeDeclaration.h"
+#include "WHLSLNode.h"
+#include "WHLSLNullLiteral.h"
+#include "WHLSLNumThreadsFunctionAttribute.h"
+#include "WHLSLPointerType.h"
+#include "WHLSLProgram.h"
+#include "WHLSLPropertyAccessExpression.h"
+#include "WHLSLQualifier.h"
+#include "WHLSLReadModifyWriteExpression.h"
+#include "WHLSLReferenceType.h"
+#include "WHLSLResourceSemantic.h"
+#include "WHLSLReturn.h"
+#include "WHLSLSemantic.h"
+#include "WHLSLSpecializationConstantSemantic.h"
+#include "WHLSLStageInOutSemantic.h"
+#include "WHLSLStatement.h"
+#include "WHLSLStructureDefinition.h"
+#include "WHLSLStructureElement.h"
+#include "WHLSLSwitchCase.h"
+#include "WHLSLSwitchStatement.h"
+#include "WHLSLTernaryExpression.h"
+#include "WHLSLTrap.h"
+#include "WHLSLType.h"
+#include "WHLSLTypeArgument.h"
+#include "WHLSLTypeDefinition.h"
+#include "WHLSLTypeReference.h"
+#include "WHLSLUnsignedIntegerLiteral.h"
+#include "WHLSLValue.h"
+#include "WHLSLVariableDeclaration.h"
+#include "WHLSLVariableDeclarationsStatement.h"
+#include "WHLSLVariableReference.h"
+#include "WHLSLWhileLoop.h"
+#include <wtf/Expected.h>
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+class Parser {
+
+};
+
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLProgram.h
new file mode 100644 (file)
index 0000000..a69e843
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * 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 "WHLSLEnumerationDefinition.h"
+#include "WHLSLFunctionDefinition.h"
+#include "WHLSLNativeFunctionDeclaration.h"
+#include "WHLSLNativeTypeDeclaration.h"
+#include "WHLSLStructureDefinition.h"
+#include "WHLSLTypeDefinition.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+namespace WHLSL {
+
+class Program {
+public:
+    Program() = default;
+    Program(Program&&) = default;
+
+    bool append(AST::TypeDefinition&& typeDefinition)
+    {
+        m_typeDefinitions.append(makeUniqueRef<AST::TypeDefinition>(WTFMove(typeDefinition)));
+        return true;
+    }
+
+    bool append(AST::StructureDefinition&& structureDefinition)
+    {
+        m_structureDefinitions.append(makeUniqueRef<AST::StructureDefinition>(WTFMove(structureDefinition)));
+        return true;
+    }
+
+    bool append(AST::EnumerationDefinition&& enumerationDefinition)
+    {
+        m_enumerationDefinitions.append(makeUniqueRef<AST::EnumerationDefinition>(WTFMove(enumerationDefinition)));
+        return true;
+    }
+
+    bool append(AST::FunctionDefinition&& functionDefinition)
+    {
+        m_functionDefinitions.append(makeUniqueRef<AST::FunctionDefinition>(WTFMove(functionDefinition)));
+        return true;
+    }
+
+    bool append(AST::NativeFunctionDeclaration&& nativeFunctionDeclaration)
+    {
+        m_nativeFunctionDeclarations.append(makeUniqueRef<AST::NativeFunctionDeclaration>(WTFMove(nativeFunctionDeclaration)));
+        return true;
+    }
+
+    bool append(AST::NativeTypeDeclaration&& nativeTypeDeclaration)
+    {
+        m_nativeTypeDeclarations.append(makeUniqueRef<AST::NativeTypeDeclaration>(WTFMove(nativeTypeDeclaration)));
+        return true;
+    }
+
+    Vector<UniqueRef<AST::TypeDefinition>>& typeDefinitions() { return m_typeDefinitions; }
+    Vector<UniqueRef<AST::StructureDefinition>>& structureDefinitions() { return m_structureDefinitions; }
+    Vector<UniqueRef<AST::EnumerationDefinition>>& enumerationDefinitions() { return m_enumerationDefinitions; }
+    const Vector<UniqueRef<AST::FunctionDefinition>>& functionDefinitions() const { return m_functionDefinitions; }
+    Vector<UniqueRef<AST::FunctionDefinition>>& functionDefinitions() { return m_functionDefinitions; }
+    const Vector<UniqueRef<AST::NativeFunctionDeclaration>>& nativeFunctionDeclarations() const { return m_nativeFunctionDeclarations; }
+    Vector<UniqueRef<AST::NativeFunctionDeclaration>>& nativeFunctionDeclarations() { return m_nativeFunctionDeclarations; }
+    Vector<UniqueRef<AST::NativeTypeDeclaration>>& nativeTypeDeclarations() { return m_nativeTypeDeclarations; }
+
+private:
+    Vector<UniqueRef<AST::TypeDefinition>> m_typeDefinitions;
+    Vector<UniqueRef<AST::StructureDefinition>> m_structureDefinitions;
+    Vector<UniqueRef<AST::EnumerationDefinition>> m_enumerationDefinitions;
+    Vector<UniqueRef<AST::FunctionDefinition>> m_functionDefinitions;
+    Vector<UniqueRef<AST::NativeFunctionDeclaration>> m_nativeFunctionDeclarations;
+    Vector<UniqueRef<AST::NativeTypeDeclaration>> m_nativeTypeDeclarations;
+};
+
+}
+
+}
+
+#endif
index 238ea7d..e703460 100644 (file)
@@ -307,6 +307,19 @@ Modules/websockets/WorkerThreadableWebSocketChannel.cpp
 
 Modules/webgpu/DOMWindowWebGPU.cpp
 Modules/webgpu/WHLSL/WHLSLLexer.cpp
+Modules/webgpu/WHLSL/WHLSLParser.cpp
+Modules/webgpu/WHLSL/AST/WHLSLTypeArgument.cpp
+Modules/webgpu/WHLSL/AST/WHLSLBuiltInSemantic.cpp
+Modules/webgpu/WHLSL/AST/WHLSLResourceSemantic.cpp
+Modules/webgpu/WHLSL/AST/WHLSLSpecializationConstantSemantic.cpp
+Modules/webgpu/WHLSL/AST/WHLSLStageInOutSemantic.cpp
+Modules/webgpu/WHLSL/AST/WHLSLFloatLiteralType.cpp
+Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteralType.cpp
+Modules/webgpu/WHLSL/AST/WHLSLNullLiteralType.cpp
+Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteralType.cpp
+Modules/webgpu/WHLSL/AST/WHLSLTypeReference.cpp
+Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.cpp
+Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.cpp
 Modules/webgpu/WebGPU.cpp
 Modules/webgpu/WebGPUAdapter.cpp
 Modules/webgpu/WebGPUBindGroupLayout.cpp
index ad97b5b..09c07bb 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>"; };
                1C66260E1C6E7CA600AB527C /* FontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFace.cpp; sourceTree = "<group>"; };
                1C66260F1C6E7CA600AB527C /* FontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFace.h; sourceTree = "<group>"; };
                1CAF347E0A6C405200ABE06E /* WebScriptObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObject.h; sourceTree = "<group>"; };
                1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptObject.mm; sourceTree = "<group>"; };
                1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObjectPrivate.h; sourceTree = "<group>"; };
+               1CB69B3221DED40B006E846A /* WHLSLResolvableType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLResolvableType.h; sourceTree = "<group>"; };
+               1CB69B3421DED63A006E846A /* WHLSLFloatLiteralType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFloatLiteralType.h; sourceTree = "<group>"; };
+               1CB69B3521DED649006E846A /* WHLSLIntegerLiteralType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLIntegerLiteralType.h; sourceTree = "<group>"; };
+               1CB69B3621DED657006E846A /* WHLSLNullLiteralType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNullLiteralType.h; sourceTree = "<group>"; };
+               1CB69B3721DED66B006E846A /* WHLSLUnsignedIntegerLiteralType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLUnsignedIntegerLiteralType.h; sourceTree = "<group>"; };
+               1CB69B3821DF03E1006E846A /* WHLSLFloatLiteralType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLFloatLiteralType.cpp; sourceTree = "<group>"; };
+               1CB69B3921DF03F3006E846A /* WHLSLIntegerLiteralType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLIntegerLiteralType.cpp; sourceTree = "<group>"; };
+               1CB69B3A21DF0403006E846A /* WHLSLNullLiteralType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLNullLiteralType.cpp; sourceTree = "<group>"; };
+               1CB69B3B21DF041E006E846A /* WHLSLUnsignedIntegerLiteralType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLUnsignedIntegerLiteralType.cpp; sourceTree = "<group>"; };
                1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextDecorationThickness.h; sourceTree = "<group>"; };
                1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextUnderlineOffset.h; sourceTree = "<group>"; };
                1CCDF5BB1990332400BCEBAD /* SVGToOTFFontConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGToOTFFontConversion.cpp; sourceTree = "<group>"; };
                C11A9ED22140578B00CFB20A /* SwitchingGPUClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SwitchingGPUClient.cpp; sourceTree = "<group>"; };
                C1E1D235203DF15400584665 /* ScreenProperties.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScreenProperties.h; sourceTree = "<group>"; };
                C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontVariantBuilder.h; sourceTree = "<group>"; };
+               C20F4F6421DFBE5C0070C45A /* WHLSLTypeReference.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLTypeReference.cpp; sourceTree = "<group>"; };
+               C20F4F6621DFF2360070C45A /* WHLSLIntegerLiteral.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLIntegerLiteral.cpp; sourceTree = "<group>"; };
+               C20F4F6721DFF3A70070C45A /* WHLSLUnsignedIntegerLiteral.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLUnsignedIntegerLiteral.cpp; sourceTree = "<group>"; };
                C210E91121B4BD1000B7F83D /* WHLSLLexer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLLexer.cpp; sourceTree = "<group>"; };
                C210E91221B4BD1000B7F83D /* WHLSLLexer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLLexer.h; sourceTree = "<group>"; };
+               C2138A1321DDECD300F516BA /* WHLSLBuiltInSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLBuiltInSemantic.cpp; sourceTree = "<group>"; };
+               C2138A1521DDECE900F516BA /* WHLSLResourceSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLResourceSemantic.cpp; sourceTree = "<group>"; };
+               C2138A1621DDECFB00F516BA /* WHLSLSpecializationConstantSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLSpecializationConstantSemantic.cpp; sourceTree = "<group>"; };
+               C2138A1721DDED0D00F516BA /* WHLSLStageInOutSemantic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLStageInOutSemantic.cpp; sourceTree = "<group>"; };
+               C21BF6F321CD89AD00227979 /* WHLSLTrap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLTrap.h; sourceTree = "<group>"; };
+               C21BF6F421CD89B300227979 /* WHLSLFunctionDefinition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFunctionDefinition.h; sourceTree = "<group>"; };
+               C21BF6F521CD89B500227979 /* WHLSLContinue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLContinue.h; sourceTree = "<group>"; };
+               C21BF6F621CD89B700227979 /* WHLSLBooleanLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBooleanLiteral.h; sourceTree = "<group>"; };
+               C21BF6F721CD89B900227979 /* WHLSLIndexExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLIndexExpression.h; sourceTree = "<group>"; };
+               C21BF6F821CD89BB00227979 /* WHLSLIntegerLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLIntegerLiteral.h; sourceTree = "<group>"; };
+               C21BF6F921CD89BD00227979 /* WHLSLSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSemantic.h; sourceTree = "<group>"; };
+               C21BF6FA21CD89BE00227979 /* WHLSLBaseSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBaseSemantic.h; sourceTree = "<group>"; };
+               C21BF6FB21CD89BE00227979 /* WHLSLDoWhileLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLDoWhileLoop.h; sourceTree = "<group>"; };
+               C21BF6FC21CD89BF00227979 /* WHLSLValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLValue.h; sourceTree = "<group>"; };
+               C21BF6FD21CD89C000227979 /* WHLSLFunctionDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFunctionDeclaration.h; sourceTree = "<group>"; };
+               C21BF6FE21CD89C100227979 /* WHLSLStructureElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStructureElement.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>"; };
+               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>"; };
+               C21BF70621CD89C700227979 /* WHLSLCommaExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLCommaExpression.h; sourceTree = "<group>"; };
+               C21BF70721CD89C800227979 /* WHLSLNullLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNullLiteral.h; sourceTree = "<group>"; };
+               C21BF70821CD89C900227979 /* WHLSLResourceSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLResourceSemantic.h; sourceTree = "<group>"; };
+               C21BF70921CD89CA00227979 /* WHLSLArrayType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLArrayType.h; sourceTree = "<group>"; };
+               C21BF70A21CD89CB00227979 /* WHLSLBaseFunctionAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBaseFunctionAttribute.h; sourceTree = "<group>"; };
+               C21BF70B21CD89CC00227979 /* WHLSLQualifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLQualifier.h; sourceTree = "<group>"; };
+               C21BF70C21CD89CC00227979 /* WHLSLExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLExpression.h; sourceTree = "<group>"; };
+               C21BF70D21CD89CD00227979 /* WHLSLReferenceType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLReferenceType.h; sourceTree = "<group>"; };
+               C21BF70E21CD89CE00227979 /* WHLSLStageInOutSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStageInOutSemantic.h; sourceTree = "<group>"; };
+               C21BF71021CD89D000227979 /* WHLSLVariableDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLVariableDeclaration.h; sourceTree = "<group>"; };
+               C21BF71121CD89D100227979 /* WHLSLTypeArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLTypeArgument.h; sourceTree = "<group>"; };
+               C21BF71221CD89D100227979 /* WHLSLStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStatement.h; sourceTree = "<group>"; };
+               C21BF71321CD89D200227979 /* WHLSLVariableReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLVariableReference.h; sourceTree = "<group>"; };
+               C21BF71421CD89D300227979 /* WHLSLVariableDeclarationsStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLVariableDeclarationsStatement.h; sourceTree = "<group>"; };
+               C21BF71521CD89D400227979 /* WHLSLLogicalNotExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLLogicalNotExpression.h; sourceTree = "<group>"; };
+               C21BF71621CD89D500227979 /* WHLSLCallExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLCallExpression.h; sourceTree = "<group>"; };
+               C21BF71821CD89D700227979 /* WHLSLDotExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLDotExpression.h; sourceTree = "<group>"; };
+               C21BF71921CD89D700227979 /* WHLSLSwitchCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSwitchCase.h; sourceTree = "<group>"; };
+               C21BF71A21CD89D800227979 /* WHLSLBreak.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBreak.h; sourceTree = "<group>"; };
+               C21BF71B21CD89D900227979 /* WHLSLReadModifyWriteExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLReadModifyWriteExpression.h; sourceTree = "<group>"; };
+               C21BF71C21CD89DA00227979 /* WHLSLTernaryExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLTernaryExpression.h; sourceTree = "<group>"; };
+               C21BF71D21CD89DB00227979 /* WHLSLType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLType.h; sourceTree = "<group>"; };
+               C21BF71E21CD89DC00227979 /* WHLSLBlock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBlock.h; sourceTree = "<group>"; };
+               C21BF71F21CD89DC00227979 /* WHLSLTypeReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLTypeReference.h; sourceTree = "<group>"; };
+               C21BF72021CD89DD00227979 /* WHLSLEnumerationDefinition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEnumerationDefinition.h; sourceTree = "<group>"; };
+               C21BF72121CD89DE00227979 /* WHLSLNumThreadsFunctionAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNumThreadsFunctionAttribute.h; sourceTree = "<group>"; };
+               C21BF72221CD89DF00227979 /* WHLSLBuiltInSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLBuiltInSemantic.h; sourceTree = "<group>"; };
+               C21BF72321CD89E100227979 /* WHLSLNativeFunctionDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNativeFunctionDeclaration.h; sourceTree = "<group>"; };
+               C21BF72421CD89E100227979 /* WHLSLNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNode.h; sourceTree = "<group>"; };
+               C21BF72521CD89E200227979 /* WHLSLArrayReferenceType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLArrayReferenceType.h; sourceTree = "<group>"; };
+               C21BF72621CD89E300227979 /* WHLSLEnumerationMember.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEnumerationMember.h; sourceTree = "<group>"; };
+               C21BF72721CD89E400227979 /* WHLSLStructureDefinition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStructureDefinition.h; sourceTree = "<group>"; };
+               C21BF72821CD89E500227979 /* WHLSLEffectfulExpressionStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEffectfulExpressionStatement.h; sourceTree = "<group>"; };
+               C21BF72921CD89E600227979 /* WHLSLTypeDefinition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLTypeDefinition.h; sourceTree = "<group>"; };
+               C21BF72A21CD89E700227979 /* WHLSLNativeTypeDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNativeTypeDeclaration.h; sourceTree = "<group>"; };
+               C21BF72B21CD89E800227979 /* WHLSLUnsignedIntegerLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLUnsignedIntegerLiteral.h; sourceTree = "<group>"; };
+               C21BF72C21CD89E900227979 /* WHLSLMakePointerExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLMakePointerExpression.h; sourceTree = "<group>"; };
+               C21BF72D21CD89E900227979 /* WHLSLMakeArrayReferenceExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLMakeArrayReferenceExpression.h; sourceTree = "<group>"; };
+               C21BF72E21CD89EA00227979 /* WHLSLPropertyAccessExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLPropertyAccessExpression.h; sourceTree = "<group>"; };
+               C21BF72F21CD89EC00227979 /* WHLSLPointerType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLPointerType.h; sourceTree = "<group>"; };
+               C21BF73021CD89ED00227979 /* WHLSLAssignmentExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLAssignmentExpression.h; sourceTree = "<group>"; };
+               C21BF73121CD89EE00227979 /* WHLSLSwitchStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSwitchStatement.h; sourceTree = "<group>"; };
+               C21BF73221CD89EF00227979 /* WHLSLLogicalExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLLogicalExpression.h; sourceTree = "<group>"; };
+               C21BF73321CD89F000227979 /* WHLSLConstantExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLConstantExpression.h; sourceTree = "<group>"; };
+               C21BF73421CD89F100227979 /* WHLSLForLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLForLoop.h; sourceTree = "<group>"; };
+               C21BF73521CD89F200227979 /* WHLSLFloatLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFloatLiteral.h; sourceTree = "<group>"; };
+               C21BF73621CD89F300227979 /* WHLSLSpecializationConstantSemantic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLSpecializationConstantSemantic.h; sourceTree = "<group>"; };
+               C21BF73721CD8A0200227979 /* WHLSLParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLParser.cpp; sourceTree = "<group>"; };
+               C21BF73821CD8A0300227979 /* WHLSLParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLParser.h; sourceTree = "<group>"; };
+               C21BF73A21CD8D7000227979 /* WHLSLProgram.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLProgram.h; sourceTree = "<group>"; };
                C21DF2E71D9E4E9900F5B24C /* CSSFontVariationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontVariationValue.cpp; sourceTree = "<group>"; };
                C21DF2E81D9E4E9900F5B24C /* CSSFontVariationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontVariationValue.h; sourceTree = "<group>"; };
                C2458E611FE8979E00594759 /* FontCacheCoreText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontCacheCoreText.h; sourceTree = "<group>"; };
                C280833D1C6DC22C001451B6 /* JSFontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSFontFace.cpp; path = DerivedSources/WebCore/JSFontFace.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
                C280833E1C6DC22C001451B6 /* JSFontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSFontFace.h; path = DerivedSources/WebCore/JSFontFace.h; sourceTree = BUILT_PRODUCTS_DIR; };
                C280B3FD1EF4608900D35135 /* FontFamilySpecificationNull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFamilySpecificationNull.cpp; sourceTree = "<group>"; };
+               C288C72D21C991DA002DF5CA /* WHLSLTypeArgument.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLTypeArgument.cpp; sourceTree = "<group>"; };
                C2AB0AF41E6B3C6C001348C5 /* FontSelectionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontSelectionAlgorithm.cpp; sourceTree = "<group>"; };
                C2AB0AF51E6B3C6C001348C5 /* FontSelectionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSelectionAlgorithm.h; sourceTree = "<group>"; };
                C2AB0B031E6DE92C001348C5 /* FontSelectionValueInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontSelectionValueInlines.h; sourceTree = "<group>"; };
                C210E90D21B4BCA400B7F83D /* WHLSL */ = {
                        isa = PBXGroup;
                        children = (
+                               C21BF6F121CD898D00227979 /* AST */,
                                C210E91121B4BD1000B7F83D /* WHLSLLexer.cpp */,
                                C210E91221B4BD1000B7F83D /* WHLSLLexer.h */,
+                               C21BF73721CD8A0200227979 /* WHLSLParser.cpp */,
+                               C21BF73821CD8A0300227979 /* WHLSLParser.h */,
+                               C21BF73A21CD8D7000227979 /* WHLSLProgram.h */,
                        );
                        path = WHLSL;
                        sourceTree = "<group>";
                };
+               C21BF6F121CD898D00227979 /* AST */ = {
+                       isa = PBXGroup;
+                       children = (
+                               C21BF72521CD89E200227979 /* WHLSLArrayReferenceType.h */,
+                               C21BF70921CD89CA00227979 /* WHLSLArrayType.h */,
+                               C21BF73021CD89ED00227979 /* WHLSLAssignmentExpression.h */,
+                               C21BF70A21CD89CB00227979 /* WHLSLBaseFunctionAttribute.h */,
+                               C21BF6FA21CD89BE00227979 /* WHLSLBaseSemantic.h */,
+                               C21BF71E21CD89DC00227979 /* WHLSLBlock.h */,
+                               C21BF6F621CD89B700227979 /* WHLSLBooleanLiteral.h */,
+                               C21BF71A21CD89D800227979 /* WHLSLBreak.h */,
+                               C2138A1321DDECD300F516BA /* WHLSLBuiltInSemantic.cpp */,
+                               C21BF72221CD89DF00227979 /* WHLSLBuiltInSemantic.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 */,
+                               C21BF72021CD89DD00227979 /* WHLSLEnumerationDefinition.h */,
+                               C21BF72621CD89E300227979 /* WHLSLEnumerationMember.h */,
+                               1C33276C21CEDA42000DC9F2 /* WHLSLEnumerationMemberLiteral.h */,
+                               C21BF70C21CD89CC00227979 /* WHLSLExpression.h */,
+                               C21BF70021CD89C200227979 /* WHLSLFallthrough.h */,
+                               C21BF73521CD89F200227979 /* WHLSLFloatLiteral.h */,
+                               1CB69B3821DF03E1006E846A /* WHLSLFloatLiteralType.cpp */,
+                               1CB69B3421DED63A006E846A /* WHLSLFloatLiteralType.h */,
+                               C21BF73421CD89F100227979 /* WHLSLForLoop.h */,
+                               C21BF70521CD89C700227979 /* WHLSLFunctionAttribute.h */,
+                               C21BF6FD21CD89C000227979 /* WHLSLFunctionDeclaration.h */,
+                               C21BF6F421CD89B300227979 /* WHLSLFunctionDefinition.h */,
+                               C21BF6FF21CD89C200227979 /* WHLSLIfStatement.h */,
+                               C21BF6F721CD89B900227979 /* WHLSLIndexExpression.h */,
+                               C20F4F6621DFF2360070C45A /* WHLSLIntegerLiteral.cpp */,
+                               C21BF6F821CD89BB00227979 /* WHLSLIntegerLiteral.h */,
+                               1CB69B3921DF03F3006E846A /* WHLSLIntegerLiteralType.cpp */,
+                               1CB69B3521DED649006E846A /* WHLSLIntegerLiteralType.h */,
+                               C21BF73221CD89EF00227979 /* WHLSLLogicalExpression.h */,
+                               C21BF71521CD89D400227979 /* WHLSLLogicalNotExpression.h */,
+                               C21BF72D21CD89E900227979 /* WHLSLMakeArrayReferenceExpression.h */,
+                               C21BF72C21CD89E900227979 /* WHLSLMakePointerExpression.h */,
+                               1C33277121CF0BE1000DC9F2 /* WHLSLNamedType.h */,
+                               C21BF72321CD89E100227979 /* WHLSLNativeFunctionDeclaration.h */,
+                               C21BF72A21CD89E700227979 /* WHLSLNativeTypeDeclaration.h */,
+                               C21BF72421CD89E100227979 /* WHLSLNode.h */,
+                               C21BF70721CD89C800227979 /* WHLSLNullLiteral.h */,
+                               1CB69B3A21DF0403006E846A /* WHLSLNullLiteralType.cpp */,
+                               1CB69B3621DED657006E846A /* WHLSLNullLiteralType.h */,
+                               C21BF72121CD89DE00227979 /* WHLSLNumThreadsFunctionAttribute.h */,
+                               C21BF72F21CD89EC00227979 /* WHLSLPointerType.h */,
+                               C21BF72E21CD89EA00227979 /* WHLSLPropertyAccessExpression.h */,
+                               C21BF70B21CD89CC00227979 /* WHLSLQualifier.h */,
+                               C21BF71B21CD89D900227979 /* WHLSLReadModifyWriteExpression.h */,
+                               C21BF70D21CD89CD00227979 /* WHLSLReferenceType.h */,
+                               1CB69B3221DED40B006E846A /* WHLSLResolvableType.h */,
+                               C2138A1521DDECE900F516BA /* WHLSLResourceSemantic.cpp */,
+                               C21BF70821CD89C900227979 /* WHLSLResourceSemantic.h */,
+                               C21BF70321CD89C500227979 /* WHLSLReturn.h */,
+                               C21BF6F921CD89BD00227979 /* WHLSLSemantic.h */,
+                               C2138A1621DDECFB00F516BA /* WHLSLSpecializationConstantSemantic.cpp */,
+                               C21BF73621CD89F300227979 /* WHLSLSpecializationConstantSemantic.h */,
+                               C2138A1721DDED0D00F516BA /* WHLSLStageInOutSemantic.cpp */,
+                               C21BF70E21CD89CE00227979 /* WHLSLStageInOutSemantic.h */,
+                               C21BF71221CD89D100227979 /* WHLSLStatement.h */,
+                               C21BF72721CD89E400227979 /* WHLSLStructureDefinition.h */,
+                               C21BF6FE21CD89C100227979 /* WHLSLStructureElement.h */,
+                               C21BF71921CD89D700227979 /* WHLSLSwitchCase.h */,
+                               C21BF73121CD89EE00227979 /* WHLSLSwitchStatement.h */,
+                               C21BF71C21CD89DA00227979 /* WHLSLTernaryExpression.h */,
+                               C21BF6F321CD89AD00227979 /* WHLSLTrap.h */,
+                               C21BF71D21CD89DB00227979 /* WHLSLType.h */,
+                               C288C72D21C991DA002DF5CA /* WHLSLTypeArgument.cpp */,
+                               C21BF71121CD89D100227979 /* WHLSLTypeArgument.h */,
+                               C21BF72921CD89E600227979 /* WHLSLTypeDefinition.h */,
+                               C20F4F6421DFBE5C0070C45A /* WHLSLTypeReference.cpp */,
+                               C21BF71F21CD89DC00227979 /* WHLSLTypeReference.h */,
+                               1C33277221CF0D2E000DC9F2 /* WHLSLUnnamedType.h */,
+                               C20F4F6721DFF3A70070C45A /* WHLSLUnsignedIntegerLiteral.cpp */,
+                               C21BF72B21CD89E800227979 /* WHLSLUnsignedIntegerLiteral.h */,
+                               1CB69B3B21DF041E006E846A /* WHLSLUnsignedIntegerLiteralType.cpp */,
+                               1CB69B3721DED66B006E846A /* WHLSLUnsignedIntegerLiteralType.h */,
+                               C21BF6FC21CD89BF00227979 /* WHLSLValue.h */,
+                               C21BF71021CD89D000227979 /* WHLSLVariableDeclaration.h */,
+                               C21BF71421CD89D300227979 /* WHLSLVariableDeclarationsStatement.h */,
+                               C21BF71321CD89D200227979 /* WHLSLVariableReference.h */,
+                               C21BF70421CD89C600227979 /* WHLSLWhileLoop.h */,
+                       );
+                       path = AST;
+                       sourceTree = "<group>";
+               };
                C96F5EBF1B5872260091EA9D /* mediasession */ = {
                        isa = PBXGroup;
                        children = (