Use explicit types everywhere

このコミットが含まれているのは:
Sergio Pedri committed 2022-10-15 09:10:18 -07:00
1 親 27c629f3b4
コミット 16c0fc9aab
74ファイル変更
+455 -446

検索条件に一致するファイルはありません

+3 -2
ファイルの表示
@@ -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;
+2 -2
ファイルの表示
@@ -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))
+1 -1
ファイルの表示
@@ -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_")
+3 -3
ファイルの表示
@@ -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;
+2 -1
ファイルの表示
@@ -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)
+8 -8
ファイルの表示
@@ -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);
}