diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-05-06 00:02:10 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-05-06 00:02:10 -0400 |
commit | f16e477fc22bf76c33d8860acda090a199a0dcdb (patch) | |
tree | cfd1c0701869b7254b8122e9ab56a5652df729de /src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs | |
parent | cfc07c1ee58b113c4e2ec8d6de28a57397589068 (diff) | |
download | SMAPI-f16e477fc22bf76c33d8860acda090a199a0dcdb.tar.gz SMAPI-f16e477fc22bf76c33d8860acda090a199a0dcdb.tar.bz2 SMAPI-f16e477fc22bf76c33d8860acda090a199a0dcdb.zip |
add base instruction handler (#711)
Diffstat (limited to 'src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs index c4c740b3..c6388295 100644 --- a/src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs +++ b/src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs @@ -2,11 +2,12 @@ using System; using System.Linq; using Mono.Cecil; using Mono.Cecil.Cil; +using StardewModdingAPI.Framework.ModLoading.Framework; namespace StardewModdingAPI.Framework.ModLoading.Rewriters { /// <summary>Rewrites method references from one parent type to another if the signatures match.</summary> - internal class MethodParentRewriter : IInstructionHandler + internal class MethodParentRewriter : BaseInstructionHandler { /********* ** Fields @@ -22,13 +23,6 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters /********* - ** Accessors - *********/ - /// <summary>A brief noun phrase indicating what the instruction finder matches.</summary> - public string NounPhrase { get; } - - - /********* ** Public methods *********/ /// <summary>Construct an instance.</summary> @@ -37,10 +31,10 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters /// <param name="onlyIfPlatformChanged">Whether to only rewrite references if loading the assembly on a different platform than it was compiled on.</param> /// <param name="nounPhrase">A brief noun phrase indicating what the instruction finder matches (or <c>null</c> to generate one).</param> public MethodParentRewriter(string fromType, Type toType, bool onlyIfPlatformChanged = false, string nounPhrase = null) + : base(nounPhrase ?? $"{fromType.Split('.').Last()} methods") { this.FromType = fromType; this.ToType = toType; - this.NounPhrase = nounPhrase ?? $"{fromType.Split('.').Last()} methods"; this.OnlyIfPlatformChanged = onlyIfPlatformChanged; } @@ -51,23 +45,14 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters public MethodParentRewriter(Type fromType, Type toType, bool onlyIfPlatformChanged = false) : this(fromType.FullName, toType, onlyIfPlatformChanged) { } - /// <summary>Perform the predefined logic for a method if applicable.</summary> - /// <param name="module">The assembly module containing the instruction.</param> - /// <param name="method">The method definition containing the instruction.</param> - /// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param> - /// <param name="platformChanged">Whether the mod was compiled on a different platform.</param> - public InstructionHandleResult Handle(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged) - { - return InstructionHandleResult.None; - } /// <summary>Perform the predefined logic for an instruction if applicable.</summary> /// <param name="module">The assembly module containing the instruction.</param> /// <param name="cil">The CIL processor.</param> - /// <param name="instruction">The instruction to handle.</param> + /// <param name="instruction">The CIL instruction to handle.</param> /// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param> /// <param name="platformChanged">Whether the mod was compiled on a different platform.</param> - public InstructionHandleResult Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged) + public override InstructionHandleResult Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged) { if (!this.IsMatch(instruction, platformChanged)) return InstructionHandleResult.None; |