|
|
@ -343,77 +343,6 @@ namespace ICSharpCode.Decompiler.ILAst |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static int? GetPopCount(this Instruction inst) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch(inst.OpCode.StackBehaviourPop) { |
|
|
|
|
|
|
|
case StackBehaviour.Pop0: return 0; |
|
|
|
|
|
|
|
case StackBehaviour.Pop1: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Popi: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Popref: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Pop1_pop1: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Popi_pop1: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Popi_popi: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Popi_popi8: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Popi_popr4: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Popi_popr8: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Popref_pop1: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Popref_popi: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Popi_popi_popi: return 3; |
|
|
|
|
|
|
|
case StackBehaviour.Popref_popi_popi: return 3; |
|
|
|
|
|
|
|
case StackBehaviour.Popref_popi_popi8: return 3; |
|
|
|
|
|
|
|
case StackBehaviour.Popref_popi_popr4: return 3; |
|
|
|
|
|
|
|
case StackBehaviour.Popref_popi_popr8: return 3; |
|
|
|
|
|
|
|
case StackBehaviour.Popref_popi_popref: return 3; |
|
|
|
|
|
|
|
case StackBehaviour.PopAll: return null; |
|
|
|
|
|
|
|
case StackBehaviour.Varpop: |
|
|
|
|
|
|
|
switch(inst.OpCode.Code) { |
|
|
|
|
|
|
|
case Code.Call: |
|
|
|
|
|
|
|
case Code.Callvirt: |
|
|
|
|
|
|
|
MethodReference cecilMethod = ((MethodReference)inst.Operand); |
|
|
|
|
|
|
|
if (cecilMethod.HasThis) { |
|
|
|
|
|
|
|
return cecilMethod.Parameters.Count + 1 /* this */; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return cecilMethod.Parameters.Count; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case Code.Calli: throw new NotImplementedException(); |
|
|
|
|
|
|
|
case Code.Ret: return null; |
|
|
|
|
|
|
|
case Code.Newobj: |
|
|
|
|
|
|
|
MethodReference ctorMethod = ((MethodReference)inst.Operand); |
|
|
|
|
|
|
|
return ctorMethod.Parameters.Count; |
|
|
|
|
|
|
|
default: throw new Exception("Unknown Varpop opcode"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: throw new Exception("Unknown pop behaviour: " + inst.OpCode.StackBehaviourPop); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int GetPushCount(this Instruction inst) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch(inst.OpCode.StackBehaviourPush) { |
|
|
|
|
|
|
|
case StackBehaviour.Push0: return 0; |
|
|
|
|
|
|
|
case StackBehaviour.Push1: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Push1_push1: return 2; |
|
|
|
|
|
|
|
case StackBehaviour.Pushi: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Pushi8: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Pushr4: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Pushr8: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Pushref: return 1; |
|
|
|
|
|
|
|
case StackBehaviour.Varpush: // Happens only for calls
|
|
|
|
|
|
|
|
switch(inst.OpCode.Code) { |
|
|
|
|
|
|
|
case Code.Call: |
|
|
|
|
|
|
|
case Code.Callvirt: |
|
|
|
|
|
|
|
MethodReference cecilMethod = ((MethodReference)inst.Operand); |
|
|
|
|
|
|
|
if (cecilMethod.ReturnType.FullName == "System.Void") { |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case Code.Calli: throw new NotImplementedException(); |
|
|
|
|
|
|
|
default: throw new Exception("Unknown Varpush opcode"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: throw new Exception("Unknown push behaviour: " + inst.OpCode.StackBehaviourPush); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void ExpandMacro(ref ILCode code, ref object operand, MethodBody methodBody) |
|
|
|
public static void ExpandMacro(ref ILCode code, ref object operand, MethodBody methodBody) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (code) { |
|
|
|
switch (code) { |
|
|
|