Diff
Modified: trunk/Source/WebGPU/ChangeLog (291004 => 291005)
--- trunk/Source/WebGPU/ChangeLog 2022-03-08 20:15:09 UTC (rev 291004)
+++ trunk/Source/WebGPU/ChangeLog 2022-03-08 20:41:12 UTC (rev 291005)
@@ -1,5 +1,148 @@
2022-03-08 Robin Morisset <[email protected]>
+ [WGSL] Add enough of the AST for the simplest shaders
+ https://bugs.webkit.org/show_bug.cgi?id=236655
+
+ Reviewed by Myles Maxfield.
+
+ These AST nodes are just those required for the most trivial graphics and compute shaders.
+ I used the machinery from wtf/TypeCasts as suggested by Myles in https://bugs.webkit.org/show_bug.cgi?id=233276.
+ Currently all of the code for these nodes is included in WGSL.cpp to verify that they build. This will be removed in the parser patch.
+
+ Attributes are added in setAttributes methods instead of being part of the constructors, because it can fail, and returning an error from a constructor is tricky.
+
+ * WGSL/AST/Attribute.h: Added.
+ (WGSL::AST::Attribute::Attribute):
+ (WGSL::AST::Attribute::kind const):
+ (WGSL::AST::Attribute::isBlock const):
+ (WGSL::AST::Attribute::isGroup const):
+ (WGSL::AST::Attribute::isBinding const):
+ (WGSL::AST::Attribute::isStage const):
+ (WGSL::AST::Attribute::isLocation const):
+ (WGSL::AST::Attribute::isBuiltin const):
+ (WGSL::AST::BlockAttribute::BlockAttribute):
+ (WGSL::AST::GroupAttribute::GroupAttribute):
+ (WGSL::AST::GroupAttribute::group const):
+ (WGSL::AST::BindingAttribute::BindingAttribute):
+ (WGSL::AST::BindingAttribute::binding const):
+ (WGSL::AST::StageAttribute::StageAttribute):
+ (WGSL::AST::StageAttribute::stage const):
+ (WGSL::AST::BuiltinAttribute::BuiltinAttribute):
+ (WGSL::AST::BuiltinAttribute::name const):
+ (WGSL::AST::LocationAttribute::LocationAttribute):
+ (WGSL::AST::LocationAttribute::location const):
+ * WGSL/AST/_expression_.h: Added.
+ (WGSL::AST::_expression_::_expression_):
+ (WGSL::AST::_expression_::kind const):
+ (WGSL::AST::_expression_::isBoolLiteral const):
+ (WGSL::AST::_expression_::isInt32Literal const):
+ (WGSL::AST::_expression_::isUInt32Literal const):
+ (WGSL::AST::_expression_::isFloat32Literal const):
+ (WGSL::AST::_expression_::isIdentifier const):
+ (WGSL::AST::_expression_::isStructureAccess const):
+ (WGSL::AST::_expression_::isTypeConversion const):
+ * WGSL/AST/Expressions/IdentifierExpression.h: Added.
+ (WGSL::AST::IdentifierExpression::IdentifierExpression):
+ (WGSL::AST::IdentifierExpression::identifier const):
+ * WGSL/AST/Expressions/LiteralExpressions.h: Added.
+ (WGSL::AST::BoolLiteral::BoolLiteral):
+ (WGSL::AST::BoolLiteral::value const):
+ (WGSL::AST::Int32Literal::Int32Literal):
+ (WGSL::AST::Int32Literal::value const):
+ (WGSL::AST::Uint32Literal::Uint32Literal):
+ (WGSL::AST::Uint32Literal::value const):
+ (WGSL::AST::Float32Literal::Float32Literal):
+ (WGSL::AST::Float32Literal::value const):
+ * WGSL/AST/Expressions/StructureAccess.h: Added.
+ (WGSL::AST::StructureAccess::StructureAccess):
+ (WGSL::AST::StructureAccess::base):
+ (WGSL::AST::StructureAccess::fieldName const):
+ * WGSL/AST/Expressions/TypeConversion.h: Added.
+ (WGSL::AST::TypeConversion::TypeConversion):
+ (WGSL::AST::TypeConversion::typeDecl):
+ (WGSL::AST::TypeConversion::arguments):
+ * WGSL/AST/FunctionDecl.h: Added.
+ (WGSL::AST::Parameter::Parameter):
+ (WGSL::AST::Parameter::setAttributes):
+ (WGSL::AST::Parameter::builtin const):
+ (WGSL::AST::Parameter::location const):
+ (WGSL::AST::Parameter::name const):
+ (WGSL::AST::Parameter::type):
+ (WGSL::AST::FunctionDecl::FunctionDecl):
+ (WGSL::AST::FunctionDecl::setAttributes):
+ (WGSL::AST::FunctionDecl::setReturnAttributes):
+ (WGSL::AST::FunctionDecl::entryPointStage const):
+ (WGSL::AST::FunctionDecl::name const):
+ (WGSL::AST::FunctionDecl::parameters):
+ (WGSL::AST::FunctionDecl::returnBuiltin const):
+ (WGSL::AST::FunctionDecl::returnLocation const):
+ (WGSL::AST::FunctionDecl::maybeReturnType):
+ (WGSL::AST::FunctionDecl::body):
+ * WGSL/AST/GlobalDecl.h: Added.
+ (WGSL::AST::GlobalDecl::GlobalDecl):
+ (WGSL::AST::GlobalDecl::kind const):
+ (WGSL::AST::GlobalDecl::isGlobalVariable const):
+ (WGSL::AST::GlobalDecl::isStruct const):
+ (WGSL::AST::GlobalDecl::isFunction const):
+ * WGSL/AST/GlobalDirective.h: Added.
+ (WGSL::AST::GlobalDirective::name const):
+ * WGSL/AST/GlobalVariableDecl.h: Added.
+ (WGSL::AST::GlobalVariableDecl::GlobalVariableDecl):
+ (WGSL::AST::GlobalVariableDecl::setAttributes):
+ (WGSL::AST::GlobalVariableDecl::group const):
+ (WGSL::AST::GlobalVariableDecl::binding const):
+ (WGSL::AST::GlobalVariableDecl::name const):
+ (WGSL::AST::GlobalVariableDecl::maybeQualifier):
+ (WGSL::AST::GlobalVariableDecl::maybeTypeDecl):
+ (WGSL::AST::GlobalVariableDecl::maybeInitializer):
+ * WGSL/AST/Shader.h: Renamed from Source/WebGPU/WGSL/AST.h.
+ * WGSL/AST/Statement.h: Added.
+ (WGSL::AST::Statement::Statement):
+ (WGSL::AST::Statement::kind const):
+ (WGSL::AST::Statement::isCompound const):
+ (WGSL::AST::Statement::isReturn const):
+ (WGSL::AST::Statement::isAssignment const):
+ * WGSL/AST/Statements/AssignmentStatement.h: Added.
+ (WGSL::AST::AssignmentStatement::AssignmentStatement):
+ (WGSL::AST::AssignmentStatement::maybeLhs):
+ (WGSL::AST::AssignmentStatement::rhs):
+ * WGSL/AST/Statements/ReturnStatement.h: Added.
+ (WGSL::AST::ReturnStatement::ReturnStatement):
+ (WGSL::AST::ReturnStatement::maybeExpression):
+ * WGSL/AST/StructureDecl.h: Added.
+ (WGSL::AST::StructMember::StructMember):
+ (WGSL::AST::StructMember::setAttributes):
+ (WGSL::AST::StructMember::builtin const):
+ (WGSL::AST::StructMember::location const):
+ (WGSL::AST::StructMember::name const):
+ (WGSL::AST::StructMember::type):
+ (WGSL::AST::StructDecl::StructDecl):
+ (WGSL::AST::StructDecl::setAttributes):
+ (WGSL::AST::StructDecl::isBlock const):
+ (WGSL::AST::StructDecl::name const):
+ (WGSL::AST::StructDecl::members):
+ * WGSL/AST/TypeDecl.h: Added.
+ (WGSL::AST::TypeDecl::TypeDecl):
+ (WGSL::AST::TypeDecl::kind const):
+ (WGSL::AST::TypeDecl::isNamed const):
+ (WGSL::AST::TypeDecl::isParameterized const):
+ * WGSL/AST/VariableQualifier.h: Added.
+ (WGSL::AST::VariableQualifier::VariableQualifier):
+ (WGSL::AST::VariableQualifier::storageClass const):
+ (WGSL::AST::VariableQualifier::accessMode const):
+ * WGSL/ASTNode.h: Added.
+ (WGSL::AST::ASTNode::ASTNode):
+ (WGSL::AST::ASTNode::span const):
+ * WGSL/CompilationMessage.cpp: Added.
+ (WGSL::CompilationMessage::dump const):
+ * WGSL/CompilationMessage.h: Added.
+ (WGSL::CompilationMessage::CompilationMessage):
+ * WGSL/WGSL.cpp:
+ * WGSL/WGSL.h:
+ * WebGPU.xcodeproj/project.pbxproj:
+
+2022-03-08 Robin Morisset <[email protected]>
+
[WGSL] The lexer should use the functions from wtf/ASCIICType.h
https://bugs.webkit.org/show_bug.cgi?id=236783
Added: trunk/Source/WebGPU/WGSL/AST/Attribute.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Attribute.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Attribute.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+#include <wtf/text/StringView.h>
+#include <wtf/UniqueRef.h>
+#include <wtf/Vector.h>
+
+namespace WGSL::AST {
+
+class Attribute : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ enum class Kind {
+ Block,
+ Group,
+ Binding,
+ Stage,
+ Location,
+ Builtin,
+ };
+
+ Attribute(SourceSpan span)
+ : ASTNode(span)
+ {
+ }
+
+ virtual ~Attribute() {};
+
+ virtual Kind kind() const = 0 ;
+ bool isBlock() const { return kind() == Kind::Block; }
+ bool isGroup() const { return kind() == Kind::Group; }
+ bool isBinding() const { return kind() == Kind::Binding; }
+ bool isStage() const { return kind() == Kind::Stage; }
+ bool isLocation() const { return kind() == Kind::Location; }
+ bool isBuiltin() const { return kind() == Kind::Builtin; }
+};
+
+class BlockAttribute final : public Attribute {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ BlockAttribute(SourceSpan span)
+ : Attribute(span)
+ {
+ }
+
+ Kind kind() const override { return Kind::Block; }
+};
+
+class GroupAttribute final : public Attribute {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ GroupAttribute(SourceSpan span, unsigned group)
+ : Attribute(span)
+ , m_value(group)
+ {
+ }
+
+ Kind kind() const override { return Kind::Group; }
+ unsigned group() const { return m_value; }
+
+private:
+ unsigned m_value;
+};
+
+class BindingAttribute final : public Attribute {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ BindingAttribute(SourceSpan span, unsigned binding)
+ : Attribute(span)
+ , m_value(binding)
+ {
+ }
+
+ Kind kind() const override { return Kind::Binding; }
+ unsigned binding() const { return m_value; }
+
+private:
+ unsigned m_value;
+};
+
+class StageAttribute final : public Attribute {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ enum class Stage : uint8_t {
+ Compute,
+ Vertex,
+ Fragment
+ };
+
+ StageAttribute(SourceSpan span, Stage stage)
+ : Attribute(span)
+ , m_stage(stage)
+ {
+ }
+
+ Kind kind() const override { return Kind::Stage; }
+ Stage stage() const { return m_stage; }
+
+private:
+ Stage m_stage;
+};
+
+class BuiltinAttribute final : public Attribute {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ BuiltinAttribute(SourceSpan span, StringView name)
+ : Attribute(span)
+ , m_name(name)
+ {
+ }
+
+ Kind kind() const override { return Kind::Builtin; }
+ const StringView& name() const { return m_name; }
+
+private:
+ StringView m_name;
+};
+
+class LocationAttribute final : public Attribute {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ LocationAttribute(SourceSpan span, unsigned value)
+ : Attribute(span)
+ , m_value(value)
+ {
+ }
+
+ Kind kind() const override { return Kind::Location; }
+ unsigned location() const { return m_value; }
+
+private:
+ unsigned m_value;
+};
+
+using Attributes = Vector<UniqueRef<Attribute>, 2>;
+
+} // namespace WGSL::AST
+
+#define SPECIALIZE_TYPE_TRAITS_WGSL_ATTRIBUTE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WGSL::AST::ToValueTypeName) \
+ static bool isType(const WGSL::AST::Attribute& attr) { return attr.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_WGSL_ATTRIBUTE(BlockAttribute, isBlock())
+SPECIALIZE_TYPE_TRAITS_WGSL_ATTRIBUTE(GroupAttribute, isGroup())
+SPECIALIZE_TYPE_TRAITS_WGSL_ATTRIBUTE(BindingAttribute, isBinding())
+SPECIALIZE_TYPE_TRAITS_WGSL_ATTRIBUTE(StageAttribute, isStage())
+SPECIALIZE_TYPE_TRAITS_WGSL_ATTRIBUTE(LocationAttribute, isLocation())
+SPECIALIZE_TYPE_TRAITS_WGSL_ATTRIBUTE(BuiltinAttribute, isBuiltin())
+
Added: trunk/Source/WebGPU/WGSL/AST/_expression_.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/_expression_.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/_expression_.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+#include <wtf/TypeCasts.h>
+
+namespace WGSL::AST {
+
+class _expression_ : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ enum class Kind {
+ BoolLiteral,
+ Int32Literal,
+ Uint32Literal,
+ Float32Literal,
+ Identifier,
+ StructureAccess,
+ TypeConversion,
+ };
+
+ _expression_(SourceSpan span)
+ : ASTNode(span)
+ {
+ }
+
+ virtual ~_expression_() {}
+
+ virtual Kind kind() const = 0;
+ bool isBoolLiteral() const { return kind() == Kind::BoolLiteral; }
+ bool isInt32Literal() const { return kind() == Kind::Int32Literal; }
+ bool isUInt32Literal() const { return kind() == Kind::Uint32Literal; }
+ bool isFloat32Literal() const { return kind() == Kind::Float32Literal; }
+ bool isIdentifier() const { return kind() == Kind::Identifier; }
+ bool isStructureAccess() const { return kind() == Kind::StructureAccess; }
+ bool isTypeConversion() const { return kind() == Kind::TypeConversion; }
+};
+
+} // namespace WGSL::AST
+
+#define SPECIALIZE_TYPE_TRAITS_WGSL_EXPRESSION(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WGSL::AST::ToValueTypeName) \
+ static bool isType(const WGSL::AST::_expression_& _expression_) { return _expression_.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
Added: trunk/Source/WebGPU/WGSL/AST/Expressions/IdentifierExpression.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Expressions/IdentifierExpression.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Expressions/IdentifierExpression.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2022 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 "_expression_.h"
+#include <wtf/text/StringView.h>
+
+namespace WGSL::AST {
+
+class IdentifierExpression final : public _expression_ {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ IdentifierExpression(SourceSpan span, StringView identifier)
+ : _expression_(span)
+ , m_identifier(identifier)
+ {
+ }
+
+ Kind kind() const override { return Kind::Identifier; }
+ const StringView& identifier() const { return m_identifier; }
+
+private:
+ StringView m_identifier;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_EXPRESSION(IdentifierExpression, isIdentifier())
Added: trunk/Source/WebGPU/WGSL/AST/Expressions/LiteralExpressions.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Expressions/LiteralExpressions.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Expressions/LiteralExpressions.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2022 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
+
+namespace WGSL::AST {
+
+class BoolLiteral final : public _expression_ {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ BoolLiteral(SourceSpan span, bool value)
+ : _expression_(span)
+ , m_value(value)
+ {
+ }
+
+ Kind kind() const override { return Kind::BoolLiteral; }
+ bool value() const { return m_value; }
+
+private:
+ bool m_value;
+};
+
+class Int32Literal final : public _expression_ {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ Int32Literal(SourceSpan span, int32_t value)
+ : _expression_(span)
+ , m_value(value)
+ {
+ }
+
+ Kind kind() const override { return Kind::Int32Literal; }
+ int32_t value() const { return m_value; }
+
+private:
+ int32_t m_value;
+};
+
+class Uint32Literal final : public _expression_ {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ Uint32Literal(SourceSpan span, uint32_t value)
+ : _expression_(span)
+ , m_value(value)
+ {
+ }
+
+ Kind kind() const override { return Kind::Uint32Literal; }
+ uint32_t value() const { return m_value; }
+
+private:
+ uint32_t m_value;
+};
+
+class Float32Literal final : public _expression_ {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ Float32Literal(SourceSpan span, float value)
+ : _expression_(span)
+ , m_value(value)
+ {
+ }
+
+ Kind kind() const override { return Kind::Float32Literal; }
+ float value() const { return m_value; }
+
+private:
+ float m_value;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_EXPRESSION(BoolLiteral, isBoolLiteral())
+SPECIALIZE_TYPE_TRAITS_WGSL_EXPRESSION(Int32Literal, isInt32Literal())
+SPECIALIZE_TYPE_TRAITS_WGSL_EXPRESSION(Float32Literal, isFloat32Literal())
+SPECIALIZE_TYPE_TRAITS_WGSL_EXPRESSION(Uint32Literal, isUInt32Literal())
Added: trunk/Source/WebGPU/WGSL/AST/Expressions/StructureAccess.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Expressions/StructureAccess.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Expressions/StructureAccess.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2022 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 "_expression_.h"
+#include <wtf/text/StringView.h>
+
+namespace WGSL::AST {
+
+class StructureAccess final : public _expression_ {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ StructureAccess(SourceSpan span, UniqueRef<_expression_>&& base, StringView fieldName)
+ : _expression_(span)
+ , m_base(WTFMove(base))
+ , m_fieldName(fieldName)
+ {
+ }
+
+ Kind kind() const override { return Kind::StructureAccess; }
+ UniqueRef<_expression_>& base() { return m_base; }
+ const StringView& fieldName() const { return m_fieldName; }
+
+private:
+ UniqueRef<_expression_> m_base;
+ StringView m_fieldName;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_EXPRESSION(StructureAccess, isStructureAccess())
Added: trunk/Source/WebGPU/WGSL/AST/Expressions/TypeConversion.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Expressions/TypeConversion.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Expressions/TypeConversion.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2022 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 "_expression_.h"
+#include <wtf/UniqueRef.h>
+#include <wtf/Vector.h>
+
+namespace WGSL::AST {
+
+// May be converted to a function call during validation, as we can't tell the difference during parsing.
+class TypeConversion final : public _expression_ {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ TypeConversion(SourceSpan span, UniqueRef<TypeDecl>&& typeDecl, Vector<UniqueRef<_expression_>>&& arguments)
+ : _expression_(span)
+ , m_typeDecl(WTFMove(typeDecl))
+ , m_arguments(WTFMove(arguments))
+ {
+ }
+
+ Kind kind() const override { return Kind::TypeConversion; }
+ UniqueRef<TypeDecl>& typeDecl() { return m_typeDecl; }
+ Vector<UniqueRef<_expression_>>& arguments() { return m_arguments; }
+
+private:
+ UniqueRef<TypeDecl> m_typeDecl;
+ Vector<UniqueRef<_expression_>> m_arguments;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_EXPRESSION(TypeConversion, isTypeConversion())
Added: trunk/Source/WebGPU/WGSL/AST/FunctionDecl.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/FunctionDecl.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/FunctionDecl.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+#include "Attribute.h"
+#include "CompilationMessage.h"
+#include "Statements/CompoundStatement.h"
+#include "TypeDecl.h"
+
+namespace WGSL::AST {
+
+class Parameter final : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ Parameter(SourceSpan span, StringView name, UniqueRef<TypeDecl>&& type, Attributes&& attributes)
+ : ASTNode(span)
+ , m_name(WTFMove(name))
+ , m_type(WTFMove(type))
+ , m_attributes(WTFMove(attributes))
+ {
+ }
+
+ const StringView& name() const { return m_name; }
+ TypeDecl& type() { return m_type; }
+
+private:
+ StringView m_name;
+ UniqueRef<TypeDecl> m_type;
+ Attributes m_attributes;
+};
+
+class FunctionDecl final : public GlobalDecl {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ FunctionDecl(SourceSpan sourceSpan, StringView name, Vector<UniqueRef<Parameter>>&& parameters, std::unique_ptr<TypeDecl>&& returnType, CompoundStatement&& body, Attributes&& attributes, Attributes&& returnAttributes)
+ : GlobalDecl(sourceSpan)
+ , m_name(name)
+ , m_parameters(WTFMove(parameters))
+ , m_attributes(WTFMove(attributes))
+ , m_returnAttributes(WTFMove(returnAttributes))
+ , m_returnType(WTFMove(returnType))
+ , m_body(WTFMove(body))
+ {
+ }
+
+ Kind kind() const override { return Kind::Function; }
+ const StringView& name() const { return m_name; }
+ Vector<UniqueRef<Parameter>>& parameters() { return m_parameters; }
+ Attributes& attributes() { return m_attributes; }
+ Attributes& returnAttributes() { return m_returnAttributes; }
+ TypeDecl* maybeReturnType() { return m_returnType.get(); }
+ CompoundStatement& body() { return m_body; }
+
+private:
+ StringView m_name;
+ Vector<UniqueRef<Parameter>> m_parameters;
+ Attributes m_attributes;
+ Attributes m_returnAttributes;
+ std::unique_ptr<TypeDecl> m_returnType;
+ CompoundStatement m_body;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_GLOBAL_DECL(FunctionDecl, isFunction())
Added: trunk/Source/WebGPU/WGSL/AST/GlobalDecl.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/GlobalDecl.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/GlobalDecl.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+#include <wtf/TypeCasts.h>
+
+namespace WGSL::AST {
+
+class GlobalDecl : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ enum class Kind {
+ GlobalVariable,
+ Struct,
+ Function,
+ };
+
+ GlobalDecl(SourceSpan span)
+ : ASTNode(span)
+ {
+ }
+
+ virtual ~GlobalDecl() {}
+
+ virtual Kind kind() const = 0;
+ bool isGlobalVariable() const { return kind() == Kind::GlobalVariable; }
+ bool isStruct() const { return kind() == Kind::Struct; }
+ bool isFunction() const { return kind() == Kind::Function; }
+};
+
+} // namespace WGSL::AST
+
+#define SPECIALIZE_TYPE_TRAITS_WGSL_GLOBAL_DECL(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WGSL::AST::ToValueTypeName) \
+ static bool isType(const WGSL::AST::GlobalDecl& decl) { return decl.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
Added: trunk/Source/WebGPU/WGSL/AST/GlobalDirective.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/GlobalDirective.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/GlobalDirective.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+#include <wtf/text/WTFString.h>
+
+namespace WGSL::AST {
+
+class GlobalDirective : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ GlobalDirective(SourceSpan span, StringView name)
+ : ASTNode(span)
+ , m_name(name)
+ {
+ }
+
+ const StringView& name() const { return m_name; }
+
+private:
+ StringView m_name;
+};
+
+} // namespace WGSL::AST
Added: trunk/Source/WebGPU/WGSL/AST/GlobalVariableDecl.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/GlobalVariableDecl.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/GlobalVariableDecl.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2022 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 "Attribute.h"
+#include "CompilationMessage.h"
+#include "_expression_.h"
+#include "GlobalDecl.h"
+#include "TypeDecl.h"
+#include "VariableQualifier.h"
+#include <wtf/text/WTFString.h>
+
+namespace WGSL::AST {
+
+class GlobalVariableDecl final : public GlobalDecl {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ GlobalVariableDecl(SourceSpan span, StringView name, std::unique_ptr<VariableQualifier>&& qualifier, std::unique_ptr<TypeDecl>&& type, std::unique_ptr<_expression_>&& initializer, Attributes&& attributes)
+ : GlobalDecl(span)
+ , m_name(name)
+ , m_attributes(WTFMove(attributes))
+ , m_qualifier(WTFMove(qualifier))
+ , m_type(WTFMove(type))
+ , m_initializer(WTFMove(initializer))
+ {
+ ASSERT(m_type || m_initializer);
+ }
+
+ Kind kind() const override { return Kind::GlobalVariable; }
+ const StringView& name() const { return m_name; }
+ Attributes& attributes() { return m_attributes; }
+ VariableQualifier* maybeQualifier() { return m_qualifier.get(); }
+ TypeDecl* maybeTypeDecl() { return m_type.get(); }
+ _expression_* maybeInitializer() { return m_initializer.get(); }
+
+private:
+ StringView m_name;
+ Attributes m_attributes;
+ // Each of the following may be null
+ // But at least one of type and initializer must be non-null
+ std::unique_ptr<VariableQualifier> m_qualifier;
+ std::unique_ptr<TypeDecl> m_type;
+ std::unique_ptr<_expression_> m_initializer;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_GLOBAL_DECL(GlobalVariableDecl, isGlobalVariable())
Added: trunk/Source/WebGPU/WGSL/AST/ShaderModule.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/ShaderModule.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/ShaderModule.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2021 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. ``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
+ * 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 "ASTNode.h"
+#include "GlobalDecl.h"
+#include "GlobalDirective.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace WGSL::AST {
+
+class ShaderModule final : ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ ShaderModule(SourceSpan span, Vector<UniqueRef<GlobalDirective>>&& directives, Vector<UniqueRef<GlobalDecl>>&& decls)
+ : ASTNode(span)
+ , m_directives(WTFMove(directives))
+ {
+ for (auto& decl : decls) {
+ if (is<StructDecl>(decl.get())) {
+ // We want to go from UniqueRef<BaseClass> to UniqueRef<DerivedClass>, but that is not supported by downcast.
+ // So instead we do UniqueRef -> unique_ptr -> raw_pointer -(downcast)-> raw_pointer -> unique_ptr -> UniqueRef...
+ GlobalDecl* rawPtr = decl.moveToUniquePtr().release();
+ StructDecl* downcastedRawPtr = downcast<StructDecl>(rawPtr);
+ m_structs.append(makeUniqueRefFromNonNullUniquePtr(std::unique_ptr<StructDecl>(downcastedRawPtr)));
+ } else if (is<GlobalVariableDecl>(decl.get())) {
+ GlobalDecl* rawPtr = decl.moveToUniquePtr().release();
+ GlobalVariableDecl* downcastedRawPtr = downcast<GlobalVariableDecl>(rawPtr);
+ m_globalVars.append(makeUniqueRefFromNonNullUniquePtr(std::unique_ptr<GlobalVariableDecl>(downcastedRawPtr)));
+ } else {
+ GlobalDecl* rawPtr = decl.moveToUniquePtr().release();
+ FunctionDecl* func = downcast<FunctionDecl>(rawPtr);
+ m_functions.append(makeUniqueRefFromNonNullUniquePtr(std::unique_ptr<FunctionDecl>(func)));
+ }
+ }
+ }
+
+ Vector<UniqueRef<GlobalDirective>>& directives() { return m_directives; }
+ Vector<UniqueRef<StructDecl>>& structs() { return m_structs; }
+ Vector<UniqueRef<GlobalVariableDecl>>& globalVars() { return m_globalVars; }
+ Vector<UniqueRef<FunctionDecl>>& functions() { return m_functions; }
+
+private:
+ Vector<UniqueRef<GlobalDirective>> m_directives;
+
+ Vector<UniqueRef<StructDecl>> m_structs;
+ Vector<UniqueRef<GlobalVariableDecl>> m_globalVars;
+ Vector<UniqueRef<FunctionDecl>> m_functions;
+};
+
+} // namespace WGSL::AST
Added: trunk/Source/WebGPU/WGSL/AST/Statement.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Statement.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Statement.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+#include <wtf/TypeCasts.h>
+
+namespace WGSL::AST {
+
+class Statement : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ enum class Kind : uint8_t {
+ Compound,
+ Return,
+ Assignment,
+ };
+
+ Statement(SourceSpan span)
+ : ASTNode(span)
+ {
+ }
+
+ virtual ~Statement() {}
+
+ virtual Kind kind() const = 0;
+ bool isCompound() const { return kind() == Kind::Compound; }
+ bool isReturn() const { return kind() == Kind::Return; }
+ bool isAssignment() const { return kind() == Kind::Assignment; }
+};
+
+} // namespace WGSL::AST
+
+#define SPECIALIZE_TYPE_TRAITS_WGSL_STATEMENT(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WGSL::AST::ToValueTypeName) \
+ static bool isType(const WGSL::AST::Statement& statement) { return statement.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
Added: trunk/Source/WebGPU/WGSL/AST/Statements/AssignmentStatement.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Statements/AssignmentStatement.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Statements/AssignmentStatement.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2022 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 "_expression_.h"
+#include "Statement.h"
+
+namespace WGSL::AST {
+
+class AssignmentStatement final : public Statement {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ AssignmentStatement(SourceSpan span, std::unique_ptr<_expression_>&& lhs, UniqueRef<_expression_>&& rhs)
+ : Statement(span)
+ , m_lhs(WTFMove(lhs))
+ , m_rhs(WTFMove(rhs))
+ {
+ }
+
+ Kind kind() const override { return Kind::Assignment; }
+ _expression_* maybeLhs() { return m_lhs.get(); }
+ _expression_& rhs() { return m_rhs; }
+
+private:
+ // LHS can be null in the case it is '_', but RHS is never null
+ std::unique_ptr<_expression_> m_lhs;
+ UniqueRef<_expression_> m_rhs;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_STATEMENT(AssignmentStatement, isAssignment())
Added: trunk/Source/WebGPU/WGSL/AST/Statements/CompoundStatement.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Statements/CompoundStatement.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Statements/CompoundStatement.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2022 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 "Statement.h"
+
+namespace WGSL::AST {
+
+class CompoundStatement final : public Statement {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ CompoundStatement(SourceSpan span, Vector<UniqueRef<Statement>>&& statements)
+ : Statement(span)
+ , m_statements(WTFMove(statements))
+ {
+ }
+
+ Kind kind() const override { return Kind::Compound; }
+ Vector<UniqueRef<Statement>>& statements() { return m_statements; }
+
+private:
+ Vector<UniqueRef<Statement>> m_statements;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_STATEMENT(CompoundStatement, isCompound())
Added: trunk/Source/WebGPU/WGSL/AST/Statements/ReturnStatement.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/Statements/ReturnStatement.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/Statements/ReturnStatement.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2022 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
+
+#pragma once
+
+#include "_expression_.h"
+#include "Statement.h"
+
+namespace WGSL::AST {
+
+class ReturnStatement final : public Statement {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ ReturnStatement(SourceSpan span, std::unique_ptr<_expression_>&& _expression_)
+ : Statement(span)
+ , m_expression(WTFMove(_expression_))
+ {
+ }
+
+ Kind kind() const override { return Kind::Return; }
+ _expression_* maybeExpression() { return m_expression.get(); }
+
+private:
+ std::unique_ptr<_expression_> m_expression;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_STATEMENT(ReturnStatement, isReturn())
Added: trunk/Source/WebGPU/WGSL/AST/StructureDecl.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/StructureDecl.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/StructureDecl.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+#include "Attribute.h"
+#include "CompilationMessage.h"
+#include "GlobalDecl.h"
+#include "TypeDecl.h"
+#include <wtf/text/StringView.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/UniqueRef.h>
+
+
+namespace WGSL::AST {
+
+class StructMember final : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ StructMember(SourceSpan span, StringView name, UniqueRef<TypeDecl>&& type, Attributes&& attributes)
+ : ASTNode(span)
+ , m_name(name)
+ , m_attributes(WTFMove(attributes))
+ , m_type(WTFMove(type))
+ {
+ }
+
+ const StringView& name() const { return m_name; }
+ TypeDecl& type() { return m_type; }
+
+private:
+ StringView m_name;
+ Attributes m_attributes;
+ UniqueRef<TypeDecl> m_type;
+};
+
+class StructDecl final : public GlobalDecl {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ StructDecl(SourceSpan sourceSpan, StringView name, Vector<UniqueRef<StructMember>>&& members, Attributes&& attributes)
+ : GlobalDecl(sourceSpan)
+ , m_name(name)
+ , m_attributes(WTFMove(attributes))
+ , m_members(WTFMove(members))
+ {
+ }
+
+ Kind kind() const override { return Kind::Struct; }
+ const StringView& name() const { return m_name; }
+ Attributes& attributes() { return m_attributes; }
+ Vector<UniqueRef<StructMember>>& members() { return m_members; }
+
+private:
+ StringView m_name;
+ Attributes m_attributes;
+ Vector<UniqueRef<StructMember>> m_members;
+};
+
+} // namespace WGSL::AST
+
+SPECIALIZE_TYPE_TRAITS_WGSL_GLOBAL_DECL(StructDecl, isStruct())
Added: trunk/Source/WebGPU/WGSL/AST/TypeDecl.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/TypeDecl.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/TypeDecl.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+#include <wtf/TypeCasts.h>
+
+namespace WGSL::AST {
+
+class TypeDecl : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ enum class Kind : uint8_t {
+ Named,
+ Parameterized,
+ };
+
+ TypeDecl(SourceSpan span)
+ : ASTNode(span)
+ {
+ }
+
+ virtual ~TypeDecl() {}
+
+ virtual Kind kind() const = 0;
+ bool isNamed() const { return kind() == Kind::Named; }
+ bool isParameterized() const { return kind() == Kind::Parameterized; }
+};
+
+class NamedType final : public TypeDecl {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ NamedType(SourceSpan span, StringView&& name)
+ : TypeDecl(span)
+ , m_name(WTFMove(name))
+ {
+ }
+
+ Kind kind() const override { return Kind::Named; }
+ const StringView& name() const { return m_name; }
+
+private:
+ StringView m_name;
+};
+
+class ParameterizedType : public TypeDecl {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ enum class Base {
+ Vec2,
+ Vec3,
+ Vec4,
+ Mat2x2,
+ Mat2x3,
+ Mat2x4,
+ Mat3x2,
+ Mat3x3,
+ Mat3x4,
+ Mat4x2,
+ Mat4x3,
+ Mat4x4
+ };
+
+ ParameterizedType(SourceSpan span, Base base, UniqueRef<TypeDecl>&& elementType)
+ : TypeDecl(span)
+ , m_base(base)
+ , m_elementType(WTFMove(elementType))
+ {
+ }
+
+ Kind kind() const override { return Kind::Parameterized; }
+ Base base() const { return m_base; }
+ TypeDecl& elementType() { return m_elementType; }
+
+private:
+ Base m_base;
+ UniqueRef<TypeDecl> m_elementType;
+};
+
+} // namespace WGSL::AST
+
+#define SPECIALIZE_TYPE_TRAITS_WGSL_TYPE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WGSL::AST::ToValueTypeName) \
+ static bool isType(const WGSL::AST::TypeDecl& type) { return type.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_WGSL_TYPE(NamedType, isNamed())
+SPECIALIZE_TYPE_TRAITS_WGSL_TYPE(ParameterizedType, isParameterized())
Added: trunk/Source/WebGPU/WGSL/AST/VariableQualifier.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/AST/VariableQualifier.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/AST/VariableQualifier.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2022 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 "ASTNode.h"
+
+namespace WGSL::AST {
+
+enum class StorageClass : uint8_t {
+ Function,
+ Private,
+ Workgroup,
+ Uniform,
+ Storage
+};
+
+enum class AccessMode : uint8_t {
+ Read,
+ Write,
+ ReadWrite
+};
+
+class VariableQualifier final : public ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ VariableQualifier(SourceSpan span, StorageClass storageClass, AccessMode accessMode)
+ : ASTNode(span)
+ , m_storageClass(storageClass)
+ , m_accessMode(accessMode)
+ {
+ }
+
+ StorageClass storageClass() const { return m_storageClass; }
+ AccessMode accessMode() const { return m_accessMode; }
+
+private:
+ StorageClass m_storageClass;
+ AccessMode m_accessMode;
+};
+
+} // namespace WGSL::AST
Deleted: trunk/Source/WebGPU/WGSL/AST.h (291004 => 291005)
--- trunk/Source/WebGPU/WGSL/AST.h 2022-03-08 20:15:09 UTC (rev 291004)
+++ trunk/Source/WebGPU/WGSL/AST.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2021 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. ``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
- * 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
-
-namespace WGSL {
-
-class AST {
-
-};
-
-}
Added: trunk/Source/WebGPU/WGSL/ASTNode.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/ASTNode.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/ASTNode.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2022 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 "SourceSpan.h"
+#include <wtf/FastMalloc.h>
+
+namespace WGSL::AST {
+
+class ASTNode {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ ASTNode(SourceSpan span)
+ : m_span(span)
+ {
+ }
+
+ const SourceSpan& span() const { return m_span; }
+
+private:
+ SourceSpan m_span;
+};
+
+} // namespace WGSL::AST
Added: trunk/Source/WebGPU/WGSL/CompilationMessage.cpp (0 => 291005)
--- trunk/Source/WebGPU/WGSL/CompilationMessage.cpp (rev 0)
+++ trunk/Source/WebGPU/WGSL/CompilationMessage.cpp 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2022 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 "CompilationMessage.h"
+
+#include <wtf/PrintStream.h>
+
+namespace WGSL {
+
+void CompilationMessage::dump(PrintStream& out) const
+{
+ out.print(m_span.m_line, ":", m_span.m_lineOffset, " length:", m_span.m_length, m_message);
+}
+
+} // namespace WGSL
Added: trunk/Source/WebGPU/WGSL/CompilationMessage.h (0 => 291005)
--- trunk/Source/WebGPU/WGSL/CompilationMessage.h (rev 0)
+++ trunk/Source/WebGPU/WGSL/CompilationMessage.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2022 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 "SourceSpan.h"
+#include <wtf/FastMalloc.h>
+#include <wtf/text/WTFString.h>
+
+namespace WGSL {
+
+class CompilationMessage {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ CompilationMessage(String&& message, SourceSpan span)
+ : m_message(WTFMove(message))
+ , m_span(span)
+ {
+ }
+
+ void dump(PrintStream& out) const;
+
+ const String& message() const { return m_message; }
+ unsigned lineNumber() const { return m_span.m_line; }
+ unsigned lineOffset() const { return m_span.m_lineOffset; }
+ unsigned offset() const { return m_span.m_offset; }
+ unsigned length() const { return m_span.m_length; }
+
+private:
+ String m_message;
+ SourceSpan m_span;
+};
+
+} // namespace WGSL
Modified: trunk/Source/WebGPU/WGSL/WGSL.cpp (291004 => 291005)
--- trunk/Source/WebGPU/WGSL/WGSL.cpp 2022-03-08 20:15:09 UTC (rev 291004)
+++ trunk/Source/WebGPU/WGSL/WGSL.cpp 2022-03-08 20:41:12 UTC (rev 291005)
@@ -26,8 +26,18 @@
#include "config.h"
#include "WGSL.h"
-#include "AST.h"
#include "Lexer.h"
+// All of these are just to check that they compile, since for now they are not really used.
+#include "AST/GlobalVariableDecl.h"
+#include "AST/StructureDecl.h"
+#include "AST/FunctionDecl.h"
+#include "AST/ShaderModule.h"
+#include "AST/Statements/AssignmentStatement.h"
+#include "AST/Statements/ReturnStatement.h"
+#include "AST/Expressions/IdentifierExpression.h"
+#include "AST/Expressions/TypeConversion.h"
+#include "AST/Expressions/StructureAccess.h"
+#include "AST/Expressions/LiteralExpressions.h"
namespace WGSL {
@@ -43,7 +53,7 @@
SuccessfulCheck::~SuccessfulCheck() = default;
-PrepareResult prepare(const AST& ast, const HashMap<String, PipelineLayout>& pipelineLayouts)
+PrepareResult prepare(const AST::ShaderModule& ast, const HashMap<String, PipelineLayout>& pipelineLayouts)
{
UNUSED_PARAM(ast);
UNUSED_PARAM(pipelineLayouts);
@@ -50,7 +60,7 @@
return { String(), { } };
}
-PrepareResult prepare(const AST& ast, const String& entryPointName, const std::optional<PipelineLayout>& pipelineLayouts)
+PrepareResult prepare(const AST::ShaderModule& ast, const String& entryPointName, const std::optional<PipelineLayout>& pipelineLayouts)
{
UNUSED_PARAM(ast);
UNUSED_PARAM(entryPointName);
Modified: trunk/Source/WebGPU/WGSL/WGSL.h (291004 => 291005)
--- trunk/Source/WebGPU/WGSL/WGSL.h 2022-03-08 20:15:09 UTC (rev 291004)
+++ trunk/Source/WebGPU/WGSL/WGSL.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -25,6 +25,7 @@
#pragma once
+#include "CompilationMessage.h"
#include <cinttypes>
#include <cstdint>
#include <memory>
@@ -41,28 +42,16 @@
// Step 1
//
-enum class CompilationMessageType : uint8_t {
- Error,
- Warning,
- Info
-};
+namespace AST {
+class ShaderModule;
+}
-struct CompilationMessage {
- String message;
- uint64_t lineNumber;
- uint64_t linePosition;
- uint64_t offset;
- uint64_t length;
-};
-
-class AST;
-
struct SuccessfulCheck {
SuccessfulCheck() = delete;
SuccessfulCheck(SuccessfulCheck&&);
~SuccessfulCheck();
Vector<CompilationMessage> warnings;
- UniqueRef<AST> ast;
+ UniqueRef<AST::ShaderModule> ast;
};
struct FailedCheck {
@@ -214,7 +203,7 @@
// These are not allowed to fail.
// All failures must have already been caught in check().
-PrepareResult prepare(const AST&, const HashMap<String, PipelineLayout>&);
-PrepareResult prepare(const AST&, const String& entryPointName, const std::optional<PipelineLayout>&);
+PrepareResult prepare(const AST::ShaderModule&, const HashMap<String, PipelineLayout>&);
+PrepareResult prepare(const AST::ShaderModule&, const String& entryPointName, const std::optional<PipelineLayout>&);
} // namespace WGSL
Modified: trunk/Source/WebGPU/WebGPU/ShaderModule.h (291004 => 291005)
--- trunk/Source/WebGPU/WebGPU/ShaderModule.h 2022-03-08 20:15:09 UTC (rev 291004)
+++ trunk/Source/WebGPU/WebGPU/ShaderModule.h 2022-03-08 20:41:12 UTC (rev 291005)
@@ -52,7 +52,7 @@
static WGSL::PipelineLayout convertPipelineLayout(const PipelineLayout&);
static id<MTLLibrary> createLibrary(id<MTLDevice>, const String& msl, NSString *label);
- const WGSL::AST* ast() const;
+ const WGSL::AST::ShaderModule* ast() const;
const PipelineLayout* pipelineLayoutHint(const String&) const;
const WGSL::Reflection::EntryPointInformation* entryPointInformation(const String&) const;
Modified: trunk/Source/WebGPU/WebGPU/ShaderModule.mm (291004 => 291005)
--- trunk/Source/WebGPU/WebGPU/ShaderModule.mm 2022-03-08 20:15:09 UTC (rev 291004)
+++ trunk/Source/WebGPU/WebGPU/ShaderModule.mm 2022-03-08 20:41:12 UTC (rev 291005)
@@ -153,7 +153,7 @@
auto populateMessages = [&] (const Messages& compilationMessages) {
for (const auto& compilationMessage : compilationMessages.messages)
- flattenedMessages.append(compilationMessage.message.utf8());
+ flattenedMessages.append(compilationMessage.message().utf8());
};
populateMessages(messages1);
@@ -167,10 +167,10 @@
nullptr,
flattenedMessages[i + base].data(),
compilationMessages.type,
- compilationMessage.lineNumber,
- compilationMessage.linePosition,
- compilationMessage.offset,
- compilationMessage.length,
+ compilationMessage.lineNumber(),
+ compilationMessage.lineOffset(),
+ compilationMessage.offset(),
+ compilationMessage.length(),
});
}
};
@@ -218,11 +218,11 @@
return { { } };
}
-const WGSL::AST* ShaderModule::ast() const
+const WGSL::AST::ShaderModule* ShaderModule::ast() const
{
- return WTF::switchOn(m_checkResult, [&] (const WGSL::SuccessfulCheck& successfulCheck) -> const WGSL::AST* {
+ return WTF::switchOn(m_checkResult, [&] (const WGSL::SuccessfulCheck& successfulCheck) -> const WGSL::AST::ShaderModule* {
return successfulCheck.ast.ptr();
- }, [&] (const WGSL::FailedCheck&) -> const WGSL::AST* {
+ }, [&] (const WGSL::FailedCheck&) -> const WGSL::AST::ShaderModule* {
return nullptr;
});
}
Modified: trunk/Source/WebGPU/WebGPU.xcodeproj/project.pbxproj (291004 => 291005)
--- trunk/Source/WebGPU/WebGPU.xcodeproj/project.pbxproj 2022-03-08 20:15:09 UTC (rev 291004)
+++ trunk/Source/WebGPU/WebGPU.xcodeproj/project.pbxproj 2022-03-08 20:41:12 UTC (rev 291005)
@@ -49,6 +49,27 @@
338BB2D427B6B66C00E066AB /* Lexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 338BB2D327B6B66C00E066AB /* Lexer.h */; };
338BB2D627B6B68700E066AB /* Lexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 338BB2D527B6B68700E066AB /* Lexer.cpp */; };
DD05A35C27BF09C60096EFAB /* libWTF.a in Product Dependencies */ = {isa = PBXBuildFile; fileRef = 1CEBD8292716CAE700A5254D /* libWTF.a */; };
+ 33EA185E27BC194F00A1DD52 /* ASTNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA185D27BC194F00A1DD52 /* ASTNode.h */; };
+ 33EA186027BC198100A1DD52 /* GlobalDirective.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA185F27BC198100A1DD52 /* GlobalDirective.h */; };
+ 33EA186227BC19C100A1DD52 /* GlobalDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA186127BC19C100A1DD52 /* GlobalDecl.h */; };
+ 33EA186427BC1A1D00A1DD52 /* GlobalVariableDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA186327BC1A1D00A1DD52 /* GlobalVariableDecl.h */; };
+ 33EA186627BC1AD500A1DD52 /* CompilationMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA186527BC1AD500A1DD52 /* CompilationMessage.h */; };
+ 33EA186827BC1B1400A1DD52 /* CompilationMessage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33EA186727BC1B1400A1DD52 /* CompilationMessage.cpp */; };
+ 33EA186A27BC1BE600A1DD52 /* Attribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA186927BC1BE600A1DD52 /* Attribute.h */; };
+ 33EA186C27BC1CBC00A1DD52 /* _expression_.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA186B27BC1CBC00A1DD52 /* _expression_.h */; };
+ 33EA186E27BC1D4C00A1DD52 /* TypeDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA186D27BC1D4C00A1DD52 /* TypeDecl.h */; };
+ 33EA187027BC1E8A00A1DD52 /* ShaderModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA186F27BC1E8A00A1DD52 /* ShaderModule.h */; };
+ 33EA187227BC1FE100A1DD52 /* VariableQualifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA187127BC1FE100A1DD52 /* VariableQualifier.h */; };
+ 33EA187427BC204900A1DD52 /* StructureDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA187327BC204900A1DD52 /* StructureDecl.h */; };
+ 33EA187627BC216B00A1DD52 /* FunctionDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA187527BC216B00A1DD52 /* FunctionDecl.h */; };
+ 33EA187927BC22AA00A1DD52 /* Statement.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA187827BC22AA00A1DD52 /* Statement.h */; };
+ 33EA187B27BC230E00A1DD52 /* CompoundStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA187A27BC230E00A1DD52 /* CompoundStatement.h */; };
+ 33EA187E27BC249000A1DD52 /* ReturnStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA187D27BC249000A1DD52 /* ReturnStatement.h */; };
+ 33EA188027BC24E200A1DD52 /* AssignmentStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA187F27BC24E200A1DD52 /* AssignmentStatement.h */; };
+ 33EA188227BC25D000A1DD52 /* IdentifierExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA188127BC25D000A1DD52 /* IdentifierExpression.h */; };
+ 33EA188427BC268600A1DD52 /* StructureAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA188327BC268600A1DD52 /* StructureAccess.h */; };
+ 33EA188627BC26DF00A1DD52 /* TypeConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA188527BC26DF00A1DD52 /* TypeConversion.h */; };
+ 33EA188827BC361E00A1DD52 /* LiteralExpressions.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EA188727BC361E00A1DD52 /* LiteralExpressions.h */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -167,7 +188,6 @@
1CEBD8012716B9AB00A5254D /* SDKVariant.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; };
1CEBD8022716BF8200A5254D /* WGSL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WGSL.cpp; sourceTree = "<group>"; };
1CEBD8042716BFAB00A5254D /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
- 1CEBD8072716C2C000A5254D /* AST.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AST.h; sourceTree = "<group>"; };
1CEBD80A2716C36C00A5254D /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
1CEBD80B2716C37900A5254D /* ExportMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExportMacros.h; sourceTree = "<group>"; };
1CEBD80D2716C3D800A5254D /* ShaderModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShaderModule.h; sourceTree = "<group>"; };
@@ -181,6 +201,27 @@
338BB2D127B6B63F00E066AB /* SourceSpan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SourceSpan.h; sourceTree = "<group>"; };
338BB2D327B6B66C00E066AB /* Lexer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Lexer.h; sourceTree = "<group>"; };
338BB2D527B6B68700E066AB /* Lexer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Lexer.cpp; sourceTree = "<group>"; };
+ 33EA185D27BC194F00A1DD52 /* ASTNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ASTNode.h; path = WGSL/ASTNode.h; sourceTree = SOURCE_ROOT; };
+ 33EA185F27BC198100A1DD52 /* GlobalDirective.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalDirective.h; sourceTree = "<group>"; };
+ 33EA186127BC19C100A1DD52 /* GlobalDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalDecl.h; sourceTree = "<group>"; };
+ 33EA186327BC1A1D00A1DD52 /* GlobalVariableDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalVariableDecl.h; sourceTree = "<group>"; };
+ 33EA186527BC1AD500A1DD52 /* CompilationMessage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompilationMessage.h; sourceTree = "<group>"; };
+ 33EA186727BC1B1400A1DD52 /* CompilationMessage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompilationMessage.cpp; sourceTree = "<group>"; };
+ 33EA186927BC1BE600A1DD52 /* Attribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Attribute.h; sourceTree = "<group>"; };
+ 33EA186B27BC1CBC00A1DD52 /* _expression_.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _expression_.h; sourceTree = "<group>"; };
+ 33EA186D27BC1D4C00A1DD52 /* TypeDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeDecl.h; sourceTree = "<group>"; };
+ 33EA186F27BC1E8A00A1DD52 /* ShaderModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShaderModule.h; sourceTree = "<group>"; };
+ 33EA187127BC1FE100A1DD52 /* VariableQualifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VariableQualifier.h; sourceTree = "<group>"; };
+ 33EA187327BC204900A1DD52 /* StructureDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StructureDecl.h; sourceTree = "<group>"; };
+ 33EA187527BC216B00A1DD52 /* FunctionDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FunctionDecl.h; sourceTree = "<group>"; };
+ 33EA187827BC22AA00A1DD52 /* Statement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Statement.h; sourceTree = "<group>"; };
+ 33EA187A27BC230E00A1DD52 /* CompoundStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompoundStatement.h; sourceTree = "<group>"; };
+ 33EA187D27BC249000A1DD52 /* ReturnStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReturnStatement.h; sourceTree = "<group>"; };
+ 33EA187F27BC24E200A1DD52 /* AssignmentStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AssignmentStatement.h; sourceTree = "<group>"; };
+ 33EA188127BC25D000A1DD52 /* IdentifierExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IdentifierExpression.h; sourceTree = "<group>"; };
+ 33EA188327BC268600A1DD52 /* StructureAccess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StructureAccess.h; sourceTree = "<group>"; };
+ 33EA188527BC26DF00A1DD52 /* TypeConversion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeConversion.h; sourceTree = "<group>"; };
+ 33EA188727BC361E00A1DD52 /* LiteralExpressions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LiteralExpressions.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -323,8 +364,11 @@
1CEBD7F62716B33100A5254D /* WGSL */ = {
isa = PBXGroup;
children = (
- 1CEBD8072716C2C000A5254D /* AST.h */,
+ 33EA185C27BC193D00A1DD52 /* AST */,
1CEBD8042716BFAB00A5254D /* config.h */,
+ 33EA186527BC1AD500A1DD52 /* CompilationMessage.h */,
+ 33EA186727BC1B1400A1DD52 /* CompilationMessage.cpp */,
+ 338BB2D327B6B66C00E066AB /* Lexer.h */,
338BB2D527B6B68700E066AB /* Lexer.cpp */,
338BB2D327B6B66C00E066AB /* Lexer.h */,
338BB2D127B6B63F00E066AB /* SourceSpan.h */,
@@ -365,6 +409,48 @@
name = Frameworks;
sourceTree = "<group>";
};
+ 33EA185C27BC193D00A1DD52 /* AST */ = {
+ isa = PBXGroup;
+ children = (
+ 33EA185D27BC194F00A1DD52 /* ASTNode.h */,
+ 33EA186927BC1BE600A1DD52 /* Attribute.h */,
+ 33EA186B27BC1CBC00A1DD52 /* _expression_.h */,
+ 33EA187C27BC246000A1DD52 /* Expressions */,
+ 33EA187527BC216B00A1DD52 /* FunctionDecl.h */,
+ 33EA185F27BC198100A1DD52 /* GlobalDirective.h */,
+ 33EA186127BC19C100A1DD52 /* GlobalDecl.h */,
+ 33EA186327BC1A1D00A1DD52 /* GlobalVariableDecl.h */,
+ 33EA186F27BC1E8A00A1DD52 /* ShaderModule.h */,
+ 33EA187827BC22AA00A1DD52 /* Statement.h */,
+ 33EA187727BC229A00A1DD52 /* Statements */,
+ 33EA187327BC204900A1DD52 /* StructureDecl.h */,
+ 33EA186D27BC1D4C00A1DD52 /* TypeDecl.h */,
+ 33EA187127BC1FE100A1DD52 /* VariableQualifier.h */,
+ );
+ path = AST;
+ sourceTree = "<group>";
+ };
+ 33EA187727BC229A00A1DD52 /* Statements */ = {
+ isa = PBXGroup;
+ children = (
+ 33EA187F27BC24E200A1DD52 /* AssignmentStatement.h */,
+ 33EA187A27BC230E00A1DD52 /* CompoundStatement.h */,
+ 33EA187D27BC249000A1DD52 /* ReturnStatement.h */,
+ );
+ path = Statements;
+ sourceTree = "<group>";
+ };
+ 33EA187C27BC246000A1DD52 /* Expressions */ = {
+ isa = PBXGroup;
+ children = (
+ 33EA188127BC25D000A1DD52 /* IdentifierExpression.h */,
+ 33EA188327BC268600A1DD52 /* StructureAccess.h */,
+ 33EA188527BC26DF00A1DD52 /* TypeConversion.h */,
+ 33EA188727BC361E00A1DD52 /* LiteralExpressions.h */,
+ );
+ path = Expressions;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@@ -382,10 +468,30 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 33EA187927BC22AA00A1DD52 /* Statement.h in Headers */,
+ 33EA185E27BC194F00A1DD52 /* ASTNode.h in Headers */,
+ 33EA188627BC26DF00A1DD52 /* TypeConversion.h in Headers */,
+ 33EA186427BC1A1D00A1DD52 /* GlobalVariableDecl.h in Headers */,
+ 33EA187B27BC230E00A1DD52 /* CompoundStatement.h in Headers */,
+ 33EA187627BC216B00A1DD52 /* FunctionDecl.h in Headers */,
+ 338BB2D227B6B63F00E066AB /* SourceSpan.h in Headers */,
+ 33EA186627BC1AD500A1DD52 /* CompilationMessage.h in Headers */,
+ 33EA187027BC1E8A00A1DD52 /* ShaderModule.h in Headers */,
338BB2D427B6B66C00E066AB /* Lexer.h in Headers */,
- 338BB2D227B6B63F00E066AB /* SourceSpan.h in Headers */,
+ 33EA188827BC361E00A1DD52 /* LiteralExpressions.h in Headers */,
338BB2CE27B6B60200E066AB /* Token.h in Headers */,
+ 33EA186C27BC1CBC00A1DD52 /* _expression_.h in Headers */,
1CEBD7F82716B34400A5254D /* WGSL.h in Headers */,
+ 33EA186227BC19C100A1DD52 /* GlobalDecl.h in Headers */,
+ 33EA188027BC24E200A1DD52 /* AssignmentStatement.h in Headers */,
+ 33EA188427BC268600A1DD52 /* StructureAccess.h in Headers */,
+ 33EA188227BC25D000A1DD52 /* IdentifierExpression.h in Headers */,
+ 33EA186027BC198100A1DD52 /* GlobalDirective.h in Headers */,
+ 33EA186E27BC1D4C00A1DD52 /* TypeDecl.h in Headers */,
+ 33EA187427BC204900A1DD52 /* StructureDecl.h in Headers */,
+ 33EA187E27BC249000A1DD52 /* ReturnStatement.h in Headers */,
+ 33EA186A27BC1BE600A1DD52 /* Attribute.h in Headers */,
+ 33EA187227BC1FE100A1DD52 /* VariableQualifier.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};