|
|
@ -1208,9 +1208,9 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
case BinaryNumericOperator.BitXor: |
|
|
|
return HandleBinaryNumeric(inst, BinaryOperatorType.ExclusiveOr, context); |
|
|
|
case BinaryNumericOperator.ShiftLeft: |
|
|
|
return HandleShift(inst, BinaryOperatorType.ShiftLeft); |
|
|
|
return HandleShift(inst, BinaryOperatorType.ShiftLeft, context); |
|
|
|
case BinaryNumericOperator.ShiftRight: |
|
|
|
return HandleShift(inst, BinaryOperatorType.ShiftRight); |
|
|
|
return HandleShift(inst, BinaryOperatorType.ShiftRight, context); |
|
|
|
default: |
|
|
|
throw new ArgumentOutOfRangeException(); |
|
|
|
} |
|
|
@ -1736,7 +1736,7 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TranslatedExpression HandleShift(BinaryNumericInstruction inst, BinaryOperatorType op) |
|
|
|
TranslatedExpression HandleShift(BinaryNumericInstruction inst, BinaryOperatorType op, TranslationContext context) |
|
|
|
{ |
|
|
|
var left = Translate(inst.Left); |
|
|
|
var right = Translate(inst.Right); |
|
|
@ -1748,6 +1748,8 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
bool couldUseUnsignedRightShift = ( |
|
|
|
sign == Sign.Unsigned && op == BinaryOperatorType.ShiftRight && settings.UnsignedRightShift |
|
|
|
&& (leftUType.IsCSharpPrimitiveIntegerType() || leftUType.IsCSharpNativeIntegerType()) |
|
|
|
// If we need to cast to unsigned anyway, don't use >>> operator.
|
|
|
|
&& context.TypeHint.GetSign() != Sign.Unsigned |
|
|
|
); |
|
|
|
if (leftUType.IsCSharpSmallIntegerType() && inst.UnderlyingResultType == StackType.I4 && |
|
|
|
(sign != Sign.Unsigned || couldUseUnsignedRightShift)) |
|
|
@ -1760,7 +1762,7 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
op = BinaryOperatorType.UnsignedShiftRight; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (couldUseUnsignedRightShift && leftUType.GetSize() == inst.UnderlyingResultType.GetSize()) |
|
|
|
else if (couldUseUnsignedRightShift && leftUType.GetSize() == inst.UnderlyingResultType.GetSize() && leftUType.GetSign() == Sign.Signed) |
|
|
|
{ |
|
|
|
// Use C# 11 unsigned right shift operator. We don't need any casts in this case.
|
|
|
|
op = BinaryOperatorType.UnsignedShiftRight; |
|
|
|