Browse Source

Rename HasILRange to ILRangeIsEmpty to properly reflect its implementation.

pull/1967/head
Siegfried Pammer 5 years ago
parent
commit
e4fda5c2e4
  1. 2
      ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs
  2. 4
      ICSharpCode.Decompiler/IL/BlockBuilder.cs
  3. 4
      ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs
  4. 4
      ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs
  5. 2
      ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs
  6. 2
      ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs

2
ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs

@ -275,7 +275,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -275,7 +275,7 @@ namespace ICSharpCode.Decompiler.CSharp
internal static bool HasUsableILRange(ILInstruction inst)
{
if (inst.HasILRange)
if (inst.ILRangeIsEmpty)
return false;
return !(inst is BlockContainer || inst is Block);
}

4
ICSharpCode.Decompiler/IL/BlockBuilder.cs

@ -137,7 +137,7 @@ namespace ICSharpCode.Decompiler.IL @@ -137,7 +137,7 @@ namespace ICSharpCode.Decompiler.IL
// this container is skipped (i.e. the loop will execute again)
// set ILRange to the last instruction offset inside the block.
if (start >= currentContainer.EndILOffset) {
Debug.Assert(currentBlock.HasILRange);
Debug.Assert(currentBlock.ILRangeIsEmpty);
currentBlock.AddILRange(new Interval(currentBlock.StartILOffset, start));
}
}
@ -190,7 +190,7 @@ namespace ICSharpCode.Decompiler.IL @@ -190,7 +190,7 @@ namespace ICSharpCode.Decompiler.IL
{
if (currentBlock == null)
return;
Debug.Assert(currentBlock.HasILRange);
Debug.Assert(currentBlock.ILRangeIsEmpty);
currentBlock.SetILRange(new Interval(currentBlock.StartILOffset, currentILOffset));
if (fallthrough) {
if (currentBlock.Instructions.LastOrDefault() is SwitchInstruction switchInst && switchInst.Sections.Last().Body.MatchNop()) {

4
ICSharpCode.Decompiler/IL/ControlFlow/ConditionDetection.cs

@ -442,11 +442,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -442,11 +442,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
// some compilers merge the leave instructions for different arguments using stack variables
// these get split and inlined, but the ILRange of the value remains a better indicator of the actual location
if (inst is Leave leave && !leave.Value.MatchNop()) {
isEmpty = leave.Value.HasILRange;
isEmpty = leave.Value.ILRangeIsEmpty;
return leave.Value.StartILOffset;
}
isEmpty = inst.HasILRange;
isEmpty = inst.ILRangeIsEmpty;
return inst.StartILOffset;
}

4
ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs

@ -166,7 +166,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -166,7 +166,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
context.Step("Replace branch to leave with leave", branch);
// Replace branches to 'leave' instruction with the leave instruction
var leave2 = leave.Clone();
if (!branch.HasILRange) // use the ILRange of the branch if possible
if (!branch.ILRangeIsEmpty) // use the ILRange of the branch if possible
leave2.AddILRange(branch);
branch.ReplaceWith(leave2);
}
@ -221,7 +221,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -221,7 +221,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
block.Instructions.RemoveRange(block.Instructions.Count - 3, 2);
}
if (block.HasILRange)
if (block.ILRangeIsEmpty)
block.AddILRange(targetBlock);
block.Instructions.Remove(br);

2
ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs

@ -181,7 +181,7 @@ namespace ICSharpCode.Decompiler.IL @@ -181,7 +181,7 @@ namespace ICSharpCode.Decompiler.IL
base.CheckInvariant(phase);
Debug.Assert(Blocks.Count > 0 && EntryPoint == Blocks[0]);
Debug.Assert(!IsConnected || EntryPoint?.IncomingEdgeCount >= 1);
Debug.Assert(EntryPoint == null || Parent is ILFunction || !HasILRange);
Debug.Assert(EntryPoint == null || Parent is ILFunction || !ILRangeIsEmpty);
Debug.Assert(Blocks.All(b => b.HasFlag(InstructionFlags.EndPointUnreachable)));
Debug.Assert(Blocks.All(b => b.Kind == BlockKind.ControlFlow)); // this also implies that the blocks don't use FinalInstruction
Debug.Assert(TopologicalSort(deleteUnreachableBlocks: true).Count == Blocks.Count, "Container should not have any unreachable blocks");

2
ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs

@ -253,7 +253,7 @@ namespace ICSharpCode.Decompiler.IL @@ -253,7 +253,7 @@ namespace ICSharpCode.Decompiler.IL
public int EndILOffset => ILRange.End;
public bool HasILRange => ILRange.IsEmpty;
public bool ILRangeIsEmpty => ILRange.IsEmpty;
public IEnumerable<Interval> ILRanges => new[] { ILRange };

Loading…
Cancel
Save