From 74820e1b57985acfbe88e8a2b5a26b5cfaf624db Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 5 Dec 2023 22:24:48 +0100 Subject: [PATCH] Remove unnecessary ShaderSourceRewriter constructor Also fix the nullability of the shaderType field --- .../SyntaxRewriters/ShaderSourceRewriter.cs | 38 +++---------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index da4705af..5d51696c 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -24,7 +24,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter /// /// The type symbol for the shader type. /// - private readonly INamedTypeSymbol? shaderType; + private readonly INamedTypeSymbol shaderType; /// /// The collection of discovered static methods. @@ -92,7 +92,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter IDictionary staticFieldDefinitions, ImmutableArrayBuilder diagnostics, CancellationToken token, - bool isEntryPoint) + bool isEntryPoint = false) : base(semanticModel, discoveredTypes, constantDefinitions, staticFieldDefinitions, diagnostics, token) { this.shaderType = shaderType; @@ -104,37 +104,6 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter this.isEntryPoint = isEntryPoint; } - /// - /// Creates a new instance with the specified parameters. - /// - /// The instance for the target syntax tree. - /// The set of discovered custom types. - /// The set of discovered and processed static methods. - /// The collection of discovered instance methods for custom struct types. - /// The collection of discovered constructors for custom struct types. - /// The collection of discovered constant definitions. - /// The collection of discovered static field definitions. - /// The collection of produced instances. - /// The value for the current operation. - private ShaderSourceRewriter( - SemanticModelProvider semanticModel, - ICollection discoveredTypes, - IDictionary staticMethods, - IDictionary instanceMethods, - IDictionary constructors, - IDictionary constantDefinitions, - IDictionary staticFieldDefinitions, - ImmutableArrayBuilder diagnostics, - CancellationToken token) - : base(semanticModel, discoveredTypes, constantDefinitions, staticFieldDefinitions, diagnostics, token) - { - this.staticMethods = staticMethods; - this.instanceMethods = instanceMethods; - this.constructors = constructors; - this.implicitVariables = []; - this.localFunctions = []; - } - /// /// Gets the collection of processed local functions in the current tree. /// @@ -543,6 +512,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter } ShaderSourceRewriter shaderSourceRewriter = new( + this.shaderType, SemanticModel, DiscoveredTypes, this.staticMethods, @@ -597,6 +567,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter } ShaderSourceRewriter shaderSourceRewriter = new( + this.shaderType, SemanticModel, DiscoveredTypes, this.instanceMethods, @@ -685,6 +656,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter } ShaderSourceRewriter shaderSourceRewriter = new( + this.shaderType, SemanticModel, DiscoveredTypes, this.instanceMethods,