Browse Source

Fix array creation with unsigned integers.

pull/312/merge
Daniel Grunwald 14 years ago
parent
commit
c3b9fd63c1
  1. 4
      ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs
  2. 10
      ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs

4
ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs

@ -96,7 +96,9 @@ namespace ICSharpCode.Decompiler.ILAst
ILExpression length; ILExpression length;
ILExpression input; ILExpression input;
if (expr.Match(ILCode.Newarr, out typeRef, out length)) { if (expr.Match(ILCode.Newarr, out typeRef, out length)) {
if (length.Match(ILCode.Conv_Ovf_I, out input) || length.Match(ILCode.Conv_I, out input)) { if (length.Match(ILCode.Conv_Ovf_I, out input) || length.Match(ILCode.Conv_I, out input)
|| length.Match(ILCode.Conv_Ovf_I_Un, out input) || length.Match(ILCode.Conv_U, out input))
{
expr.Arguments[0] = input; expr.Arguments[0] = input;
return true; return true;
} }

10
ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs

@ -130,4 +130,14 @@ public class TypeAnalysisTests
{ {
return new byte[length]; return new byte[length];
} }
public byte[] CreateArrayWithUInt(uint length)
{
return new byte[length];
}
public byte[] CreateArrayWithULong(ulong length)
{
return new byte[length];
}
} }

Loading…
Cancel
Save