Browse Source

Simplify TranslateArrayIndex.

pull/2063/head
Daniel Grunwald 6 years ago
parent
commit
8f6bf3b45b
  1. 13
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

13
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -2301,19 +2301,14 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2301,19 +2301,14 @@ namespace ICSharpCode.Decompiler.CSharp
.WithoutILInstruction().WithRR(new ByReferenceResolveResult(expr.Type, ReferenceKind.Ref));
}
TranslatedExpression TranslateArrayIndex(ILInstruction i, bool expectSystemIndex = false)
TranslatedExpression TranslateArrayIndex(ILInstruction i)
{
var input = Translate(i);
KnownTypeCode targetType;
if (i.ResultType == StackType.I4) {
if (input.Type.IsSmallIntegerType() && input.Type.Kind != TypeKind.Enum) {
if (i.ResultType == StackType.I4 && input.Type.IsSmallIntegerType() && input.Type.Kind != TypeKind.Enum) {
return input; // we don't need a cast, just let small integers be promoted to int
}
targetType = input.Type.GetSign() == Sign.Unsigned ? KnownTypeCode.UInt32 : KnownTypeCode.Int32;
} else {
targetType = input.Type.GetSign() == Sign.Unsigned ? KnownTypeCode.UInt64 : KnownTypeCode.Int64;
}
return input.ConvertTo(compilation.FindType(targetType), this);
IType targetType = FindArithmeticType(i.ResultType, input.Type.GetSign());
return input.ConvertTo(targetType, this);
}
internal static bool IsUnboxAnyWithIsInst(UnboxAny unboxAny, IsInst isInst)

Loading…
Cancel
Save