summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-08-26 21:55:08 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-08-26 21:55:08 -0400
commit16161a214fddea19b908d7ca3dc0d39f81c259c8 (patch)
treee5cb86f44a675bf66dd2022644c9b4698d7e474b
parentfd6835555ccdfecc09d87aab29b9c5cec3820720 (diff)
downloadSMAPI-16161a214fddea19b908d7ca3dc0d39f81c259c8.tar.gz
SMAPI-16161a214fddea19b908d7ca3dc0d39f81c259c8.tar.bz2
SMAPI-16161a214fddea19b908d7ca3dc0d39f81c259c8.zip
remove now-unused instruction replace callback
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyLoader.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/EventFinder.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/FieldFinder.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/MethodFinder.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/PropertyFinder.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/ReferenceToMissingMemberFinder.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/BaseInstructionHandler.cs2
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/IInstructionHandler.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs2
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs2
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/MethodWithMissingOptionalParameterRewriter.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/StaticFieldToConstantRewriter.cs2
15 files changed, 17 insertions, 32 deletions
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
index c8c1ca08..cfe4c747 100644
--- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
+++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
@@ -318,11 +318,11 @@ namespace StardewModdingAPI.Framework.ModLoading
rewritten |= handler.Handle(module, type, replaceWith);
return rewritten;
},
- rewriteInstruction: (ref Instruction instruction, ILProcessor cil, Action<Instruction> replaceWith) =>
+ rewriteInstruction: (ref Instruction instruction, ILProcessor cil) =>
{
bool rewritten = false;
foreach (IInstructionHandler handler in handlers)
- rewritten |= handler.Handle(module, cil, instruction, replaceWith);
+ rewritten |= handler.Handle(module, cil, instruction);
return rewritten;
}
);
diff --git a/src/SMAPI/Framework/ModLoading/Finders/EventFinder.cs b/src/SMAPI/Framework/ModLoading/Finders/EventFinder.cs
index 3d23da87..01ed153b 100644
--- a/src/SMAPI/Framework/ModLoading/Finders/EventFinder.cs
+++ b/src/SMAPI/Framework/ModLoading/Finders/EventFinder.cs
@@ -1,4 +1,3 @@
-using System;
using Mono.Cecil;
using Mono.Cecil.Cil;
using StardewModdingAPI.Framework.ModLoading.Framework;
@@ -37,7 +36,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
if (!this.Flags.Contains(this.Result) && this.IsMatch(instruction))
this.MarkFlag(this.Result);
diff --git a/src/SMAPI/Framework/ModLoading/Finders/FieldFinder.cs b/src/SMAPI/Framework/ModLoading/Finders/FieldFinder.cs
index b4063078..2c062243 100644
--- a/src/SMAPI/Framework/ModLoading/Finders/FieldFinder.cs
+++ b/src/SMAPI/Framework/ModLoading/Finders/FieldFinder.cs
@@ -1,4 +1,3 @@
-using System;
using Mono.Cecil;
using Mono.Cecil.Cil;
using StardewModdingAPI.Framework.ModLoading.Framework;
@@ -37,7 +36,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
if (!this.Flags.Contains(this.Result) && RewriteHelper.IsFieldReferenceTo(instruction, this.FullTypeName, this.FieldName))
this.MarkFlag(this.Result);
diff --git a/src/SMAPI/Framework/ModLoading/Finders/MethodFinder.cs b/src/SMAPI/Framework/ModLoading/Finders/MethodFinder.cs
index 187bdefc..d2340f01 100644
--- a/src/SMAPI/Framework/ModLoading/Finders/MethodFinder.cs
+++ b/src/SMAPI/Framework/ModLoading/Finders/MethodFinder.cs
@@ -1,4 +1,3 @@
-using System;
using Mono.Cecil;
using Mono.Cecil.Cil;
using StardewModdingAPI.Framework.ModLoading.Framework;
@@ -37,7 +36,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
if (!this.Flags.Contains(this.Result) && this.IsMatch(instruction))
this.MarkFlag(this.Result);
diff --git a/src/SMAPI/Framework/ModLoading/Finders/PropertyFinder.cs b/src/SMAPI/Framework/ModLoading/Finders/PropertyFinder.cs
index d14058dc..99344848 100644
--- a/src/SMAPI/Framework/ModLoading/Finders/PropertyFinder.cs
+++ b/src/SMAPI/Framework/ModLoading/Finders/PropertyFinder.cs
@@ -1,4 +1,3 @@
-using System;
using Mono.Cecil;
using Mono.Cecil.Cil;
using StardewModdingAPI.Framework.ModLoading.Framework;
@@ -37,7 +36,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
if (!this.Flags.Contains(this.Result) && this.IsMatch(instruction))
this.MarkFlag(this.Result);
diff --git a/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs b/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs
index 2402bf48..b01a3240 100644
--- a/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs
+++ b/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
@@ -30,7 +29,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
// field reference
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
diff --git a/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMissingMemberFinder.cs b/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMissingMemberFinder.cs
index f97783da..9afd1de0 100644
--- a/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMissingMemberFinder.cs
+++ b/src/SMAPI/Framework/ModLoading/Finders/ReferenceToMissingMemberFinder.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
@@ -30,7 +29,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
// field reference
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
diff --git a/src/SMAPI/Framework/ModLoading/Framework/BaseInstructionHandler.cs b/src/SMAPI/Framework/ModLoading/Framework/BaseInstructionHandler.cs
index ef619761..624113b3 100644
--- a/src/SMAPI/Framework/ModLoading/Framework/BaseInstructionHandler.cs
+++ b/src/SMAPI/Framework/ModLoading/Framework/BaseInstructionHandler.cs
@@ -31,7 +31,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
}
/// <inheritdoc />
- public virtual bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public virtual bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
return false;
}
diff --git a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
index fb651465..ea29550a 100644
--- a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
@@ -22,9 +22,8 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
/// <summary>Rewrite a CIL instruction in the assembly code.</summary>
/// <param name="instruction">The current CIL instruction.</param>
/// <param name="cil">The CIL instruction processor.</param>
- /// <param name="replaceWith">Replaces the CIL instruction with the given instruction.</param>
/// <returns>Returns whether the instruction was changed.</returns>
- public delegate bool RewriteInstructionDelegate(ref Instruction instruction, ILProcessor cil, Action<Instruction> replaceWith);
+ public delegate bool RewriteInstructionDelegate(ref Instruction instruction, ILProcessor cil);
/*********
@@ -161,12 +160,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
// instruction itself
// (should be done after the above type rewrites to ensure valid types)
- rewritten |= this.RewriteInstructionImpl(ref instruction, cil, newInstruction =>
- {
- rewritten = true;
- cil.Replace(instruction, newInstruction);
- instruction = newInstruction;
- });
+ rewritten |= this.RewriteInstructionImpl(ref instruction, cil);
return rewritten;
}
diff --git a/src/SMAPI/Framework/ModLoading/IInstructionHandler.cs b/src/SMAPI/Framework/ModLoading/IInstructionHandler.cs
index e6de6785..17c9ba68 100644
--- a/src/SMAPI/Framework/ModLoading/IInstructionHandler.cs
+++ b/src/SMAPI/Framework/ModLoading/IInstructionHandler.cs
@@ -35,8 +35,7 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <param name="module">The assembly module containing the instruction.</param>
/// <param name="cil">The CIL processor.</param>
/// <param name="instruction">The CIL instruction to handle.</param>
- /// <param name="replaceWith">Replaces the CIL instruction with a new one.</param>
/// <returns>Returns whether the instruction was changed.</returns>
- bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith);
+ bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction);
}
}
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs
index c251a30c..0b679e9d 100644
--- a/src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs
@@ -50,7 +50,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
// get field reference
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs
index 0a99bde0..aaf04b79 100644
--- a/src/SMAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
@@ -29,7 +28,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
// get field ref
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs
index dc04478f..9933e2ca 100644
--- a/src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs
@@ -41,7 +41,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
: this(fromType.FullName, toType, nounPhrase) { }
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
// get method ref
MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/MethodWithMissingOptionalParameterRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/MethodWithMissingOptionalParameterRewriter.cs
index e6e7a847..89c8ede7 100644
--- a/src/SMAPI/Framework/ModLoading/Rewriters/MethodWithMissingOptionalParameterRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/MethodWithMissingOptionalParameterRewriter.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
@@ -29,7 +28,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
// get method ref
MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/StaticFieldToConstantRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/StaticFieldToConstantRewriter.cs
index 2f1122b4..f34d4943 100644
--- a/src/SMAPI/Framework/ModLoading/Rewriters/StaticFieldToConstantRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/StaticFieldToConstantRewriter.cs
@@ -38,7 +38,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <inheritdoc />
- public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action<Instruction> replaceWith)
+ public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction)
{
// get field reference
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);