private void RemoveUnnecessaryEnumerable(IEnumerableCollectionProcessor processor, IDependency[] dependencies, out Dictionary <string, TypeDefinition> enumerableDefinitionDictionary, out Dictionary <string, IDependency> dependencyDictionary) { enumerableDefinitionDictionary = new Dictionary <string, TypeDefinition>(); var names = processor.NameCollection.ToArray(); foreach (var name in names) { if (!processor.IsSpecialType(name, out var value) || value) { continue; } enumerableDefinitionDictionary.Add(name, mainModule.GetType("UniNativeLinq", string.Intern(name + "Enumerable`" + processor.GetGenericParameterCount(name)))); } dependencyDictionary = dependencies.ToDictionary(x => x.Enumerable, x => x); foreach (var name in names) { if (!processor.IsSpecialType(name, out var isSpecial) || isSpecial) { continue; } if (!processor.TryGetEnabled(name, out var enabled) || enabled) { continue; } var type = enumerableDefinitionDictionary[name]; if (dependencyDictionary.TryGetValue(name, out var dependency)) { RemoveDependency(type, dependency); } mainModule.Types.Remove(type); } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Api.Name + (IsNullable ? Api.Description.Replace('<', '_').Replace('>', '_') : Api.Description) + "Helper")); foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) { continue; } GenerateEach(name, isSpecial, @static, mainModule, systemModule); } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { var returnTypeReference = CalculateReturnType(mainModule); var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Api.Name + processType + "FuncHelper")); if (Api.TryGetEnabled("TEnumerable", out var genericEnabled) && genericEnabled) { GenerateGeneric(@static, mainModule, systemModule, returnTypeReference); } foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) { continue; } GenerateEach(name, isSpecial, @static, mainModule, systemModule, returnTypeReference); } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { if (!processor.TryGetEnabled(Api.Name, out var enabled) || !enabled) { return; } var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Api.Name + Api.Description + "Helper")); TypeReference elementTypeReference; switch (elementTypeName) { case "Double": elementTypeReference = mainModule.TypeSystem.Double; break; case "Single": elementTypeReference = mainModule.TypeSystem.Single; break; case "Int32": elementTypeReference = mainModule.TypeSystem.Int32; break; case "UInt32": elementTypeReference = mainModule.TypeSystem.UInt32; break; case "Int64": elementTypeReference = mainModule.TypeSystem.Int64; break; case "UInt64": elementTypeReference = mainModule.TypeSystem.UInt64; break; default: throw new ArgumentException(); } foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) { continue; } GenerateEach(name, isSpecial, @static, mainModule, systemModule, elementTypeReference); } }
public static void HelpWithGenerate(this IDoubleApi Api, IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, Action <string, bool, string, bool, TypeDefinition, ModuleDefinition, ModuleDefinition> GenerateEachPair) { if (!processor.TryGetEnabled(Api.Name, out var enabled) || !enabled) { return; } var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Api.Name + Api.Description + "Helper")); var count = Api.Count; for (var row = 0; row < count; row++) { var rowName = Api.NameCollection[row]; if (!processor.IsSpecialType(rowName, out var isRowSpecial)) { throw new KeyNotFoundException(); } for (var column = 0; column < count; column++) { var columnName = Api.NameCollection[column]; if (!processor.IsSpecialType(columnName, out var isColumnSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(rowName, columnName, out var apiEnabled) || !apiEnabled) { continue; } GenerateEachPair(rowName, isRowSpecial, columnName, isColumnSpecial, @static, mainModule, systemModule); } } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } var @static = mainModule.GetType("UniNativeLinq", "NativeEnumerable"); foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) { continue; } GenerateEach(name, isSpecial, @static, mainModule, systemModule); } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { if (!processor.TryGetEnabled(Name + keyName, out var enabled) || !enabled) return; var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) return; TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Name + "RefFunc" + keyName + "Helper")); TypeReference keyType; switch (keyName) { case "Double": keyType = mainModule.TypeSystem.Double; break; case "Single": keyType = mainModule.TypeSystem.Single; break; case "Int32": keyType = mainModule.TypeSystem.Int32; break; case "UInt32": keyType = mainModule.TypeSystem.UInt32; break; case "Int64": keyType = mainModule.TypeSystem.Int64; break; case "UInt64": keyType = mainModule.TypeSystem.UInt64; break; default: throw new ArgumentOutOfRangeException(); } foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) throw new KeyNotFoundException(); if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) continue; GenerateEach(name, isSpecial, @static, mainModule, systemModule, keyType); } }