Browse Source

force int/long cast on array access

pull/728/head
Siegfried Pammer 9 years ago
parent
commit
55b89bdd77
  1. 8
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

8
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -766,12 +766,18 @@ namespace ICSharpCode.Decompiler.CSharp @@ -766,12 +766,18 @@ namespace ICSharpCode.Decompiler.CSharp
arrayType = new ArrayType(compilation, inst.Type, inst.Indices.Count);
arrayExpr = arrayExpr.ConvertTo(arrayType, this);
}
TranslatedExpression expr = new IndexerExpression(arrayExpr, inst.Indices.Select(i => Translate(i).Expression))
TranslatedExpression expr = new IndexerExpression(arrayExpr, inst.Indices.Select(TranslateArrayIndex))
.WithILInstruction(inst).WithRR(new ResolveResult(arrayType.ElementType));
return new DirectionExpression(FieldDirection.Ref, expr)
.WithoutILInstruction().WithRR(new ResolveResult(new ByReferenceType(expr.Type)));
}
Expression TranslateArrayIndex(ILInstruction i)
{
var stackType = i.ResultType == StackType.I4 ? KnownTypeCode.Int32 : KnownTypeCode.Int64;
return Translate(i).ConvertTo(compilation.FindType(stackType), this).Expression;
}
protected internal override TranslatedExpression VisitUnboxAny(UnboxAny inst)
{
var arg = Translate(inst.Argument);

Loading…
Cancel
Save