Centralize leftover TrackType method, simplify code
このコミットが含まれているのは:
1 親
0e82ce93e3
コミット
9bba3e58f6
3ファイル変更
+12
-21
検索条件に一致するファイルはありません
@@ -245,26 +245,6 @@ internal static partial class HlslKnownTypes
|
||||
return KnownHlslTypeMetadataNames.TryGetValue(originalName, out mappedName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracks an <see cref="ITypeSymbol"/> instance and returns an HLSL compatible type name.
|
||||
/// </summary>
|
||||
/// <param name="typeSymbol">The input <see cref="ITypeSymbol"/> instance to process.</param>
|
||||
/// <param name="discoveredTypes">The collection of currently discovered types.</param>
|
||||
/// <returns>A type name that represents a type compatible with HLSL.</returns>
|
||||
public static string TrackType(ITypeSymbol typeSymbol, ICollection<INamedTypeSymbol> discoveredTypes)
|
||||
{
|
||||
string typeName = typeSymbol.GetFullyQualifiedName();
|
||||
|
||||
discoveredTypes.Add((INamedTypeSymbol)typeSymbol);
|
||||
|
||||
if (TryGetMappedName(typeName, out string? mappedName))
|
||||
{
|
||||
return mappedName!;
|
||||
}
|
||||
|
||||
return typeName.ToHlslIdentifierName();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sequence of unique custom types from a collection of discovered types.
|
||||
/// </summary>
|
||||
|
||||
@@ -18,6 +18,17 @@ partial class HlslSourceRewriter
|
||||
protected TypeSyntax TrackType(SyntaxNode node, SemanticModel semanticModel)
|
||||
{
|
||||
ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(node, CancellationToken).Type!;
|
||||
|
||||
return TrackType(typeSymbol);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tracks an <see cref="ITypeSymbol"/> instance and returns the HLSL compatible <see cref="TypeSyntax"/>.
|
||||
/// </summary>
|
||||
/// <param name="typeSymbol">The input <see cref="ITypeSymbol"/> instance to process.</param>
|
||||
/// <returns>A <see cref="SyntaxNode"/> instance that represents a type compatible with HLSL.</returns>
|
||||
protected TypeSyntax TrackType(ITypeSymbol typeSymbol)
|
||||
{
|
||||
string typeName = typeSymbol.GetFullyQualifiedName();
|
||||
|
||||
DiscoveredTypes.Add((INamedTypeSymbol)typeSymbol);
|
||||
|
||||
@@ -627,7 +627,7 @@ internal sealed partial class ShaderSourceRewriter(
|
||||
// Track and rewrite the discarded declaration
|
||||
if (SemanticModel.For(node).GetOperation(node.Expression, CancellationToken) is IDiscardOperation operation)
|
||||
{
|
||||
TypeSyntax typeSyntax = ParseTypeName(HlslKnownTypes.TrackType(operation.Type!, DiscoveredTypes));
|
||||
TypeSyntax typeSyntax = TrackType(operation.Type!);
|
||||
string identifier = $"__implicit{this.implicitVariables.Count}";
|
||||
|
||||
// Add the variable to the list of implicit declarations
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする