|
|
|
@ -17,6 +17,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -17,6 +17,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
|
|
|
|
|
void Run(CallInstruction inst, ILTransformContext context) |
|
|
|
|
{ |
|
|
|
|
if (inst.Method.IsStatic) |
|
|
|
|
return; |
|
|
|
|
if (inst.Method.MetadataToken.IsNil || inst.Method.MetadataToken.Kind != HandleKind.MethodDefinition) |
|
|
|
|
return; |
|
|
|
|
var handle = (MethodDefinitionHandle)inst.Method.MetadataToken; |
|
|
|
@ -42,28 +44,33 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -42,28 +44,33 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
if (blockContainer.Blocks.Count != 1) |
|
|
|
|
return; |
|
|
|
|
var block = blockContainer.Blocks[0]; |
|
|
|
|
Call call = null; |
|
|
|
|
if (block.Instructions.Count == 1) { |
|
|
|
|
// leave IL_0000 (call Test(ldloc this, ldloc A_1))
|
|
|
|
|
if (!block.Instructions[0].MatchLeave(blockContainer, out ILInstruction returnValue)) |
|
|
|
|
return; |
|
|
|
|
call = returnValue as Call; |
|
|
|
|
} else if (block.Instructions.Count == 2) { |
|
|
|
|
// call Test(ldloc this, ldloc A_1)
|
|
|
|
|
// leave IL_0000(nop)
|
|
|
|
|
call = block.Instructions[0] as Call; |
|
|
|
|
if (!block.Instructions[1].MatchLeave(blockContainer, out ILInstruction returnValue)) |
|
|
|
|
return; |
|
|
|
|
if (!returnValue.MatchNop()) |
|
|
|
|
Call call; |
|
|
|
|
ILInstruction returnValue; |
|
|
|
|
switch (block.Instructions.Count) { |
|
|
|
|
case 1: |
|
|
|
|
// leave IL_0000 (call Test(ldloc this, ldloc A_1))
|
|
|
|
|
if (!block.Instructions[0].MatchLeave(blockContainer, out returnValue)) |
|
|
|
|
return; |
|
|
|
|
call = returnValue as Call; |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
// call Test(ldloc this, ldloc A_1)
|
|
|
|
|
// leave IL_0000(nop)
|
|
|
|
|
call = block.Instructions[0] as Call; |
|
|
|
|
if (!block.Instructions[1].MatchLeave(blockContainer, out returnValue)) |
|
|
|
|
return; |
|
|
|
|
if (!returnValue.MatchNop()) |
|
|
|
|
return; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (call == null || call.Method.IsConstructor) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (call.Method.IsStatic != inst.Method.IsStatic || call.Method.Parameters.Count != inst.Method.Parameters.Count) { |
|
|
|
|
if (call.Method.IsStatic || call.Method.Parameters.Count != inst.Method.Parameters.Count) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// check if original arguments are only correct ldloc calls
|
|
|
|
|
for (int i = 0; i < call.Arguments.Count; i++) { |
|
|
|
|
var originalArg = call.Arguments[i]; |
|
|
|
|