Browse Source

Merge pull request #1855 from yyjdelete/issue1854

Fix #1854
pull/1857/head
Siegfried Pammer 6 years ago committed by GitHub
parent
commit
0d895e0ca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs
  2. 2
      ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs
  3. 2
      ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

22
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs

@ -379,11 +379,33 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return UseSpan(span); return UseSpan(span);
} }
public string GetSpan3()
{
Span<decimal> span = stackalloc decimal[GetSize()];
return UseSpan(span);
}
public string GetSpan4()
{
Span<decimal> span = stackalloc decimal[4] {
1m,
2m,
3m,
4m
};
return UseSpan(span);
}
public string UseSpan(Span<int> span) public string UseSpan(Span<int> span)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public string UseSpan(Span<decimal> span)
{
throw new NotImplementedException();
}
public int GetSize() public int GetSize()
{ {
throw new NotImplementedException(); throw new NotImplementedException();

2
ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs

@ -77,6 +77,8 @@ namespace ICSharpCode.Decompiler.IL
case KnownTypeCode.UInt64: case KnownTypeCode.UInt64:
case KnownTypeCode.Double: case KnownTypeCode.Double:
return 8; return 8;
case KnownTypeCode.Decimal:
return 16;
} }
return null; return null;
} }

2
ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

@ -405,7 +405,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
var pointerType = new PointerType(elementType); var pointerType = new PointerType(elementType);
var elementCountInstr = PointerArithmeticOffset.Detect(sizeInBytesInstr, pointerType.ElementType, checkForOverflow: true, unwrapZeroExtension: true); var elementCountInstr = PointerArithmeticOffset.Detect(sizeInBytesInstr, pointerType.ElementType, checkForOverflow: true, unwrapZeroExtension: true);
if (!elementCountInstr.Match(elementCountInstr2).Success) if (elementCountInstr == null || !elementCountInstr.Match(elementCountInstr2).Success)
return false; return false;
return true; return true;
} }

Loading…
Cancel
Save