-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes type used to load values from inline arrays (#257)
there are at least 2 (unrelated) cases (marked as TODOs) not supported
- Loading branch information
Showing
9 changed files
with
284 additions
and
4 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Cecilifier.Core.Tests/TestResources/Integration/Misc/InlineArrays.cs.il.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
.locals init (ByteBuffer V_0, InterfaceBuffer V_1, StructBuffer V_2, SomeStruct V_3) | ||
IL_0000: ldloca.s V_0 | ||
IL_0002: initobj ByteBuffer | ||
IL_0008: ldloca V_0 | ||
IL_000c: call TElement& <PrivateImplementationDetails>::InlineArrayFirstElementRef<ByteBuffer,System.Byte>(TBuffer&) | ||
IL_0011: ldc.i4 1 | ||
IL_0016: stind.i1 | ||
IL_0017: ldloca V_0 | ||
IL_001b: ldc.i4 1 | ||
IL_0020: call TElement& <PrivateImplementationDetails>::InlineArrayElementRef<ByteBuffer,System.Byte>(TBuffer&,System.Int32) | ||
IL_0025: ldloca V_0 | ||
IL_0029: call TElement& <PrivateImplementationDetails>::InlineArrayFirstElementRef<ByteBuffer,System.Byte>(TBuffer&) | ||
IL_002e: ldind.u1 | ||
IL_002f: ldc.i4 1 | ||
IL_0034: add | ||
IL_0035: conv.u1 | ||
IL_0036: stind.i1 | ||
IL_0037: ldloca V_0 | ||
IL_003b: ldc.i4 1 | ||
IL_0040: call TElement& <PrivateImplementationDetails>::InlineArrayElementRef<ByteBuffer,System.Byte>(TBuffer&,System.Int32) | ||
IL_0045: ldind.u1 | ||
IL_0046: call System.Void System.Console::WriteLine(System.Int32) | ||
IL_004b: ldloca.s V_1 | ||
IL_004d: initobj InterfaceBuffer | ||
IL_0053: ldloca V_1 | ||
IL_0057: call TElement& <PrivateImplementationDetails>::InlineArrayFirstElementRef<InterfaceBuffer,System.IComparable>(TBuffer&) | ||
IL_005c: ldc.i4 1 | ||
IL_0061: box System.Int32 | ||
IL_0066: stind.ref | ||
IL_0067: ldloca.s V_2 | ||
IL_0069: initobj StructBuffer | ||
IL_006f: ldloca V_2 | ||
IL_0073: call TElement& <PrivateImplementationDetails>::InlineArrayFirstElementRef<StructBuffer,SomeStruct>(TBuffer&) | ||
IL_0078: ldloca.s V_3 | ||
IL_007a: initobj SomeStruct | ||
IL_0080: ldloca.s V_3 | ||
IL_0082: dup | ||
IL_0083: ldc.i4 42 | ||
IL_0088: stfld System.Int32 SomeStruct::Value | ||
IL_008d: pop | ||
IL_008e: ldloc V_3 | ||
IL_0092: stobj SomeStruct | ||
IL_0097: ldloca V_2 | ||
IL_009b: call TElement& <PrivateImplementationDetails>::InlineArrayFirstElementRef<StructBuffer,SomeStruct>(TBuffer&) | ||
IL_00a0: ldfld System.Int32 SomeStruct::Value | ||
IL_00a5: call System.Void System.Console::WriteLine(System.Int32) | ||
IL_00aa: ret |
42 changes: 42 additions & 0 deletions
42
Cecilifier.Core.Tests/TestResources/Integration/Misc/InlineArrays.cs.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
class InlineArrayTests | ||
{ | ||
void Test() | ||
{ | ||
var byteBuffer = new ByteBuffer(); | ||
byteBuffer[0] = 1; | ||
byteBuffer[1] = (byte) (byteBuffer[0] + 1); | ||
Console.WriteLine(byteBuffer[1]); | ||
|
||
var interfaceBuffer = new InterfaceBuffer(); | ||
interfaceBuffer[0] = 1; | ||
|
||
var StructBuffer = new StructBuffer(); | ||
StructBuffer[0] = new SomeStruct { Value = 42 }; | ||
Console.WriteLine(StructBuffer[0].Value); | ||
} | ||
} | ||
[InlineArray(2)] | ||
struct ByteBuffer | ||
{ | ||
private byte _data; | ||
} | ||
|
||
[InlineArray(2)] | ||
struct InterfaceBuffer | ||
{ | ||
private IComparable _data; | ||
} | ||
|
||
struct SomeStruct | ||
{ | ||
public int Value; | ||
} | ||
|
||
[InlineArray(2)] | ||
struct StructBuffer | ||
{ | ||
private SomeStruct _data; | ||
} |
13 changes: 13 additions & 0 deletions
13
Cecilifier.Core.Tests/Tests/Integration/Miscelaneous/InlineArraysTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Cecilifier.Core.Tests.Framework; | ||
using NUnit.Framework; | ||
|
||
namespace Cecilifier.Core.Tests.Integration; | ||
|
||
public class InlineArraysTests : ResourceTestBase | ||
{ | ||
[Test] | ||
public void TestInlineArrays() | ||
{ | ||
AssertResourceTestWithExplicitExpectation("Misc/InlineArrays", "System.Void InlineArrayTests::Test()"); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters