Browse Source

Fix bugs in IfInstruction.TransformStackIntoVariables

pull/728/head
Daniel Grunwald 11 years ago
parent
commit
f57e159c35
  1. 15
      ICSharpCode.Decompiler/IL/Instructions/IfInstruction.cs

15
ICSharpCode.Decompiler/IL/Instructions/IfInstruction.cs

@ -63,13 +63,22 @@ namespace ICSharpCode.Decompiler.IL
{ {
Condition.TransformStackIntoVariables(state); Condition.TransformStackIntoVariables(state);
var stackAfterCondition = state.Variables.Clone(); var stackAfterCondition = state.Variables.Clone();
TrueInst.Inline(InstructionFlags.None, state).TransformStackIntoVariables(state); TrueInst = TrueInst.Inline(InstructionFlags.None, state);
TrueInst.TransformStackIntoVariables(state);
var afterTrue = state.Variables.Clone(); var afterTrue = state.Variables.Clone();
state.Variables = stackAfterCondition; state.Variables = stackAfterCondition;
FalseInst.Inline(InstructionFlags.None, state).TransformStackIntoVariables(state); FalseInst = FalseInst.Inline(InstructionFlags.None, state);
if (!TrueInst.HasFlag(InstructionFlags.EndPointUnreachable) && !FalseInst.HasFlag(InstructionFlags.EndPointUnreachable)) FalseInst.TransformStackIntoVariables(state);
if (!TrueInst.HasFlag(InstructionFlags.EndPointUnreachable) && !FalseInst.HasFlag(InstructionFlags.EndPointUnreachable)) {
// If end-points of both instructions are reachable, merge their states
state.MergeVariables(state.Variables, afterTrue); state.MergeVariables(state.Variables, afterTrue);
} }
if (FalseInst.HasFlag(InstructionFlags.EndPointUnreachable)) {
// If the end-point of FalseInst is unreachable, continue with the end-state of TrueInst instead
// (if both are unreachable, it doesn't matter what we continue with)
state.Variables = afterTrue;
}
}
protected override InstructionFlags ComputeFlags() protected override InstructionFlags ComputeFlags()
{ {

Loading…
Cancel
Save