diff options
Diffstat (limited to 'Mono.Cecil.Cil/ILProcessor.cs')
-rw-r--r-- | Mono.Cecil.Cil/ILProcessor.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Mono.Cecil.Cil/ILProcessor.cs b/Mono.Cecil.Cil/ILProcessor.cs index 039d2fc..a3fb8f1 100644 --- a/Mono.Cecil.Cil/ILProcessor.cs +++ b/Mono.Cecil.Cil/ILProcessor.cs @@ -229,6 +229,16 @@ namespace Mono.Cecil.Cil { instructions.Insert (index + 1, instruction); } + public void InsertAfter (int index, Instruction instruction) + { + if (index < 0 || index >= instructions.Count) + throw new ArgumentOutOfRangeException ("index"); + if (instruction == null) + throw new ArgumentNullException ("instruction"); + + instructions.Insert (index + 1, instruction); + } + public void Append (Instruction instruction) { if (instruction == null) @@ -248,6 +258,15 @@ namespace Mono.Cecil.Cil { Remove (target); } + public void Replace (int index, Instruction instruction) + { + if (instruction == null) + throw new ArgumentNullException ("instruction"); + + InsertAfter (index, instruction); + RemoveAt (index); + } + public void Remove (Instruction instruction) { if (instruction == null) @@ -256,5 +275,13 @@ namespace Mono.Cecil.Cil { if (!instructions.Remove (instruction)) throw new ArgumentOutOfRangeException ("instruction"); } + + public void RemoveAt (int index) + { + if (index < 0 || index >= instructions.Count) + throw new ArgumentOutOfRangeException ("index"); + + instructions.RemoveAt (index); + } } } |