diff --git a/src/Ryujinx.HLE.Generators/IpcCommandGenerator.cs b/src/Ryujinx.HLE.Generators/IpcCommandGenerator.cs index b201220fe..3e77fb1fb 100644 --- a/src/Ryujinx.HLE.Generators/IpcCommandGenerator.cs +++ b/src/Ryujinx.HLE.Generators/IpcCommandGenerator.cs @@ -68,8 +68,8 @@ namespace Ryujinx.HLE.Generators public void Initialize(IncrementalGeneratorInitializationContext context) { - var predicate = (SyntaxNode node, CancellationToken _) => node is MethodDeclarationSyntax; - var transform = (GeneratorAttributeSyntaxContext ctx, CancellationToken _) => + Func predicate = (node, _) => node is MethodDeclarationSyntax; + Func transform = (ctx, _) => { var target = (IMethodSymbol)ctx.TargetSymbol; return new CommandData @@ -80,27 +80,28 @@ namespace Ryujinx.HLE.Generators CommandIds = ctx.Attributes.Select(attr => (int)attr.ConstructorArguments[0].Value!).ToImmutableArray(), }; }; - var cmifCommands = + IncrementalValuesProvider cmifCommands = context.SyntaxProvider.ForAttributeWithMetadataName("Ryujinx.HLE.HOS.Services.CommandCmifAttribute", predicate, transform ); - var tipcCommands = + IncrementalValuesProvider tipcCommands = context.SyntaxProvider.ForAttributeWithMetadataName("Ryujinx.HLE.HOS.Services.CommandTipcAttribute", predicate, transform ); - var allCommands = cmifCommands.Collect().Combine(tipcCommands.Collect()); + IncrementalValueProvider<(ImmutableArray Left, ImmutableArray Right)> allCommands = + cmifCommands.Collect().Combine(tipcCommands.Collect()); - var types = allCommands.SelectMany((commands, _) => + IncrementalValuesProvider types = allCommands.SelectMany((commands, _) => { - var cmif = commands.Left.ToLookup(c => (c.Namespace, c.TypeName)); - var tipc = commands.Right.ToLookup(c => (c.Namespace, c.TypeName)); + ILookup<(string Namespace, string TypeName), CommandData> cmif = commands.Left.ToLookup(c => (c.Namespace, c.TypeName)); + ILookup<(string Namespace, string TypeName), CommandData> tipc = commands.Right.ToLookup(c => (c.Namespace, c.TypeName)); - var builder = ImmutableArray.CreateBuilder(); + ImmutableArray.Builder builder = ImmutableArray.CreateBuilder(); - foreach (var type in cmif.Select(c => c.Key).Union(tipc.Select(t => t.Key))) + foreach ((string Namespace, string TypeName) type in cmif.Select(c => c.Key).Union(tipc.Select(t => t.Key))) { builder.Add(new ServiceData { @@ -143,7 +144,7 @@ namespace Ryujinx.HLE.Generators { generator.EnterScope($"protected override RC Invoke{commandType}Method(int id, ServiceCtx context)"); generator.EnterScope("switch (id)"); - foreach (var command in commands) + foreach (CommandData command in commands) { generator.AppendLine($"case {string.Join(" or ", command.CommandIds)}:"); generator.IncreaseIndentation(); @@ -157,7 +158,7 @@ namespace Ryujinx.HLE.Generators generator.EnterScope($"public override int {commandType}CommandIdByMethodName(string name)"); generator.EnterScope("return name switch"); - foreach (var command in commands) + foreach (CommandData command in commands) { // just return the first command with this name generator.AppendLine($"\"{command.MethodName}\" => {command.CommandIds[0]},"); diff --git a/src/Ryujinx.HLE.Generators/UserServiceGenerator.cs b/src/Ryujinx.HLE.Generators/UserServiceGenerator.cs index ace720667..7b30988fb 100644 --- a/src/Ryujinx.HLE.Generators/UserServiceGenerator.cs +++ b/src/Ryujinx.HLE.Generators/UserServiceGenerator.cs @@ -28,12 +28,12 @@ namespace Ryujinx.HLE.Generators public void Initialize(IncrementalGeneratorInitializationContext context) { - var pipeline = context.SyntaxProvider.ForAttributeWithMetadataName("Ryujinx.HLE.HOS.Services.ServiceAttribute", + IncrementalValuesProvider pipeline = context.SyntaxProvider.ForAttributeWithMetadataName("Ryujinx.HLE.HOS.Services.ServiceAttribute", predicate: (node, _) => node is ClassDeclarationSyntax decl && !decl.Modifiers.Any(SyntaxKind.AbstractKeyword) && !decl.Modifiers.Any(SyntaxKind.PrivateKeyword), transform: (ctx, _) => { var target = (INamedTypeSymbol)ctx.TargetSymbol; - var instances = ctx.Attributes.Select(attr => + IEnumerable<(string, string param)> instances = ctx.Attributes.Select(attr => { string param = attr.ConstructorArguments is [_, { IsNull: false } arg] ? arg.ToCSharpString() : null; return ((string)attr.ConstructorArguments[0].Value, param); @@ -60,9 +60,9 @@ namespace Ryujinx.HLE.Generators generator.EnterScope("return name switch"); - foreach (var serviceImpl in data) + foreach (ServiceData serviceImpl in data) { - foreach (var instance in serviceImpl.Instances) + foreach ((string ServiceName, string ParameterValue) instance in serviceImpl.Instances) { if (instance.ParameterValue == null) { diff --git a/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs b/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs index 038eed023..19684c273 100644 --- a/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs +++ b/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs @@ -48,7 +48,7 @@ namespace Ryujinx.HLE.Exceptions { StringBuilder sb = new(); - var commandId = Request.Type > IpcMessageType.TipcCloseSession + int commandId = Request.Type > IpcMessageType.TipcCloseSession ? Service.TipcCommandIdByMethodName(MethodName) : Service.CmifCommandIdByMethodName(MethodName); diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/Arithmetic.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/Arithmetic.cs index d0a2e2aa1..b93efbe43 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/Arithmetic.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/Arithmetic.cs @@ -69,7 +69,7 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters throw new TamperCompilationException($"Invalid right-hand side switch {rightHandSideIsImmediate} in Atmosphere cheat"); } - void EmitCore(IOperand rhs = null) where TOp : IOperation + void EmitCore(IOperand rhs = null) where TOp : IOperationFactory { InstructionHelper.Emit(operationWidth, context, destinationRegister, leftHandSideRegister, rhs); } @@ -77,34 +77,34 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters switch (operation) { case Add: - EmitCore>(rightHandSideOperand); + EmitCore(rightHandSideOperand); break; case Sub: - EmitCore>(rightHandSideOperand); + EmitCore(rightHandSideOperand); break; case Mul: - EmitCore>(rightHandSideOperand); + EmitCore(rightHandSideOperand); break; case Lsh: - EmitCore>(rightHandSideOperand); + EmitCore(rightHandSideOperand); break; case Rsh: - EmitCore>(rightHandSideOperand); + EmitCore(rightHandSideOperand); break; case And: - EmitCore>(rightHandSideOperand); + EmitCore(rightHandSideOperand); break; case Or: - EmitCore>(rightHandSideOperand); + EmitCore(rightHandSideOperand); break; case Not: - EmitCore>(); + EmitCore(); break; case Xor: - EmitCore>(rightHandSideOperand); + EmitCore(rightHandSideOperand); break; case Mov: - EmitCore>(); + EmitCore(); break; default: throw new TamperCompilationException($"Invalid arithmetic operation {operation} in Atmosphere cheat"); diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/LegacyArithmetic.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/LegacyArithmetic.cs index df60b058d..ba1acb172 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/LegacyArithmetic.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/LegacyArithmetic.cs @@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters ulong immediate = InstructionHelper.GetImmediate(instruction, ValueImmediateIndex, ValueImmediateSize); Value rightHandSideValue = new(immediate); - void EmitCore() where TOp : IOperation + void EmitCore() where TOp : IOperationFactory { InstructionHelper.Emit(operationWidth, context, register, register, rightHandSideValue); } @@ -45,19 +45,19 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters switch (operation) { case Add: - EmitCore>(); + EmitCore(); break; case Sub: - EmitCore>(); + EmitCore(); break; case Mul: - EmitCore>(); + EmitCore(); break; case Lsh: - EmitCore>(); + EmitCore(); break; case Rsh: - EmitCore>(); + EmitCore(); break; default: throw new TamperCompilationException($"Invalid arithmetic operation {operation} in Atmosphere cheat"); diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/LoadRegisterWithMemory.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/LoadRegisterWithMemory.cs index 183f4dd2f..45448b99d 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/LoadRegisterWithMemory.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/LoadRegisterWithMemory.cs @@ -53,7 +53,7 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters throw new TamperCompilationException($"Invalid source mode {useDestinationAsSourceIndex} in Atmosphere cheat"); } - InstructionHelper.Emit>(operationWidth, context, destinationRegister, sourceMemory, null); + InstructionHelper.Emit(operationWidth, context, destinationRegister, sourceMemory, null); } } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreConstantToAddress.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreConstantToAddress.cs index beb61b459..25e39bd71 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreConstantToAddress.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreConstantToAddress.cs @@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters ulong valueImmediate = InstructionHelper.GetImmediate(instruction, ValueImmediateIndex, valueImmediateSize); Value storeValue = new(valueImmediate); - InstructionHelper.Emit>(operationWidth, context, dstMem, storeValue, null); + InstructionHelper.Emit(operationWidth, context, dstMem, storeValue, null); } } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreConstantToMemory.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreConstantToMemory.cs index 8426592ba..bb53f3a7b 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreConstantToMemory.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreConstantToMemory.cs @@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters throw new TamperCompilationException($"Invalid offset mode {useOffsetRegister} in Atmosphere cheat"); } - InstructionHelper.Emit>(operationWidth, context, destinationMemory, storeValue, null); + InstructionHelper.Emit(operationWidth, context, destinationMemory, storeValue, null); switch (incrementAddressRegister) { diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreRegisterToMemory.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreRegisterToMemory.cs index 3b7df67b2..a64b4ebbc 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreRegisterToMemory.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/StoreRegisterToMemory.cs @@ -79,7 +79,7 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters throw new TamperCompilationException($"Invalid offset type {offsetType} in Atmosphere cheat"); } - InstructionHelper.Emit>(operationWidth, context, destinationMemory, sourceRegister, null); + InstructionHelper.Emit(operationWidth, context, destinationMemory, sourceRegister, null); switch (incrementAddressRegister) { diff --git a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondEQ.cs b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondEQ.cs index e0b98e3d8..897170864 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondEQ.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondEQ.cs @@ -3,6 +3,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Conditions { + sealed class CondEQFactory : IConditionFactory + { + private CondEQFactory() { } + + public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T : unmanaged, INumber + => new CondEQ(lhs, rhs); + } class CondEQ : ICondition where T : unmanaged, INumber { private readonly IOperand _lhs; @@ -18,8 +25,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Conditions { return _lhs.Get() == _rhs.Get(); } - - public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T1 : INumber - => new CondEQ(lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondGE.cs b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondGE.cs index 5c3ef83e6..7442d1f63 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondGE.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondGE.cs @@ -3,6 +3,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Conditions { + sealed class CondGEFactory : IConditionFactory + { + private CondGEFactory() { } + + public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T : unmanaged, INumber + => new CondGE(lhs, rhs); + } class CondGE : ICondition where T : unmanaged, INumber { private readonly IOperand _lhs; @@ -18,8 +25,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Conditions { return _lhs.Get() >= _rhs.Get(); } - - public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T1 : INumber - => new CondGE(lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondGT.cs b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondGT.cs index 131da14bb..7b631b887 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondGT.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondGT.cs @@ -3,6 +3,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Conditions { + sealed class CondGTFactory : IConditionFactory + { + private CondGTFactory() { } + + public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T : unmanaged, INumber + => new CondGT(lhs, rhs); + } class CondGT : ICondition where T : unmanaged, INumber { private readonly IOperand _lhs; @@ -18,8 +25,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Conditions { return _lhs.Get() > _rhs.Get(); } - - public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T1 : INumber - => new CondGT(lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondLE.cs b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondLE.cs index 2e709e243..81bdb4056 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondLE.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondLE.cs @@ -3,6 +3,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Conditions { + sealed class CondLEFactory : IConditionFactory + { + private CondLEFactory() { } + + public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T : unmanaged, INumber + => new CondLE(lhs, rhs); + } class CondLE : ICondition where T : unmanaged, INumber { private readonly IOperand _lhs; @@ -18,8 +25,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Conditions { return _lhs.Get() <= _rhs.Get(); } - - public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T1 : INumber - => new CondLE(lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondLT.cs b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondLT.cs index 7393d9ec5..980ab8515 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondLT.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondLT.cs @@ -3,6 +3,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Conditions { + sealed class CondLTFactory : IConditionFactory + { + private CondLTFactory() { } + + public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T : unmanaged, INumber + => new CondLT(lhs, rhs); + } class CondLT : ICondition where T : unmanaged, INumber { private readonly IOperand _lhs; diff --git a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondNE.cs b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondNE.cs index fdd0a4845..0cbd62a54 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondNE.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Conditions/CondNE.cs @@ -3,6 +3,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Conditions { + sealed class CondNEFactory : IConditionFactory + { + private CondNEFactory() { } + + public static ICondition CreateFor(IOperand lhs, IOperand rhs) where T : unmanaged, INumber + => new CondNE(lhs, rhs); + } class CondNE : ICondition where T : unmanaged, INumber { private readonly IOperand _lhs; diff --git a/src/Ryujinx.HLE/HOS/Tamper/Conditions/ICondition.cs b/src/Ryujinx.HLE/HOS/Tamper/Conditions/ICondition.cs index 130fb5623..f15ceffe1 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Conditions/ICondition.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Conditions/ICondition.cs @@ -1,13 +1,7 @@ -using Ryujinx.HLE.HOS.Tamper.Operations; -using System; -using System.Numerics; - namespace Ryujinx.HLE.HOS.Tamper.Conditions { interface ICondition { bool Evaluate(); - - static virtual ICondition CreateFor(IOperand lhs, IOperand rhs) where T : INumber => throw new NotImplementedException(); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Conditions/IConditionFactory.cs b/src/Ryujinx.HLE/HOS/Tamper/Conditions/IConditionFactory.cs new file mode 100644 index 000000000..af0886307 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Tamper/Conditions/IConditionFactory.cs @@ -0,0 +1,10 @@ +using Ryujinx.HLE.HOS.Tamper.Operations; +using System.Numerics; + +namespace Ryujinx.HLE.HOS.Tamper.Conditions +{ + interface IConditionFactory + { + static abstract ICondition CreateFor(IOperand lhs, IOperand rhs) where T : unmanaged, INumber; + } +} diff --git a/src/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs b/src/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs index e50a5bd7f..76409945e 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs @@ -15,14 +15,14 @@ namespace Ryujinx.HLE.HOS.Tamper context.CurrentOperations.Add(operation); } - public static void Emit(byte width, CompilationContext context, IOperand destination, IOperand lhs, IOperand rhs) where TOp : IOperation + public static void Emit(byte width, CompilationContext context, IOperand destination, IOperand lhs, IOperand rhs) where TOp : IOperationFactory { Emit(Create(width, destination, lhs, rhs), context); } public static ICondition CreateCondition(Comparison comparison, byte width, IOperand lhs, IOperand rhs) { - ICondition CreateCore() where TOp : ICondition + ICondition CreateCore() where TOp : IConditionFactory { return width switch { @@ -36,17 +36,17 @@ namespace Ryujinx.HLE.HOS.Tamper return comparison switch { - Comparison.Greater => CreateCore>(), - Comparison.GreaterOrEqual => CreateCore>(), - Comparison.Less => CreateCore>(), - Comparison.LessOrEqual => CreateCore>(), - Comparison.Equal => CreateCore>(), - Comparison.NotEqual => CreateCore>(), + Comparison.Greater => CreateCore(), + Comparison.GreaterOrEqual => CreateCore(), + Comparison.Less => CreateCore(), + Comparison.LessOrEqual => CreateCore(), + Comparison.Equal => CreateCore(), + Comparison.NotEqual => CreateCore(), _ => throw new TamperCompilationException($"Invalid comparison {comparison} in Atmosphere cheat"), }; } - public static IOperation Create(byte width, IOperand destination, IOperand lhs, IOperand rhs) where TOp : IOperation + public static IOperation Create(byte width, IOperand destination, IOperand lhs, IOperand rhs) where TOp : IOperationFactory { return width switch { diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/IOperation.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/IOperation.cs index a0af81409..7ffbb4a9a 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/IOperation.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/IOperation.cs @@ -6,8 +6,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations interface IOperation { void Execute(); - - static virtual IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger - => throw new NotImplementedException(); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/IOperationFactory.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/IOperationFactory.cs new file mode 100644 index 000000000..85f7c90c0 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/IOperationFactory.cs @@ -0,0 +1,10 @@ +using System; +using System.Numerics; + +namespace Ryujinx.HLE.HOS.Tamper.Operations +{ + interface IOperationFactory + { + static abstract IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger; + } +} diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpAdd.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpAdd.cs index 9154b20ea..9cbf44b12 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpAdd.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpAdd.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpAddFactory : IOperationFactory + { + private OpAddFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpAdd(destination, lhs, rhs); + } class OpAdd : IOperation where T : unmanaged, INumber { readonly IOperand _destination; @@ -19,8 +26,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_lhs.Get() + _rhs.Get()); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpAdd(destination, lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpAnd.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpAnd.cs index b0a1031a5..5e623702c 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpAnd.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpAnd.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpAndFactory : IOperationFactory + { + private OpAndFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpAnd(destination, lhs, rhs); + } class OpAnd : IOperation where T : unmanaged, IBinaryNumber { readonly IOperand _destination; @@ -19,8 +26,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_lhs.Get() & _rhs.Get()); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpAnd(destination, lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpLsh.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpLsh.cs index cb7ae2237..18156f1ff 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpLsh.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpLsh.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpLshFactory : IOperationFactory + { + private OpLshFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpLsh(destination, lhs, rhs); + } class OpLsh : IOperation where T : unmanaged, IBinaryInteger { readonly IOperand _destination; @@ -19,8 +26,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_lhs.Get() << int.CreateTruncating(_rhs.Get())); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpLsh(destination, lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpMov.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpMov.cs index 54266b422..13c3009a3 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpMov.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpMov.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpMovFactory : IOperationFactory + { + private OpMovFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpMov(destination, lhs); + } class OpMov : IOperation where T : unmanaged, INumber { readonly IOperand _destination; @@ -17,8 +24,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_source.Get()); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpMov(destination, lhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpMul.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpMul.cs index 14c43dd03..f760447b8 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpMul.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpMul.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpMulFactory : IOperationFactory + { + private OpMulFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpMul(destination, lhs, rhs); + } class OpMul : IOperation where T : unmanaged, INumber { readonly IOperand _destination; @@ -19,8 +26,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_lhs.Get() * _rhs.Get()); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpMul(destination, lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpNot.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpNot.cs index 91e0f6321..56f9c3f82 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpNot.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpNot.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpNotFactory : IOperationFactory + { + private OpNotFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpNot(destination, lhs); + } class OpNot : IOperation where T : unmanaged, IBinaryNumber { readonly IOperand _destination; @@ -17,8 +24,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(~_source.Get()); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpNot(destination, lhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpOr.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpOr.cs index 704597423..4e47dacd4 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpOr.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpOr.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpOrFactory : IOperationFactory + { + private OpOrFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpOr(destination, lhs, rhs); + } class OpOr : IOperation where T : unmanaged, IBinaryNumber { readonly IOperand _destination; @@ -19,8 +26,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_lhs.Get() | _rhs.Get()); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpOr(destination, lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpRsh.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpRsh.cs index b48c76a5c..d40b29ee8 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpRsh.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpRsh.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpRshFactory : IOperationFactory + { + private OpRshFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpRsh(destination, lhs, rhs); + } class OpRsh : IOperation where T : unmanaged, IBinaryInteger { readonly IOperand _destination; @@ -19,8 +26,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_lhs.Get() >> int.CreateTruncating(_rhs.Get())); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpRsh(destination, lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpSub.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpSub.cs index 1092643cf..9f76b1ffd 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpSub.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpSub.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpSubFactory : IOperationFactory + { + private OpSubFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpSub(destination, lhs, rhs); + } class OpSub : IOperation where T : unmanaged, INumber { readonly IOperand _destination; @@ -19,8 +26,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_lhs.Get() - _rhs.Get()); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpSub(destination, lhs, rhs); } } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpXor.cs b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpXor.cs index 8fc241ced..8a820f4a1 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Operations/OpXor.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Operations/OpXor.cs @@ -2,6 +2,13 @@ using System.Numerics; namespace Ryujinx.HLE.HOS.Tamper.Operations { + sealed class OpXorFactory : IOperationFactory + { + private OpXorFactory() { } + + public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T : unmanaged, IBinaryInteger + => new OpXor(destination, lhs, rhs); + } class OpXor : IOperation where T : unmanaged, IBinaryNumber { readonly IOperand _destination; @@ -19,8 +26,5 @@ namespace Ryujinx.HLE.HOS.Tamper.Operations { _destination.Set(_lhs.Get() ^ _rhs.Get()); } - - public static IOperation CreateFor(IOperand destination, IOperand lhs, IOperand rhs) where T1 : unmanaged, IBinaryInteger - => new OpXor(destination, lhs, rhs); } }