From 4148cd4534d291a3af74ad6c43fb1a6b5dbef286 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 2 Nov 2022 18:37:18 -0700 Subject: [PATCH] Fix ThunkGenerator build break Apply all style auto-fixers on ThunkGenerator --- .../ThunkGenerator/InstructionSetGenerator.cs | 53 ++++++++++--------- .../JitInterface/ThunkGenerator/Program.cs | 39 +++++++------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs index 3b0f45e59b97c5..bc218f33d34b59 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs @@ -13,7 +13,7 @@ namespace Thunkerator { public class InstructionSetGenerator { - sealed class InstructionSetInfo + private sealed class InstructionSetInfo { public string Architecture { get; } public string ManagedName { get; } @@ -26,7 +26,7 @@ public InstructionSetInfo(string architecture, string managedName, string r2rNam { Architecture = architecture; ManagedName = managedName; - R2rName = String.IsNullOrEmpty(r2rName) ? managedName : r2rName; + R2rName = string.IsNullOrEmpty(r2rName) ? managedName : r2rName; R2rNumericValue = r2rNumericValue; JitName = jitName; CommandLineName = commandLineName; @@ -46,11 +46,11 @@ public string PublicName { get { - if (!String.IsNullOrEmpty(CommandLineName)) + if (!string.IsNullOrEmpty(CommandLineName)) return CommandLineName; - if (!String.IsNullOrEmpty(ManagedName)) + if (!string.IsNullOrEmpty(ManagedName)) return ManagedName; - else if (!String.IsNullOrEmpty(R2rName)) + else if (!string.IsNullOrEmpty(R2rName)) return R2rName; else return JitName; @@ -58,9 +58,9 @@ public string PublicName } } - sealed record InstructionSetGroup(string Names, string Archs, string Sets); + private sealed record InstructionSetGroup(string Names, string Archs, string Sets); - sealed class InstructionSetImplication + private sealed class InstructionSetImplication { public string Architecture { get; } public string JitName { get; } @@ -81,21 +81,22 @@ public InstructionSetImplication(string architecture, InstructionSetImplication } } - List _instructionSets = new List(); - List _implications = new List(); - List _instructionSetsGroups = new List(); - Dictionary> _64bitVariants = new Dictionary>(); - SortedDictionary _r2rNamesByName = new SortedDictionary(); - SortedDictionary _r2rNamesByNumber = new SortedDictionary(); - SortedSet _architectures = new SortedSet(); - Dictionary> _architectureJitNames = new Dictionary>(); - Dictionary> _architectureVectorInstructionSetJitNames = new Dictionary>(); - HashSet _64BitArchitectures = new HashSet(); - Dictionary _64BitVariantArchitectureJitNameSuffix = new Dictionary(); + private List _instructionSets = new List(); + private List _implications = new List(); + private List _instructionSetsGroups = new List(); + private Dictionary> _64bitVariants = new Dictionary>(); + private SortedDictionary _r2rNamesByName = new SortedDictionary(); + private SortedDictionary _r2rNamesByNumber = new SortedDictionary(); + private SortedSet _architectures = new SortedSet(); + private Dictionary> _architectureJitNames = new Dictionary>(); + private Dictionary> _architectureVectorInstructionSetJitNames = new Dictionary>(); + private HashSet _64BitArchitectures = new HashSet(); + private Dictionary _64BitVariantArchitectureJitNameSuffix = new Dictionary(); + // This represents the number of flags fields we currently track - const int FlagsFieldCount = 1; + private const int FlagsFieldCount = 1; - void ArchitectureEncountered(string arch) + private void ArchitectureEncountered(string arch) { if (!_64bitVariants.ContainsKey(arch)) _64bitVariants.Add(arch, new HashSet()); @@ -106,7 +107,7 @@ void ArchitectureEncountered(string arch) _architectureVectorInstructionSetJitNames.Add(arch, new List()); } - void ValidateArchitectureEncountered(string arch) + private void ValidateArchitectureEncountered(string arch) { if (!_architectures.Contains(arch)) throw new Exception("Architecture not defined"); @@ -237,9 +238,9 @@ public bool ParseInput(TextReader tr) foreach (var instructionSet in _instructionSets) { - if (!String.IsNullOrEmpty(instructionSet.R2rName)) + if (!string.IsNullOrEmpty(instructionSet.R2rName)) { - int r2rValue = Int32.Parse(instructionSet.R2rNumericValue); + int r2rValue = int.Parse(instructionSet.R2rNumericValue); if (_r2rNamesByName.ContainsKey(instructionSet.R2rName)) { if (_r2rNamesByName[instructionSet.R2rName] != r2rValue) @@ -330,7 +331,7 @@ public static class ReadyToRunInstructionSetHelper if (instructionSet.Architecture != architecture) continue; string r2rEnumerationValue; - if (!String.IsNullOrEmpty(instructionSet.R2rName)) + if (!string.IsNullOrEmpty(instructionSet.R2rName)) r2rEnumerationValue = $"ReadyToRunInstructionSet.{instructionSet.R2rName}"; else r2rEnumerationValue = $"null"; @@ -706,7 +707,7 @@ public static IEnumerable ArchitectureToValidInstructionSets foreach (var instructionSet in _instructionSets) { if (instructionSet.Architecture != architecture) continue; - bool instructionSetIsSpecifiable = !String.IsNullOrEmpty(instructionSet.CommandLineName); + bool instructionSetIsSpecifiable = !string.IsNullOrEmpty(instructionSet.CommandLineName); string name = instructionSet.PublicName; string managedName = instructionSet.ManagedName; string specifiable = instructionSetIsSpecifiable ? "true" : "false"; @@ -1024,7 +1025,7 @@ inline CORINFO_InstructionSet InstructionSetFromR2RInstructionSet(ReadyToRunInst { if (instructionSet.Architecture != architecture) continue; string r2rEnumerationValue; - if (String.IsNullOrEmpty(instructionSet.R2rName)) + if (string.IsNullOrEmpty(instructionSet.R2rName)) continue; r2rEnumerationValue = $"READYTORUN_INSTRUCTION_{instructionSet.R2rName}"; diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs index fd224997bde779..633e8a92ddd0f1 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs @@ -34,7 +34,7 @@ public static string Canonicalize(this string current) } } - sealed class TypeReplacement + internal sealed class TypeReplacement { public TypeReplacement(string line) { @@ -100,7 +100,7 @@ public string UnmanagedTypeName } } - sealed class Parameter + internal sealed class Parameter { public Parameter(string name, TypeReplacement type) { @@ -114,7 +114,7 @@ public Parameter(string name, TypeReplacement type) public readonly TypeReplacement Type; } - sealed class FunctionDecl + internal sealed class FunctionDecl { public FunctionDecl(string line, Dictionary ThunkReturnTypes, Dictionary ThunkTypes) { @@ -135,7 +135,7 @@ public FunctionDecl(string line, Dictionary ThunkReturn if (!ThunkReturnTypes.TryGetValue(returnType, out ReturnType)) { - throw new Exception(String.Format("Type {0} unknown", returnType)); + throw new Exception(string.Format("Type {0} unknown", returnType)); } string parameterList = line.Substring(indexOfOpenParen + 1, indexOfCloseParen - indexOfOpenParen - 1).Canonicalize(); @@ -150,7 +150,7 @@ public FunctionDecl(string line, Dictionary ThunkReturn TypeReplacement tr; if (!ThunkTypes.TryGetValue(paramType, out tr)) { - throw new Exception(String.Format("Type {0} unknown", paramType)); + throw new Exception(string.Format("Type {0} unknown", paramType)); } parameters.Add(new Parameter(paramName, tr)); } @@ -164,16 +164,17 @@ public FunctionDecl(string line, Dictionary ThunkReturn public readonly bool ManualNativeWrapper; } - static class Program + internal static class Program { - enum ParseMode + private enum ParseMode { RETURNTYPES, NORMALTYPES, FUNCTIONS, IFDEFING } - static IEnumerable ParseInput(TextReader tr) + + private static IEnumerable ParseInput(TextReader tr) { Dictionary ThunkReturnTypes = new Dictionary(); Dictionary ThunkTypes = new Dictionary(); @@ -258,7 +259,7 @@ static IEnumerable ParseInput(TextReader tr) return functions.AsReadOnly(); } - static void WriteAutogeneratedHeader(TextWriter tw) + private static void WriteAutogeneratedHeader(TextWriter tw) { // Write header tw.Write(@"// Licensed to the .NET Foundation under one or more agreements. @@ -270,7 +271,7 @@ static void WriteAutogeneratedHeader(TextWriter tw) "); } - static void WriteManagedThunkInterface(TextWriter tw, IEnumerable functionData) + private static void WriteManagedThunkInterface(TextWriter tw, IEnumerable functionData) { WriteAutogeneratedHeader(tw); tw.Write(@" @@ -368,7 +369,7 @@ private static IntPtr GetUnmanagedCallbacks() }"); } - static void WriteNativeWrapperInterface(TextWriter tw, IEnumerable functionData) + private static void WriteNativeWrapperInterface(TextWriter tw, IEnumerable functionData) { WriteAutogeneratedHeader(tw); tw.Write(@" @@ -418,7 +419,7 @@ class JitInterfaceWrapper : public ICorJitInfo tw.WriteLine("};"); } - static void WriteAPI_Names(TextWriter tw, IEnumerable functionData) + private static void WriteAPI_Names(TextWriter tw, IEnumerable functionData) { WriteAutogeneratedHeader(tw); @@ -432,7 +433,7 @@ static void WriteAPI_Names(TextWriter tw, IEnumerable functionData "); } - static void API_Wrapper_Generic_Core(TextWriter tw, IEnumerable functionData, Func funcNameFunc, Func beforeCallFunc, Func afterCallFunc, string wrappedObjectName, bool useNativeType2, bool addVirtualPrefix, bool skipManualWrapper) + private static void API_Wrapper_Generic_Core(TextWriter tw, IEnumerable functionData, Func funcNameFunc, Func beforeCallFunc, Func afterCallFunc, string wrappedObjectName, bool useNativeType2, bool addVirtualPrefix, bool skipManualWrapper) { foreach (FunctionDecl decl in functionData) { @@ -516,7 +517,7 @@ string GetNativeType(TypeReplacement typeReplacement) } } - static void API_Wrapper_Generic(TextWriter tw, IEnumerable functionData, string header, string footer, string cppType, Func beforeCallFunc, Func afterCallFunc, string wrappedObjectName) + private static void API_Wrapper_Generic(TextWriter tw, IEnumerable functionData, string header, string footer, string cppType, Func beforeCallFunc, Func afterCallFunc, string wrappedObjectName) { WriteAutogeneratedHeader(tw); tw.Write(header); @@ -526,7 +527,7 @@ static void API_Wrapper_Generic(TextWriter tw, IEnumerable functio tw.Write(footer); } - static void API_Wrapper(TextWriter tw, IEnumerable functionData) + private static void API_Wrapper(TextWriter tw, IEnumerable functionData) { API_Wrapper_Generic(tw, functionData, header: @" @@ -548,7 +549,7 @@ static void API_Wrapper(TextWriter tw, IEnumerable functionData) wrappedObjectName: "wrapHnd"); } - static void SPMI_ICorJitInfoImpl(TextWriter tw, IEnumerable functionData) + private static void SPMI_ICorJitInfoImpl(TextWriter tw, IEnumerable functionData) { WriteAutogeneratedHeader(tw); tw.Write(@" @@ -595,7 +596,7 @@ static void SPMI_ICorJitInfoImpl(TextWriter tw, IEnumerable functi "); } - static void SPMI_ShimCounter_ICorJitInfo(TextWriter tw, IEnumerable functionData) + private static void SPMI_ShimCounter_ICorJitInfo(TextWriter tw, IEnumerable functionData) { API_Wrapper_Generic(tw, functionData, header: @" @@ -613,7 +614,7 @@ static void SPMI_ShimCounter_ICorJitInfo(TextWriter tw, IEnumerable functionData) + private static void SPMI_ShimSimple_ICorJitInfo(TextWriter tw, IEnumerable functionData) { API_Wrapper_Generic(tw, functionData, header: @" @@ -631,7 +632,7 @@ static void SPMI_ShimSimple_ICorJitInfo(TextWriter tw, IEnumerable wrappedObjectName: "original_ICorJitInfo"); } - static void Main(string[] args) + private static void Main(string[] args) { if (args.Length == 0) {