-
-
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.
adds support for indexing with ranges (i.e, convert to span and slice) (
#257)
- Loading branch information
1 parent
f3c547a
commit 651c15d
Showing
7 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
Cecilifier.Core.Tests/TestResources/Integration/Misc/InlineArraysRanges.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,53 @@ | ||
.locals init (Buffer`1<System.String> V_0, System.Span`1<System.String> V_1, System.Span`1<System.String> V_2, System.Int32 V_3, System.Int32 V_4) | ||
IL_0000: ldloca.s V_0 | ||
IL_0002: initobj Buffer`1<System.String> | ||
IL_0008: ldloca V_0 | ||
IL_000c: call TElement& <PrivateImplementationDetails>::InlineArrayFirstElementRef<Buffer`1<System.String>,System.String>(TBuffer&) | ||
IL_0011: ldstr "zero" | ||
IL_0016: stind.ref | ||
IL_0017: ldloca V_0 | ||
IL_001b: ldc.i4 1 | ||
IL_0020: call TElement& <PrivateImplementationDetails>::InlineArrayElementRef<Buffer`1<System.String>,System.String>(TBuffer&,System.Int32) | ||
IL_0025: ldstr "um, une, one" | ||
IL_002a: stind.ref | ||
IL_002b: ldloca V_0 | ||
IL_002f: ldc.i4 2 | ||
IL_0034: call TElement& <PrivateImplementationDetails>::InlineArrayElementRef<Buffer`1<System.String>,System.String>(TBuffer&,System.Int32) | ||
IL_0039: ldstr "dois, deux, two" | ||
IL_003e: stind.ref | ||
IL_003f: ldloca V_0 | ||
IL_0043: ldarg.1 | ||
IL_0044: call TElement& <PrivateImplementationDetails>::InlineArrayElementRef<Buffer`1<System.String>,System.String>(TBuffer&,System.Int32) | ||
IL_0049: ldstr "i" | ||
IL_004e: stind.ref | ||
IL_004f: ldloca.s V_0 | ||
IL_0051: ldc.i4 10 | ||
IL_0056: call System.Span`1<TElement> <PrivateImplementationDetails>::InlineArrayAsSpan<Buffer`1<System.String>,System.String>(TBuffer&,System.Int32) | ||
IL_005b: stloc V_2 | ||
IL_005f: ldloca V_2 | ||
IL_0063: ldc.i4 2 | ||
IL_0068: stloc V_3 | ||
IL_006c: ldc.i4 5 | ||
IL_0071: ldloc V_3 | ||
IL_0075: sub | ||
IL_0076: stloc V_4 | ||
IL_007a: ldloc V_3 | ||
IL_007e: ldloc V_4 | ||
IL_0082: call System.Span`1<!0> System.Span`1<System.String>::Slice(System.Int32,System.Int32) | ||
IL_0087: stloc V_1 | ||
IL_008b: ldloca V_1 | ||
IL_008f: ldc.i4 0 | ||
IL_0094: call !0& System.Span`1<System.String>::get_Item(System.Int32) | ||
IL_0099: ldind.ref | ||
IL_009a: call System.Void System.Console::WriteLine(System.String) | ||
IL_009f: ldloca V_1 | ||
IL_00a3: ldc.i4 1 | ||
IL_00a8: call !0& System.Span`1<System.String>::get_Item(System.Int32) | ||
IL_00ad: ldind.ref | ||
IL_00ae: call System.Void System.Console::WriteLine(System.String) | ||
IL_00b3: ldloca V_1 | ||
IL_00b7: ldarg.1 | ||
IL_00b8: call !0& System.Span`1<System.String>::get_Item(System.Int32) | ||
IL_00bd: ldind.ref | ||
IL_00be: call System.Void System.Console::WriteLine(System.String) | ||
IL_00c3: ret |
23 changes: 23 additions & 0 deletions
23
Cecilifier.Core.Tests/TestResources/Integration/Misc/InlineArraysRanges.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,23 @@ | ||
using System; | ||
class InlineArrayRangeTests | ||
{ | ||
void Test(int i) | ||
{ | ||
var buffer = new Buffer<string>(); | ||
buffer[0] = "zero"; | ||
buffer[1] = "um, une, one"; | ||
buffer[2] = "dois, deux, two"; | ||
buffer[i] = "i"; | ||
|
||
var span = buffer[2..5]; | ||
Console.WriteLine(span[0]); | ||
Console.WriteLine(span[1]); | ||
Console.WriteLine(span[i]); | ||
} | ||
} | ||
|
||
[System.Runtime.CompilerServices.InlineArray(10)] | ||
struct Buffer<T> | ||
{ | ||
private T _data; | ||
} |
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