|
|
|
@ -271,10 +271,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -271,10 +271,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (rangeVar != null) { |
|
|
|
|
if (!MatchIndexFromRange(startIndexKind, startIndexLoad, rangeVar, "get_Start")) |
|
|
|
|
return; |
|
|
|
|
if (!MatchIndexFromRange(endIndexKind, endIndexLoad, rangeVar, "get_End")) |
|
|
|
|
return; |
|
|
|
|
return; // this should only ever happen in the second step (ExtendSlicing)
|
|
|
|
|
} |
|
|
|
|
if (!(sliceLengthVar.LoadInstructions.Single().Parent is CallInstruction call)) |
|
|
|
|
return; |
|
|
|
@ -291,9 +288,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -291,9 +288,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} else { |
|
|
|
|
if (!call.Arguments[1].MatchLdLoc(startOffsetVar)) |
|
|
|
|
return; |
|
|
|
|
if (!ILInlining.CanMoveInto(startOffsetVarInit, block.Instructions[pos], call.Arguments[1])) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!call.Arguments[2].MatchLdLoc(sliceLengthVar)) |
|
|
|
|
return; |
|
|
|
|
if (!ILInlining.CanMoveInto(sliceLengthVarInit, block.Instructions[pos], call.Arguments[2])) |
|
|
|
|
return; |
|
|
|
|
if (!CSharpWillGenerateIndexer(call.Method.DeclaringType, slicing: true)) |
|
|
|
|
return; |
|
|
|
|
var specialMethods = new IndexMethods(context.TypeSystem); |
|
|
|
@ -385,13 +386,17 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -385,13 +386,17 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
// holds because we've used containerLengthVar at least once
|
|
|
|
|
Debug.Assert(startIndexKind != IndexKind.FromStart || endIndexKind != IndexKind.FromStart); |
|
|
|
|
if (rangeVar != null) { |
|
|
|
|
if (!ILInlining.CanMoveInto(rangeVarInit, block.Instructions[pos], startIndexLoad)) |
|
|
|
|
return; |
|
|
|
|
if (!MatchIndexFromRange(startIndexKind, startIndexLoad, rangeVar, "get_Start")) |
|
|
|
|
return; |
|
|
|
|
if (!MatchIndexFromRange(endIndexKind, endIndexLoad, rangeVar, "get_End")) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
context.Step("Merge containerLengthVar into slicing", slicingCall); |
|
|
|
|
var specialMethods = new IndexMethods(context.TypeSystem); |
|
|
|
|
if (!specialMethods.IsValid) |
|
|
|
|
return; |
|
|
|
|
context.Step("Merge containerLengthVar into slicing", slicingCall); |
|
|
|
|
rangeCtorCall.ReplaceWith(MakeRange(startIndexKind, startIndexLoad, endIndexKind, endIndexLoad, specialMethods)); |
|
|
|
|
for (int i = startPos; i < pos; i++) { |
|
|
|
|
slicingCall.AddILRange(block.Instructions[i]); |
|
|
|
|