|
|
@ -141,7 +141,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
} |
|
|
|
} |
|
|
|
else if (rightWithoutConv.MatchLdcI4(0) && inst.Kind.IsEqualityOrInequality()) |
|
|
|
else if (rightWithoutConv.MatchLdcI4(0) && inst.Kind.IsEqualityOrInequality()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (inst.Left.MatchLdLen(StackType.I, out ILInstruction array)) |
|
|
|
if (inst.Left.MatchLdLen(StackType.I, out ILInstruction? array)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// comp.unsigned(ldlen array == conv i4->i(ldc.i4 0))
|
|
|
|
// comp.unsigned(ldlen array == conv i4->i(ldc.i4 0))
|
|
|
|
// => comp(ldlen.i4 array == ldc.i4 0)
|
|
|
|
// => comp(ldlen.i4 array == ldc.i4 0)
|
|
|
@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
protected internal override void VisitConv(Conv inst) |
|
|
|
protected internal override void VisitConv(Conv inst) |
|
|
|
{ |
|
|
|
{ |
|
|
|
inst.Argument.AcceptVisitor(this); |
|
|
|
inst.Argument.AcceptVisitor(this); |
|
|
|
if (inst.Argument.MatchLdLen(StackType.I, out ILInstruction array) && inst.TargetType.IsIntegerType() |
|
|
|
if (inst.Argument.MatchLdLen(StackType.I, out ILInstruction? array) && inst.TargetType.IsIntegerType() |
|
|
|
&& (!inst.CheckForOverflow || context.Settings.AssumeArrayLengthFitsIntoInt32)) |
|
|
|
&& (!inst.CheckForOverflow || context.Settings.AssumeArrayLengthFitsIntoInt32)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
context.Step("conv.i4(ldlen array) => ldlen.i4(array)", inst); |
|
|
|
context.Step("conv.i4(ldlen array) => ldlen.i4(array)", inst); |
|
|
@ -303,7 +303,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
protected internal override void VisitNewObj(NewObj inst) |
|
|
|
protected internal override void VisitNewObj(NewObj inst) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Block? block; |
|
|
|
Block? block; |
|
|
|
if (TransformSpanTCtorContainingStackAlloc(inst, out ILInstruction locallocSpan)) |
|
|
|
if (TransformSpanTCtorContainingStackAlloc(inst, out ILInstruction? locallocSpan)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
context.Step("new Span<T>(stackalloc) -> stackalloc Span<T>", inst); |
|
|
|
context.Step("new Span<T>(stackalloc) -> stackalloc Span<T>", inst); |
|
|
|
inst.ReplaceWith(locallocSpan); |
|
|
|
inst.ReplaceWith(locallocSpan); |
|
|
@ -329,7 +329,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
inst.ReplaceWith(replacement); |
|
|
|
inst.ReplaceWith(replacement); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (TransformDelegateCtorLdVirtFtnToLdVirtDelegate(inst, out LdVirtDelegate ldVirtDelegate)) |
|
|
|
if (TransformDelegateCtorLdVirtFtnToLdVirtDelegate(inst, out LdVirtDelegate? ldVirtDelegate)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
context.Step("new Delegate(target, ldvirtftn Method) -> ldvirtdelegate Delegate Method(target)", inst); |
|
|
|
context.Step("new Delegate(target, ldvirtftn Method) -> ldvirtdelegate Delegate Method(target)", inst); |
|
|
|
inst.ReplaceWith(ldVirtDelegate); |
|
|
|
inst.ReplaceWith(ldVirtDelegate); |
|
|
@ -462,7 +462,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
EarlyExpressionTransforms.AddressOfLdLocToLdLoca(inst, context); |
|
|
|
EarlyExpressionTransforms.AddressOfLdLocToLdLoca(inst, context); |
|
|
|
if (EarlyExpressionTransforms.LdObjToLdLoc(inst, context)) |
|
|
|
if (EarlyExpressionTransforms.LdObjToLdLoc(inst, context)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
if (TransformDecimalFieldToConstant(inst, out LdcDecimal decimalConstant)) |
|
|
|
if (TransformDecimalFieldToConstant(inst, out LdcDecimal? decimalConstant)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
context.Step("TransformDecimalFieldToConstant", inst); |
|
|
|
context.Step("TransformDecimalFieldToConstant", inst); |
|
|
|
inst.ReplaceWith(decimalConstant); |
|
|
|
inst.ReplaceWith(decimalConstant); |
|
|
@ -549,8 +549,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
Block? falseInst = inst.FalseInst as Block; |
|
|
|
Block? falseInst = inst.FalseInst as Block; |
|
|
|
if (falseInst == null || falseInst.Instructions.Count != 1) |
|
|
|
if (falseInst == null || falseInst.Instructions.Count != 1) |
|
|
|
return inst; |
|
|
|
return inst; |
|
|
|
ILVariable v; |
|
|
|
ILVariable? v; |
|
|
|
ILInstruction value1, value2; |
|
|
|
ILInstruction? value1, value2; |
|
|
|
if (trueInst.Instructions[0].MatchStLoc(out v, out value1) && falseInst.Instructions[0].MatchStLoc(v, out value2)) |
|
|
|
if (trueInst.Instructions[0].MatchStLoc(out v, out value1) && falseInst.Instructions[0].MatchStLoc(v, out value2)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
context.Step("conditional operator", inst); |
|
|
|
context.Step("conditional operator", inst); |
|
|
@ -629,7 +629,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
{ |
|
|
|
{ |
|
|
|
// validate that each integer is used for exactly one value
|
|
|
|
// validate that each integer is used for exactly one value
|
|
|
|
var integersUsed = new HashSet<int>(); |
|
|
|
var integersUsed = new HashSet<int>(); |
|
|
|
foreach ((string key, int val) in str2int.Map) |
|
|
|
foreach ((string? key, int val) in str2int.Map) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!integersUsed.Add(val)) |
|
|
|
if (!integersUsed.Add(val)) |
|
|
|
return; |
|
|
|
return; |
|
|
|