Changed signatures back to IEnumerable and added full enumeration to list where needed.

This commit is contained in:
Jarl Gullberg 2017-05-29 22:22:26 +02:00
parent b420ce8735
commit 1cda816b97
No known key found for this signature in database
GPG key ID: 750FF6F6BDA72D23

View file

@ -44,7 +44,7 @@ namespace OpenTK.Rewrite
var file = args[0];
var key = args[1];
var options = args.Where(a => a.StartsWith("-") || a.StartsWith("/"));
program.Rewrite(file, key, options.ToList());
program.Rewrite(file, key, options);
}
// mscorlib types
@ -60,9 +60,10 @@ namespace OpenTK.Rewrite
static bool dllimport;
void Rewrite(string file, string keyfile, List<string> options)
void Rewrite(string file, string keyfile, IEnumerable<string> options)
{
dllimport = options.Contains("-dllimport");
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
dllimport = optionsEnumerated.Contains("-dllimport");
// Specify assembly read and write parameters
// We want to keep a valid symbols file (pdb or mdb)
@ -130,7 +131,7 @@ namespace OpenTK.Rewrite
{
foreach (var type in module.Types)
{
Rewrite(type, options);
Rewrite(type, optionsEnumerated);
}
}
}
@ -144,7 +145,7 @@ namespace OpenTK.Rewrite
}
}
void Rewrite(TypeDefinition type, List<string> options)
void Rewrite(TypeDefinition type, IEnumerable<string> options)
{
var entry_points = type.Fields.FirstOrDefault(f => f.Name == "EntryPoints");
if (entry_points != null)
@ -186,13 +187,14 @@ namespace OpenTK.Rewrite
}
void Rewrite(TypeDefinition type, FieldDefinition entry_points,
List<MethodDefinition> entry_signatures, List<string> options)
List<MethodDefinition> entry_signatures, IEnumerable<string> options)
{
// Rewrite all wrapper methods
var wrapper_signatures = new List<MethodDefinition>();
wrapper_signatures.AddRange(type.Methods
.Where(m => m.IsPublic && m.CustomAttributes.Any(a => a.AttributeType.Name == "AutoGeneratedAttribute")));
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
foreach (var wrapper in wrapper_signatures)
{
var autogenerated = wrapper.CustomAttributes
@ -204,7 +206,7 @@ namespace OpenTK.Rewrite
var signature = entry_signatures.FirstOrDefault(s => s.Name == signature_name);
int slot = GetSlot(signature);
ProcessMethod(wrapper, signature, slot, entry_points, options);
ProcessMethod(wrapper, signature, slot, entry_points, optionsEnumerated);
}
}
@ -214,7 +216,7 @@ namespace OpenTK.Rewrite
{
foreach (var nested_type in type.NestedTypes)
{
Rewrite(nested_type, entry_points, entry_signatures, options);
Rewrite(nested_type, entry_points, entry_signatures, optionsEnumerated);
}
}
}
@ -248,7 +250,7 @@ namespace OpenTK.Rewrite
// Create body for method
static void ProcessMethod(MethodDefinition wrapper, MethodDefinition native, int slot,
FieldDefinition entry_points, List<string> options)
FieldDefinition entry_points, IEnumerable<string> options)
{
var body = wrapper.Body;
var il = body.GetILProcessor();
@ -259,7 +261,8 @@ namespace OpenTK.Rewrite
// and push each parameter on the stack
DebugVariables vars = null;
if (options.Contains("-debug"))
IEnumerable<string> optionsEnumerated = options as IList<string> ?? options.ToList();
if (optionsEnumerated.Contains("-debug"))
{
vars = EmitDebugPrologue(wrapper, il);
}
@ -297,7 +300,7 @@ namespace OpenTK.Rewrite
EmitParameterEpilogues(wrapper, native, body, il, generatedVariables);
if (options.Contains("-debug"))
if (optionsEnumerated.Contains("-debug"))
{
EmitDebugEpilogue(wrapper, il, vars);
}