提交 343ada1b 编写于 作者: A Andy Gocke

Re-baseline some emit tests

The frame creation pass now considers scope of captured variable
introduction instead of closure creation, so the ordering can change if
two or more nested functions access variables 'outside-in', e.g.

```csharp
{
    int x = 0;
    {
        int y = 0;
        int L1() => y;

        {
             int z = 0;
             int L2() => x;
        }
    }
}
```

If we visit closures in-order in the previous example, we create frames
for L1, then L2. If we visit captured variables scopes, however, we
visit `x` (captured by L2), then `y` (captued by L1).
上级 012c7fe9
......@@ -1015,17 +1015,17 @@ static void Main()
{
// Code size 131 (0x83)
.maxstack 3
.locals init (Program.<>c__DisplayClass1_2<T> V_0, //CS$<>8__locals0
Program.<>c__DisplayClass1_1<T> V_1, //CS$<>8__locals1
.locals init (Program.<>c__DisplayClass1_1<T> V_0, //CS$<>8__locals0
Program.<>c__DisplayClass1_2<T> V_1, //CS$<>8__locals1
T V_2)
IL_0000: newobj ""Program.<>c__DisplayClass1_2<T>..ctor()""
IL_0000: newobj ""Program.<>c__DisplayClass1_1<T>..ctor()""
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldarg.0
IL_0008: stfld ""Program.<>c__DisplayClass1_0<T> Program.<>c__DisplayClass1_2<T>.CS$<>8__locals1""
IL_0008: stfld ""Program.<>c__DisplayClass1_0<T> Program.<>c__DisplayClass1_1<T>.CS$<>8__locals1""
IL_000d: ldloc.0
IL_000e: ldstr ""y""
IL_0013: stfld ""string Program.<>c__DisplayClass1_2<T>.y""
IL_0013: stfld ""string Program.<>c__DisplayClass1_1<T>.y""
.try
{
IL_0018: ldstr ""xy""
......@@ -1041,17 +1041,17 @@ .maxstack 3
IL_002c: ldc.i4.0
IL_002d: br.s IL_005d
IL_002f: unbox.any ""T""
IL_0034: newobj ""Program.<>c__DisplayClass1_1<T>..ctor()""
IL_0034: newobj ""Program.<>c__DisplayClass1_2<T>..ctor()""
IL_0039: stloc.1
IL_003a: ldloc.1
IL_003b: ldloc.0
IL_003c: stfld ""Program.<>c__DisplayClass1_2<T> Program.<>c__DisplayClass1_1<T>.CS$<>8__locals2""
IL_003c: stfld ""Program.<>c__DisplayClass1_1<T> Program.<>c__DisplayClass1_2<T>.CS$<>8__locals2""
IL_0041: stloc.2
IL_0042: ldloc.1
IL_0043: ldloc.2
IL_0044: stfld ""T Program.<>c__DisplayClass1_1<T>.e""
IL_0044: stfld ""T Program.<>c__DisplayClass1_2<T>.e""
IL_0049: ldloc.1
IL_004a: ldftn ""bool Program.<>c__DisplayClass1_1<T>.<F>b__1()""
IL_004a: ldftn ""bool Program.<>c__DisplayClass1_2<T>.<F>b__1()""
IL_0050: newobj ""System.Func<bool>..ctor(object, System.IntPtr)""
IL_0055: callvirt ""bool System.Func<bool>.Invoke()""
IL_005a: ldc.i4.0
......@@ -1064,8 +1064,8 @@ .maxstack 3
IL_0065: ldarg.0
IL_0066: ldfld ""string Program.<>c__DisplayClass1_0<T>.x""
IL_006b: ldloc.1
IL_006c: ldfld ""Program.<>c__DisplayClass1_2<T> Program.<>c__DisplayClass1_1<T>.CS$<>8__locals2""
IL_0071: ldfld ""string Program.<>c__DisplayClass1_2<T>.y""
IL_006c: ldfld ""Program.<>c__DisplayClass1_1<T> Program.<>c__DisplayClass1_2<T>.CS$<>8__locals2""
IL_0071: ldfld ""string Program.<>c__DisplayClass1_1<T>.y""
IL_0076: call ""string string.Concat(string, string, string)""
IL_007b: call ""void System.Console.Write(string)""
IL_0080: leave.s IL_0082
......@@ -3646,12 +3646,12 @@ private bool T()
{
// Code size 89 (0x59)
.maxstack 2
.locals init (Program.c1.<>c__DisplayClass1_1 V_0) //CS$<>8__locals0
IL_0000: newobj ""Program.c1.<>c__DisplayClass1_1..ctor()""
.locals init (Program.c1.<>c__DisplayClass1_0 V_0) //CS$<>8__locals0
IL_0000: newobj ""Program.c1.<>c__DisplayClass1_0..ctor()""
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldarg.0
IL_0008: stfld ""Program.c1 Program.c1.<>c__DisplayClass1_1.<>4__this""
IL_0008: stfld ""Program.c1 Program.c1.<>c__DisplayClass1_0.<>4__this""
IL_000d: ldarg.0
IL_000e: call ""bool Program.c1.T()""
IL_0013: brfalse.s IL_002e
......@@ -3664,12 +3664,12 @@ .maxstack 2
IL_002d: ret
IL_002e: ldloc.0
IL_002f: ldc.i4.s 42
IL_0031: stfld ""int Program.c1.<>c__DisplayClass1_1.aaa""
IL_0031: stfld ""int Program.c1.<>c__DisplayClass1_0.aaa""
IL_0036: ldarg.0
IL_0037: call ""bool Program.c1.T()""
IL_003c: brfalse.s IL_0057
IL_003e: ldloc.0
IL_003f: ldftn ""bool Program.c1.<>c__DisplayClass1_1.<Test>b__2(int)""
IL_003f: ldftn ""bool Program.c1.<>c__DisplayClass1_0.<Test>b__2(int)""
IL_0045: newobj ""System.Func<int, bool>..ctor(object, System.IntPtr)""
IL_004a: ldc.i4.s 42
IL_004c: callvirt ""bool System.Func<int, bool>.Invoke(int)""
......
......@@ -76,6 +76,28 @@ void L5()
}", expectedOutput:
@"0
1");
verifier.VerifyIL("C.M()", @"
{
// Code size 46 (0x2e)
.maxstack 2
.locals init (C.<>c__DisplayClass2_0 V_0) //CS$<>8__locals0
IL_0000: ldloca.s V_0
IL_0002: ldarg.0
IL_0003: stfld ""C C.<>c__DisplayClass2_0.<>4__this""
IL_0008: ldloca.s V_0
IL_000a: ldc.i4.0
IL_000b: stfld ""int C.<>c__DisplayClass2_0.var1""
IL_0010: ldarg.0
IL_0011: ldfld ""int C._x""
IL_0016: call ""void System.Console.WriteLine(int)""
IL_001b: ldloca.s V_0
IL_001d: call ""void C.<M>g__L12_0(ref C.<>c__DisplayClass2_0)""
IL_0022: ldarg.0
IL_0023: ldfld ""int C._x""
IL_0028: call ""void System.Console.WriteLine(int)""
IL_002d: ret
}");
// L1
verifier.VerifyIL("C.<M>g__L12_0(ref C.<>c__DisplayClass2_0)", @"
{
......
......@@ -271,8 +271,8 @@ int F(int a)
// no new synthesized members generated (with #1 in names):
diff1.VerifySynthesizedMembers(
"C: {<>c__DisplayClass0_0}",
"C.<>c__DisplayClass0_0: {a, <>4__this, <F>b__0}");
"C.<>c__DisplayClass0_0: {<>4__this, a, <F>b__0}",
"C: {<>c__DisplayClass0_0}");
var md1 = diff1.GetMetadata();
var reader1 = md1.Reader;
......
......@@ -1128,11 +1128,11 @@ void F()
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>1</methodOrdinal>
<closure offset=""102"" />
<closure offset=""41"" />
<lambda offset=""149"" closure=""0"" />
<lambda offset=""73"" closure=""1"" />
<lambda offset=""87"" closure=""1"" />
<closure offset=""102"" />
<lambda offset=""149"" closure=""1"" />
<lambda offset=""73"" closure=""0"" />
<lambda offset=""87"" closure=""0"" />
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
......
......@@ -2948,12 +2948,12 @@ class Student : Person { public double GPA; }
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>2</methodOrdinal>
<closure offset=""383"" />
<closure offset=""0"" />
<lambda offset=""109"" closure=""0"" />
<lambda offset=""202"" closure=""0"" />
<lambda offset=""295"" closure=""0"" />
<lambda offset=""383"" closure=""1"" />
<closure offset=""383"" />
<lambda offset=""109"" closure=""1"" />
<lambda offset=""202"" closure=""1"" />
<lambda offset=""295"" closure=""1"" />
<lambda offset=""383"" closure=""0"" />
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册