Browse Source

Add Switch pretty tests

pull/887/head
Siegfried Pammer 8 years ago
parent
commit
2145543ada
  1. 1
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 6
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  3. 226
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs
  4. 694
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il
  5. 558
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il
  6. 700
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il
  7. 890
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il

1
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -100,6 +100,7 @@ @@ -100,6 +100,7 @@
<Compile Include="TestCases\Pretty\PropertiesAndEvents.cs" />
<Compile Include="TestCases\Pretty\QueryExpressions.cs" />
<Compile Include="TestCases\Pretty\ShortCircuit.cs" />
<Compile Include="TestCases\Pretty\Switch.cs" />
<Compile Include="TestCases\Pretty\TypeAnalysisTests.cs" />
<Compile Include="TestCases\Pretty\Using.cs" />
<Compile Include="TestTraceListener.cs" />

6
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -97,6 +97,12 @@ namespace ICSharpCode.Decompiler.Tests @@ -97,6 +97,12 @@ namespace ICSharpCode.Decompiler.Tests
Run(cscOptions: cscOptions);
}
[Test]
public void Switch([ValueSource("defaultOptions")] CompilerOptions cscOptions)
{
Run(cscOptions: cscOptions);
}
[Test]
public void AnonymousTypes([Values(CompilerOptions.None, CompilerOptions.Optimize)] CompilerOptions cscOptions)
{

226
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs

@ -0,0 +1,226 @@ @@ -0,0 +1,226 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
public static class Switch
{
public static string SparseIntegerSwitch(int i)
{
Console.WriteLine("SparseIntegerSwitch: " + i);
switch (i) {
case -10000000: {
return "-10 mln";
}
case -100: {
return "-hundred";
}
case -1: {
return "-1";
}
case 0: {
return "0";
}
case 1: {
return "1";
}
case 2: {
return "2";
}
case 4: {
return "4";
}
case 100: {
return "hundred";
}
case 10000: {
return "ten thousand";
}
case 10001: {
return "ten thousand and one";
}
case int.MaxValue: {
return "int.MaxValue";
}
default: {
return "something else";
}
}
}
public static string ShortSwitchOverString(string text)
{
Console.WriteLine("ShortSwitchOverString: " + text);
switch (text) {
case "First case": {
return "Text1";
}
case "Second case": {
return "Text2";
}
case "Third case": {
return "Text3";
}
default: {
return "Default";
}
}
}
public static string SwitchOverString1(string text)
{
Console.WriteLine("SwitchOverString1: " + text);
switch (text) {
case "First case": {
return "Text1";
}
case "Second case":
case "2nd case": {
return "Text2";
}
case "Third case": {
return "Text3";
}
case "Fourth case": {
return "Text4";
}
case "Fifth case": {
return "Text5";
}
case "Sixth case": {
return "Text6";
}
case null: {
return null;
}
default: {
return "Default";
}
}
}
public static string SwitchOverString2()
{
Console.WriteLine("SwitchOverString2:");
switch (Environment.UserName) {
case "First case": {
return "Text1";
}
case "Second case": {
return "Text2";
}
case "Third case": {
return "Text3";
}
case "Fourth case": {
return "Text4";
}
case "Fifth case": {
return "Text5";
}
case "Sixth case": {
return "Text6";
}
case "Seventh case": {
return "Text7";
}
case "Eighth case": {
return "Text8";
}
case "Ninth case": {
return "Text9";
}
case "Tenth case": {
return "Text10";
}
case "Eleventh case": {
return "Text11";
}
default: {
return "Default";
}
}
}
public static string SwitchOverBool(bool b)
{
Console.WriteLine("SwitchOverBool: " + b.ToString());
switch (b) {
case true: {
return bool.TrueString;
}
case false: {
return bool.FalseString;
}
default: {
return null;
}
}
}
public static void SwitchInLoop(int i)
{
Console.WriteLine("SwitchInLoop: " + i);
while (true) {
switch (i) {
case 1:
Console.WriteLine("one");
break;
case 2:
Console.WriteLine("two");
break;
case 3:
Console.WriteLine("three");
continue;
case 4:
Console.WriteLine("four");
return;
default:
Console.WriteLine("default");
Console.WriteLine("more code");
return;
}
i++;
}
}
public static void SwitchWithGoto(int i)
{
Console.WriteLine("SwitchWithGoto: " + i);
switch (i) {
case 1:
Console.WriteLine("one");
goto default;
case 2:
Console.WriteLine("two");
goto case 3;
case 3:
Console.WriteLine("three");
break;
case 4:
Console.WriteLine("four");
return;
default:
Console.WriteLine("default");
break;
}
}
}
}

694
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il

@ -0,0 +1,694 @@ @@ -0,0 +1,694 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly wau4yvxd
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module wau4yvxd.dll
// MVID: {102ACC94-685A-42C5-9229-AC386C0A78B1}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x01440000
// =============== CLASS MEMBERS DECLARATION ===================
.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
extends [mscorlib]System.Object
{
.method public hidebysig static string
SparseIntegerSwitch(int32 i) cil managed
{
// Code size 224 (0xe0)
.maxstack 2
.locals init (string V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldstr "SparseIntegerSwitch: "
IL_0006: ldarg.0
IL_0007: box [mscorlib]System.Int32
IL_000c: call string [mscorlib]System.String::Concat(object,
object)
IL_0011: call void [mscorlib]System.Console::WriteLine(string)
IL_0016: nop
IL_0017: ldarg.0
IL_0018: stloc.1
IL_0019: ldloc.1
IL_001a: ldc.i4.4
IL_001b: bgt.s IL_004f
IL_001d: ldloc.1
IL_001e: ldc.i4 0xff676980
IL_0023: beq.s IL_0072
IL_0025: ldloc.1
IL_0026: ldc.i4.s -100
IL_0028: beq.s IL_007b
IL_002a: ldloc.1
IL_002b: ldc.i4.m1
IL_002c: sub
IL_002d: switch (
IL_0084,
IL_008d,
IL_0096,
IL_009f,
IL_00d5,
IL_00a8)
IL_004a: br IL_00d5
IL_004f: ldloc.1
IL_0050: ldc.i4.s 100
IL_0052: beq.s IL_00b1
IL_0054: ldloc.1
IL_0055: ldc.i4 0x2710
IL_005a: sub
IL_005b: switch (
IL_00ba,
IL_00c3)
IL_0068: ldloc.1
IL_0069: ldc.i4 0x7fffffff
IL_006e: beq.s IL_00cc
IL_0070: br.s IL_00d5
IL_0072: nop
IL_0073: ldstr "-10 mln"
IL_0078: stloc.0
IL_0079: br.s IL_00de
IL_007b: nop
IL_007c: ldstr "-hundred"
IL_0081: stloc.0
IL_0082: br.s IL_00de
IL_0084: nop
IL_0085: ldstr "-1"
IL_008a: stloc.0
IL_008b: br.s IL_00de
IL_008d: nop
IL_008e: ldstr "0"
IL_0093: stloc.0
IL_0094: br.s IL_00de
IL_0096: nop
IL_0097: ldstr "1"
IL_009c: stloc.0
IL_009d: br.s IL_00de
IL_009f: nop
IL_00a0: ldstr "2"
IL_00a5: stloc.0
IL_00a6: br.s IL_00de
IL_00a8: nop
IL_00a9: ldstr "4"
IL_00ae: stloc.0
IL_00af: br.s IL_00de
IL_00b1: nop
IL_00b2: ldstr "hundred"
IL_00b7: stloc.0
IL_00b8: br.s IL_00de
IL_00ba: nop
IL_00bb: ldstr "ten thousand"
IL_00c0: stloc.0
IL_00c1: br.s IL_00de
IL_00c3: nop
IL_00c4: ldstr "ten thousand and one"
IL_00c9: stloc.0
IL_00ca: br.s IL_00de
IL_00cc: nop
IL_00cd: ldstr "int.MaxValue"
IL_00d2: stloc.0
IL_00d3: br.s IL_00de
IL_00d5: nop
IL_00d6: ldstr "something else"
IL_00db: stloc.0
IL_00dc: br.s IL_00de
IL_00de: ldloc.0
IL_00df: ret
} // end of method Switch::SparseIntegerSwitch
.method public hidebysig static string
ShortSwitchOverString(string text) cil managed
{
// Code size 102 (0x66)
.maxstack 2
.locals init (string V_0,
string V_1)
IL_0000: nop
IL_0001: ldstr "ShortSwitchOverString: "
IL_0006: ldarg.0
IL_0007: call string [mscorlib]System.String::Concat(string,
string)
IL_000c: call void [mscorlib]System.Console::WriteLine(string)
IL_0011: nop
IL_0012: ldarg.0
IL_0013: stloc.1
IL_0014: ldloc.1
IL_0015: brfalse.s IL_005b
IL_0017: ldloc.1
IL_0018: ldstr "First case"
IL_001d: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0022: brtrue.s IL_0040
IL_0024: ldloc.1
IL_0025: ldstr "Second case"
IL_002a: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_002f: brtrue.s IL_0049
IL_0031: ldloc.1
IL_0032: ldstr "Third case"
IL_0037: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_003c: brtrue.s IL_0052
IL_003e: br.s IL_005b
IL_0040: nop
IL_0041: ldstr "Text1"
IL_0046: stloc.0
IL_0047: br.s IL_0064
IL_0049: nop
IL_004a: ldstr "Text2"
IL_004f: stloc.0
IL_0050: br.s IL_0064
IL_0052: nop
IL_0053: ldstr "Text3"
IL_0058: stloc.0
IL_0059: br.s IL_0064
IL_005b: nop
IL_005c: ldstr "Default"
IL_0061: stloc.0
IL_0062: br.s IL_0064
IL_0064: ldloc.0
IL_0065: ret
} // end of method Switch::ShortSwitchOverString
.method public hidebysig static string
SwitchOverString1(string text) cil managed
{
// Code size 255 (0xff)
.maxstack 4
.locals init (string V_0,
string V_1,
int32 V_2)
IL_0000: nop
IL_0001: ldstr "SwitchOverString1: "
IL_0006: ldarg.0
IL_0007: call string [mscorlib]System.String::Concat(string,
string)
IL_000c: call void [mscorlib]System.Console::WriteLine(string)
IL_0011: nop
IL_0012: ldarg.0
IL_0013: stloc.1
IL_0014: ldloc.1
IL_0015: brfalse IL_00ef
IL_001a: volatile.
IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{102ACC94-685A-42C5-9229-AC386C0A78B1}'::'$$method0x6000003-1'
IL_0021: brtrue.s IL_0084
IL_0023: ldc.i4.7
IL_0024: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::.ctor(int32)
IL_0029: dup
IL_002a: ldstr "First case"
IL_002f: ldc.i4.0
IL_0030: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0035: dup
IL_0036: ldstr "Second case"
IL_003b: ldc.i4.1
IL_003c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0041: dup
IL_0042: ldstr "2nd case"
IL_0047: ldc.i4.2
IL_0048: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_004d: dup
IL_004e: ldstr "Third case"
IL_0053: ldc.i4.3
IL_0054: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0059: dup
IL_005a: ldstr "Fourth case"
IL_005f: ldc.i4.4
IL_0060: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0065: dup
IL_0066: ldstr "Fifth case"
IL_006b: ldc.i4.5
IL_006c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0071: dup
IL_0072: ldstr "Sixth case"
IL_0077: ldc.i4.6
IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_007d: volatile.
IL_007f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{102ACC94-685A-42C5-9229-AC386C0A78B1}'::'$$method0x6000003-1'
IL_0084: volatile.
IL_0086: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{102ACC94-685A-42C5-9229-AC386C0A78B1}'::'$$method0x6000003-1'
IL_008b: ldloc.1
IL_008c: ldloca.s V_2
IL_008e: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
!1&)
IL_0093: brfalse.s IL_00f4
IL_0095: ldloc.2
IL_0096: switch (
IL_00b9,
IL_00c2,
IL_00c2,
IL_00cb,
IL_00d4,
IL_00dd,
IL_00e6)
IL_00b7: br.s IL_00f4
IL_00b9: nop
IL_00ba: ldstr "Text1"
IL_00bf: stloc.0
IL_00c0: br.s IL_00fd
IL_00c2: nop
IL_00c3: ldstr "Text2"
IL_00c8: stloc.0
IL_00c9: br.s IL_00fd
IL_00cb: nop
IL_00cc: ldstr "Text3"
IL_00d1: stloc.0
IL_00d2: br.s IL_00fd
IL_00d4: nop
IL_00d5: ldstr "Text4"
IL_00da: stloc.0
IL_00db: br.s IL_00fd
IL_00dd: nop
IL_00de: ldstr "Text5"
IL_00e3: stloc.0
IL_00e4: br.s IL_00fd
IL_00e6: nop
IL_00e7: ldstr "Text6"
IL_00ec: stloc.0
IL_00ed: br.s IL_00fd
IL_00ef: nop
IL_00f0: ldnull
IL_00f1: stloc.0
IL_00f2: br.s IL_00fd
IL_00f4: nop
IL_00f5: ldstr "Default"
IL_00fa: stloc.0
IL_00fb: br.s IL_00fd
IL_00fd: ldloc.0
IL_00fe: ret
} // end of method Switch::SwitchOverString1
.method public hidebysig static string
SwitchOverString2() cil managed
{
// Code size 366 (0x16e)
.maxstack 4
.locals init (string V_0,
string V_1,
int32 V_2)
IL_0000: nop
IL_0001: ldstr "SwitchOverString2:"
IL_0006: call void [mscorlib]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: call string [mscorlib]System.Environment::get_UserName()
IL_0011: stloc.1
IL_0012: ldloc.1
IL_0013: brfalse IL_0163
IL_0018: volatile.
IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{102ACC94-685A-42C5-9229-AC386C0A78B1}'::'$$method0x6000004-1'
IL_001f: brtrue IL_00b8
IL_0024: ldc.i4.s 11
IL_0026: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::.ctor(int32)
IL_002b: dup
IL_002c: ldstr "First case"
IL_0031: ldc.i4.0
IL_0032: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0037: dup
IL_0038: ldstr "Second case"
IL_003d: ldc.i4.1
IL_003e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0043: dup
IL_0044: ldstr "Third case"
IL_0049: ldc.i4.2
IL_004a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_004f: dup
IL_0050: ldstr "Fourth case"
IL_0055: ldc.i4.3
IL_0056: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_005b: dup
IL_005c: ldstr "Fifth case"
IL_0061: ldc.i4.4
IL_0062: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0067: dup
IL_0068: ldstr "Sixth case"
IL_006d: ldc.i4.5
IL_006e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0073: dup
IL_0074: ldstr "Seventh case"
IL_0079: ldc.i4.6
IL_007a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_007f: dup
IL_0080: ldstr "Eighth case"
IL_0085: ldc.i4.7
IL_0086: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_008b: dup
IL_008c: ldstr "Ninth case"
IL_0091: ldc.i4.8
IL_0092: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0097: dup
IL_0098: ldstr "Tenth case"
IL_009d: ldc.i4.s 9
IL_009f: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_00a4: dup
IL_00a5: ldstr "Eleventh case"
IL_00aa: ldc.i4.s 10
IL_00ac: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_00b1: volatile.
IL_00b3: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{102ACC94-685A-42C5-9229-AC386C0A78B1}'::'$$method0x6000004-1'
IL_00b8: volatile.
IL_00ba: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{102ACC94-685A-42C5-9229-AC386C0A78B1}'::'$$method0x6000004-1'
IL_00bf: ldloc.1
IL_00c0: ldloca.s V_2
IL_00c2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
!1&)
IL_00c7: brfalse IL_0163
IL_00cc: ldloc.2
IL_00cd: switch (
IL_0100,
IL_0109,
IL_0112,
IL_011b,
IL_0124,
IL_012d,
IL_0136,
IL_013f,
IL_0148,
IL_0151,
IL_015a)
IL_00fe: br.s IL_0163
IL_0100: nop
IL_0101: ldstr "Text1"
IL_0106: stloc.0
IL_0107: br.s IL_016c
IL_0109: nop
IL_010a: ldstr "Text2"
IL_010f: stloc.0
IL_0110: br.s IL_016c
IL_0112: nop
IL_0113: ldstr "Text3"
IL_0118: stloc.0
IL_0119: br.s IL_016c
IL_011b: nop
IL_011c: ldstr "Text4"
IL_0121: stloc.0
IL_0122: br.s IL_016c
IL_0124: nop
IL_0125: ldstr "Text5"
IL_012a: stloc.0
IL_012b: br.s IL_016c
IL_012d: nop
IL_012e: ldstr "Text6"
IL_0133: stloc.0
IL_0134: br.s IL_016c
IL_0136: nop
IL_0137: ldstr "Text7"
IL_013c: stloc.0
IL_013d: br.s IL_016c
IL_013f: nop
IL_0140: ldstr "Text8"
IL_0145: stloc.0
IL_0146: br.s IL_016c
IL_0148: nop
IL_0149: ldstr "Text9"
IL_014e: stloc.0
IL_014f: br.s IL_016c
IL_0151: nop
IL_0152: ldstr "Text10"
IL_0157: stloc.0
IL_0158: br.s IL_016c
IL_015a: nop
IL_015b: ldstr "Text11"
IL_0160: stloc.0
IL_0161: br.s IL_016c
IL_0163: nop
IL_0164: ldstr "Default"
IL_0169: stloc.0
IL_016a: br.s IL_016c
IL_016c: ldloc.0
IL_016d: ret
} // end of method Switch::SwitchOverString2
.method public hidebysig static string
SwitchOverBool(bool b) cil managed
{
// Code size 67 (0x43)
.maxstack 2
.locals init (string V_0,
bool V_1)
IL_0000: nop
IL_0001: ldstr "SwitchOverBool: "
IL_0006: ldarga.s b
IL_0008: call instance string [mscorlib]System.Boolean::ToString()
IL_000d: call string [mscorlib]System.String::Concat(string,
string)
IL_0012: call void [mscorlib]System.Console::WriteLine(string)
IL_0017: nop
IL_0018: ldarg.0
IL_0019: stloc.1
IL_001a: ldloc.1
IL_001b: switch (
IL_0033,
IL_002a)
IL_0028: br.s IL_003c
IL_002a: nop
IL_002b: ldsfld string [mscorlib]System.Boolean::TrueString
IL_0030: stloc.0
IL_0031: br.s IL_0041
IL_0033: nop
IL_0034: ldsfld string [mscorlib]System.Boolean::FalseString
IL_0039: stloc.0
IL_003a: br.s IL_0041
IL_003c: nop
IL_003d: ldnull
IL_003e: stloc.0
IL_003f: br.s IL_0041
IL_0041: ldloc.0
IL_0042: ret
} // end of method Switch::SwitchOverBool
.method public hidebysig static void SwitchInLoop(int32 i) cil managed
{
// Code size 141 (0x8d)
.maxstack 2
.locals init (int32 V_0,
bool V_1)
IL_0000: nop
IL_0001: ldstr "SwitchInLoop: "
IL_0006: ldarg.0
IL_0007: box [mscorlib]System.Int32
IL_000c: call string [mscorlib]System.String::Concat(object,
object)
IL_0011: call void [mscorlib]System.Console::WriteLine(string)
IL_0016: nop
IL_0017: br.s IL_0088
IL_0019: nop
IL_001a: ldarg.0
IL_001b: stloc.0
IL_001c: ldloc.0
IL_001d: ldc.i4.1
IL_001e: sub
IL_001f: switch (
IL_0036,
IL_0043,
IL_0050,
IL_005d)
IL_0034: br.s IL_006a
IL_0036: ldstr "one"
IL_003b: call void [mscorlib]System.Console::WriteLine(string)
IL_0040: nop
IL_0041: br.s IL_0082
IL_0043: ldstr "two"
IL_0048: call void [mscorlib]System.Console::WriteLine(string)
IL_004d: nop
IL_004e: br.s IL_0082
IL_0050: ldstr "three"
IL_0055: call void [mscorlib]System.Console::WriteLine(string)
IL_005a: nop
IL_005b: br.s IL_0088
IL_005d: ldstr "four"
IL_0062: call void [mscorlib]System.Console::WriteLine(string)
IL_0067: nop
IL_0068: br.s IL_008c
IL_006a: ldstr "default"
IL_006f: call void [mscorlib]System.Console::WriteLine(string)
IL_0074: nop
IL_0075: ldstr "more code"
IL_007a: call void [mscorlib]System.Console::WriteLine(string)
IL_007f: nop
IL_0080: br.s IL_008c
IL_0082: ldarg.0
IL_0083: ldc.i4.1
IL_0084: add
IL_0085: starg.s i
IL_0087: nop
IL_0088: ldc.i4.1
IL_0089: stloc.1
IL_008a: br.s IL_0019
IL_008c: ret
} // end of method Switch::SwitchInLoop
.method public hidebysig static void SwitchWithGoto(int32 i) cil managed
{
// Code size 117 (0x75)
.maxstack 2
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldstr "SwitchWithGoto: "
IL_0006: ldarg.0
IL_0007: box [mscorlib]System.Int32
IL_000c: call string [mscorlib]System.String::Concat(object,
object)
IL_0011: call void [mscorlib]System.Console::WriteLine(string)
IL_0016: nop
IL_0017: ldarg.0
IL_0018: stloc.0
IL_0019: ldloc.0
IL_001a: ldc.i4.1
IL_001b: sub
IL_001c: switch (
IL_0033,
IL_0040,
IL_004d,
IL_005a)
IL_0031: br.s IL_0067
IL_0033: ldstr "one"
IL_0038: call void [mscorlib]System.Console::WriteLine(string)
IL_003d: nop
IL_003e: br.s IL_0067
IL_0040: ldstr "two"
IL_0045: call void [mscorlib]System.Console::WriteLine(string)
IL_004a: nop
IL_004b: br.s IL_004d
IL_004d: ldstr "three"
IL_0052: call void [mscorlib]System.Console::WriteLine(string)
IL_0057: nop
IL_0058: br.s IL_0074
IL_005a: ldstr "four"
IL_005f: call void [mscorlib]System.Console::WriteLine(string)
IL_0064: nop
IL_0065: br.s IL_0074
IL_0067: ldstr "default"
IL_006c: call void [mscorlib]System.Console::WriteLine(string)
IL_0071: nop
IL_0072: br.s IL_0074
IL_0074: ret
} // end of method Switch::SwitchWithGoto
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
.class private auto ansi '<PrivateImplementationDetails>{102ACC94-685A-42C5-9229-AC386C0A78B1}'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000003-1'
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000004-1'
} // end of class '<PrivateImplementationDetails>{102ACC94-685A-42C5-9229-AC386C0A78B1}'
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file ../../../TestCases/Pretty\Switch.res

558
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il

@ -0,0 +1,558 @@ @@ -0,0 +1,558 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly gz2l4xfo
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module gz2l4xfo.dll
// MVID: {FFA858C4-FC28-4EB1-BDB5-C80B304AD168}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x008F0000
// =============== CLASS MEMBERS DECLARATION ===================
.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
extends [mscorlib]System.Object
{
.method public hidebysig static string
SparseIntegerSwitch(int32 i) cil managed
{
// Code size 181 (0xb5)
.maxstack 2
.locals init (int32 V_0)
IL_0000: ldstr "SparseIntegerSwitch: "
IL_0005: ldarg.0
IL_0006: box [mscorlib]System.Int32
IL_000b: call string [mscorlib]System.String::Concat(object,
object)
IL_0010: call void [mscorlib]System.Console::WriteLine(string)
IL_0015: ldarg.0
IL_0016: stloc.0
IL_0017: ldloc.0
IL_0018: ldc.i4.4
IL_0019: bgt.s IL_004a
IL_001b: ldloc.0
IL_001c: ldc.i4 0xff676980
IL_0021: beq.s IL_006d
IL_0023: ldloc.0
IL_0024: ldc.i4.s -100
IL_0026: beq.s IL_0073
IL_0028: ldloc.0
IL_0029: ldc.i4.m1
IL_002a: sub
IL_002b: switch (
IL_0079,
IL_007f,
IL_0085,
IL_008b,
IL_00af,
IL_0091)
IL_0048: br.s IL_00af
IL_004a: ldloc.0
IL_004b: ldc.i4.s 100
IL_004d: beq.s IL_0097
IL_004f: ldloc.0
IL_0050: ldc.i4 0x2710
IL_0055: sub
IL_0056: switch (
IL_009d,
IL_00a3)
IL_0063: ldloc.0
IL_0064: ldc.i4 0x7fffffff
IL_0069: beq.s IL_00a9
IL_006b: br.s IL_00af
IL_006d: ldstr "-10 mln"
IL_0072: ret
IL_0073: ldstr "-hundred"
IL_0078: ret
IL_0079: ldstr "-1"
IL_007e: ret
IL_007f: ldstr "0"
IL_0084: ret
IL_0085: ldstr "1"
IL_008a: ret
IL_008b: ldstr "2"
IL_0090: ret
IL_0091: ldstr "4"
IL_0096: ret
IL_0097: ldstr "hundred"
IL_009c: ret
IL_009d: ldstr "ten thousand"
IL_00a2: ret
IL_00a3: ldstr "ten thousand and one"
IL_00a8: ret
IL_00a9: ldstr "int.MaxValue"
IL_00ae: ret
IL_00af: ldstr "something else"
IL_00b4: ret
} // end of method Switch::SparseIntegerSwitch
.method public hidebysig static string
ShortSwitchOverString(string text) cil managed
{
// Code size 86 (0x56)
.maxstack 2
.locals init (string V_0)
IL_0000: ldstr "ShortSwitchOverString: "
IL_0005: ldarg.0
IL_0006: call string [mscorlib]System.String::Concat(string,
string)
IL_000b: call void [mscorlib]System.Console::WriteLine(string)
IL_0010: ldarg.0
IL_0011: dup
IL_0012: stloc.0
IL_0013: brfalse.s IL_0050
IL_0015: ldloc.0
IL_0016: ldstr "First case"
IL_001b: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0020: brtrue.s IL_003e
IL_0022: ldloc.0
IL_0023: ldstr "Second case"
IL_0028: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_002d: brtrue.s IL_0044
IL_002f: ldloc.0
IL_0030: ldstr "Third case"
IL_0035: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_003a: brtrue.s IL_004a
IL_003c: br.s IL_0050
IL_003e: ldstr "Text1"
IL_0043: ret
IL_0044: ldstr "Text2"
IL_0049: ret
IL_004a: ldstr "Text3"
IL_004f: ret
IL_0050: ldstr "Default"
IL_0055: ret
} // end of method Switch::ShortSwitchOverString
.method public hidebysig static string
SwitchOverString1(string text) cil managed
{
// Code size 227 (0xe3)
.maxstack 4
.locals init (string V_0,
int32 V_1)
IL_0000: ldstr "SwitchOverString1: "
IL_0005: ldarg.0
IL_0006: call string [mscorlib]System.String::Concat(string,
string)
IL_000b: call void [mscorlib]System.Console::WriteLine(string)
IL_0010: ldarg.0
IL_0011: dup
IL_0012: stloc.0
IL_0013: brfalse IL_00db
IL_0018: volatile.
IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{FFA858C4-FC28-4EB1-BDB5-C80B304AD168}'::'$$method0x6000003-1'
IL_001f: brtrue.s IL_0082
IL_0021: ldc.i4.7
IL_0022: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::.ctor(int32)
IL_0027: dup
IL_0028: ldstr "First case"
IL_002d: ldc.i4.0
IL_002e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0033: dup
IL_0034: ldstr "Second case"
IL_0039: ldc.i4.1
IL_003a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_003f: dup
IL_0040: ldstr "2nd case"
IL_0045: ldc.i4.2
IL_0046: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_004b: dup
IL_004c: ldstr "Third case"
IL_0051: ldc.i4.3
IL_0052: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0057: dup
IL_0058: ldstr "Fourth case"
IL_005d: ldc.i4.4
IL_005e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0063: dup
IL_0064: ldstr "Fifth case"
IL_0069: ldc.i4.5
IL_006a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_006f: dup
IL_0070: ldstr "Sixth case"
IL_0075: ldc.i4.6
IL_0076: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_007b: volatile.
IL_007d: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{FFA858C4-FC28-4EB1-BDB5-C80B304AD168}'::'$$method0x6000003-1'
IL_0082: volatile.
IL_0084: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{FFA858C4-FC28-4EB1-BDB5-C80B304AD168}'::'$$method0x6000003-1'
IL_0089: ldloc.0
IL_008a: ldloca.s V_1
IL_008c: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
!1&)
IL_0091: brfalse.s IL_00dd
IL_0093: ldloc.1
IL_0094: switch (
IL_00b7,
IL_00bd,
IL_00bd,
IL_00c3,
IL_00c9,
IL_00cf,
IL_00d5)
IL_00b5: br.s IL_00dd
IL_00b7: ldstr "Text1"
IL_00bc: ret
IL_00bd: ldstr "Text2"
IL_00c2: ret
IL_00c3: ldstr "Text3"
IL_00c8: ret
IL_00c9: ldstr "Text4"
IL_00ce: ret
IL_00cf: ldstr "Text5"
IL_00d4: ret
IL_00d5: ldstr "Text6"
IL_00da: ret
IL_00db: ldnull
IL_00dc: ret
IL_00dd: ldstr "Default"
IL_00e2: ret
} // end of method Switch::SwitchOverString1
.method public hidebysig static string
SwitchOverString2() cil managed
{
// Code size 323 (0x143)
.maxstack 4
.locals init (string V_0,
int32 V_1)
IL_0000: ldstr "SwitchOverString2:"
IL_0005: call void [mscorlib]System.Console::WriteLine(string)
IL_000a: call string [mscorlib]System.Environment::get_UserName()
IL_000f: dup
IL_0010: stloc.0
IL_0011: brfalse IL_013d
IL_0016: volatile.
IL_0018: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{FFA858C4-FC28-4EB1-BDB5-C80B304AD168}'::'$$method0x6000004-1'
IL_001d: brtrue IL_00b6
IL_0022: ldc.i4.s 11
IL_0024: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::.ctor(int32)
IL_0029: dup
IL_002a: ldstr "First case"
IL_002f: ldc.i4.0
IL_0030: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0035: dup
IL_0036: ldstr "Second case"
IL_003b: ldc.i4.1
IL_003c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0041: dup
IL_0042: ldstr "Third case"
IL_0047: ldc.i4.2
IL_0048: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_004d: dup
IL_004e: ldstr "Fourth case"
IL_0053: ldc.i4.3
IL_0054: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0059: dup
IL_005a: ldstr "Fifth case"
IL_005f: ldc.i4.4
IL_0060: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0065: dup
IL_0066: ldstr "Sixth case"
IL_006b: ldc.i4.5
IL_006c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0071: dup
IL_0072: ldstr "Seventh case"
IL_0077: ldc.i4.6
IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_007d: dup
IL_007e: ldstr "Eighth case"
IL_0083: ldc.i4.7
IL_0084: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0089: dup
IL_008a: ldstr "Ninth case"
IL_008f: ldc.i4.8
IL_0090: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_0095: dup
IL_0096: ldstr "Tenth case"
IL_009b: ldc.i4.s 9
IL_009d: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_00a2: dup
IL_00a3: ldstr "Eleventh case"
IL_00a8: ldc.i4.s 10
IL_00aa: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1)
IL_00af: volatile.
IL_00b1: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{FFA858C4-FC28-4EB1-BDB5-C80B304AD168}'::'$$method0x6000004-1'
IL_00b6: volatile.
IL_00b8: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{FFA858C4-FC28-4EB1-BDB5-C80B304AD168}'::'$$method0x6000004-1'
IL_00bd: ldloc.0
IL_00be: ldloca.s V_1
IL_00c0: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
!1&)
IL_00c5: brfalse.s IL_013d
IL_00c7: ldloc.1
IL_00c8: switch (
IL_00fb,
IL_0101,
IL_0107,
IL_010d,
IL_0113,
IL_0119,
IL_011f,
IL_0125,
IL_012b,
IL_0131,
IL_0137)
IL_00f9: br.s IL_013d
IL_00fb: ldstr "Text1"
IL_0100: ret
IL_0101: ldstr "Text2"
IL_0106: ret
IL_0107: ldstr "Text3"
IL_010c: ret
IL_010d: ldstr "Text4"
IL_0112: ret
IL_0113: ldstr "Text5"
IL_0118: ret
IL_0119: ldstr "Text6"
IL_011e: ret
IL_011f: ldstr "Text7"
IL_0124: ret
IL_0125: ldstr "Text8"
IL_012a: ret
IL_012b: ldstr "Text9"
IL_0130: ret
IL_0131: ldstr "Text10"
IL_0136: ret
IL_0137: ldstr "Text11"
IL_013c: ret
IL_013d: ldstr "Default"
IL_0142: ret
} // end of method Switch::SwitchOverString2
.method public hidebysig static string
SwitchOverBool(bool b) cil managed
{
// Code size 54 (0x36)
.maxstack 2
.locals init (bool V_0)
IL_0000: ldstr "SwitchOverBool: "
IL_0005: ldarga.s b
IL_0007: call instance string [mscorlib]System.Boolean::ToString()
IL_000c: call string [mscorlib]System.String::Concat(string,
string)
IL_0011: call void [mscorlib]System.Console::WriteLine(string)
IL_0016: ldarg.0
IL_0017: stloc.0
IL_0018: ldloc.0
IL_0019: switch (
IL_002e,
IL_0028)
IL_0026: br.s IL_0034
IL_0028: ldsfld string [mscorlib]System.Boolean::TrueString
IL_002d: ret
IL_002e: ldsfld string [mscorlib]System.Boolean::FalseString
IL_0033: ret
IL_0034: ldnull
IL_0035: ret
} // end of method Switch::SwitchOverBool
.method public hidebysig static void SwitchInLoop(int32 i) cil managed
{
// Code size 124 (0x7c)
.maxstack 2
.locals init (int32 V_0)
IL_0000: ldstr "SwitchInLoop: "
IL_0005: ldarg.0
IL_0006: box [mscorlib]System.Int32
IL_000b: call string [mscorlib]System.String::Concat(object,
object)
IL_0010: call void [mscorlib]System.Console::WriteLine(string)
IL_0015: ldarg.0
IL_0016: stloc.0
IL_0017: ldloc.0
IL_0018: ldc.i4.1
IL_0019: sub
IL_001a: switch (
IL_0031,
IL_003d,
IL_0049,
IL_0055)
IL_002f: br.s IL_0060
IL_0031: ldstr "one"
IL_0036: call void [mscorlib]System.Console::WriteLine(string)
IL_003b: br.s IL_0075
IL_003d: ldstr "two"
IL_0042: call void [mscorlib]System.Console::WriteLine(string)
IL_0047: br.s IL_0075
IL_0049: ldstr "three"
IL_004e: call void [mscorlib]System.Console::WriteLine(string)
IL_0053: br.s IL_0015
IL_0055: ldstr "four"
IL_005a: call void [mscorlib]System.Console::WriteLine(string)
IL_005f: ret
IL_0060: ldstr "default"
IL_0065: call void [mscorlib]System.Console::WriteLine(string)
IL_006a: ldstr "more code"
IL_006f: call void [mscorlib]System.Console::WriteLine(string)
IL_0074: ret
IL_0075: ldarg.0
IL_0076: ldc.i4.1
IL_0077: add
IL_0078: starg.s i
IL_007a: br.s IL_0015
} // end of method Switch::SwitchInLoop
.method public hidebysig static void SwitchWithGoto(int32 i) cil managed
{
// Code size 104 (0x68)
.maxstack 2
.locals init (int32 V_0)
IL_0000: ldstr "SwitchWithGoto: "
IL_0005: ldarg.0
IL_0006: box [mscorlib]System.Int32
IL_000b: call string [mscorlib]System.String::Concat(object,
object)
IL_0010: call void [mscorlib]System.Console::WriteLine(string)
IL_0015: ldarg.0
IL_0016: stloc.0
IL_0017: ldloc.0
IL_0018: ldc.i4.1
IL_0019: sub
IL_001a: switch (
IL_0031,
IL_003d,
IL_0047,
IL_0052)
IL_002f: br.s IL_005d
IL_0031: ldstr "one"
IL_0036: call void [mscorlib]System.Console::WriteLine(string)
IL_003b: br.s IL_005d
IL_003d: ldstr "two"
IL_0042: call void [mscorlib]System.Console::WriteLine(string)
IL_0047: ldstr "three"
IL_004c: call void [mscorlib]System.Console::WriteLine(string)
IL_0051: ret
IL_0052: ldstr "four"
IL_0057: call void [mscorlib]System.Console::WriteLine(string)
IL_005c: ret
IL_005d: ldstr "default"
IL_0062: call void [mscorlib]System.Console::WriteLine(string)
IL_0067: ret
} // end of method Switch::SwitchWithGoto
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
.class private auto ansi '<PrivateImplementationDetails>{FFA858C4-FC28-4EB1-BDB5-C80B304AD168}'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000003-1'
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000004-1'
} // end of class '<PrivateImplementationDetails>{FFA858C4-FC28-4EB1-BDB5-C80B304AD168}'
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file ../../../TestCases/Pretty\Switch.opt.res

700
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il

@ -0,0 +1,700 @@ @@ -0,0 +1,700 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly Switch
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 )
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module Switch.dll
// MVID: {3690F18D-C570-405A-8B33-B6E0A6696EFD}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x015B0000
// =============== CLASS MEMBERS DECLARATION ===================
.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
extends [mscorlib]System.Object
{
.method public hidebysig static string
SparseIntegerSwitch(int32 i) cil managed
{
// Code size 185 (0xb9)
.maxstack 2
IL_0000: ldstr "SparseIntegerSwitch: "
IL_0005: ldarg.0
IL_0006: box [mscorlib]System.Int32
IL_000b: call string [mscorlib]System.String::Concat(object,
object)
IL_0010: call void [mscorlib]System.Console::WriteLine(string)
IL_0015: ldarg.0
IL_0016: ldc.i4.4
IL_0017: bgt.s IL_0048
IL_0019: ldarg.0
IL_001a: ldc.i4 0xff676980
IL_001f: beq.s IL_0071
IL_0021: ldarg.0
IL_0022: ldc.i4.s -100
IL_0024: beq.s IL_0077
IL_0026: ldarg.0
IL_0027: ldc.i4.m1
IL_0028: sub
IL_0029: switch (
IL_007d,
IL_0083,
IL_0089,
IL_008f,
IL_00b3,
IL_0095)
IL_0046: br.s IL_00b3
IL_0048: ldarg.0
IL_0049: ldc.i4 0x2710
IL_004e: bgt.s IL_005f
IL_0050: ldarg.0
IL_0051: ldc.i4.s 100
IL_0053: beq.s IL_009b
IL_0055: ldarg.0
IL_0056: ldc.i4 0x2710
IL_005b: beq.s IL_00a1
IL_005d: br.s IL_00b3
IL_005f: ldarg.0
IL_0060: ldc.i4 0x2711
IL_0065: beq.s IL_00a7
IL_0067: ldarg.0
IL_0068: ldc.i4 0x7fffffff
IL_006d: beq.s IL_00ad
IL_006f: br.s IL_00b3
IL_0071: ldstr "-10 mln"
IL_0076: ret
IL_0077: ldstr "-hundred"
IL_007c: ret
IL_007d: ldstr "-1"
IL_0082: ret
IL_0083: ldstr "0"
IL_0088: ret
IL_0089: ldstr "1"
IL_008e: ret
IL_008f: ldstr "2"
IL_0094: ret
IL_0095: ldstr "4"
IL_009a: ret
IL_009b: ldstr "hundred"
IL_00a0: ret
IL_00a1: ldstr "ten thousand"
IL_00a6: ret
IL_00a7: ldstr "ten thousand and one"
IL_00ac: ret
IL_00ad: ldstr "int.MaxValue"
IL_00b2: ret
IL_00b3: ldstr "something else"
IL_00b8: ret
} // end of method Switch::SparseIntegerSwitch
.method public hidebysig static string
ShortSwitchOverString(string text) cil managed
{
// Code size 81 (0x51)
.maxstack 2
IL_0000: ldstr "ShortSwitchOverString: "
IL_0005: ldarg.0
IL_0006: call string [mscorlib]System.String::Concat(string,
string)
IL_000b: call void [mscorlib]System.Console::WriteLine(string)
IL_0010: ldarg.0
IL_0011: ldstr "First case"
IL_0016: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_001b: brtrue.s IL_0039
IL_001d: ldarg.0
IL_001e: ldstr "Second case"
IL_0023: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0028: brtrue.s IL_003f
IL_002a: ldarg.0
IL_002b: ldstr "Third case"
IL_0030: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0035: brtrue.s IL_0045
IL_0037: br.s IL_004b
IL_0039: ldstr "Text1"
IL_003e: ret
IL_003f: ldstr "Text2"
IL_0044: ret
IL_0045: ldstr "Text3"
IL_004a: ret
IL_004b: ldstr "Default"
IL_0050: ret
} // end of method Switch::ShortSwitchOverString
.method public hidebysig static string
SwitchOverString1(string text) cil managed
{
// Code size 289 (0x121)
.maxstack 2
.locals init (uint32 V_0)
IL_0000: ldstr "SwitchOverString1: "
IL_0005: ldarg.0
IL_0006: call string [mscorlib]System.String::Concat(string,
string)
IL_000b: call void [mscorlib]System.Console::WriteLine(string)
IL_0010: ldarg.0
IL_0011: call uint32 '<PrivateImplementationDetails>'::ComputeStringHash(string)
IL_0016: stloc.0
IL_0017: ldloc.0
IL_0018: ldc.i4 0xf3d44a6
IL_001d: bgt.un.s IL_0052
IL_001f: ldloc.0
IL_0020: ldc.i4 0x8861b86
IL_0025: bgt.un.s IL_003d
IL_0027: ldloc.0
IL_0028: brfalse IL_00f0
IL_002d: ldloc.0
IL_002e: ldc.i4 0x8861b86
IL_0033: beq IL_00d2
IL_0038: br IL_011b
IL_003d: ldloc.0
IL_003e: ldc.i4 0xc9a8f4f
IL_0043: beq.s IL_0084
IL_0045: ldloc.0
IL_0046: ldc.i4 0xf3d44a6
IL_004b: beq.s IL_00b4
IL_004d: br IL_011b
IL_0052: ldloc.0
IL_0053: ldc.i4 0x652a1179
IL_0058: bgt.un.s IL_006f
IL_005a: ldloc.0
IL_005b: ldc.i4 0x51650fb9
IL_0060: beq.s IL_00e1
IL_0062: ldloc.0
IL_0063: ldc.i4 0x652a1179
IL_0068: beq.s IL_00a5
IL_006a: br IL_011b
IL_006f: ldloc.0
IL_0070: ldc.i4 0xea3d096b
IL_0075: beq.s IL_0096
IL_0077: ldloc.0
IL_0078: ldc.i4 0xf701cc7f
IL_007d: beq.s IL_00c3
IL_007f: br IL_011b
IL_0084: ldarg.0
IL_0085: ldstr "First case"
IL_008a: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_008f: brtrue.s IL_00f5
IL_0091: br IL_011b
IL_0096: ldarg.0
IL_0097: ldstr "Second case"
IL_009c: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00a1: brtrue.s IL_00fb
IL_00a3: br.s IL_011b
IL_00a5: ldarg.0
IL_00a6: ldstr "2nd case"
IL_00ab: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00b0: brtrue.s IL_00fb
IL_00b2: br.s IL_011b
IL_00b4: ldarg.0
IL_00b5: ldstr "Third case"
IL_00ba: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00bf: brtrue.s IL_0101
IL_00c1: br.s IL_011b
IL_00c3: ldarg.0
IL_00c4: ldstr "Fourth case"
IL_00c9: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00ce: brtrue.s IL_0107
IL_00d0: br.s IL_011b
IL_00d2: ldarg.0
IL_00d3: ldstr "Fifth case"
IL_00d8: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00dd: brtrue.s IL_010d
IL_00df: br.s IL_011b
IL_00e1: ldarg.0
IL_00e2: ldstr "Sixth case"
IL_00e7: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00ec: brtrue.s IL_0113
IL_00ee: br.s IL_011b
IL_00f0: ldarg.0
IL_00f1: brfalse.s IL_0119
IL_00f3: br.s IL_011b
IL_00f5: ldstr "Text1"
IL_00fa: ret
IL_00fb: ldstr "Text2"
IL_0100: ret
IL_0101: ldstr "Text3"
IL_0106: ret
IL_0107: ldstr "Text4"
IL_010c: ret
IL_010d: ldstr "Text5"
IL_0112: ret
IL_0113: ldstr "Text6"
IL_0118: ret
IL_0119: ldnull
IL_011a: ret
IL_011b: ldstr "Default"
IL_0120: ret
} // end of method Switch::SwitchOverString1
.method public hidebysig static string
SwitchOverString2() cil managed
{
// Code size 446 (0x1be)
.maxstack 2
.locals init (string V_0,
uint32 V_1)
IL_0000: ldstr "SwitchOverString2:"
IL_0005: call void [mscorlib]System.Console::WriteLine(string)
IL_000a: call string [mscorlib]System.Environment::get_UserName()
IL_000f: stloc.0
IL_0010: ldloc.0
IL_0011: call uint32 '<PrivateImplementationDetails>'::ComputeStringHash(string)
IL_0016: stloc.1
IL_0017: ldloc.1
IL_0018: ldc.i4 0x4c7c71f6
IL_001d: bgt.un.s IL_0065
IL_001f: ldloc.1
IL_0020: ldc.i4 0xc9a8f4f
IL_0025: bgt.un.s IL_003f
IL_0027: ldloc.1
IL_0028: ldc.i4 0x8861b86
IL_002d: beq IL_0107
IL_0032: ldloc.1
IL_0033: ldc.i4 0xc9a8f4f
IL_0038: beq.s IL_00b3
IL_003a: br IL_01b8
IL_003f: ldloc.1
IL_0040: ldc.i4 0xf3d44a6
IL_0045: beq IL_00dd
IL_004a: ldloc.1
IL_004b: ldc.i4 0x20289804
IL_0050: beq IL_013a
IL_0055: ldloc.1
IL_0056: ldc.i4 0x4c7c71f6
IL_005b: beq IL_0149
IL_0060: br IL_01b8
IL_0065: ldloc.1
IL_0066: ldc.i4 0xa151b28a
IL_006b: bgt.un.s IL_0093
IL_006d: ldloc.1
IL_006e: ldc.i4 0x4d0cea48
IL_0073: beq IL_0167
IL_0078: ldloc.1
IL_0079: ldc.i4 0x51650fb9
IL_007e: beq IL_0119
IL_0083: ldloc.1
IL_0084: ldc.i4 0xa151b28a
IL_0089: beq IL_012b
IL_008e: br IL_01b8
IL_0093: ldloc.1
IL_0094: ldc.i4 0xea3d096b
IL_0099: beq.s IL_00c8
IL_009b: ldloc.1
IL_009c: ldc.i4 0xed5134d4
IL_00a1: beq IL_0158
IL_00a6: ldloc.1
IL_00a7: ldc.i4 0xf701cc7f
IL_00ac: beq.s IL_00f2
IL_00ae: br IL_01b8
IL_00b3: ldloc.0
IL_00b4: ldstr "First case"
IL_00b9: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00be: brtrue IL_0176
IL_00c3: br IL_01b8
IL_00c8: ldloc.0
IL_00c9: ldstr "Second case"
IL_00ce: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00d3: brtrue IL_017c
IL_00d8: br IL_01b8
IL_00dd: ldloc.0
IL_00de: ldstr "Third case"
IL_00e3: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00e8: brtrue IL_0182
IL_00ed: br IL_01b8
IL_00f2: ldloc.0
IL_00f3: ldstr "Fourth case"
IL_00f8: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00fd: brtrue IL_0188
IL_0102: br IL_01b8
IL_0107: ldloc.0
IL_0108: ldstr "Fifth case"
IL_010d: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0112: brtrue.s IL_018e
IL_0114: br IL_01b8
IL_0119: ldloc.0
IL_011a: ldstr "Sixth case"
IL_011f: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0124: brtrue.s IL_0194
IL_0126: br IL_01b8
IL_012b: ldloc.0
IL_012c: ldstr "Seventh case"
IL_0131: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0136: brtrue.s IL_019a
IL_0138: br.s IL_01b8
IL_013a: ldloc.0
IL_013b: ldstr "Eighth case"
IL_0140: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0145: brtrue.s IL_01a0
IL_0147: br.s IL_01b8
IL_0149: ldloc.0
IL_014a: ldstr "Ninth case"
IL_014f: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0154: brtrue.s IL_01a6
IL_0156: br.s IL_01b8
IL_0158: ldloc.0
IL_0159: ldstr "Tenth case"
IL_015e: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0163: brtrue.s IL_01ac
IL_0165: br.s IL_01b8
IL_0167: ldloc.0
IL_0168: ldstr "Eleventh case"
IL_016d: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0172: brtrue.s IL_01b2
IL_0174: br.s IL_01b8
IL_0176: ldstr "Text1"
IL_017b: ret
IL_017c: ldstr "Text2"
IL_0181: ret
IL_0182: ldstr "Text3"
IL_0187: ret
IL_0188: ldstr "Text4"
IL_018d: ret
IL_018e: ldstr "Text5"
IL_0193: ret
IL_0194: ldstr "Text6"
IL_0199: ret
IL_019a: ldstr "Text7"
IL_019f: ret
IL_01a0: ldstr "Text8"
IL_01a5: ret
IL_01a6: ldstr "Text9"
IL_01ab: ret
IL_01ac: ldstr "Text10"
IL_01b1: ret
IL_01b2: ldstr "Text11"
IL_01b7: ret
IL_01b8: ldstr "Default"
IL_01bd: ret
} // end of method Switch::SwitchOverString2
.method public hidebysig static string
SwitchOverBool(bool b) cil managed
{
// Code size 43 (0x2b)
.maxstack 8
IL_0000: ldstr "SwitchOverBool: "
IL_0005: ldarga.s b
IL_0007: call instance string [mscorlib]System.Boolean::ToString()
IL_000c: call string [mscorlib]System.String::Concat(string,
string)
IL_0011: call void [mscorlib]System.Console::WriteLine(string)
IL_0016: ldarg.0
IL_0017: brfalse.s IL_0023
IL_0019: ldarg.0
IL_001a: ldc.i4.1
IL_001b: bne.un.s IL_0029
IL_001d: ldsfld string [mscorlib]System.Boolean::TrueString
IL_0022: ret
IL_0023: ldsfld string [mscorlib]System.Boolean::FalseString
IL_0028: ret
IL_0029: ldnull
IL_002a: ret
} // end of method Switch::SwitchOverBool
.method public hidebysig static void SwitchInLoop(int32 i) cil managed
{
// Code size 122 (0x7a)
.maxstack 2
IL_0000: ldstr "SwitchInLoop: "
IL_0005: ldarg.0
IL_0006: box [mscorlib]System.Int32
IL_000b: call string [mscorlib]System.String::Concat(object,
object)
IL_0010: call void [mscorlib]System.Console::WriteLine(string)
IL_0015: ldarg.0
IL_0016: ldc.i4.1
IL_0017: sub
IL_0018: switch (
IL_002f,
IL_003b,
IL_0047,
IL_0053)
IL_002d: br.s IL_005e
IL_002f: ldstr "one"
IL_0034: call void [mscorlib]System.Console::WriteLine(string)
IL_0039: br.s IL_0073
IL_003b: ldstr "two"
IL_0040: call void [mscorlib]System.Console::WriteLine(string)
IL_0045: br.s IL_0073
IL_0047: ldstr "three"
IL_004c: call void [mscorlib]System.Console::WriteLine(string)
IL_0051: br.s IL_0015
IL_0053: ldstr "four"
IL_0058: call void [mscorlib]System.Console::WriteLine(string)
IL_005d: ret
IL_005e: ldstr "default"
IL_0063: call void [mscorlib]System.Console::WriteLine(string)
IL_0068: ldstr "more code"
IL_006d: call void [mscorlib]System.Console::WriteLine(string)
IL_0072: ret
IL_0073: ldarg.0
IL_0074: ldc.i4.1
IL_0075: add
IL_0076: starg.s i
IL_0078: br.s IL_0015
} // end of method Switch::SwitchInLoop
.method public hidebysig static void SwitchWithGoto(int32 i) cil managed
{
// Code size 102 (0x66)
.maxstack 2
IL_0000: ldstr "SwitchWithGoto: "
IL_0005: ldarg.0
IL_0006: box [mscorlib]System.Int32
IL_000b: call string [mscorlib]System.String::Concat(object,
object)
IL_0010: call void [mscorlib]System.Console::WriteLine(string)
IL_0015: ldarg.0
IL_0016: ldc.i4.1
IL_0017: sub
IL_0018: switch (
IL_002f,
IL_003b,
IL_0045,
IL_0050)
IL_002d: br.s IL_005b
IL_002f: ldstr "one"
IL_0034: call void [mscorlib]System.Console::WriteLine(string)
IL_0039: br.s IL_005b
IL_003b: ldstr "two"
IL_0040: call void [mscorlib]System.Console::WriteLine(string)
IL_0045: ldstr "three"
IL_004a: call void [mscorlib]System.Console::WriteLine(string)
IL_004f: ret
IL_0050: ldstr "four"
IL_0055: call void [mscorlib]System.Console::WriteLine(string)
IL_005a: ret
IL_005b: ldstr "default"
IL_0060: call void [mscorlib]System.Console::WriteLine(string)
IL_0065: ret
} // end of method Switch::SwitchWithGoto
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
.class private auto ansi sealed '<PrivateImplementationDetails>'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method assembly hidebysig static uint32
ComputeStringHash(string s) cil managed
{
// Code size 44 (0x2c)
.maxstack 2
.locals init (uint32 V_0,
int32 V_1)
IL_0000: ldarg.0
IL_0001: brfalse.s IL_002a
IL_0003: ldc.i4 0x811c9dc5
IL_0008: stloc.0
IL_0009: ldc.i4.0
IL_000a: stloc.1
IL_000b: br.s IL_0021
IL_000d: ldarg.0
IL_000e: ldloc.1
IL_000f: callvirt instance char [mscorlib]System.String::get_Chars(int32)
IL_0014: ldloc.0
IL_0015: xor
IL_0016: ldc.i4 0x1000193
IL_001b: mul
IL_001c: stloc.0
IL_001d: ldloc.1
IL_001e: ldc.i4.1
IL_001f: add
IL_0020: stloc.1
IL_0021: ldloc.1
IL_0022: ldarg.0
IL_0023: callvirt instance int32 [mscorlib]System.String::get_Length()
IL_0028: blt.s IL_000d
IL_002a: ldloc.0
IL_002b: ret
} // end of method '<PrivateImplementationDetails>'::ComputeStringHash
} // end of class '<PrivateImplementationDetails>'
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************

890
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il

@ -0,0 +1,890 @@ @@ -0,0 +1,890 @@
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17929
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly Switch
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}}
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module Switch.dll
// MVID: {08E636DF-9FF0-4BF4-9F8F-69859C40E218}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x02E70000
// =============== CLASS MEMBERS DECLARATION ===================
.class public abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
extends [mscorlib]System.Object
{
.method public hidebysig static string
SparseIntegerSwitch(int32 i) cil managed
{
// Code size 238 (0xee)
.maxstack 2
.locals init (int32 V_0,
string V_1)
IL_0000: nop
IL_0001: ldstr "SparseIntegerSwitch: "
IL_0006: ldarg.0
IL_0007: box [mscorlib]System.Int32
IL_000c: call string [mscorlib]System.String::Concat(object,
object)
IL_0011: call void [mscorlib]System.Console::WriteLine(string)
IL_0016: nop
IL_0017: ldarg.0
IL_0018: stloc.0
IL_0019: ldloc.0
IL_001a: ldc.i4.4
IL_001b: bgt.s IL_0053
IL_001d: ldloc.0
IL_001e: ldc.i4 0xff676980
IL_0023: beq.s IL_0080
IL_0025: br.s IL_0027
IL_0027: ldloc.0
IL_0028: ldc.i4.s -100
IL_002a: beq.s IL_0089
IL_002c: br.s IL_002e
IL_002e: ldloc.0
IL_002f: ldc.i4.m1
IL_0030: sub
IL_0031: switch (
IL_0092,
IL_009b,
IL_00a4,
IL_00ad,
IL_00e3,
IL_00b6)
IL_004e: br IL_00e3
IL_0053: ldloc.0
IL_0054: ldc.i4 0x2710
IL_0059: bgt.s IL_006c
IL_005b: ldloc.0
IL_005c: ldc.i4.s 100
IL_005e: beq.s IL_00bf
IL_0060: br.s IL_0062
IL_0062: ldloc.0
IL_0063: ldc.i4 0x2710
IL_0068: beq.s IL_00c8
IL_006a: br.s IL_00e3
IL_006c: ldloc.0
IL_006d: ldc.i4 0x2711
IL_0072: beq.s IL_00d1
IL_0074: br.s IL_0076
IL_0076: ldloc.0
IL_0077: ldc.i4 0x7fffffff
IL_007c: beq.s IL_00da
IL_007e: br.s IL_00e3
IL_0080: nop
IL_0081: ldstr "-10 mln"
IL_0086: stloc.1
IL_0087: br.s IL_00ec
IL_0089: nop
IL_008a: ldstr "-hundred"
IL_008f: stloc.1
IL_0090: br.s IL_00ec
IL_0092: nop
IL_0093: ldstr "-1"
IL_0098: stloc.1
IL_0099: br.s IL_00ec
IL_009b: nop
IL_009c: ldstr "0"
IL_00a1: stloc.1
IL_00a2: br.s IL_00ec
IL_00a4: nop
IL_00a5: ldstr "1"
IL_00aa: stloc.1
IL_00ab: br.s IL_00ec
IL_00ad: nop
IL_00ae: ldstr "2"
IL_00b3: stloc.1
IL_00b4: br.s IL_00ec
IL_00b6: nop
IL_00b7: ldstr "4"
IL_00bc: stloc.1
IL_00bd: br.s IL_00ec
IL_00bf: nop
IL_00c0: ldstr "hundred"
IL_00c5: stloc.1
IL_00c6: br.s IL_00ec
IL_00c8: nop
IL_00c9: ldstr "ten thousand"
IL_00ce: stloc.1
IL_00cf: br.s IL_00ec
IL_00d1: nop
IL_00d2: ldstr "ten thousand and one"
IL_00d7: stloc.1
IL_00d8: br.s IL_00ec
IL_00da: nop
IL_00db: ldstr "int.MaxValue"
IL_00e0: stloc.1
IL_00e1: br.s IL_00ec
IL_00e3: nop
IL_00e4: ldstr "something else"
IL_00e9: stloc.1
IL_00ea: br.s IL_00ec
IL_00ec: ldloc.1
IL_00ed: ret
} // end of method Switch::SparseIntegerSwitch
.method public hidebysig static string
ShortSwitchOverString(string text) cil managed
{
// Code size 99 (0x63)
.maxstack 2
.locals init (string V_0,
string V_1)
IL_0000: nop
IL_0001: ldstr "ShortSwitchOverString: "
IL_0006: ldarg.0
IL_0007: call string [mscorlib]System.String::Concat(string,
string)
IL_000c: call void [mscorlib]System.Console::WriteLine(string)
IL_0011: nop
IL_0012: ldarg.0
IL_0013: stloc.0
IL_0014: ldloc.0
IL_0015: ldstr "First case"
IL_001a: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_001f: brtrue.s IL_003d
IL_0021: ldloc.0
IL_0022: ldstr "Second case"
IL_0027: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_002c: brtrue.s IL_0046
IL_002e: ldloc.0
IL_002f: ldstr "Third case"
IL_0034: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0039: brtrue.s IL_004f
IL_003b: br.s IL_0058
IL_003d: nop
IL_003e: ldstr "Text1"
IL_0043: stloc.1
IL_0044: br.s IL_0061
IL_0046: nop
IL_0047: ldstr "Text2"
IL_004c: stloc.1
IL_004d: br.s IL_0061
IL_004f: nop
IL_0050: ldstr "Text3"
IL_0055: stloc.1
IL_0056: br.s IL_0061
IL_0058: nop
IL_0059: ldstr "Default"
IL_005e: stloc.1
IL_005f: br.s IL_0061
IL_0061: ldloc.1
IL_0062: ret
} // end of method Switch::ShortSwitchOverString
.method public hidebysig static string
SwitchOverString1(string text) cil managed
{
// Code size 333 (0x14d)
.maxstack 2
.locals init (string V_0,
uint32 V_1,
string V_2)
IL_0000: nop
IL_0001: ldstr "SwitchOverString1: "
IL_0006: ldarg.0
IL_0007: call string [mscorlib]System.String::Concat(string,
string)
IL_000c: call void [mscorlib]System.Console::WriteLine(string)
IL_0011: nop
IL_0012: ldarg.0
IL_0013: stloc.0
IL_0014: ldloc.0
IL_0015: call uint32 '<PrivateImplementationDetails>'::ComputeStringHash(string)
IL_001a: stloc.1
IL_001b: ldloc.1
IL_001c: ldc.i4 0xf3d44a6
IL_0021: bgt.un.s IL_005a
IL_0023: ldloc.1
IL_0024: ldc.i4 0x8861b86
IL_0029: bgt.un.s IL_0043
IL_002b: ldloc.1
IL_002c: brfalse IL_0102
IL_0031: br.s IL_0033
IL_0033: ldloc.1
IL_0034: ldc.i4 0x8861b86
IL_0039: beq IL_00e4
IL_003e: br IL_0142
IL_0043: ldloc.1
IL_0044: ldc.i4 0xc9a8f4f
IL_0049: beq.s IL_0093
IL_004b: br.s IL_004d
IL_004d: ldloc.1
IL_004e: ldc.i4 0xf3d44a6
IL_0053: beq.s IL_00c6
IL_0055: br IL_0142
IL_005a: ldloc.1
IL_005b: ldc.i4 0x652a1179
IL_0060: bgt.un.s IL_007c
IL_0062: ldloc.1
IL_0063: ldc.i4 0x51650fb9
IL_0068: beq IL_00f3
IL_006d: br.s IL_006f
IL_006f: ldloc.1
IL_0070: ldc.i4 0x652a1179
IL_0075: beq.s IL_00b7
IL_0077: br IL_0142
IL_007c: ldloc.1
IL_007d: ldc.i4 0xea3d096b
IL_0082: beq.s IL_00a5
IL_0084: br.s IL_0086
IL_0086: ldloc.1
IL_0087: ldc.i4 0xf701cc7f
IL_008c: beq.s IL_00d5
IL_008e: br IL_0142
IL_0093: ldloc.0
IL_0094: ldstr "First case"
IL_0099: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_009e: brtrue.s IL_0107
IL_00a0: br IL_0142
IL_00a5: ldloc.0
IL_00a6: ldstr "Second case"
IL_00ab: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00b0: brtrue.s IL_0110
IL_00b2: br IL_0142
IL_00b7: ldloc.0
IL_00b8: ldstr "2nd case"
IL_00bd: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00c2: brtrue.s IL_0110
IL_00c4: br.s IL_0142
IL_00c6: ldloc.0
IL_00c7: ldstr "Third case"
IL_00cc: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00d1: brtrue.s IL_0119
IL_00d3: br.s IL_0142
IL_00d5: ldloc.0
IL_00d6: ldstr "Fourth case"
IL_00db: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00e0: brtrue.s IL_0122
IL_00e2: br.s IL_0142
IL_00e4: ldloc.0
IL_00e5: ldstr "Fifth case"
IL_00ea: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00ef: brtrue.s IL_012b
IL_00f1: br.s IL_0142
IL_00f3: ldloc.0
IL_00f4: ldstr "Sixth case"
IL_00f9: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00fe: brtrue.s IL_0134
IL_0100: br.s IL_0142
IL_0102: ldloc.0
IL_0103: brfalse.s IL_013d
IL_0105: br.s IL_0142
IL_0107: nop
IL_0108: ldstr "Text1"
IL_010d: stloc.2
IL_010e: br.s IL_014b
IL_0110: nop
IL_0111: ldstr "Text2"
IL_0116: stloc.2
IL_0117: br.s IL_014b
IL_0119: nop
IL_011a: ldstr "Text3"
IL_011f: stloc.2
IL_0120: br.s IL_014b
IL_0122: nop
IL_0123: ldstr "Text4"
IL_0128: stloc.2
IL_0129: br.s IL_014b
IL_012b: nop
IL_012c: ldstr "Text5"
IL_0131: stloc.2
IL_0132: br.s IL_014b
IL_0134: nop
IL_0135: ldstr "Text6"
IL_013a: stloc.2
IL_013b: br.s IL_014b
IL_013d: nop
IL_013e: ldnull
IL_013f: stloc.2
IL_0140: br.s IL_014b
IL_0142: nop
IL_0143: ldstr "Default"
IL_0148: stloc.2
IL_0149: br.s IL_014b
IL_014b: ldloc.2
IL_014c: ret
} // end of method Switch::SwitchOverString1
.method public hidebysig static string
SwitchOverString2() cil managed
{
// Code size 518 (0x206)
.maxstack 2
.locals init (string V_0,
uint32 V_1,
string V_2)
IL_0000: nop
IL_0001: ldstr "SwitchOverString2:"
IL_0006: call void [mscorlib]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: call string [mscorlib]System.Environment::get_UserName()
IL_0011: stloc.0
IL_0012: ldloc.0
IL_0013: call uint32 '<PrivateImplementationDetails>'::ComputeStringHash(string)
IL_0018: stloc.1
IL_0019: ldloc.1
IL_001a: ldc.i4 0x4c7c71f6
IL_001f: bgt.un.s IL_0070
IL_0021: ldloc.1
IL_0022: ldc.i4 0xc9a8f4f
IL_0027: bgt.un.s IL_0046
IL_0029: ldloc.1
IL_002a: ldc.i4 0x8861b86
IL_002f: beq IL_011a
IL_0034: br.s IL_0036
IL_0036: ldloc.1
IL_0037: ldc.i4 0xc9a8f4f
IL_003c: beq IL_00c6
IL_0041: br IL_01fb
IL_0046: ldloc.1
IL_0047: ldc.i4 0xf3d44a6
IL_004c: beq IL_00f0
IL_0051: br.s IL_0053
IL_0053: ldloc.1
IL_0054: ldc.i4 0x20289804
IL_0059: beq IL_0156
IL_005e: br.s IL_0060
IL_0060: ldloc.1
IL_0061: ldc.i4 0x4c7c71f6
IL_0066: beq IL_0168
IL_006b: br IL_01fb
IL_0070: ldloc.1
IL_0071: ldc.i4 0xa151b28a
IL_0076: bgt.un.s IL_00a2
IL_0078: ldloc.1
IL_0079: ldc.i4 0x4d0cea48
IL_007e: beq IL_0189
IL_0083: br.s IL_0085
IL_0085: ldloc.1
IL_0086: ldc.i4 0x51650fb9
IL_008b: beq IL_012f
IL_0090: br.s IL_0092
IL_0092: ldloc.1
IL_0093: ldc.i4 0xa151b28a
IL_0098: beq IL_0144
IL_009d: br IL_01fb
IL_00a2: ldloc.1
IL_00a3: ldc.i4 0xea3d096b
IL_00a8: beq.s IL_00db
IL_00aa: br.s IL_00ac
IL_00ac: ldloc.1
IL_00ad: ldc.i4 0xed5134d4
IL_00b2: beq IL_017a
IL_00b7: br.s IL_00b9
IL_00b9: ldloc.1
IL_00ba: ldc.i4 0xf701cc7f
IL_00bf: beq.s IL_0105
IL_00c1: br IL_01fb
IL_00c6: ldloc.0
IL_00c7: ldstr "First case"
IL_00cc: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00d1: brtrue IL_0198
IL_00d6: br IL_01fb
IL_00db: ldloc.0
IL_00dc: ldstr "Second case"
IL_00e1: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00e6: brtrue IL_01a1
IL_00eb: br IL_01fb
IL_00f0: ldloc.0
IL_00f1: ldstr "Third case"
IL_00f6: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_00fb: brtrue IL_01aa
IL_0100: br IL_01fb
IL_0105: ldloc.0
IL_0106: ldstr "Fourth case"
IL_010b: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0110: brtrue IL_01b3
IL_0115: br IL_01fb
IL_011a: ldloc.0
IL_011b: ldstr "Fifth case"
IL_0120: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0125: brtrue IL_01bc
IL_012a: br IL_01fb
IL_012f: ldloc.0
IL_0130: ldstr "Sixth case"
IL_0135: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_013a: brtrue IL_01c5
IL_013f: br IL_01fb
IL_0144: ldloc.0
IL_0145: ldstr "Seventh case"
IL_014a: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_014f: brtrue.s IL_01ce
IL_0151: br IL_01fb
IL_0156: ldloc.0
IL_0157: ldstr "Eighth case"
IL_015c: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0161: brtrue.s IL_01d7
IL_0163: br IL_01fb
IL_0168: ldloc.0
IL_0169: ldstr "Ninth case"
IL_016e: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0173: brtrue.s IL_01e0
IL_0175: br IL_01fb
IL_017a: ldloc.0
IL_017b: ldstr "Tenth case"
IL_0180: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0185: brtrue.s IL_01e9
IL_0187: br.s IL_01fb
IL_0189: ldloc.0
IL_018a: ldstr "Eleventh case"
IL_018f: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0194: brtrue.s IL_01f2
IL_0196: br.s IL_01fb
IL_0198: nop
IL_0199: ldstr "Text1"
IL_019e: stloc.2
IL_019f: br.s IL_0204
IL_01a1: nop
IL_01a2: ldstr "Text2"
IL_01a7: stloc.2
IL_01a8: br.s IL_0204
IL_01aa: nop
IL_01ab: ldstr "Text3"
IL_01b0: stloc.2
IL_01b1: br.s IL_0204
IL_01b3: nop
IL_01b4: ldstr "Text4"
IL_01b9: stloc.2
IL_01ba: br.s IL_0204
IL_01bc: nop
IL_01bd: ldstr "Text5"
IL_01c2: stloc.2
IL_01c3: br.s IL_0204
IL_01c5: nop
IL_01c6: ldstr "Text6"
IL_01cb: stloc.2
IL_01cc: br.s IL_0204
IL_01ce: nop
IL_01cf: ldstr "Text7"
IL_01d4: stloc.2
IL_01d5: br.s IL_0204
IL_01d7: nop
IL_01d8: ldstr "Text8"
IL_01dd: stloc.2
IL_01de: br.s IL_0204
IL_01e0: nop
IL_01e1: ldstr "Text9"
IL_01e6: stloc.2
IL_01e7: br.s IL_0204
IL_01e9: nop
IL_01ea: ldstr "Text10"
IL_01ef: stloc.2
IL_01f0: br.s IL_0204
IL_01f2: nop
IL_01f3: ldstr "Text11"
IL_01f8: stloc.2
IL_01f9: br.s IL_0204
IL_01fb: nop
IL_01fc: ldstr "Default"
IL_0201: stloc.2
IL_0202: br.s IL_0204
IL_0204: ldloc.2
IL_0205: ret
} // end of method Switch::SwitchOverString2
.method public hidebysig static string
SwitchOverBool(bool b) cil managed
{
// Code size 62 (0x3e)
.maxstack 2
.locals init (bool V_0,
string V_1)
IL_0000: nop
IL_0001: ldstr "SwitchOverBool: "
IL_0006: ldarga.s b
IL_0008: call instance string [mscorlib]System.Boolean::ToString()
IL_000d: call string [mscorlib]System.String::Concat(string,
string)
IL_0012: call void [mscorlib]System.Console::WriteLine(string)
IL_0017: nop
IL_0018: ldarg.0
IL_0019: stloc.0
IL_001a: ldloc.0
IL_001b: brfalse.s IL_002e
IL_001d: br.s IL_001f
IL_001f: ldloc.0
IL_0020: ldc.i4.1
IL_0021: beq.s IL_0025
IL_0023: br.s IL_0037
IL_0025: nop
IL_0026: ldsfld string [mscorlib]System.Boolean::TrueString
IL_002b: stloc.1
IL_002c: br.s IL_003c
IL_002e: nop
IL_002f: ldsfld string [mscorlib]System.Boolean::FalseString
IL_0034: stloc.1
IL_0035: br.s IL_003c
IL_0037: nop
IL_0038: ldnull
IL_0039: stloc.1
IL_003a: br.s IL_003c
IL_003c: ldloc.1
IL_003d: ret
} // end of method Switch::SwitchOverBool
.method public hidebysig static void SwitchInLoop(int32 i) cil managed
{
// Code size 141 (0x8d)
.maxstack 2
.locals init (int32 V_0,
bool V_1)
IL_0000: nop
IL_0001: ldstr "SwitchInLoop: "
IL_0006: ldarg.0
IL_0007: box [mscorlib]System.Int32
IL_000c: call string [mscorlib]System.String::Concat(object,
object)
IL_0011: call void [mscorlib]System.Console::WriteLine(string)
IL_0016: nop
IL_0017: br.s IL_0088
IL_0019: nop
IL_001a: ldarg.0
IL_001b: stloc.0
IL_001c: ldloc.0
IL_001d: ldc.i4.1
IL_001e: sub
IL_001f: switch (
IL_0036,
IL_0043,
IL_0050,
IL_005d)
IL_0034: br.s IL_006a
IL_0036: ldstr "one"
IL_003b: call void [mscorlib]System.Console::WriteLine(string)
IL_0040: nop
IL_0041: br.s IL_0082
IL_0043: ldstr "two"
IL_0048: call void [mscorlib]System.Console::WriteLine(string)
IL_004d: nop
IL_004e: br.s IL_0082
IL_0050: ldstr "three"
IL_0055: call void [mscorlib]System.Console::WriteLine(string)
IL_005a: nop
IL_005b: br.s IL_0088
IL_005d: ldstr "four"
IL_0062: call void [mscorlib]System.Console::WriteLine(string)
IL_0067: nop
IL_0068: br.s IL_008c
IL_006a: ldstr "default"
IL_006f: call void [mscorlib]System.Console::WriteLine(string)
IL_0074: nop
IL_0075: ldstr "more code"
IL_007a: call void [mscorlib]System.Console::WriteLine(string)
IL_007f: nop
IL_0080: br.s IL_008c
IL_0082: ldarg.0
IL_0083: ldc.i4.1
IL_0084: add
IL_0085: starg.s i
IL_0087: nop
IL_0088: ldc.i4.1
IL_0089: stloc.1
IL_008a: br.s IL_0019
IL_008c: ret
} // end of method Switch::SwitchInLoop
.method public hidebysig static void SwitchWithGoto(int32 i) cil managed
{
// Code size 117 (0x75)
.maxstack 2
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldstr "SwitchWithGoto: "
IL_0006: ldarg.0
IL_0007: box [mscorlib]System.Int32
IL_000c: call string [mscorlib]System.String::Concat(object,
object)
IL_0011: call void [mscorlib]System.Console::WriteLine(string)
IL_0016: nop
IL_0017: ldarg.0
IL_0018: stloc.0
IL_0019: ldloc.0
IL_001a: ldc.i4.1
IL_001b: sub
IL_001c: switch (
IL_0033,
IL_0040,
IL_004d,
IL_005a)
IL_0031: br.s IL_0067
IL_0033: ldstr "one"
IL_0038: call void [mscorlib]System.Console::WriteLine(string)
IL_003d: nop
IL_003e: br.s IL_0067
IL_0040: ldstr "two"
IL_0045: call void [mscorlib]System.Console::WriteLine(string)
IL_004a: nop
IL_004b: br.s IL_004d
IL_004d: ldstr "three"
IL_0052: call void [mscorlib]System.Console::WriteLine(string)
IL_0057: nop
IL_0058: br.s IL_0074
IL_005a: ldstr "four"
IL_005f: call void [mscorlib]System.Console::WriteLine(string)
IL_0064: nop
IL_0065: br.s IL_0074
IL_0067: ldstr "default"
IL_006c: call void [mscorlib]System.Console::WriteLine(string)
IL_0071: nop
IL_0072: br.s IL_0074
IL_0074: ret
} // end of method Switch::SwitchWithGoto
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
.class private auto ansi sealed '<PrivateImplementationDetails>'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.method assembly hidebysig static uint32
ComputeStringHash(string s) cil managed
{
// Code size 46 (0x2e)
.maxstack 2
.locals init (uint32 V_0,
int32 V_1)
IL_0000: ldarg.0
IL_0001: brfalse.s IL_002c
IL_0003: ldc.i4 0x811c9dc5
IL_0008: stloc.0
IL_0009: ldc.i4.0
IL_000a: stloc.1
IL_000b: br.s IL_0021
IL_000d: ldarg.0
IL_000e: ldloc.1
IL_000f: callvirt instance char [mscorlib]System.String::get_Chars(int32)
IL_0014: ldloc.0
IL_0015: xor
IL_0016: ldc.i4 0x1000193
IL_001b: mul
IL_001c: stloc.0
IL_001d: ldloc.1
IL_001e: ldc.i4.1
IL_001f: add
IL_0020: stloc.1
IL_0021: ldloc.1
IL_0022: ldarg.0
IL_0023: callvirt instance int32 [mscorlib]System.String::get_Length()
IL_0028: bge.s IL_002c
IL_002a: br.s IL_000d
IL_002c: ldloc.0
IL_002d: ret
} // end of method '<PrivateImplementationDetails>'::ComputeStringHash
} // end of class '<PrivateImplementationDetails>'
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
Loading…
Cancel
Save