mirror of https://github.com/icsharpcode/ILSpy.git
15 changed files with 942 additions and 113 deletions
@ -0,0 +1,146 @@
@@ -0,0 +1,146 @@
|
||||
|
||||
// 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 '1c2baaro' |
||||
{ |
||||
.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 '1c2baaro.dll' |
||||
// MVID: {5FC5B58D-AAD7-4436-A58F-6F3D75486C66} |
||||
.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: 0x00C60000 |
||||
|
||||
|
||||
// =============== CLASS MEMBERS DECLARATION =================== |
||||
|
||||
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.method public hidebysig instance void |
||||
LockThis() cil managed |
||||
{ |
||||
// Code size 42 (0x2a) |
||||
.maxstack 2 |
||||
.locals init (bool V_0, |
||||
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock V_1, |
||||
bool V_2) |
||||
IL_0000: nop |
||||
IL_0001: ldc.i4.0 |
||||
IL_0002: stloc.0 |
||||
.try |
||||
{ |
||||
IL_0003: ldarg.0 |
||||
IL_0004: dup |
||||
IL_0005: stloc.1 |
||||
IL_0006: ldloca.s V_0 |
||||
IL_0008: call void [mscorlib]System.Threading.Monitor::Enter(object, |
||||
bool&) |
||||
IL_000d: nop |
||||
IL_000e: nop |
||||
IL_000f: call void [mscorlib]System.Console::WriteLine() |
||||
IL_0014: nop |
||||
IL_0015: nop |
||||
IL_0016: leave.s IL_0028 |
||||
|
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0018: ldloc.0 |
||||
IL_0019: ldc.i4.0 |
||||
IL_001a: ceq |
||||
IL_001c: stloc.2 |
||||
IL_001d: ldloc.2 |
||||
IL_001e: brtrue.s IL_0027 |
||||
|
||||
IL_0020: ldloc.1 |
||||
IL_0021: call void [mscorlib]System.Threading.Monitor::Exit(object) |
||||
IL_0026: nop |
||||
IL_0027: endfinally |
||||
} // end handler |
||||
IL_0028: nop |
||||
IL_0029: ret |
||||
} // end of method Lock::LockThis |
||||
|
||||
.method public hidebysig instance void |
||||
LockOnType() cil managed |
||||
{ |
||||
// Code size 51 (0x33) |
||||
.maxstack 2 |
||||
.locals init (bool V_0, |
||||
class [mscorlib]System.Type V_1, |
||||
bool V_2) |
||||
IL_0000: nop |
||||
IL_0001: ldc.i4.0 |
||||
IL_0002: stloc.0 |
||||
.try |
||||
{ |
||||
IL_0003: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
IL_0008: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) |
||||
IL_000d: dup |
||||
IL_000e: stloc.1 |
||||
IL_000f: ldloca.s V_0 |
||||
IL_0011: call void [mscorlib]System.Threading.Monitor::Enter(object, |
||||
bool&) |
||||
IL_0016: nop |
||||
IL_0017: nop |
||||
IL_0018: call void [mscorlib]System.Console::WriteLine() |
||||
IL_001d: nop |
||||
IL_001e: nop |
||||
IL_001f: leave.s IL_0031 |
||||
|
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0021: ldloc.0 |
||||
IL_0022: ldc.i4.0 |
||||
IL_0023: ceq |
||||
IL_0025: stloc.2 |
||||
IL_0026: ldloc.2 |
||||
IL_0027: brtrue.s IL_0030 |
||||
|
||||
IL_0029: ldloc.1 |
||||
IL_002a: call void [mscorlib]System.Threading.Monitor::Exit(object) |
||||
IL_002f: nop |
||||
IL_0030: endfinally |
||||
} // end handler |
||||
IL_0031: nop |
||||
IL_0032: ret |
||||
} // end of method Lock::LockOnType |
||||
|
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor() cil managed |
||||
{ |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: ret |
||||
} // end of method Lock::.ctor |
||||
|
||||
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
|
||||
|
||||
// ============================================================= |
||||
|
||||
// *********** DISASSEMBLY COMPLETE *********************** |
||||
// WARNING: Created Win32 resource file ../../../TestCases/Pretty\Lock.res |
@ -0,0 +1,122 @@
@@ -0,0 +1,122 @@
|
||||
|
||||
// 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 titpuxma |
||||
{ |
||||
.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 titpuxma.dll |
||||
// MVID: {8B90EB29-A139-4376-848E-C5D4D42952F1} |
||||
.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: 0x02AF0000 |
||||
|
||||
|
||||
// =============== CLASS MEMBERS DECLARATION =================== |
||||
|
||||
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.method public hidebysig instance void |
||||
LockThis() cil managed |
||||
{ |
||||
// Code size 30 (0x1e) |
||||
.maxstack 2 |
||||
.locals init (bool V_0, |
||||
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock V_1) |
||||
IL_0000: ldc.i4.0 |
||||
IL_0001: stloc.0 |
||||
.try |
||||
{ |
||||
IL_0002: ldarg.0 |
||||
IL_0003: dup |
||||
IL_0004: stloc.1 |
||||
IL_0005: ldloca.s V_0 |
||||
IL_0007: call void [mscorlib]System.Threading.Monitor::Enter(object, |
||||
bool&) |
||||
IL_000c: call void [mscorlib]System.Console::WriteLine() |
||||
IL_0011: leave.s IL_001d |
||||
|
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0013: ldloc.0 |
||||
IL_0014: brfalse.s IL_001c |
||||
|
||||
IL_0016: ldloc.1 |
||||
IL_0017: call void [mscorlib]System.Threading.Monitor::Exit(object) |
||||
IL_001c: endfinally |
||||
} // end handler |
||||
IL_001d: ret |
||||
} // end of method Lock::LockThis |
||||
|
||||
.method public hidebysig instance void |
||||
LockOnType() cil managed |
||||
{ |
||||
// Code size 39 (0x27) |
||||
.maxstack 2 |
||||
.locals init (bool V_0, |
||||
class [mscorlib]System.Type V_1) |
||||
IL_0000: ldc.i4.0 |
||||
IL_0001: stloc.0 |
||||
.try |
||||
{ |
||||
IL_0002: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
IL_0007: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) |
||||
IL_000c: dup |
||||
IL_000d: stloc.1 |
||||
IL_000e: ldloca.s V_0 |
||||
IL_0010: call void [mscorlib]System.Threading.Monitor::Enter(object, |
||||
bool&) |
||||
IL_0015: call void [mscorlib]System.Console::WriteLine() |
||||
IL_001a: leave.s IL_0026 |
||||
|
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_001c: ldloc.0 |
||||
IL_001d: brfalse.s IL_0025 |
||||
|
||||
IL_001f: ldloc.1 |
||||
IL_0020: call void [mscorlib]System.Threading.Monitor::Exit(object) |
||||
IL_0025: endfinally |
||||
} // end handler |
||||
IL_0026: ret |
||||
} // end of method Lock::LockOnType |
||||
|
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor() cil managed |
||||
{ |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: ret |
||||
} // end of method Lock::.ctor |
||||
|
||||
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
|
||||
|
||||
// ============================================================= |
||||
|
||||
// *********** DISASSEMBLY COMPLETE *********************** |
||||
// WARNING: Created Win32 resource file ../../../TestCases/Pretty\Lock.opt.res |
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
|
||||
// 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 Lock |
||||
{ |
||||
.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 Lock.dll |
||||
// MVID: {5161B18E-7152-4B49-B4A8-67524BD74953} |
||||
.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: 0x00E10000 |
||||
|
||||
|
||||
// =============== CLASS MEMBERS DECLARATION =================== |
||||
|
||||
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.method public hidebysig instance void |
||||
LockThis() cil managed |
||||
{ |
||||
// Code size 30 (0x1e) |
||||
.maxstack 2 |
||||
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock V_0, |
||||
bool V_1) |
||||
IL_0000: ldarg.0 |
||||
IL_0001: stloc.0 |
||||
IL_0002: ldc.i4.0 |
||||
IL_0003: stloc.1 |
||||
.try |
||||
{ |
||||
IL_0004: ldloc.0 |
||||
IL_0005: ldloca.s V_1 |
||||
IL_0007: call void [mscorlib]System.Threading.Monitor::Enter(object, |
||||
bool&) |
||||
IL_000c: call void [mscorlib]System.Console::WriteLine() |
||||
IL_0011: leave.s IL_001d |
||||
|
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0013: ldloc.1 |
||||
IL_0014: brfalse.s IL_001c |
||||
|
||||
IL_0016: ldloc.0 |
||||
IL_0017: call void [mscorlib]System.Threading.Monitor::Exit(object) |
||||
IL_001c: endfinally |
||||
} // end handler |
||||
IL_001d: ret |
||||
} // end of method Lock::LockThis |
||||
|
||||
.method public hidebysig instance void |
||||
LockOnType() cil managed |
||||
{ |
||||
// Code size 39 (0x27) |
||||
.maxstack 2 |
||||
.locals init (class [mscorlib]System.Type V_0, |
||||
bool V_1) |
||||
IL_0000: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
IL_0005: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) |
||||
IL_000a: stloc.0 |
||||
IL_000b: ldc.i4.0 |
||||
IL_000c: stloc.1 |
||||
.try |
||||
{ |
||||
IL_000d: ldloc.0 |
||||
IL_000e: ldloca.s V_1 |
||||
IL_0010: call void [mscorlib]System.Threading.Monitor::Enter(object, |
||||
bool&) |
||||
IL_0015: call void [mscorlib]System.Console::WriteLine() |
||||
IL_001a: leave.s IL_0026 |
||||
|
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_001c: ldloc.1 |
||||
IL_001d: brfalse.s IL_0025 |
||||
|
||||
IL_001f: ldloc.0 |
||||
IL_0020: call void [mscorlib]System.Threading.Monitor::Exit(object) |
||||
IL_0025: endfinally |
||||
} // end handler |
||||
IL_0026: ret |
||||
} // end of method Lock::LockOnType |
||||
|
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor() cil managed |
||||
{ |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: ret |
||||
} // end of method Lock::.ctor |
||||
|
||||
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
|
||||
|
||||
// ============================================================= |
||||
|
||||
// *********** DISASSEMBLY COMPLETE *********************** |
@ -0,0 +1,138 @@
@@ -0,0 +1,138 @@
|
||||
|
||||
// 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 Lock |
||||
{ |
||||
.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 Lock.dll |
||||
// MVID: {3273D43A-61AF-4B6E-B6CF-5B3C9A7E807A} |
||||
.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: 0x029B0000 |
||||
|
||||
|
||||
// =============== CLASS MEMBERS DECLARATION =================== |
||||
|
||||
.class public auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.method public hidebysig instance void |
||||
LockThis() cil managed |
||||
{ |
||||
// Code size 36 (0x24) |
||||
.maxstack 2 |
||||
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock V_0, |
||||
bool V_1) |
||||
IL_0000: nop |
||||
IL_0001: ldarg.0 |
||||
IL_0002: stloc.0 |
||||
IL_0003: ldc.i4.0 |
||||
IL_0004: stloc.1 |
||||
.try |
||||
{ |
||||
IL_0005: ldloc.0 |
||||
IL_0006: ldloca.s V_1 |
||||
IL_0008: call void [mscorlib]System.Threading.Monitor::Enter(object, |
||||
bool&) |
||||
IL_000d: nop |
||||
IL_000e: nop |
||||
IL_000f: call void [mscorlib]System.Console::WriteLine() |
||||
IL_0014: nop |
||||
IL_0015: nop |
||||
IL_0016: leave.s IL_0023 |
||||
|
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0018: ldloc.1 |
||||
IL_0019: brfalse.s IL_0022 |
||||
|
||||
IL_001b: ldloc.0 |
||||
IL_001c: call void [mscorlib]System.Threading.Monitor::Exit(object) |
||||
IL_0021: nop |
||||
IL_0022: endfinally |
||||
} // end handler |
||||
IL_0023: ret |
||||
} // end of method Lock::LockThis |
||||
|
||||
.method public hidebysig instance void |
||||
LockOnType() cil managed |
||||
{ |
||||
// Code size 45 (0x2d) |
||||
.maxstack 2 |
||||
.locals init (class [mscorlib]System.Type V_0, |
||||
bool V_1) |
||||
IL_0000: nop |
||||
IL_0001: ldtoken ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
IL_0006: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) |
||||
IL_000b: stloc.0 |
||||
IL_000c: ldc.i4.0 |
||||
IL_000d: stloc.1 |
||||
.try |
||||
{ |
||||
IL_000e: ldloc.0 |
||||
IL_000f: ldloca.s V_1 |
||||
IL_0011: call void [mscorlib]System.Threading.Monitor::Enter(object, |
||||
bool&) |
||||
IL_0016: nop |
||||
IL_0017: nop |
||||
IL_0018: call void [mscorlib]System.Console::WriteLine() |
||||
IL_001d: nop |
||||
IL_001e: nop |
||||
IL_001f: leave.s IL_002c |
||||
|
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0021: ldloc.1 |
||||
IL_0022: brfalse.s IL_002b |
||||
|
||||
IL_0024: ldloc.0 |
||||
IL_0025: call void [mscorlib]System.Threading.Monitor::Exit(object) |
||||
IL_002a: nop |
||||
IL_002b: endfinally |
||||
} // end handler |
||||
IL_002c: ret |
||||
} // end of method Lock::LockOnType |
||||
|
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor() cil managed |
||||
{ |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: nop |
||||
IL_0007: ret |
||||
} // end of method Lock::.ctor |
||||
|
||||
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Lock |
||||
|
||||
|
||||
// ============================================================= |
||||
|
||||
// *********** DISASSEMBLY COMPLETE *********************** |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
|
||||
namespace ICSharpCode.Decompiler.IL |
||||
{ |
||||
partial class LockInstruction |
||||
{ |
||||
protected override InstructionFlags ComputeFlags() |
||||
{ |
||||
return Body.Flags | OnExpression.Flags | InstructionFlags.ControlFlow | InstructionFlags.SideEffect; |
||||
} |
||||
|
||||
public override InstructionFlags DirectFlags => InstructionFlags.ControlFlow | InstructionFlags.SideEffect; |
||||
|
||||
public override StackType ResultType => StackType.Void; |
||||
|
||||
public override void WriteTo(ITextOutput output) |
||||
{ |
||||
output.Write(".lock ("); |
||||
OnExpression.WriteTo(output); |
||||
output.WriteLine(") {"); |
||||
output.Indent(); |
||||
Body.WriteTo(output); |
||||
output.Unindent(); |
||||
output.WriteLine(); |
||||
output.Write("}"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,225 @@
@@ -0,0 +1,225 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
using ICSharpCode.Decompiler.TypeSystem; |
||||
|
||||
namespace ICSharpCode.Decompiler.IL.Transforms |
||||
{ |
||||
class LockTransform : IBlockTransform |
||||
{ |
||||
BlockTransformContext context; |
||||
|
||||
void IBlockTransform.Run(Block block, BlockTransformContext context) |
||||
{ |
||||
if (!context.Settings.LockStatement) return; |
||||
this.context = context; |
||||
for (int i = block.Instructions.Count - 1; i >= 0; i--) { |
||||
if (!TransformLockRoslyn(block, i)) |
||||
if (!TransformLockV4(block, i)) |
||||
TransformLockV2(block, i); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// stloc lockObj(ldloc tempVar)
|
||||
/// call Enter(ldloc tempVar)
|
||||
/// .try BlockContainer {
|
||||
/// Block lockBlock(incoming: 1) {
|
||||
/// call WriteLine()
|
||||
/// leave lockBlock (nop)
|
||||
/// }
|
||||
/// } finally BlockContainer {
|
||||
/// Block exitBlock(incoming: 1) {
|
||||
/// call Exit(ldloc lockObj)
|
||||
/// leave exitBlock (nop)
|
||||
/// }
|
||||
/// }
|
||||
/// .lock (lockObj) BlockContainer {
|
||||
/// Block lockBlock (incoming: 1) {
|
||||
/// call WriteLine()
|
||||
/// leave lockBlock (nop)
|
||||
/// }
|
||||
/// }
|
||||
/// </summary>
|
||||
bool TransformLockV2(Block block, int i) |
||||
{ |
||||
if (i < 2) return false; |
||||
if (!(block.Instructions[i] is TryFinally body) || !(block.Instructions[i - 2] is StLoc objectStore) || |
||||
!objectStore.Value.MatchLdLoc(out var tempVar) || !MatchCall(block.Instructions[i - 1] as Call, "Enter", tempVar)) |
||||
return false; |
||||
if (!objectStore.Variable.IsSingleDefinition) |
||||
return false; |
||||
if (!(body.TryBlock is BlockContainer tryContainer) || tryContainer.EntryPoint.Instructions.Count == 0 || tryContainer.EntryPoint.IncomingEdgeCount != 1) |
||||
return false; |
||||
if (!(body.FinallyBlock is BlockContainer finallyContainer) || !MatchExitBlock(finallyContainer.EntryPoint, null, objectStore.Variable)) |
||||
return false; |
||||
context.Step("LockTransformV2", block); |
||||
block.Instructions.RemoveAt(i - 1); |
||||
block.Instructions.RemoveAt(i - 2); |
||||
body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock)); |
||||
return true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// stloc flag(ldc.i4 0)
|
||||
/// .try BlockContainer {
|
||||
/// Block lockBlock (incoming: 1) {
|
||||
/// call Enter(stloc obj(lockObj), ldloca flag)
|
||||
/// call WriteLine()
|
||||
/// leave lockBlock (nop)
|
||||
/// }
|
||||
/// } finally BlockContainer {
|
||||
/// Block (incoming: 1) {
|
||||
/// if (ldloc flag) Block {
|
||||
/// call Exit(ldloc obj)
|
||||
/// }
|
||||
/// leave lockBlock (nop)
|
||||
/// }
|
||||
/// }
|
||||
/// =>
|
||||
/// .lock (lockObj) BlockContainer {
|
||||
/// Block lockBlock (incoming: 1) {
|
||||
/// call WriteLine()
|
||||
/// leave lockBlock (nop)
|
||||
/// }
|
||||
/// }
|
||||
/// </summary>
|
||||
bool TransformLockV4(Block block, int i) |
||||
{ |
||||
if (i < 1) return false; |
||||
if (!(block.Instructions[i] is TryFinally body) || !(block.Instructions[i - 1] is StLoc flagStore)) |
||||
return false; |
||||
if (!flagStore.Variable.Type.IsKnownType(KnownTypeCode.Boolean) || !flagStore.Value.MatchLdcI4(0)) |
||||
return false; |
||||
if (!(body.TryBlock is BlockContainer tryContainer) || !MatchLockEntryPoint(tryContainer.EntryPoint, flagStore.Variable, out StLoc objectStore)) |
||||
return false; |
||||
if (!(body.FinallyBlock is BlockContainer finallyContainer) || !MatchExitBlock(finallyContainer.EntryPoint, flagStore.Variable, objectStore.Variable)) |
||||
return false; |
||||
context.Step("LockTransformV4", block); |
||||
block.Instructions.RemoveAt(i - 1); |
||||
tryContainer.EntryPoint.Instructions.RemoveAt(0); |
||||
body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock)); |
||||
return true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// stloc obj(lockObj)
|
||||
/// stloc flag(ldc.i4 0)
|
||||
/// .try BlockContainer {
|
||||
/// Block lockBlock (incoming: 1) {
|
||||
/// call Enter(ldloc obj, ldloca flag)
|
||||
/// call WriteLine()
|
||||
/// leave lockBlock (nop)
|
||||
/// }
|
||||
/// } finally BlockContainer {
|
||||
/// Block (incoming: 1) {
|
||||
/// if (ldloc flag) Block {
|
||||
/// call Exit(ldloc obj)
|
||||
/// }
|
||||
/// leave lockBlock (nop)
|
||||
/// }
|
||||
/// }
|
||||
/// =>
|
||||
/// .lock (lockObj) BlockContainer {
|
||||
/// Block lockBlock (incoming: 1) {
|
||||
/// call WriteLine()
|
||||
/// leave lockBlock (nop)
|
||||
/// }
|
||||
/// }
|
||||
/// </summary>
|
||||
bool TransformLockRoslyn(Block block, int i) |
||||
{ |
||||
if (i < 2) return false; |
||||
if (!(block.Instructions[i] is TryFinally body) || !(block.Instructions[i - 1] is StLoc flagStore) || !(block.Instructions[i - 2] is StLoc objectStore)) |
||||
return false; |
||||
if (!objectStore.Variable.IsSingleDefinition || !flagStore.Variable.Type.IsKnownType(KnownTypeCode.Boolean) || !flagStore.Value.MatchLdcI4(0)) |
||||
return false; |
||||
if (!(body.TryBlock is BlockContainer tryContainer) || !MatchLockEntryPoint(tryContainer.EntryPoint, flagStore.Variable, objectStore.Variable)) |
||||
return false; |
||||
if (!(body.FinallyBlock is BlockContainer finallyContainer) || !MatchExitBlock(finallyContainer.EntryPoint, flagStore.Variable, objectStore.Variable)) |
||||
return false; |
||||
context.Step("LockTransformRoslyn", block); |
||||
block.Instructions.RemoveAt(i - 1); |
||||
block.Instructions.RemoveAt(i - 2); |
||||
tryContainer.EntryPoint.Instructions.RemoveAt(0); |
||||
body.ReplaceWith(new LockInstruction(objectStore.Value, body.TryBlock)); |
||||
return true; |
||||
} |
||||
|
||||
bool MatchExitBlock(Block entryPoint, ILVariable flag, ILVariable obj) |
||||
{ |
||||
if (entryPoint.Instructions.Count != 2 || entryPoint.IncomingEdgeCount != 1) |
||||
return false; |
||||
if (flag != null) { |
||||
if (!entryPoint.Instructions[0].MatchIfInstruction(out var cond, out var trueInst) || !(trueInst is Block trueBlock)) |
||||
return false; |
||||
if (!(cond.MatchLdLoc(flag) || (cond.MatchCompNotEquals(out var left, out var right) && left.MatchLdLoc(flag) && right.MatchLdcI4(0))) || !MatchExitBlock(trueBlock, obj)) |
||||
return false; |
||||
} else { |
||||
if (!MatchCall(entryPoint.Instructions[0] as Call, "Exit", obj)) |
||||
return false; |
||||
} |
||||
if (!entryPoint.Instructions[1].MatchLeave((BlockContainer)entryPoint.Parent, out var retVal) || !retVal.MatchNop()) |
||||
return false; |
||||
return true; |
||||
} |
||||
|
||||
bool MatchExitBlock(Block exitBlock, ILVariable obj) |
||||
{ |
||||
if (exitBlock.Instructions.Count != 1) |
||||
return false; |
||||
if (!MatchCall(exitBlock.Instructions[0] as Call, "Exit", obj)) |
||||
return false; |
||||
return true; |
||||
} |
||||
|
||||
bool MatchLockEntryPoint(Block entryPoint, ILVariable flag, ILVariable obj) |
||||
{ |
||||
if (entryPoint.Instructions.Count == 0 || entryPoint.IncomingEdgeCount != 1) |
||||
return false; |
||||
if (!MatchCall(entryPoint.Instructions[0] as Call, "Enter", obj, flag)) |
||||
return false; |
||||
return true; |
||||
} |
||||
|
||||
bool MatchLockEntryPoint(Block entryPoint, ILVariable flag, out StLoc obj) |
||||
{ |
||||
obj = null; |
||||
if (entryPoint.Instructions.Count == 0 || entryPoint.IncomingEdgeCount != 1) |
||||
return false; |
||||
if (!MatchCall(entryPoint.Instructions[0] as Call, "Enter", flag, out obj)) |
||||
return false; |
||||
return true; |
||||
} |
||||
|
||||
bool MatchCall(Call call, string methodName, ILVariable flag, out StLoc obj) |
||||
{ |
||||
obj = null; |
||||
const string ThreadingMonitor = "System.Threading.Monitor"; |
||||
if (call == null || call.Method.Name != methodName || call.Method.DeclaringType.FullName != ThreadingMonitor || |
||||
call.Method.TypeArguments.Count != 0 || call.Arguments.Count != 2) |
||||
return false; |
||||
if (!call.Arguments[1].MatchLdLoca(flag) || !(call.Arguments[0] is StLoc val)) |
||||
return false; |
||||
obj = val; |
||||
return true; |
||||
} |
||||
|
||||
bool MatchCall(Call call, string methodName, params ILVariable[] variables) |
||||
{ |
||||
const string ThreadingMonitor = "System.Threading.Monitor"; |
||||
if (call == null || call.Method.Name != methodName || call.Method.DeclaringType.FullName != ThreadingMonitor || |
||||
call.Method.TypeArguments.Count != 0 || call.Arguments.Count != variables.Length) |
||||
return false; |
||||
if (!call.Arguments[0].MatchLdLoc(variables[0])) |
||||
return false; |
||||
if (variables.Length == 2) { |
||||
if (!call.Arguments[1].MatchLdLoca(variables[1])) |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue