Use explicit types everywhere
このコミットが含まれているのは:
1 親
27c629f3b4
コミット
16c0fc9aab
74ファイル変更
+455
-446
検索条件に一致するファイルはありません
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -44,13 +45,13 @@ internal static partial class HlslKnownKeywords
|
||||
});
|
||||
|
||||
// HLSL primitive names
|
||||
foreach (var type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes))
|
||||
foreach (Type? type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes))
|
||||
{
|
||||
_ = knownKeywords.Add(type.Name.ToLowerInvariant());
|
||||
}
|
||||
|
||||
// HLSL intrinsics method names
|
||||
foreach (var method in typeof(Hlsl).GetMethods(BindingFlags.Public | BindingFlags.Static))
|
||||
foreach (MethodInfo? method in typeof(Hlsl).GetMethods(BindingFlags.Public | BindingFlags.Static))
|
||||
{
|
||||
string name = method.GetCustomAttribute<HlslIntrinsicNameAttribute>()?.Name ?? method.Name;
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ internal static partial class HlslKnownMethods
|
||||
};
|
||||
|
||||
// Programmatically load mappings from the Hlsl class as well (the ones with no parameter matching)
|
||||
foreach (var method in
|
||||
foreach (MethodInfo? method in
|
||||
from method in typeof(Hlsl).GetMethods(BindingFlags.Public | BindingFlags.Static)
|
||||
group method by method.Name
|
||||
into groups
|
||||
@@ -171,7 +171,7 @@ internal static partial class HlslKnownMethods
|
||||
Dictionary<string, string> knownMethods = new();
|
||||
|
||||
// Go through the previously discovered methods to find the ones requiring parameters mapping
|
||||
foreach (var pair in KnownMethods)
|
||||
foreach (KeyValuePair<string, string> pair in KnownMethods)
|
||||
{
|
||||
// Only process methods marked as requiring parameters mapping
|
||||
if (pair.Value != nameof(HlslIntrinsicNameAttribute.RequiresParametersMatching))
|
||||
|
||||
@@ -24,7 +24,7 @@ internal static partial class HlslKnownOperators
|
||||
Dictionary<string, string> knownOperators = new();
|
||||
|
||||
// Programmatically load mappings for the intrinsic operators on each HLSL primitive type
|
||||
foreach (var item in
|
||||
foreach ((Type Type, MethodInfo Operator, string IntrinsicName, bool RequiresParametersMatching) item in
|
||||
from type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes)
|
||||
from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public)
|
||||
where method.IsSpecialName && method.Name.StartsWith("op_")
|
||||
|
||||
@@ -140,7 +140,7 @@ internal static partial class HlslKnownProperties
|
||||
};
|
||||
|
||||
// Programmatically load mappings for the instance members of the HLSL vector types
|
||||
foreach (var item in
|
||||
foreach ((Type Type, PropertyInfo Property) item in
|
||||
from type in HlslKnownTypes.KnownVectorTypes
|
||||
from property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
select (Type: type, Property: property))
|
||||
@@ -149,7 +149,7 @@ internal static partial class HlslKnownProperties
|
||||
}
|
||||
|
||||
// Load mappings for the matrix properties as well
|
||||
foreach (var item in
|
||||
foreach ((Type Type, PropertyInfo Property) item in
|
||||
from type in HlslKnownTypes.KnownMatrixTypes
|
||||
from property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
where Regex.IsMatch(property.Name, "^M[1-4]{2}$")
|
||||
@@ -282,7 +282,7 @@ internal static partial class HlslKnownProperties
|
||||
/// <returns>Whether or not a rank and axis could be resolved by the input indexer name.</returns>
|
||||
public static bool TryGetAccessorRankAndAxis(string name, out int rank, out int axis)
|
||||
{
|
||||
if (KnownSizeAccessors.TryGetValue(name, out var info))
|
||||
if (KnownSizeAccessors.TryGetValue(name, out (int Rank, int Axis) info))
|
||||
{
|
||||
(rank, axis) = info;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
@@ -35,7 +36,7 @@ internal static class HlslKnownSizes
|
||||
};
|
||||
|
||||
foreach (
|
||||
var type in
|
||||
Type? type in
|
||||
from type in Assembly.GetExecutingAssembly().ExportedTypes
|
||||
where Regex.IsMatch(type.FullName, @"^ComputeSharp\.(Bool|Double|Float|Int|UInt)")
|
||||
select type)
|
||||
|
||||
@@ -78,13 +78,13 @@ internal static partial class HlslKnownTypes
|
||||
};
|
||||
|
||||
// Add all the vector types
|
||||
foreach (var type in KnownVectorTypes)
|
||||
foreach (Type type in KnownVectorTypes)
|
||||
{
|
||||
knownTypes.Add(type.FullName, type.Name.ToLowerInvariant());
|
||||
}
|
||||
|
||||
// Add all the matrix types
|
||||
foreach (var type in KnownMatrixTypes)
|
||||
foreach (Type type in KnownMatrixTypes)
|
||||
{
|
||||
knownTypes.Add(type.FullName, type.Name.ToLowerInvariant());
|
||||
}
|
||||
@@ -135,7 +135,7 @@ internal static partial class HlslKnownTypes
|
||||
{
|
||||
if (KnownMatrixTypes.Any(type => type.FullName == typeName))
|
||||
{
|
||||
var match = Regex.Match(typeName, @"^ComputeSharp\.(Bool|Int|UInt|Float|Double)([2-4])x([1-4])$");
|
||||
Match match = Regex.Match(typeName, @"^ComputeSharp\.(Bool|Int|UInt|Float|Double)([2-4])x([1-4])$");
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ internal static partial class HlslKnownTypes
|
||||
|
||||
if (!customTypes.Add(type)) return;
|
||||
|
||||
foreach (var field in type.GetMembers().OfType<IFieldSymbol>())
|
||||
foreach (IFieldSymbol field in type.GetMembers().OfType<IFieldSymbol>())
|
||||
{
|
||||
if (field.IsStatic) continue;
|
||||
|
||||
@@ -291,12 +291,12 @@ internal static partial class HlslKnownTypes
|
||||
// types and their dependencies, and iteratively remove items from the map when they have no
|
||||
// dependencies left. When one type is processed and removed, it is also removed from the list
|
||||
// of dependencies of all other remaining types in the map, until there is none left.
|
||||
foreach (var type in types)
|
||||
foreach (INamedTypeSymbol type in types)
|
||||
{
|
||||
HashSet<INamedTypeSymbol> dependencies = new(SymbolEqualityComparer.Default);
|
||||
|
||||
// Only add other custom types as dependencies, and ignore HLSL types
|
||||
foreach (var field in type.GetMembers().OfType<IFieldSymbol>())
|
||||
foreach (IFieldSymbol field in type.GetMembers().OfType<IFieldSymbol>())
|
||||
{
|
||||
if (field.IsStatic) continue;
|
||||
|
||||
@@ -314,13 +314,13 @@ internal static partial class HlslKnownTypes
|
||||
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var entry = queue.Dequeue();
|
||||
(INamedTypeSymbol Type, HashSet<INamedTypeSymbol> Fields) entry = queue.Dequeue();
|
||||
|
||||
// No dependencies left, we can declare this type
|
||||
if (entry.Fields.Count == 0)
|
||||
{
|
||||
// Remove the current type from dependencies of others
|
||||
foreach (var pair in queue)
|
||||
foreach ((INamedTypeSymbol Type, HashSet<INamedTypeSymbol> Fields) pair in queue)
|
||||
{
|
||||
_ = pair.Fields.Remove(entry.Type);
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ partial class HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (AnonymousObjectCreationExpressionSyntax)base.VisitAnonymousObjectCreationExpression(node)!;
|
||||
AnonymousObjectCreationExpressionSyntax updatedNode = (AnonymousObjectCreationExpressionSyntax)base.VisitAnonymousObjectCreationExpression(node)!;
|
||||
|
||||
Diagnostics.Add(AnonymousObjectCreationExpression, node);
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitCastExpression(CastExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (CastExpressionSyntax)base.VisitCastExpression(node)!;
|
||||
CastExpressionSyntax updatedNode = (CastExpressionSyntax)base.VisitCastExpression(node)!;
|
||||
|
||||
return updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitVariableDeclaration(VariableDeclarationSyntax node)
|
||||
{
|
||||
var updatedNode = (VariableDeclarationSyntax)base.VisitVariableDeclaration(node)!;
|
||||
VariableDeclarationSyntax updatedNode = (VariableDeclarationSyntax)base.VisitVariableDeclaration(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetTypeInfo(node.Type).Type is ITypeSymbol { IsUnmanagedType: false } type)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitObjectCreationExpression(ObjectCreationExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (ObjectCreationExpressionSyntax)base.VisitObjectCreationExpression(node)!;
|
||||
ObjectCreationExpressionSyntax updatedNode = (ObjectCreationExpressionSyntax)base.VisitObjectCreationExpression(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetTypeInfo(node).Type is ITypeSymbol { IsUnmanagedType: false } type)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitImplicitObjectCreationExpression(ImplicitObjectCreationExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (ImplicitObjectCreationExpressionSyntax)base.VisitImplicitObjectCreationExpression(node)!;
|
||||
ImplicitObjectCreationExpressionSyntax updatedNode = (ImplicitObjectCreationExpressionSyntax)base.VisitImplicitObjectCreationExpression(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetTypeInfo(node).Type is ITypeSymbol { IsUnmanagedType: false } type)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitDefaultExpression(DefaultExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (DefaultExpressionSyntax)base.VisitDefaultExpression(node)!;
|
||||
DefaultExpressionSyntax updatedNode = (DefaultExpressionSyntax)base.VisitDefaultExpression(node)!;
|
||||
|
||||
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
|
||||
|
||||
@@ -178,7 +178,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitLiteralExpression(LiteralExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (LiteralExpressionSyntax)base.VisitLiteralExpression(node)!;
|
||||
LiteralExpressionSyntax updatedNode = (LiteralExpressionSyntax)base.VisitLiteralExpression(node)!;
|
||||
|
||||
if (updatedNode.IsKind(SyntaxKind.DefaultLiteralExpression))
|
||||
{
|
||||
@@ -236,7 +236,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitElementAccessExpression(ElementAccessExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (ElementAccessExpressionSyntax)base.VisitElementAccessExpression(node)!;
|
||||
ElementAccessExpressionSyntax updatedNode = (ElementAccessExpressionSyntax)base.VisitElementAccessExpression(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetOperation(node) is IPropertyReferenceOperation operation)
|
||||
{
|
||||
@@ -246,7 +246,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
// For instance: texture[ThreadIds.X, ThreadIds.Y] will be rewritten as texture[int2(ThreadIds.X, ThreadIds.Y)].
|
||||
if (HlslKnownProperties.TryGetMappedResourceIndexerTypeName(propertyName, out string? mapping))
|
||||
{
|
||||
var index = InvocationExpression(IdentifierName(mapping!), ArgumentList(updatedNode.ArgumentList.Arguments));
|
||||
InvocationExpressionSyntax index = InvocationExpression(IdentifierName(mapping!), ArgumentList(updatedNode.ArgumentList.Arguments));
|
||||
|
||||
return updatedNode.WithArgumentList(BracketedArgumentList(SingletonSeparatedList(Argument(index))));
|
||||
}
|
||||
@@ -294,7 +294,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitAssignmentExpression(AssignmentExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (AssignmentExpressionSyntax)base.VisitAssignmentExpression(node)!;
|
||||
AssignmentExpressionSyntax updatedNode = (AssignmentExpressionSyntax)base.VisitAssignmentExpression(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetOperation(node) is ICompoundAssignmentOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method })
|
||||
{
|
||||
@@ -321,7 +321,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitBinaryExpression(BinaryExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (BinaryExpressionSyntax)base.VisitBinaryExpression(node)!;
|
||||
BinaryExpressionSyntax updatedNode = (BinaryExpressionSyntax)base.VisitBinaryExpression(node)!;
|
||||
|
||||
// Process binary operations to see if the target operator method is an intrinsic
|
||||
if (SemanticModel.For(node).GetOperation(node) is IBinaryOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method })
|
||||
@@ -346,7 +346,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitIdentifierName(IdentifierNameSyntax node)
|
||||
{
|
||||
var updatedNode = (IdentifierNameSyntax)base.VisitIdentifierName(node)!;
|
||||
IdentifierNameSyntax updatedNode = (IdentifierNameSyntax)base.VisitIdentifierName(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetOperation(node) is IFieldReferenceOperation operation &&
|
||||
operation.Field.IsConst &&
|
||||
@@ -354,8 +354,8 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
{
|
||||
ConstantDefinitions[operation.Field] = ((IFormattable)operation.Field.ConstantValue!).ToString(null, CultureInfo.InvariantCulture);
|
||||
|
||||
var ownerTypeName = ((INamedTypeSymbol)operation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName();
|
||||
var constantName = $"__{ownerTypeName}__{operation.Field.Name}";
|
||||
string ownerTypeName = ((INamedTypeSymbol)operation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName();
|
||||
string constantName = $"__{ownerTypeName}__{operation.Field.Name}";
|
||||
|
||||
return IdentifierName(constantName);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
|
||||
this.currentMethodIdentifier = node.Identifier;
|
||||
|
||||
var updatedNode = (MethodDeclarationSyntax?)base.Visit(node)!;
|
||||
MethodDeclarationSyntax? updatedNode = (MethodDeclarationSyntax?)base.Visit(node)!;
|
||||
|
||||
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node), DiscoveredTypes);
|
||||
|
||||
@@ -145,7 +145,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
|
||||
if (updatedNode is not null)
|
||||
{
|
||||
var implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray());
|
||||
BlockSyntax implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray());
|
||||
|
||||
// Add the tracked implicit declarations (at the start of the body)
|
||||
updatedNode = updatedNode.WithBody(implicitBlock).AddBodyStatements(updatedNode.Body!.Statements.ToArray());
|
||||
@@ -164,7 +164,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
|
||||
this.currentMethodIdentifier = node.Identifier;
|
||||
|
||||
var updatedNode = (LocalFunctionStatementSyntax?)base.Visit(node)!;
|
||||
LocalFunctionStatementSyntax? updatedNode = (LocalFunctionStatementSyntax?)base.Visit(node)!;
|
||||
|
||||
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node), DiscoveredTypes);
|
||||
|
||||
@@ -180,7 +180,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
|
||||
if (updatedNode is not null)
|
||||
{
|
||||
var implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray());
|
||||
BlockSyntax implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray());
|
||||
|
||||
updatedNode = updatedNode.WithBody(implicitBlock).AddBodyStatements(updatedNode.Body!.Statements.ToArray());
|
||||
}
|
||||
@@ -191,7 +191,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitParameter(ParameterSyntax node)
|
||||
{
|
||||
var updatedNode = (ParameterSyntax)base.VisitParameter(node)!;
|
||||
ParameterSyntax updatedNode = (ParameterSyntax)base.VisitParameter(node)!;
|
||||
|
||||
// Convert the C# parameter modifiers to the HLSL equivalent
|
||||
SyntaxToken modifier =
|
||||
@@ -214,7 +214,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node)
|
||||
{
|
||||
var updatedNode = ((LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node)!);
|
||||
LocalDeclarationStatementSyntax updatedNode = ((LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node)!);
|
||||
|
||||
if (SemanticModel.For(node).GetOperation(node) is IOperation { Kind: OperationKind.UsingDeclaration })
|
||||
{
|
||||
@@ -227,7 +227,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitDeclarationExpression(DeclarationExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (DeclarationExpressionSyntax)base.VisitDeclarationExpression(node)!;
|
||||
DeclarationExpressionSyntax updatedNode = (DeclarationExpressionSyntax)base.VisitDeclarationExpression(node)!;
|
||||
|
||||
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes);
|
||||
|
||||
@@ -255,7 +255,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
// being parsed. That is, this was a blobal method that was annotated in source.
|
||||
if (node.Identifier == this.currentMethodIdentifier)
|
||||
{
|
||||
var updatedNode =
|
||||
LocalFunctionStatementSyntax updatedNode =
|
||||
((LocalFunctionStatementSyntax)base.VisitLocalFunctionStatement(node)!)
|
||||
.WithBlockBody()
|
||||
.WithAttributeLists(List<AttributeListSyntax>());
|
||||
@@ -278,7 +278,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
{
|
||||
this.localFunctionDepth++;
|
||||
|
||||
var updatedNode =
|
||||
LocalFunctionStatementSyntax updatedNode =
|
||||
((LocalFunctionStatementSyntax)base.VisitLocalFunctionStatement(node)!)
|
||||
.WithBlockBody()
|
||||
.WithAttributeLists(List<AttributeListSyntax>())
|
||||
@@ -311,7 +311,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!;
|
||||
MemberAccessExpressionSyntax updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!;
|
||||
|
||||
if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression) &&
|
||||
SemanticModel.For(node).GetOperation(node) is IMemberReferenceOperation operation)
|
||||
@@ -329,8 +329,8 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
|
||||
ConstantDefinitions[fieldOperation.Field] = ((IFormattable)fieldOperation.Field.ConstantValue!).ToString(null, CultureInfo.InvariantCulture);
|
||||
|
||||
var ownerTypeName = ((INamedTypeSymbol)fieldOperation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName();
|
||||
var constantName = $"__{ownerTypeName}__{fieldOperation.Field.Name}";
|
||||
string ownerTypeName = ((INamedTypeSymbol)fieldOperation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName();
|
||||
string constantName = $"__{ownerTypeName}__{fieldOperation.Field.Name}";
|
||||
|
||||
return IdentifierName(constantName);
|
||||
}
|
||||
@@ -419,7 +419,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitInvocationExpression(InvocationExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!;
|
||||
InvocationExpressionSyntax updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetOperation(node) is IInvocationOperation { TargetMethod: IMethodSymbol method } operation)
|
||||
{
|
||||
@@ -447,7 +447,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
// updated name is detailed in the override handling the local function statement.
|
||||
if (method.MethodKind == MethodKind.LocalFunction)
|
||||
{
|
||||
var functionIdentifier = $"__{this.currentMethodIdentifier.Text}__{method.Name}";
|
||||
string functionIdentifier = $"__{this.currentMethodIdentifier.Text}__{method.Name}";
|
||||
|
||||
return updatedNode.WithExpression(IdentifierName(functionIdentifier));
|
||||
}
|
||||
@@ -458,7 +458,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
// type as well, as they will be processed by the generator in a different path.
|
||||
if (!SymbolEqualityComparer.Default.Equals(this.shaderType, method.ContainingType))
|
||||
{
|
||||
var methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName();
|
||||
string methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName();
|
||||
|
||||
if (!this.staticMethods.ContainsKey(method))
|
||||
{
|
||||
@@ -503,7 +503,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
{
|
||||
DiscoveredTypes.Add(structTypeSymbol);
|
||||
|
||||
var methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName();
|
||||
string methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName();
|
||||
|
||||
// Same as for static methods, ensure the method is available in source, and process it if so
|
||||
if (!this.instanceMethods.ContainsKey(method))
|
||||
@@ -540,7 +540,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitArgument(ArgumentSyntax node)
|
||||
{
|
||||
var updatedNode = (ArgumentSyntax)base.VisitArgument(node)!;
|
||||
ArgumentSyntax updatedNode = (ArgumentSyntax)base.VisitArgument(node)!;
|
||||
|
||||
// Strip the ref keywords from arguments
|
||||
updatedNode = updatedNode.WithRefKindKeyword(Token(SyntaxKind.None));
|
||||
|
||||
@@ -49,7 +49,7 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!;
|
||||
MemberAccessExpressionSyntax updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!;
|
||||
|
||||
if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression) &&
|
||||
SemanticModel.For(node).GetOperation(node) is IMemberReferenceOperation operation)
|
||||
@@ -66,8 +66,8 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter
|
||||
|
||||
ConstantDefinitions[fieldOperation.Field] = ((IFormattable)fieldOperation.Field.ConstantValue!).ToString(null, CultureInfo.InvariantCulture);
|
||||
|
||||
var ownerTypeName = ((INamedTypeSymbol)fieldOperation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName();
|
||||
var constantName = $"__{ownerTypeName}__{fieldOperation.Field.Name}";
|
||||
string ownerTypeName = ((INamedTypeSymbol)fieldOperation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName();
|
||||
string constantName = $"__{ownerTypeName}__{fieldOperation.Field.Name}";
|
||||
|
||||
return IdentifierName(constantName);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitInvocationExpression(InvocationExpressionSyntax node)
|
||||
{
|
||||
var updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!;
|
||||
InvocationExpressionSyntax updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!;
|
||||
|
||||
if (SemanticModel.For(node).GetOperation(node) is IInvocationOperation operation &&
|
||||
operation.TargetMethod is IMethodSymbol method &&
|
||||
@@ -116,7 +116,7 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitArgument(ArgumentSyntax node)
|
||||
{
|
||||
var updatedNode = (ArgumentSyntax)base.VisitArgument(node)!;
|
||||
ArgumentSyntax updatedNode = (ArgumentSyntax)base.VisitArgument(node)!;
|
||||
|
||||
updatedNode = updatedNode.WithRefKindKeyword(Token(SyntaxKind.None));
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする