HipcGenerator: return FrozenDictionary<,>.Empty
when there are no command implementations, otherwise create FrozenDictionary
from a IEnumerable<KeyValuePair<,>>
instead of a
Dictionary<,>``
This commit is contained in:
parent
e27f3c7e79
commit
bfb83f0341
1 changed files with 44 additions and 35 deletions
|
@ -116,7 +116,14 @@ namespace Ryujinx.Horizon.Generators.Hipc
|
|||
private static void GenerateMethodTable(CodeGenerator generator, Compilation compilation, CommandInterface commandInterface)
|
||||
{
|
||||
generator.EnterScope($"public IReadOnlyDictionary<int, CommandHandler> GetCommandHandlers()");
|
||||
generator.EnterScope($"return new Dictionary<int, CommandHandler>()");
|
||||
|
||||
if (commandInterface.CommandImplementations.Count == 0)
|
||||
{
|
||||
generator.AppendLine("return FrozenDictionary<int, CommandHandler>.Empty;");
|
||||
}
|
||||
else
|
||||
{
|
||||
generator.EnterScope($"return FrozenDictionary.ToFrozenDictionary(new []");
|
||||
|
||||
foreach (var method in commandInterface.CommandImplementations)
|
||||
{
|
||||
|
@ -126,7 +133,7 @@ namespace Ryujinx.Horizon.Generators.Hipc
|
|||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
generator.AppendLine($"{{ {commandId}, new CommandHandler({method.Identifier.Text}, Array.Empty<CommandArg>()) }},");
|
||||
generator.AppendLine($"KeyValuePair.Create({commandId}, new CommandHandler({method.Identifier.Text}, Array.Empty<CommandArg>())),");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -167,12 +174,14 @@ namespace Ryujinx.Horizon.Generators.Hipc
|
|||
args[index++] = arg;
|
||||
}
|
||||
|
||||
generator.AppendLine($"{{ {commandId}, new CommandHandler({method.Identifier.Text}, {string.Join(", ", args)}) }},");
|
||||
generator.AppendLine($"KeyValuePair.Create({commandId}, new CommandHandler({method.Identifier.Text}, {string.Join(", ", args)})),");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generator.LeaveScope(".ToFrozenDictionary();");
|
||||
generator.LeaveScope(");");
|
||||
}
|
||||
|
||||
generator.LeaveScope();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue