From 8bdae4066515335a5784f26580d86294693dfb8d Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 28 Mar 2018 01:16:42 +0200 Subject: [PATCH] Allow ILParser methods to be used as C# 7.2 ref extensions --- ICSharpCode.Decompiler/Disassembler/OpCodeInfo.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.Decompiler/Disassembler/OpCodeInfo.cs b/ICSharpCode.Decompiler/Disassembler/OpCodeInfo.cs index a380a4aaf..504111136 100644 --- a/ICSharpCode.Decompiler/Disassembler/OpCodeInfo.cs +++ b/ICSharpCode.Decompiler/Disassembler/OpCodeInfo.cs @@ -105,13 +105,13 @@ namespace ICSharpCode.Decompiler.Disassembler public static class ILParser { - public static ILOpCode DecodeOpCode(ref BlobReader blob) + public static ILOpCode DecodeOpCode(this ref BlobReader blob) { byte opCodeByte = blob.ReadByte(); return (ILOpCode)(opCodeByte == 0xFE ? 0xFE00 + blob.ReadByte() : opCodeByte); } - public static void SkipOperand(ref BlobReader blob, ILOpCode opCode) + public static void SkipOperand(this ref BlobReader blob, ILOpCode opCode) { switch (opCode.GetOperandType()) { // 64-bit @@ -149,12 +149,12 @@ namespace ICSharpCode.Decompiler.Disassembler } } - public static int DecodeBranchTarget(ref BlobReader blob, ILOpCode opCode) + public static int DecodeBranchTarget(this ref BlobReader blob, ILOpCode opCode) { return (opCode.GetBranchOperandSize() == 4 ? blob.ReadInt32() : blob.ReadSByte()) + blob.Offset; } - public static int[] DecodeSwitchTargets(ref BlobReader blob) + public static int[] DecodeSwitchTargets(this ref BlobReader blob) { int[] targets = new int[blob.ReadUInt32()]; int offset = blob.Offset + 4 * targets.Length; @@ -163,12 +163,12 @@ namespace ICSharpCode.Decompiler.Disassembler return targets; } - public static string DecodeUserString(ref BlobReader blob, MetadataReader metadata) + public static string DecodeUserString(this ref BlobReader blob, MetadataReader metadata) { return metadata.GetUserString(MetadataTokens.UserStringHandle(blob.ReadInt32())); } - public static int DecodeIndex(ref BlobReader blob, ILOpCode opCode) + public static int DecodeIndex(this ref BlobReader blob, ILOpCode opCode) { switch (opCode.GetOperandType()) { case OperandType.ShortVariable: