-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=261207 rdar://115060930 Reviewed by Mike Wyrzykowski. Currently, the AST treats type nodes as unrelated from expression nodes. This doesn't match the reference grammar, and causes issues since expressions are allowed as arguments to elaborated types. * Source/WebGPU/WGSL/AST/AST.h: * Source/WebGPU/WGSL/AST/ASTArrayTypeExpression.h: Copied from Source/WebGPU/WGSL/AST/ASTBitcastExpression.h. (WGSL::AST::ArrayTypeExpression::maybeElementType const): (WGSL::AST::ArrayTypeExpression::maybeElementCount const): (WGSL::AST::ArrayTypeExpression::ArrayTypeExpression): * Source/WebGPU/WGSL/AST/ASTBitcastExpression.h: * Source/WebGPU/WGSL/AST/ASTCallExpression.h: * Source/WebGPU/WGSL/AST/ASTElaboratedExpression.h: Copied from Source/WebGPU/WGSL/AST/ASTBitcastExpression.h. (WGSL::AST::ElaboratedExpression::base): (WGSL::AST::ElaboratedExpression::arguments): (WGSL::AST::ElaboratedExpression::ElaboratedExpression): * Source/WebGPU/WGSL/AST/ASTExpression.h: * Source/WebGPU/WGSL/AST/ASTForward.h: * Source/WebGPU/WGSL/AST/ASTFunction.h: * Source/WebGPU/WGSL/AST/ASTNode.h: * Source/WebGPU/WGSL/AST/ASTParameter.h: * Source/WebGPU/WGSL/AST/ASTReferenceTypeExpression.h: Copied from Source/WebGPU/WGSL/AST/ASTBitcastExpression.h. * Source/WebGPU/WGSL/AST/ASTStringDumper.cpp: (WGSL::AST::StringDumper::visit): * Source/WebGPU/WGSL/AST/ASTStringDumper.h: * Source/WebGPU/WGSL/AST/ASTStructureMember.h: * Source/WebGPU/WGSL/AST/ASTTypeName.h: Removed. * Source/WebGPU/WGSL/AST/ASTVariable.h: * Source/WebGPU/WGSL/AST/ASTVisitor.cpp: (WGSL::AST::Visitor::visit): * Source/WebGPU/WGSL/AST/ASTVisitor.h: * Source/WebGPU/WGSL/CallGraph.cpp: (WGSL::CallGraphBuilder::visit): * Source/WebGPU/WGSL/ConstantRewriter.cpp: (WGSL::ConstantRewriter::visit): * Source/WebGPU/WGSL/EntryPointRewriter.cpp: (WGSL::EntryPointRewriter::rewrite): (WGSL::EntryPointRewriter::checkReturnType): (WGSL::EntryPointRewriter::visit): * Source/WebGPU/WGSL/GlobalSorting.cpp: * Source/WebGPU/WGSL/GlobalVariableRewriter.cpp: (WGSL::RewriteGlobalVariables::pack): (WGSL::RewriteGlobalVariables::packResource): (WGSL::RewriteGlobalVariables::packStructResource): (WGSL::RewriteGlobalVariables::packArrayResource): (WGSL::RewriteGlobalVariables::updateReference): (WGSL::bindingMemberForGlobal): (WGSL::RewriteGlobalVariables::insertParameters): * Source/WebGPU/WGSL/MangleNames.cpp: * Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp: (WGSL::Metal::FunctionDefinitionWriter::visit): (WGSL::Metal::FunctionDefinitionWriter::visitArgumentBufferParameter): * Source/WebGPU/WGSL/Parser.cpp: (WGSL::Parser<Lexer>::parseTypeName): (WGSL::Parser<Lexer>::parseTypeNameAfterIdentifier): (WGSL::Parser<Lexer>::parseArrayType): (WGSL::Parser<Lexer>::parseVariableWithAttributes): (WGSL::Parser<Lexer>::parseFunction): * Source/WebGPU/WGSL/ParserPrivate.h: * Source/WebGPU/WGSL/TypeCheck.cpp: (WGSL::TypeChecker::visitVariable): (WGSL::TypeChecker::visit): (WGSL::TypeChecker::resolve): (WGSL::TypeChecker::allocateSimpleConstructor): * Source/WebGPU/WGSL/TypeStore.cpp: (WGSL::TypeStore::typeConstructorType): * Source/WebGPU/WGSL/TypeStore.h: * Source/WebGPU/WGSL/Types.h: * Source/WebGPU/WebGPU.xcodeproj/project.pbxproj: Canonical link: https://commits.webkit.org/267724@main
- Loading branch information
1 parent
939ec68
commit f5b0fa4
Showing
33 changed files
with
364 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (C) 2023 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 | ||
|
||
#include "ASTExpression.h" | ||
|
||
namespace WGSL::AST { | ||
|
||
class ArrayTypeExpression : public Expression { | ||
WGSL_AST_BUILDER_NODE(ArrayTypeExpression); | ||
|
||
public: | ||
NodeKind kind() const override; | ||
|
||
Expression* maybeElementType() const { return m_elementType; } | ||
Expression* maybeElementCount() const { return m_elementCount; } | ||
|
||
private: | ||
ArrayTypeExpression(SourceSpan span, Expression::Ptr elementType, Expression::Ptr elementCount) | ||
: Expression(span) | ||
, m_elementType(elementType) | ||
, m_elementCount(elementCount) | ||
{ } | ||
|
||
Expression::Ptr m_elementType; | ||
Expression::Ptr m_elementCount; | ||
}; | ||
|
||
} // namespace WGSL::AST | ||
|
||
SPECIALIZE_TYPE_TRAITS_WGSL_AST(ArrayTypeExpression) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2023 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 | ||
|
||
#include "ASTExpression.h" | ||
|
||
namespace WGSL::AST { | ||
|
||
class ElaboratedTypeExpression : public Expression { | ||
WGSL_AST_BUILDER_NODE(ElaboratedTypeExpression); | ||
|
||
public: | ||
NodeKind kind() const override; | ||
Identifier& base() { return m_base; } | ||
Expression::List& arguments() { return m_arguments; } | ||
|
||
private: | ||
ElaboratedTypeExpression(SourceSpan span, Identifier&& base, Expression::List&& arguments) | ||
: Expression(span) | ||
, m_base(WTFMove(base)) | ||
, m_arguments(WTFMove(arguments)) | ||
{ } | ||
|
||
Identifier m_base; | ||
Expression::List m_arguments; | ||
}; | ||
|
||
} // namespace WGSL::AST | ||
|
||
SPECIALIZE_TYPE_TRAITS_WGSL_AST(ElaboratedTypeExpression) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2023 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 | ||
|
||
#include "ASTExpression.h" | ||
|
||
namespace WGSL::AST { | ||
|
||
class ReferenceTypeExpression final : public Expression { | ||
WGSL_AST_BUILDER_NODE(ReferenceTypeExpression); | ||
|
||
public: | ||
NodeKind kind() const override; | ||
Expression& type() const { return m_type.get(); } | ||
|
||
private: | ||
ReferenceTypeExpression(SourceSpan span, Expression::Ref&& type) | ||
: Expression(span) | ||
, m_type(WTFMove(type)) | ||
{ } | ||
|
||
Expression::Ref m_type; | ||
}; | ||
|
||
} // namespace WGSL::AST | ||
|
||
SPECIALIZE_TYPE_TRAITS_WGSL_AST(ReferenceTypeExpression) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.