mirror of https://github.com/icsharpcode/ILSpy.git
128 changed files with 10982 additions and 1202 deletions
@ -1,30 +0,0 @@
@@ -1,30 +0,0 @@
|
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.FSharpPatterns |
||||
{ |
||||
[TestFixture] |
||||
public class FSharpPatternTests |
||||
{ |
||||
[Test] |
||||
public void FSharpUsingDecompilesToCSharpUsing_Debug() |
||||
{ |
||||
var ilCode = TestHelpers.FuzzyReadResource("FSharpUsing.fs.Debug.il"); |
||||
var csharpCode = TestHelpers.FuzzyReadResource("FSharpUsing.fs.Debug.cs"); |
||||
TestHelpers.RunIL(ilCode, csharpCode); |
||||
} |
||||
|
||||
[Test] |
||||
public void FSharpUsingDecompilesToCSharpUsing_Release() |
||||
{ |
||||
var ilCode = TestHelpers.FuzzyReadResource("FSharpUsing.fs.Release.il"); |
||||
var csharpCode = TestHelpers.FuzzyReadResource("FSharpUsing.fs.Release.cs"); |
||||
TestHelpers.RunIL(ilCode, csharpCode); |
||||
} |
||||
} |
||||
} |
||||
@ -1,64 +0,0 @@
@@ -1,64 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
|
||||
public static class FSharpUsingPatterns |
||||
{ |
||||
public static void sample1() |
||||
{ |
||||
using (FileStream fs = File.Create("x.txt")) |
||||
{ |
||||
fs.WriteByte((byte)1); |
||||
} |
||||
} |
||||
|
||||
public static void sample2() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
using (FileStream fs = File.Create("x.txt")) |
||||
{ |
||||
fs.WriteByte((byte)2); |
||||
Console.WriteLine("some text"); |
||||
} |
||||
} |
||||
|
||||
public static void sample3() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
using (FileStream fs = File.Create("x.txt")) |
||||
{ |
||||
fs.WriteByte((byte)3); |
||||
} |
||||
Console.WriteLine("some text"); |
||||
} |
||||
|
||||
public static void sample4() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
int num; |
||||
using (FileStream fs = File.OpenRead("x.txt")) |
||||
{ |
||||
num = fs.ReadByte(); |
||||
} |
||||
int firstByte = num; |
||||
Console.WriteLine("read:" + firstByte.ToString()); |
||||
} |
||||
|
||||
public static void sample5() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
int num; |
||||
using (FileStream fs = File.OpenRead("x.txt")) |
||||
{ |
||||
num = fs.ReadByte(); |
||||
} |
||||
int firstByte = num; |
||||
int num3; |
||||
using (FileStream fs = File.OpenRead("x.txt")) |
||||
{ |
||||
int num2 = fs.ReadByte(); |
||||
num3 = fs.ReadByte(); |
||||
} |
||||
int secondByte = num3; |
||||
Console.WriteLine("read: {0}, {1}", firstByte, secondByte); |
||||
} |
||||
} |
||||
@ -1,64 +0,0 @@
@@ -1,64 +0,0 @@
|
||||
using System; |
||||
using System.IO; |
||||
|
||||
public static class FSharpUsingPatterns |
||||
{ |
||||
public static void sample1() |
||||
{ |
||||
using (FileStream fs = File.Create("x.txt")) |
||||
{ |
||||
fs.WriteByte(1); |
||||
} |
||||
} |
||||
|
||||
public static void sample2() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
using (FileStream fs = File.Create("x.txt")) |
||||
{ |
||||
fs.WriteByte(2); |
||||
Console.WriteLine("some text"); |
||||
} |
||||
} |
||||
|
||||
public static void sample3() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
using (FileStream fs = File.Create("x.txt")) |
||||
{ |
||||
fs.WriteByte(3); |
||||
} |
||||
Console.WriteLine("some text"); |
||||
} |
||||
|
||||
public static void sample4() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
int num; |
||||
using (FileStream fs = File.OpenRead("x.txt")) |
||||
{ |
||||
num = fs.ReadByte(); |
||||
} |
||||
int firstByte = num; |
||||
Console.WriteLine("read:" + firstByte.ToString()); |
||||
} |
||||
|
||||
public static void sample5() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
int secondByte; |
||||
using (FileStream fs = File.OpenRead("x.txt")) |
||||
{ |
||||
secondByte = fs.ReadByte(); |
||||
} |
||||
int firstByte = secondByte; |
||||
int num2; |
||||
using (FileStream fs = File.OpenRead("x.txt")) |
||||
{ |
||||
int num = fs.ReadByte(); |
||||
num2 = fs.ReadByte(); |
||||
} |
||||
secondByte = num2; |
||||
Console.WriteLine("read: {0}, {1}", firstByte, secondByte); |
||||
} |
||||
} |
||||
@ -1,87 +0,0 @@
@@ -1,87 +0,0 @@
|
||||
using ICSharpCode.Decompiler.Ast; |
||||
using ICSharpCode.Decompiler.Tests.Helpers; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using Mono.Cecil; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.FSharpPatterns |
||||
{ |
||||
public class TestHelpers |
||||
{ |
||||
public static string FuzzyReadResource(string resourceName) |
||||
{ |
||||
var asm = Assembly.GetExecutingAssembly(); |
||||
var allResources = asm.GetManifestResourceNames(); |
||||
var fullResourceName = allResources.Single(r => r.EndsWith(resourceName, StringComparison.OrdinalIgnoreCase)); |
||||
return new StreamReader(asm.GetManifestResourceStream(fullResourceName)).ReadToEnd(); |
||||
} |
||||
|
||||
static Lazy<string> ilasm = new Lazy<string>(() => ToolLocator.FindTool("ilasm.exe")); |
||||
static Lazy<string> ildasm = new Lazy<string>(() => ToolLocator.FindTool("ildasm.exe")); |
||||
|
||||
public static string CompileIL(string source) |
||||
{ |
||||
if (ilasm.Value == null) |
||||
Assert.NotNull(ilasm.Value, "Could not find ILASM.exe"); |
||||
var tmp = Path.GetTempFileName(); |
||||
File.Delete(tmp); |
||||
var sourceFile = Path.ChangeExtension(tmp, ".il"); |
||||
File.WriteAllText(sourceFile, source); |
||||
var asmFile = Path.ChangeExtension(sourceFile, ".dll"); |
||||
|
||||
var args = string.Format("{0} /dll /debug /output:{1}", sourceFile, asmFile); |
||||
using (var proc = Process.Start(new ProcessStartInfo(ilasm.Value, args) { UseShellExecute = false, })) |
||||
{ |
||||
proc.WaitForExit(); |
||||
Assert.AreEqual(0, proc.ExitCode); |
||||
} |
||||
|
||||
File.Delete(sourceFile); |
||||
Assert.True(File.Exists(asmFile), "Assembly File does not exist"); |
||||
return asmFile; |
||||
} |
||||
|
||||
public static void RunIL(string ilCode, string expectedCSharpCode) |
||||
{ |
||||
var asmFilePath = CompileIL(ilCode); |
||||
CompareAssemblyAgainstCSharp(expectedCSharpCode, asmFilePath); |
||||
} |
||||
|
||||
private static void CompareAssemblyAgainstCSharp(string expectedCSharpCode, string asmFilePath) |
||||
{ |
||||
var module = ModuleDefinition.ReadModule(asmFilePath); |
||||
try |
||||
{ |
||||
try { module.ReadSymbols(); } catch { } |
||||
AstBuilder decompiler = new AstBuilder(new DecompilerContext(module)); |
||||
decompiler.AddAssembly(module); |
||||
new Helpers.RemoveCompilerAttribute().Run(decompiler.SyntaxTree); |
||||
StringWriter output = new StringWriter(); |
||||
|
||||
// the F# assembly contains a namespace `<StartupCode$tmp6D55>` where the part after tmp is randomly generated.
|
||||
// remove this from the ast to simplify the diff
|
||||
var startupCodeNode = decompiler.SyntaxTree.Children.OfType<NamespaceDeclaration>().SingleOrDefault(d => d.Name.StartsWith("<StartupCode$", StringComparison.Ordinal)); |
||||
if (startupCodeNode != null) |
||||
startupCodeNode.Remove(); |
||||
|
||||
decompiler.GenerateCode(new PlainTextOutput(output)); |
||||
var fullCSharpCode = output.ToString(); |
||||
|
||||
CodeAssert.AreEqual(expectedCSharpCode, output.ToString()); |
||||
} |
||||
finally |
||||
{ |
||||
File.Delete(asmFilePath); |
||||
File.Delete(Path.ChangeExtension(asmFilePath, ".pdb")); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -1,99 +0,0 @@
@@ -1,99 +0,0 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.FSharpPatterns |
||||
{ |
||||
public class ToolLocator |
||||
{ |
||||
public static string FindTool(string fileName) |
||||
{ |
||||
var allPaths = FindPathForDotNetFramework().Concat(FindPathForWindowsSdk()); |
||||
return allPaths.Select(dir => Path.Combine(dir, fileName)).FirstOrDefault(File.Exists); |
||||
} |
||||
|
||||
private static IEnumerable<string> FindPathForWindowsSdk() |
||||
{ |
||||
string[] windowsSdkPaths = new[] |
||||
{ |
||||
@"Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\", |
||||
@"Microsoft SDKs\Windows\v8.0A\bin\", |
||||
@"Microsoft SDKs\Windows\v8.0\bin\NETFX 4.0 Tools\", |
||||
@"Microsoft SDKs\Windows\v8.0\bin\", |
||||
@"Microsoft SDKs\Windows\v7.1A\bin\NETFX 4.0 Tools\", |
||||
@"Microsoft SDKs\Windows\v7.1A\bin\", |
||||
@"Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\", |
||||
@"Microsoft SDKs\Windows\v7.0A\bin\", |
||||
@"Microsoft SDKs\Windows\v6.1A\bin\", |
||||
@"Microsoft SDKs\Windows\v6.0A\bin\", |
||||
@"Microsoft SDKs\Windows\v6.0\bin\", |
||||
@"Microsoft.NET\FrameworkSDK\bin" |
||||
}; |
||||
|
||||
foreach (var possiblePath in windowsSdkPaths) |
||||
{ |
||||
string fullPath = string.Empty; |
||||
|
||||
// Check alternate program file paths as well as 64-bit versions.
|
||||
if (Environment.Is64BitProcess) |
||||
{ |
||||
fullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), possiblePath, "x64"); |
||||
if (Directory.Exists(fullPath)) |
||||
{ |
||||
yield return fullPath; |
||||
} |
||||
|
||||
fullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), possiblePath, "x64"); |
||||
if (Directory.Exists(fullPath)) |
||||
{ |
||||
yield return fullPath; |
||||
} |
||||
} |
||||
|
||||
fullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), possiblePath); |
||||
if (Directory.Exists(fullPath)) |
||||
{ |
||||
yield return fullPath; |
||||
} |
||||
|
||||
fullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), possiblePath); |
||||
if (Directory.Exists(fullPath)) |
||||
{ |
||||
yield return fullPath; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static IEnumerable<string> FindPathForDotNetFramework() |
||||
{ |
||||
string[] frameworkPaths = new[] |
||||
{ |
||||
@"Microsoft.NET\Framework\v4.0.30319", |
||||
@"Microsoft.NET\Framework\v2.0.50727" |
||||
}; |
||||
|
||||
foreach (var possiblePath in frameworkPaths) |
||||
{ |
||||
string fullPath = string.Empty; |
||||
|
||||
if (Environment.Is64BitProcess) |
||||
{ |
||||
fullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), possiblePath.Replace(@"\Framework\", @"\Framework64\")); |
||||
if (Directory.Exists(fullPath)) |
||||
{ |
||||
yield return fullPath; |
||||
} |
||||
} |
||||
|
||||
fullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), possiblePath); |
||||
if (Directory.Exists(fullPath)) |
||||
{ |
||||
yield return fullPath; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
open System |
||||
|
||||
let disposable() = { new IDisposable with member x.Dispose() = () } |
||||
|
||||
let getSeq() = seq { yield 1; } |
||||
let getList() = [ 1 ] |
||||
let getArray() = [| 1 |] |
||||
|
||||
[<EntryPoint>] |
||||
let main argv = |
||||
|
||||
// nested using scopes? |
||||
use disp1 = |
||||
use disp2 = disposable() |
||||
Console.WriteLine "Hello 1" |
||||
disposable() |
||||
|
||||
// for loop over seq |
||||
for i in getSeq() do |
||||
Console.WriteLine i |
||||
|
||||
// for loop over list |
||||
for i in getList() do |
||||
Console.WriteLine i |
||||
|
||||
// for loop over array |
||||
for i in getArray() do |
||||
Console.WriteLine i |
||||
|
||||
0 // return an integer exit code |
||||
@ -0,0 +1,209 @@
@@ -0,0 +1,209 @@
|
||||
|
||||
// C:\Users\Siegfried\Documents\Visual Studio 2017\Projects\ConsoleApp13\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
|
||||
// ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Global type: <Module>
|
||||
// Entry point: Program.main
|
||||
// Architecture: AnyCPU (32-bit preferred)
|
||||
// Runtime: .NET 4.0
|
||||
|
||||
using Microsoft.FSharp.Collections; |
||||
using Microsoft.FSharp.Core; |
||||
using Microsoft.FSharp.Core.CompilerServices; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
using System.Runtime.Versioning; |
||||
|
||||
[assembly: FSharpInterfaceDataVersion(2, 0, 0)] |
||||
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")] |
||||
[assembly: AssemblyTitle("ConsoleApplication1")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("ConsoleApplication1")] |
||||
[assembly: AssemblyCopyright("Copyright © 2017")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
[assembly: ComVisible(false)] |
||||
[assembly: Guid("e0674ff5-5e8f-4d4e-a88f-e447192454c7")] |
||||
[assembly: AssemblyVersion("1.0.0.0")] |
||||
[assembly: AssemblyFileVersion("1.0.0.0")] |
||||
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations)] |
||||
[assembly: AssemblyVersion("1.0.0.0")] |
||||
[CompilationMapping(SourceConstructFlags.Module)] |
||||
public static class Program |
||||
{ |
||||
[Serializable] |
||||
[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)] |
||||
[CompilationMapping(SourceConstructFlags.Closure)] |
||||
internal sealed class disposable@3 : IDisposable |
||||
{ |
||||
public disposable@3() |
||||
{ |
||||
((object)this)..ctor(); |
||||
} |
||||
|
||||
private void System-IDisposable-Dispose() |
||||
{ |
||||
} |
||||
|
||||
void IDisposable.Dispose() |
||||
{ |
||||
//ILSpy generated this explicit interface implementation from .override directive in System-IDisposable-Dispose
|
||||
this.System-IDisposable-Dispose(); |
||||
} |
||||
} |
||||
|
||||
[Serializable] |
||||
[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)] |
||||
[CompilationMapping(SourceConstructFlags.Closure)] |
||||
internal sealed class getSeq@5 : GeneratedSequenceBase<int> |
||||
{ |
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] |
||||
[CompilerGenerated] |
||||
[DebuggerNonUserCode] |
||||
public int pc = pc; |
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] |
||||
[CompilerGenerated] |
||||
[DebuggerNonUserCode] |
||||
public int current = current; |
||||
|
||||
public getSeq@5(int pc, int current) |
||||
{ |
||||
} |
||||
|
||||
public override int GenerateNext(ref IEnumerable<int> next) |
||||
{ |
||||
switch (this.pc) |
||||
{ |
||||
default: |
||||
this.pc = 1; |
||||
this.current = 1; |
||||
return 1; |
||||
case 1: |
||||
this.pc = 2; |
||||
break; |
||||
case 2: |
||||
break; |
||||
} |
||||
this.current = 0; |
||||
return 0; |
||||
} |
||||
|
||||
public override void Close() |
||||
{ |
||||
this.pc = 2; |
||||
} |
||||
|
||||
public override bool get_CheckClose() |
||||
{ |
||||
switch (this.pc) |
||||
{ |
||||
default: |
||||
return false; |
||||
case 0: |
||||
case 2: |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
[CompilerGenerated] |
||||
[DebuggerNonUserCode] |
||||
public override int get_LastGenerated() |
||||
{ |
||||
return this.current; |
||||
} |
||||
|
||||
[CompilerGenerated] |
||||
[DebuggerNonUserCode] |
||||
public override IEnumerator<int> GetFreshEnumerator() |
||||
{ |
||||
return new getSeq@5(0, 0); |
||||
} |
||||
} |
||||
|
||||
public static IDisposable disposable() |
||||
{ |
||||
return new disposable@3(); |
||||
} |
||||
|
||||
public static IEnumerable<int> getSeq() |
||||
{ |
||||
return new getSeq@5(0, 0); |
||||
} |
||||
|
||||
public static FSharpList<int> getList() |
||||
{ |
||||
return FSharpList<int>.Cons(1, FSharpList<int>.Empty); |
||||
} |
||||
|
||||
public static int[] getArray() |
||||
{ |
||||
return new int[1] |
||||
{ |
||||
1 |
||||
}; |
||||
} |
||||
|
||||
[EntryPoint] |
||||
public static int main(string[] argv) |
||||
{ |
||||
IDisposable disposable = default(IDisposable); |
||||
using (Program.disposable()) |
||||
{ |
||||
Console.WriteLine("Hello 1"); |
||||
disposable = Program.disposable(); |
||||
} |
||||
using (disposable) |
||||
{ |
||||
IEnumerable<int> seq = Program.getSeq(); |
||||
using (IEnumerator<int> enumerator = seq.GetEnumerator()) |
||||
{ |
||||
while (true) |
||||
{ |
||||
if (!enumerator.MoveNext()) |
||||
break; |
||||
int k = enumerator.Current; |
||||
Console.WriteLine(k); |
||||
} |
||||
} |
||||
FSharpList<int> fSharpList = Program.getList(); |
||||
FSharpList<int> tailOrNull = fSharpList.TailOrNull; |
||||
while (true) |
||||
{ |
||||
if (tailOrNull == null) |
||||
break; |
||||
int j = fSharpList.HeadOrDefault; |
||||
Console.WriteLine(j); |
||||
fSharpList = tailOrNull; |
||||
tailOrNull = fSharpList.TailOrNull; |
||||
} |
||||
int[] array = Program.getArray(); |
||||
for (int l = 0; l < array.Length; l++) |
||||
{ |
||||
int i = array[l]; |
||||
Console.WriteLine(i); |
||||
} |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
namespace <StartupCode$ConsoleApplication1> |
||||
{ |
||||
internal static class $Program |
||||
{ |
||||
} |
||||
internal static class $AssemblyInfo |
||||
{ |
||||
} |
||||
} |
||||
namespace <StartupCode$ConsoleApplication1>.$.NETFramework,Version=v4.6.1 |
||||
{ |
||||
internal static class AssemblyAttributes |
||||
{ |
||||
} |
||||
} |
||||
@ -0,0 +1,586 @@
@@ -0,0 +1,586 @@
|
||||
// C:\Users\Siegfried\Documents\Visual Studio 2017\Projects\ConsoleApp13\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe |
||||
|
||||
.assembly extern mscorlib |
||||
{ |
||||
.publickeytoken = ( |
||||
b7 7a 5c 56 19 34 e0 89 |
||||
) |
||||
.ver 4:0:0:0 |
||||
} |
||||
.assembly extern FSharp.Core |
||||
{ |
||||
.publickeytoken = ( |
||||
b0 3f 5f 7f 11 d5 0a 3a |
||||
) |
||||
.ver 4:4:1:0 |
||||
} |
||||
.assembly ConsoleApplication1 |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, int32, int32) = ( |
||||
01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( |
||||
01 00 1c 2e 4e 45 54 46 72 61 6d 65 77 6f 72 6b |
||||
2c 56 65 72 73 69 6f 6e 3d 76 34 2e 36 2e 31 01 |
||||
00 54 0e 14 46 72 61 6d 65 77 6f 72 6b 44 69 73 |
||||
70 6c 61 79 4e 61 6d 65 14 2e 4e 45 54 20 46 72 |
||||
61 6d 65 77 6f 72 6b 20 34 2e 36 2e 31 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( |
||||
01 00 13 43 6f 6e 73 6f 6c 65 41 70 70 6c 69 63 |
||||
61 74 69 6f 6e 31 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( |
||||
01 00 13 43 6f 6e 73 6f 6c 65 41 70 70 6c 69 63 |
||||
61 74 69 6f 6e 31 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( |
||||
01 00 12 43 6f 70 79 72 69 67 68 74 20 c2 a9 20 |
||||
20 32 30 31 37 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyCultureAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( |
||||
01 00 24 65 30 36 37 34 66 66 35 2d 35 65 38 66 |
||||
2d 34 64 34 65 2d 61 38 38 66 2d 65 34 34 37 31 |
||||
39 32 34 35 34 63 37 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyVersionAttribute::.ctor(string) = ( |
||||
01 00 07 31 2e 30 2e 30 2e 30 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( |
||||
01 00 07 31 2e 30 2e 30 2e 30 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( |
||||
01 00 01 01 00 00 00 00 |
||||
) |
||||
.hash algorithm 0x00008004 // SHA1 |
||||
.ver 1:0:0:0 |
||||
} |
||||
|
||||
.module ConsoleApplication1.exe |
||||
// MVID: {59F64D20-6A1F-D4CE-A745-0383204DF659} |
||||
.corflags 0x00020003 // ILOnly, Required32Bit, Preferred32Bit |
||||
|
||||
|
||||
.class private auto ansi '<Module>' |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
} // end of class <Module> |
||||
|
||||
.class public auto ansi abstract sealed Program |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( |
||||
01 00 07 00 00 00 00 00 |
||||
) |
||||
// Nested Types |
||||
.class nested assembly auto auto sealed specialname serializable beforefieldinit disposable@3 |
||||
extends [mscorlib]System.Object |
||||
implements [mscorlib]System.IDisposable |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( |
||||
01 00 06 00 00 00 00 00 |
||||
) |
||||
// Methods |
||||
.method public specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x21c8 |
||||
// Code size 9 (0x9) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: callvirt instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: ldarg.0 |
||||
IL_0007: pop |
||||
IL_0008: ret |
||||
} // end of method disposable@3::.ctor |
||||
|
||||
.method private final hidebysig newslot virtual |
||||
instance void 'System-IDisposable-Dispose' () cil managed |
||||
{ |
||||
.override method instance void [mscorlib]System.IDisposable::Dispose() |
||||
// Method begins at RVA 0x21d4 |
||||
// Code size 1 (0x1) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ret |
||||
} // end of method disposable@3::'System-IDisposable-Dispose' |
||||
|
||||
} // end of class disposable@3 |
||||
|
||||
.class nested assembly auto auto sealed specialname serializable beforefieldinit getSeq@5 |
||||
extends class [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1<int32> |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( |
||||
01 00 06 00 00 00 00 00 |
||||
) |
||||
// Fields |
||||
.field public int32 pc |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( |
||||
01 00 00 00 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.field public int32 current |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( |
||||
01 00 00 00 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
|
||||
// Methods |
||||
.method public specialname rtspecialname |
||||
instance void .ctor ( |
||||
int32 pc, |
||||
int32 current |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x21d8 |
||||
// Code size 21 (0x15) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld int32 Program/getSeq@5::pc |
||||
IL_0007: ldarg.0 |
||||
IL_0008: ldarg.2 |
||||
IL_0009: stfld int32 Program/getSeq@5::current |
||||
IL_000e: ldarg.0 |
||||
IL_000f: call instance void class [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1<int32>::.ctor() |
||||
IL_0014: ret |
||||
} // end of method getSeq@5::.ctor |
||||
|
||||
.method public strict virtual |
||||
instance int32 GenerateNext ( |
||||
class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>& next |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x21f0 |
||||
// Code size 66 (0x42) |
||||
.maxstack 6 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld int32 Program/getSeq@5::pc |
||||
IL_0006: ldc.i4.1 |
||||
IL_0007: sub |
||||
IL_0008: switch (IL_0017, IL_0019) |
||||
|
||||
IL_0015: br.s IL_0021 |
||||
|
||||
IL_0017: br.s IL_001b |
||||
|
||||
IL_0019: br.s IL_001e |
||||
|
||||
IL_001b: nop |
||||
IL_001c: br.s IL_0032 |
||||
|
||||
IL_001e: nop |
||||
IL_001f: br.s IL_0039 |
||||
|
||||
IL_0021: nop |
||||
IL_0022: ldarg.0 |
||||
IL_0023: ldc.i4.1 |
||||
IL_0024: stfld int32 Program/getSeq@5::pc |
||||
IL_0029: ldarg.0 |
||||
IL_002a: ldc.i4.1 |
||||
IL_002b: stfld int32 Program/getSeq@5::current |
||||
IL_0030: ldc.i4.1 |
||||
IL_0031: ret |
||||
|
||||
IL_0032: ldarg.0 |
||||
IL_0033: ldc.i4.2 |
||||
IL_0034: stfld int32 Program/getSeq@5::pc |
||||
|
||||
IL_0039: ldarg.0 |
||||
IL_003a: ldc.i4.0 |
||||
IL_003b: stfld int32 Program/getSeq@5::current |
||||
IL_0040: ldc.i4.0 |
||||
IL_0041: ret |
||||
} // end of method getSeq@5::GenerateNext |
||||
|
||||
.method public strict virtual |
||||
instance void Close () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2240 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldc.i4.2 |
||||
IL_0002: stfld int32 Program/getSeq@5::pc |
||||
IL_0007: ret |
||||
} // end of method getSeq@5::Close |
||||
|
||||
.method public strict virtual |
||||
instance bool get_CheckClose () cil managed |
||||
{ |
||||
// Method begins at RVA 0x224c |
||||
// Code size 45 (0x2d) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld int32 Program/getSeq@5::pc |
||||
IL_0006: switch (IL_0019, IL_001b, IL_001d) |
||||
|
||||
IL_0017: br.s IL_0028 |
||||
|
||||
IL_0019: br.s IL_001f |
||||
|
||||
IL_001b: br.s IL_0022 |
||||
|
||||
IL_001d: br.s IL_0025 |
||||
|
||||
IL_001f: nop |
||||
IL_0020: br.s IL_002b |
||||
|
||||
IL_0022: nop |
||||
IL_0023: br.s IL_0029 |
||||
|
||||
IL_0025: nop |
||||
IL_0026: br.s IL_002b |
||||
|
||||
IL_0028: nop |
||||
|
||||
IL_0029: ldc.i4.0 |
||||
IL_002a: ret |
||||
|
||||
IL_002b: ldc.i4.0 |
||||
IL_002c: ret |
||||
} // end of method getSeq@5::get_CheckClose |
||||
|
||||
.method public strict virtual |
||||
instance int32 get_LastGenerated () cil managed |
||||
{ |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
// Method begins at RVA 0x227c |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld int32 Program/getSeq@5::current |
||||
IL_0006: ret |
||||
} // end of method getSeq@5::get_LastGenerated |
||||
|
||||
.method public strict virtual |
||||
instance class [mscorlib]System.Collections.Generic.IEnumerator`1<int32> GetFreshEnumerator () cil managed |
||||
{ |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
// Method begins at RVA 0x2284 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldc.i4.0 |
||||
IL_0001: ldc.i4.0 |
||||
IL_0002: newobj instance void Program/getSeq@5::.ctor(int32, int32) |
||||
IL_0007: ret |
||||
} // end of method getSeq@5::GetFreshEnumerator |
||||
|
||||
} // end of class getSeq@5 |
||||
|
||||
|
||||
// Methods |
||||
.method public static |
||||
class [mscorlib]System.IDisposable disposable () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Code size 6 (0x6) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: newobj instance void Program/disposable@3::.ctor() |
||||
IL_0005: ret |
||||
} // end of method Program::disposable |
||||
|
||||
.method public static |
||||
class [mscorlib]System.Collections.Generic.IEnumerable`1<int32> getSeq () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2058 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldc.i4.0 |
||||
IL_0001: ldc.i4.0 |
||||
IL_0002: newobj instance void Program/getSeq@5::.ctor(int32, int32) |
||||
IL_0007: ret |
||||
} // end of method Program::getSeq |
||||
|
||||
.method public static |
||||
class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32> getList () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2064 |
||||
// Code size 12 (0xc) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldc.i4.1 |
||||
IL_0001: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_Empty() |
||||
IL_0006: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::Cons(!0, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0>) |
||||
IL_000b: ret |
||||
} // end of method Program::getList |
||||
|
||||
.method public static |
||||
int32[] getArray () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2074 |
||||
// Code size 15 (0xf) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldc.i4.1 |
||||
IL_0001: newarr [mscorlib]System.Int32 |
||||
IL_0006: dup |
||||
IL_0007: ldc.i4.0 |
||||
IL_0008: ldc.i4.1 |
||||
IL_0009: stelem.any [mscorlib]System.Int32 |
||||
IL_000e: ret |
||||
} // end of method Program::getArray |
||||
|
||||
.method public static |
||||
int32 main ( |
||||
string[] argv |
||||
) cil managed |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.EntryPointAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
// Method begins at RVA 0x2084 |
||||
// Code size 270 (0x10e) |
||||
.maxstack 4 |
||||
.entrypoint |
||||
.locals init ( |
||||
[0] class [mscorlib]System.IDisposable, |
||||
[1] class [mscorlib]System.IDisposable, |
||||
[2] class [mscorlib]System.IDisposable, |
||||
[3] class [mscorlib]System.IDisposable, |
||||
[4] int32, |
||||
[5] class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>, |
||||
[6] class [mscorlib]System.Collections.Generic.IEnumerator`1<int32>, |
||||
[7] class [FSharp.Core]Microsoft.FSharp.Core.Unit, |
||||
[8] int32, |
||||
[9] class [mscorlib]System.IDisposable, |
||||
[10] class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>, |
||||
[11] class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>, |
||||
[12] int32, |
||||
[13] int32[], |
||||
[14] int32, |
||||
[15] int32, |
||||
[16] class [mscorlib]System.IDisposable |
||||
) |
||||
|
||||
IL_0000: call class [mscorlib]System.IDisposable Program::disposable() |
||||
IL_0005: stloc.1 |
||||
.try |
||||
{ |
||||
IL_0006: ldstr "Hello 1" |
||||
IL_000b: call void [mscorlib]System.Console::WriteLine(string) |
||||
IL_0010: call class [mscorlib]System.IDisposable Program::disposable() |
||||
IL_0015: stloc.2 |
||||
IL_0016: leave.s IL_0032 |
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0018: ldloc.1 |
||||
IL_0019: isinst [mscorlib]System.IDisposable |
||||
IL_001e: stloc.3 |
||||
IL_001f: ldloc.3 |
||||
IL_0020: brfalse.s IL_0024 |
||||
|
||||
IL_0022: br.s IL_0026 |
||||
|
||||
IL_0024: br.s IL_002f |
||||
|
||||
IL_0026: ldloc.3 |
||||
IL_0027: callvirt instance void [mscorlib]System.IDisposable::Dispose() |
||||
IL_002c: ldnull |
||||
IL_002d: pop |
||||
IL_002e: endfinally |
||||
|
||||
IL_002f: ldnull |
||||
IL_0030: pop |
||||
IL_0031: endfinally |
||||
} // end handler |
||||
|
||||
IL_0032: ldloc.2 |
||||
IL_0033: stloc.0 |
||||
.try |
||||
{ |
||||
IL_0034: call class [mscorlib]System.Collections.Generic.IEnumerable`1<int32> Program::getSeq() |
||||
IL_0039: stloc.s 5 |
||||
IL_003b: ldloc.s 5 |
||||
IL_003d: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>::GetEnumerator() |
||||
IL_0042: stloc.s 6 |
||||
.try |
||||
{ |
||||
// loop start (head: IL_0044) |
||||
IL_0044: ldloc.s 6 |
||||
IL_0046: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() |
||||
IL_004b: brfalse.s IL_0060 |
||||
|
||||
IL_004d: ldloc.s 6 |
||||
IL_004f: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<int32>::get_Current() |
||||
IL_0054: stloc.s 8 |
||||
IL_0056: ldloc.s 8 |
||||
IL_0058: call void [mscorlib]System.Console::WriteLine(int32) |
||||
IL_005d: nop |
||||
IL_005e: br.s IL_0044 |
||||
// end loop |
||||
|
||||
IL_0060: ldnull |
||||
IL_0061: stloc.s 7 |
||||
IL_0063: leave.s IL_0083 |
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0065: ldloc.s 6 |
||||
IL_0067: isinst [mscorlib]System.IDisposable |
||||
IL_006c: stloc.s 9 |
||||
IL_006e: ldloc.s 9 |
||||
IL_0070: brfalse.s IL_0074 |
||||
|
||||
IL_0072: br.s IL_0076 |
||||
|
||||
IL_0074: br.s IL_0080 |
||||
|
||||
IL_0076: ldloc.s 9 |
||||
IL_0078: callvirt instance void [mscorlib]System.IDisposable::Dispose() |
||||
IL_007d: ldnull |
||||
IL_007e: pop |
||||
IL_007f: endfinally |
||||
|
||||
IL_0080: ldnull |
||||
IL_0081: pop |
||||
IL_0082: endfinally |
||||
} // end handler |
||||
|
||||
IL_0083: ldloc.s 7 |
||||
IL_0085: pop |
||||
IL_0086: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32> Program::getList() |
||||
IL_008b: stloc.s 10 |
||||
IL_008d: ldloc.s 10 |
||||
IL_008f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_TailOrNull() |
||||
IL_0094: stloc.s 11 |
||||
// loop start (head: IL_0096) |
||||
IL_0096: ldloc.s 11 |
||||
IL_0098: ldnull |
||||
IL_0099: cgt.un |
||||
IL_009b: brfalse.s IL_00bd |
||||
|
||||
IL_009d: ldloc.s 10 |
||||
IL_009f: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_HeadOrDefault() |
||||
IL_00a4: stloc.s 12 |
||||
IL_00a6: ldloc.s 12 |
||||
IL_00a8: call void [mscorlib]System.Console::WriteLine(int32) |
||||
IL_00ad: ldloc.s 11 |
||||
IL_00af: stloc.s 10 |
||||
IL_00b1: ldloc.s 10 |
||||
IL_00b3: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_TailOrNull() |
||||
IL_00b8: stloc.s 11 |
||||
IL_00ba: nop |
||||
IL_00bb: br.s IL_0096 |
||||
// end loop |
||||
|
||||
IL_00bd: call int32[] Program::getArray() |
||||
IL_00c2: stloc.s 13 |
||||
IL_00c4: ldc.i4.0 |
||||
IL_00c5: stloc.s 14 |
||||
IL_00c7: br.s IL_00e1 |
||||
// loop start (head: IL_00e1) |
||||
IL_00c9: ldloc.s 13 |
||||
IL_00cb: ldloc.s 14 |
||||
IL_00cd: ldelem.any [mscorlib]System.Int32 |
||||
IL_00d2: stloc.s 15 |
||||
IL_00d4: ldloc.s 15 |
||||
IL_00d6: call void [mscorlib]System.Console::WriteLine(int32) |
||||
IL_00db: ldloc.s 14 |
||||
IL_00dd: ldc.i4.1 |
||||
IL_00de: add |
||||
IL_00df: stloc.s 14 |
||||
|
||||
IL_00e1: ldloc.s 14 |
||||
IL_00e3: ldloc.s 13 |
||||
IL_00e5: ldlen |
||||
IL_00e6: conv.i4 |
||||
IL_00e7: blt.s IL_00c9 |
||||
// end loop |
||||
|
||||
IL_00e9: ldc.i4.0 |
||||
IL_00ea: stloc.s 4 |
||||
IL_00ec: leave.s IL_010b |
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_00ee: ldloc.0 |
||||
IL_00ef: isinst [mscorlib]System.IDisposable |
||||
IL_00f4: stloc.s 16 |
||||
IL_00f6: ldloc.s 16 |
||||
IL_00f8: brfalse.s IL_00fc |
||||
|
||||
IL_00fa: br.s IL_00fe |
||||
|
||||
IL_00fc: br.s IL_0108 |
||||
|
||||
IL_00fe: ldloc.s 16 |
||||
IL_0100: callvirt instance void [mscorlib]System.IDisposable::Dispose() |
||||
IL_0105: ldnull |
||||
IL_0106: pop |
||||
IL_0107: endfinally |
||||
|
||||
IL_0108: ldnull |
||||
IL_0109: pop |
||||
IL_010a: endfinally |
||||
} // end handler |
||||
|
||||
IL_010b: ldloc.s 4 |
||||
IL_010d: ret |
||||
} // end of method Program::main |
||||
|
||||
} // end of class Program |
||||
|
||||
.class private auto ansi abstract sealed '<StartupCode$ConsoleApplication1>.$Program' |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
} // end of class <StartupCode$ConsoleApplication1>.$Program |
||||
|
||||
.class private auto ansi abstract sealed '<StartupCode$ConsoleApplication1>.$AssemblyInfo' |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
} // end of class <StartupCode$ConsoleApplication1>.$AssemblyInfo |
||||
|
||||
.class private auto ansi abstract sealed '<StartupCode$ConsoleApplication1>.$.NETFramework,Version=v4.6.1.AssemblyAttributes' |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
} // end of class <StartupCode$ConsoleApplication1>.$.NETFramework,Version=v4.6.1.AssemblyAttributes |
||||
|
||||
@ -0,0 +1,210 @@
@@ -0,0 +1,210 @@
|
||||
|
||||
// C:\Users\Siegfried\Documents\Visual Studio 2017\Projects\ConsoleApp13\ConsoleApplication1\bin\Release\ConsoleApplication1.exe
|
||||
// ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Global type: <Module>
|
||||
// Entry point: Program.main
|
||||
// Architecture: AnyCPU (32-bit preferred)
|
||||
// Runtime: .NET 4.0
|
||||
|
||||
using Microsoft.FSharp.Collections; |
||||
using Microsoft.FSharp.Core; |
||||
using Microsoft.FSharp.Core.CompilerServices; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
using System.Runtime.Versioning; |
||||
|
||||
[assembly: FSharpInterfaceDataVersion(2, 0, 0)] |
||||
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")] |
||||
[assembly: AssemblyTitle("ConsoleApplication1")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("ConsoleApplication1")] |
||||
[assembly: AssemblyCopyright("Copyright © 2017")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
[assembly: ComVisible(false)] |
||||
[assembly: Guid("e0674ff5-5e8f-4d4e-a88f-e447192454c7")] |
||||
[assembly: AssemblyVersion("1.0.0.0")] |
||||
[assembly: AssemblyFileVersion("1.0.0.0")] |
||||
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.None)] |
||||
[assembly: AssemblyVersion("1.0.0.0")] |
||||
[CompilationMapping(SourceConstructFlags.Module)] |
||||
public static class Program |
||||
{ |
||||
[Serializable] |
||||
[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)] |
||||
[CompilationMapping(SourceConstructFlags.Closure)] |
||||
internal sealed class disposable@3 : IDisposable |
||||
{ |
||||
public disposable@3() |
||||
{ |
||||
((object)this)..ctor(); |
||||
} |
||||
|
||||
private void System-IDisposable-Dispose() |
||||
{ |
||||
} |
||||
|
||||
void IDisposable.Dispose() |
||||
{ |
||||
//ILSpy generated this explicit interface implementation from .override directive in System-IDisposable-Dispose
|
||||
this.System-IDisposable-Dispose(); |
||||
} |
||||
} |
||||
|
||||
[Serializable] |
||||
[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)] |
||||
[CompilationMapping(SourceConstructFlags.Closure)] |
||||
internal sealed class getSeq@5 : GeneratedSequenceBase<int> |
||||
{ |
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] |
||||
[CompilerGenerated] |
||||
[DebuggerNonUserCode] |
||||
public int pc = pc; |
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] |
||||
[CompilerGenerated] |
||||
[DebuggerNonUserCode] |
||||
public int current = current; |
||||
|
||||
public getSeq@5(int pc, int current) |
||||
{ |
||||
} |
||||
|
||||
public override int GenerateNext(ref IEnumerable<int> next) |
||||
{ |
||||
switch (this.pc) |
||||
{ |
||||
default: |
||||
this.pc = 1; |
||||
this.current = 1; |
||||
return 1; |
||||
case 1: |
||||
this.pc = 2; |
||||
break; |
||||
case 2: |
||||
break; |
||||
} |
||||
this.current = 0; |
||||
return 0; |
||||
} |
||||
|
||||
public override void Close() |
||||
{ |
||||
this.pc = 2; |
||||
} |
||||
|
||||
public override bool get_CheckClose() |
||||
{ |
||||
switch (this.pc) |
||||
{ |
||||
default: |
||||
return false; |
||||
case 0: |
||||
case 2: |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
[CompilerGenerated] |
||||
[DebuggerNonUserCode] |
||||
public override int get_LastGenerated() |
||||
{ |
||||
return this.current; |
||||
} |
||||
|
||||
[CompilerGenerated] |
||||
[DebuggerNonUserCode] |
||||
public override IEnumerator<int> GetFreshEnumerator() |
||||
{ |
||||
return new getSeq@5(0, 0); |
||||
} |
||||
} |
||||
|
||||
public static IDisposable disposable() |
||||
{ |
||||
return new disposable@3(); |
||||
} |
||||
|
||||
public static IEnumerable<int> getSeq() |
||||
{ |
||||
return new getSeq@5(0, 0); |
||||
} |
||||
|
||||
public static FSharpList<int> getList() |
||||
{ |
||||
return FSharpList<int>.Cons(1, FSharpList<int>.Empty); |
||||
} |
||||
|
||||
public static int[] getArray() |
||||
{ |
||||
return new int[1] |
||||
{ |
||||
1 |
||||
}; |
||||
} |
||||
|
||||
[EntryPoint] |
||||
public static int main(string[] argv) |
||||
{ |
||||
IDisposable disposable = default(IDisposable); |
||||
using (Program.disposable()) |
||||
{ |
||||
Console.WriteLine("Hello 1"); |
||||
disposable = Program.disposable(); |
||||
} |
||||
using (disposable) |
||||
{ |
||||
IEnumerable<int> seq = Program.getSeq(); |
||||
using (IEnumerator<int> enumerator = seq.GetEnumerator()) |
||||
{ |
||||
while (true) |
||||
{ |
||||
if (!enumerator.MoveNext()) |
||||
break; |
||||
Console.WriteLine(enumerator.Current); |
||||
} |
||||
} |
||||
FSharpList<int> fSharpList = FSharpList<int>.Cons(1, FSharpList<int>.Empty); |
||||
FSharpList<int> tailOrNull = fSharpList.TailOrNull; |
||||
while (true) |
||||
{ |
||||
if (tailOrNull == null) |
||||
break; |
||||
int j = fSharpList.HeadOrDefault; |
||||
Console.WriteLine(j); |
||||
fSharpList = tailOrNull; |
||||
tailOrNull = fSharpList.TailOrNull; |
||||
} |
||||
int[] array = new int[1] |
||||
{ |
||||
1 |
||||
}; |
||||
for (int j = 0; j < array.Length; j++) |
||||
{ |
||||
Console.WriteLine(array[j]); |
||||
} |
||||
return 0; |
||||
} |
||||
} |
||||
} |
||||
namespace <StartupCode$ConsoleApplication1> |
||||
{ |
||||
internal static class $Program |
||||
{ |
||||
} |
||||
internal static class $AssemblyInfo |
||||
{ |
||||
} |
||||
} |
||||
namespace <StartupCode$ConsoleApplication1>.$.NETFramework,Version=v4.6.1 |
||||
{ |
||||
internal static class AssemblyAttributes |
||||
{ |
||||
} |
||||
} |
||||
@ -0,0 +1,561 @@
@@ -0,0 +1,561 @@
|
||||
// C:\Users\Siegfried\Documents\Visual Studio 2017\Projects\ConsoleApp13\ConsoleApplication1\bin\Release\ConsoleApplication1.exe |
||||
|
||||
.assembly extern mscorlib |
||||
{ |
||||
.publickeytoken = ( |
||||
b7 7a 5c 56 19 34 e0 89 |
||||
) |
||||
.ver 4:0:0:0 |
||||
} |
||||
.assembly extern FSharp.Core |
||||
{ |
||||
.publickeytoken = ( |
||||
b0 3f 5f 7f 11 d5 0a 3a |
||||
) |
||||
.ver 4:4:1:0 |
||||
} |
||||
.assembly ConsoleApplication1 |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, int32, int32) = ( |
||||
01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( |
||||
01 00 1c 2e 4e 45 54 46 72 61 6d 65 77 6f 72 6b |
||||
2c 56 65 72 73 69 6f 6e 3d 76 34 2e 36 2e 31 01 |
||||
00 54 0e 14 46 72 61 6d 65 77 6f 72 6b 44 69 73 |
||||
70 6c 61 79 4e 61 6d 65 14 2e 4e 45 54 20 46 72 |
||||
61 6d 65 77 6f 72 6b 20 34 2e 36 2e 31 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( |
||||
01 00 13 43 6f 6e 73 6f 6c 65 41 70 70 6c 69 63 |
||||
61 74 69 6f 6e 31 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( |
||||
01 00 13 43 6f 6e 73 6f 6c 65 41 70 70 6c 69 63 |
||||
61 74 69 6f 6e 31 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( |
||||
01 00 12 43 6f 70 79 72 69 67 68 74 20 c2 a9 20 |
||||
20 32 30 31 37 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyCultureAttribute::.ctor(string) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( |
||||
01 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( |
||||
01 00 24 65 30 36 37 34 66 66 35 2d 35 65 38 66 |
||||
2d 34 64 34 65 2d 61 38 38 66 2d 65 34 34 37 31 |
||||
39 32 34 35 34 63 37 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyVersionAttribute::.ctor(string) = ( |
||||
01 00 07 31 2e 30 2e 30 2e 30 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( |
||||
01 00 07 31 2e 30 2e 30 2e 30 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( |
||||
01 00 00 00 00 00 00 00 |
||||
) |
||||
.hash algorithm 0x00008004 // SHA1 |
||||
.ver 1:0:0:0 |
||||
} |
||||
|
||||
.module ConsoleApplication1.exe |
||||
// MVID: {59F64D28-6A1F-D4CE-A745-0383284DF659} |
||||
.corflags 0x00020003 // ILOnly, Required32Bit, Preferred32Bit |
||||
|
||||
|
||||
.class private auto ansi '<Module>' |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
} // end of class <Module> |
||||
|
||||
.class public auto ansi abstract sealed Program |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( |
||||
01 00 07 00 00 00 00 00 |
||||
) |
||||
// Nested Types |
||||
.class nested assembly auto auto sealed specialname serializable beforefieldinit disposable@3 |
||||
extends [mscorlib]System.Object |
||||
implements [mscorlib]System.IDisposable |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( |
||||
01 00 06 00 00 00 00 00 |
||||
) |
||||
// Methods |
||||
.method public specialname rtspecialname |
||||
instance void .ctor () cil managed |
||||
{ |
||||
// Method begins at RVA 0x21bc |
||||
// Code size 9 (0x9) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: callvirt instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: ldarg.0 |
||||
IL_0007: pop |
||||
IL_0008: ret |
||||
} // end of method disposable@3::.ctor |
||||
|
||||
.method private final hidebysig newslot virtual |
||||
instance void 'System-IDisposable-Dispose' () cil managed |
||||
{ |
||||
.override method instance void [mscorlib]System.IDisposable::Dispose() |
||||
// Method begins at RVA 0x21c8 |
||||
// Code size 1 (0x1) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ret |
||||
} // end of method disposable@3::'System-IDisposable-Dispose' |
||||
|
||||
} // end of class disposable@3 |
||||
|
||||
.class nested assembly auto auto sealed specialname serializable beforefieldinit getSeq@5 |
||||
extends class [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1<int32> |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( |
||||
01 00 06 00 00 00 00 00 |
||||
) |
||||
// Fields |
||||
.field public int32 pc |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( |
||||
01 00 00 00 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.field public int32 current |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( |
||||
01 00 00 00 00 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
|
||||
// Methods |
||||
.method public specialname rtspecialname |
||||
instance void .ctor ( |
||||
int32 pc, |
||||
int32 current |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x21cc |
||||
// Code size 21 (0x15) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldarg.1 |
||||
IL_0002: stfld int32 Program/getSeq@5::pc |
||||
IL_0007: ldarg.0 |
||||
IL_0008: ldarg.2 |
||||
IL_0009: stfld int32 Program/getSeq@5::current |
||||
IL_000e: ldarg.0 |
||||
IL_000f: call instance void class [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1<int32>::.ctor() |
||||
IL_0014: ret |
||||
} // end of method getSeq@5::.ctor |
||||
|
||||
.method public strict virtual |
||||
instance int32 GenerateNext ( |
||||
class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>& next |
||||
) cil managed |
||||
{ |
||||
// Method begins at RVA 0x21e4 |
||||
// Code size 62 (0x3e) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld int32 Program/getSeq@5::pc |
||||
IL_0006: ldc.i4.1 |
||||
IL_0007: sub |
||||
IL_0008: switch (IL_0018, IL_001b) |
||||
|
||||
IL_0015: nop |
||||
IL_0016: br.s IL_001e |
||||
|
||||
IL_0018: nop |
||||
IL_0019: br.s IL_002e |
||||
|
||||
IL_001b: nop |
||||
IL_001c: br.s IL_0035 |
||||
|
||||
IL_001e: ldarg.0 |
||||
IL_001f: ldc.i4.1 |
||||
IL_0020: stfld int32 Program/getSeq@5::pc |
||||
IL_0025: ldarg.0 |
||||
IL_0026: ldc.i4.1 |
||||
IL_0027: stfld int32 Program/getSeq@5::current |
||||
IL_002c: ldc.i4.1 |
||||
IL_002d: ret |
||||
|
||||
IL_002e: ldarg.0 |
||||
IL_002f: ldc.i4.2 |
||||
IL_0030: stfld int32 Program/getSeq@5::pc |
||||
|
||||
IL_0035: ldarg.0 |
||||
IL_0036: ldc.i4.0 |
||||
IL_0037: stfld int32 Program/getSeq@5::current |
||||
IL_003c: ldc.i4.0 |
||||
IL_003d: ret |
||||
} // end of method getSeq@5::GenerateNext |
||||
|
||||
.method public strict virtual |
||||
instance void Close () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2224 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldc.i4.2 |
||||
IL_0002: stfld int32 Program/getSeq@5::pc |
||||
IL_0007: ret |
||||
} // end of method getSeq@5::Close |
||||
|
||||
.method public strict virtual |
||||
instance bool get_CheckClose () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2230 |
||||
// Code size 39 (0x27) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld int32 Program/getSeq@5::pc |
||||
IL_0006: switch (IL_001a, IL_001d, IL_0020) |
||||
|
||||
IL_0017: nop |
||||
IL_0018: br.s IL_0023 |
||||
|
||||
IL_001a: nop |
||||
IL_001b: br.s IL_0025 |
||||
|
||||
IL_001d: nop |
||||
IL_001e: br.s IL_0023 |
||||
|
||||
IL_0020: nop |
||||
IL_0021: br.s IL_0025 |
||||
|
||||
IL_0023: ldc.i4.0 |
||||
IL_0024: ret |
||||
|
||||
IL_0025: ldc.i4.0 |
||||
IL_0026: ret |
||||
} // end of method getSeq@5::get_CheckClose |
||||
|
||||
.method public strict virtual |
||||
instance int32 get_LastGenerated () cil managed |
||||
{ |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
// Method begins at RVA 0x2258 |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld int32 Program/getSeq@5::current |
||||
IL_0006: ret |
||||
} // end of method getSeq@5::get_LastGenerated |
||||
|
||||
.method public strict virtual |
||||
instance class [mscorlib]System.Collections.Generic.IEnumerator`1<int32> GetFreshEnumerator () cil managed |
||||
{ |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
// Method begins at RVA 0x2260 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldc.i4.0 |
||||
IL_0001: ldc.i4.0 |
||||
IL_0002: newobj instance void Program/getSeq@5::.ctor(int32, int32) |
||||
IL_0007: ret |
||||
} // end of method getSeq@5::GetFreshEnumerator |
||||
|
||||
} // end of class getSeq@5 |
||||
|
||||
|
||||
// Methods |
||||
.method public static |
||||
class [mscorlib]System.IDisposable disposable () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2050 |
||||
// Code size 6 (0x6) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: newobj instance void Program/disposable@3::.ctor() |
||||
IL_0005: ret |
||||
} // end of method Program::disposable |
||||
|
||||
.method public static |
||||
class [mscorlib]System.Collections.Generic.IEnumerable`1<int32> getSeq () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2058 |
||||
// Code size 8 (0x8) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldc.i4.0 |
||||
IL_0001: ldc.i4.0 |
||||
IL_0002: newobj instance void Program/getSeq@5::.ctor(int32, int32) |
||||
IL_0007: ret |
||||
} // end of method Program::getSeq |
||||
|
||||
.method public static |
||||
class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32> getList () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2064 |
||||
// Code size 12 (0xc) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldc.i4.1 |
||||
IL_0001: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_Empty() |
||||
IL_0006: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::Cons(!0, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0>) |
||||
IL_000b: ret |
||||
} // end of method Program::getList |
||||
|
||||
.method public static |
||||
int32[] getArray () cil managed |
||||
{ |
||||
// Method begins at RVA 0x2074 |
||||
// Code size 15 (0xf) |
||||
.maxstack 8 |
||||
|
||||
IL_0000: ldc.i4.1 |
||||
IL_0001: newarr [mscorlib]System.Int32 |
||||
IL_0006: dup |
||||
IL_0007: ldc.i4.0 |
||||
IL_0008: ldc.i4.1 |
||||
IL_0009: stelem.any [mscorlib]System.Int32 |
||||
IL_000e: ret |
||||
} // end of method Program::getArray |
||||
|
||||
.method public static |
||||
int32 main ( |
||||
string[] argv |
||||
) cil managed |
||||
{ |
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.EntryPointAttribute::.ctor() = ( |
||||
01 00 00 00 |
||||
) |
||||
// Method begins at RVA 0x2084 |
||||
// Code size 259 (0x103) |
||||
.maxstack 6 |
||||
.entrypoint |
||||
.locals init ( |
||||
[0] class [mscorlib]System.IDisposable, |
||||
[1] class [mscorlib]System.IDisposable, |
||||
[2] class [mscorlib]System.IDisposable, |
||||
[3] class [mscorlib]System.IDisposable, |
||||
[4] int32, |
||||
[5] class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>, |
||||
[6] class [mscorlib]System.Collections.Generic.IEnumerator`1<int32>, |
||||
[7] class [FSharp.Core]Microsoft.FSharp.Core.Unit, |
||||
[8] class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>, |
||||
[9] class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>, |
||||
[10] int32, |
||||
[11] int32[] |
||||
) |
||||
|
||||
IL_0000: call class [mscorlib]System.IDisposable Program::disposable() |
||||
IL_0005: stloc.1 |
||||
.try |
||||
{ |
||||
IL_0006: ldstr "Hello 1" |
||||
IL_000b: call void [mscorlib]System.Console::WriteLine(string) |
||||
IL_0010: call class [mscorlib]System.IDisposable Program::disposable() |
||||
IL_0015: stloc.2 |
||||
IL_0016: leave.s IL_002e |
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_0018: ldloc.1 |
||||
IL_0019: isinst [mscorlib]System.IDisposable |
||||
IL_001e: stloc.3 |
||||
IL_001f: ldloc.3 |
||||
IL_0020: brfalse.s IL_002b |
||||
|
||||
IL_0022: ldloc.3 |
||||
IL_0023: callvirt instance void [mscorlib]System.IDisposable::Dispose() |
||||
IL_0028: ldnull |
||||
IL_0029: pop |
||||
IL_002a: endfinally |
||||
|
||||
IL_002b: ldnull |
||||
IL_002c: pop |
||||
IL_002d: endfinally |
||||
} // end handler |
||||
|
||||
IL_002e: ldloc.2 |
||||
IL_002f: stloc.0 |
||||
.try |
||||
{ |
||||
IL_0030: call class [mscorlib]System.Collections.Generic.IEnumerable`1<int32> Program::getSeq() |
||||
IL_0035: stloc.s 5 |
||||
IL_0037: ldloc.s 5 |
||||
IL_0039: callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<int32>::GetEnumerator() |
||||
IL_003e: stloc.s 6 |
||||
.try |
||||
{ |
||||
// loop start (head: IL_0040) |
||||
IL_0040: ldloc.s 6 |
||||
IL_0042: callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext() |
||||
IL_0047: brfalse.s IL_0058 |
||||
|
||||
IL_0049: ldloc.s 6 |
||||
IL_004b: callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<int32>::get_Current() |
||||
IL_0050: call void [mscorlib]System.Console::WriteLine(int32) |
||||
IL_0055: nop |
||||
IL_0056: br.s IL_0040 |
||||
// end loop |
||||
|
||||
IL_0058: ldnull |
||||
IL_0059: stloc.s 7 |
||||
IL_005b: leave.s IL_0074 |
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_005d: ldloc.s 6 |
||||
IL_005f: isinst [mscorlib]System.IDisposable |
||||
IL_0064: stloc.1 |
||||
IL_0065: ldloc.1 |
||||
IL_0066: brfalse.s IL_0071 |
||||
|
||||
IL_0068: ldloc.1 |
||||
IL_0069: callvirt instance void [mscorlib]System.IDisposable::Dispose() |
||||
IL_006e: ldnull |
||||
IL_006f: pop |
||||
IL_0070: endfinally |
||||
|
||||
IL_0071: ldnull |
||||
IL_0072: pop |
||||
IL_0073: endfinally |
||||
} // end handler |
||||
|
||||
IL_0074: ldloc.s 7 |
||||
IL_0076: pop |
||||
IL_0077: ldc.i4.1 |
||||
IL_0078: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_Empty() |
||||
IL_007d: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::Cons(!0, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0>) |
||||
IL_0082: stloc.s 8 |
||||
IL_0084: ldloc.s 8 |
||||
IL_0086: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_TailOrNull() |
||||
IL_008b: stloc.s 9 |
||||
// loop start (head: IL_008d) |
||||
IL_008d: ldloc.s 9 |
||||
IL_008f: ldnull |
||||
IL_0090: cgt.un |
||||
IL_0092: brfalse.s IL_00b4 |
||||
|
||||
IL_0094: ldloc.s 8 |
||||
IL_0096: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_HeadOrDefault() |
||||
IL_009b: stloc.s 10 |
||||
IL_009d: ldloc.s 10 |
||||
IL_009f: call void [mscorlib]System.Console::WriteLine(int32) |
||||
IL_00a4: ldloc.s 9 |
||||
IL_00a6: stloc.s 8 |
||||
IL_00a8: ldloc.s 8 |
||||
IL_00aa: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<!0> class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<int32>::get_TailOrNull() |
||||
IL_00af: stloc.s 9 |
||||
IL_00b1: nop |
||||
IL_00b2: br.s IL_008d |
||||
// end loop |
||||
|
||||
IL_00b4: ldc.i4.1 |
||||
IL_00b5: newarr [mscorlib]System.Int32 |
||||
IL_00ba: dup |
||||
IL_00bb: ldc.i4.0 |
||||
IL_00bc: ldc.i4.1 |
||||
IL_00bd: stelem.any [mscorlib]System.Int32 |
||||
IL_00c2: stloc.s 11 |
||||
IL_00c4: ldc.i4.0 |
||||
IL_00c5: stloc.s 10 |
||||
IL_00c7: br.s IL_00dd |
||||
// loop start (head: IL_00dd) |
||||
IL_00c9: ldloc.s 11 |
||||
IL_00cb: ldloc.s 10 |
||||
IL_00cd: ldelem.any [mscorlib]System.Int32 |
||||
IL_00d2: call void [mscorlib]System.Console::WriteLine(int32) |
||||
IL_00d7: ldloc.s 10 |
||||
IL_00d9: ldc.i4.1 |
||||
IL_00da: add |
||||
IL_00db: stloc.s 10 |
||||
|
||||
IL_00dd: ldloc.s 10 |
||||
IL_00df: ldloc.s 11 |
||||
IL_00e1: ldlen |
||||
IL_00e2: conv.i4 |
||||
IL_00e3: blt.s IL_00c9 |
||||
// end loop |
||||
|
||||
IL_00e5: ldc.i4.0 |
||||
IL_00e6: stloc.s 4 |
||||
IL_00e8: leave.s IL_0100 |
||||
} // end .try |
||||
finally |
||||
{ |
||||
IL_00ea: ldloc.0 |
||||
IL_00eb: isinst [mscorlib]System.IDisposable |
||||
IL_00f0: stloc.1 |
||||
IL_00f1: ldloc.1 |
||||
IL_00f2: brfalse.s IL_00fd |
||||
|
||||
IL_00f4: ldloc.1 |
||||
IL_00f5: callvirt instance void [mscorlib]System.IDisposable::Dispose() |
||||
IL_00fa: ldnull |
||||
IL_00fb: pop |
||||
IL_00fc: endfinally |
||||
|
||||
IL_00fd: ldnull |
||||
IL_00fe: pop |
||||
IL_00ff: endfinally |
||||
} // end handler |
||||
|
||||
IL_0100: ldloc.s 4 |
||||
IL_0102: ret |
||||
} // end of method Program::main |
||||
|
||||
} // end of class Program |
||||
|
||||
.class private auto ansi abstract sealed '<StartupCode$ConsoleApplication1>.$Program' |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
} // end of class <StartupCode$ConsoleApplication1>.$Program |
||||
|
||||
.class private auto ansi abstract sealed '<StartupCode$ConsoleApplication1>.$AssemblyInfo' |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
} // end of class <StartupCode$ConsoleApplication1>.$AssemblyInfo |
||||
|
||||
.class private auto ansi abstract sealed '<StartupCode$ConsoleApplication1>.$.NETFramework,Version=v4.6.1.AssemblyAttributes' |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
} // end of class <StartupCode$ConsoleApplication1>.$.NETFramework,Version=v4.6.1.AssemblyAttributes |
||||
|
||||
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
using System; |
||||
using System.IO; |
||||
|
||||
public static class FSharpUsingPatterns |
||||
{ |
||||
public static void sample1() |
||||
{ |
||||
using (FileStream fileStream = File.Create("x.txt")) { |
||||
fileStream.WriteByte((byte)1); |
||||
} |
||||
} |
||||
|
||||
public static void sample2() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
using (FileStream fileStream = File.Create("x.txt")) { |
||||
fileStream.WriteByte((byte)2); |
||||
Console.WriteLine("some text"); |
||||
} |
||||
} |
||||
|
||||
public static void sample3() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
using (FileStream fileStream = File.Create("x.txt")) { |
||||
fileStream.WriteByte((byte)3); |
||||
} |
||||
Console.WriteLine("some text"); |
||||
} |
||||
|
||||
public static void sample4() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
int num = default(int); |
||||
using (FileStream fileStream = File.OpenRead("x.txt")) { |
||||
num = fileStream.ReadByte(); |
||||
} |
||||
int num2 = num; |
||||
Console.WriteLine("read:" + num2.ToString()); |
||||
} |
||||
|
||||
public static void sample5() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
int num = default(int); |
||||
using (FileStream fileStream = File.OpenRead("x.txt")) { |
||||
num = fileStream.ReadByte(); |
||||
} |
||||
int num2 = num; |
||||
int num3 = default(int); |
||||
using (FileStream fileStream = File.OpenRead("x.txt")) { |
||||
fileStream.ReadByte(); |
||||
num3 = fileStream.ReadByte(); |
||||
} |
||||
int num4 = num3; |
||||
Console.WriteLine("read: {0}, {1}", num2, num4); |
||||
} |
||||
} |
||||
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
using System; |
||||
using System.IO; |
||||
|
||||
public static class FSharpUsingPatterns |
||||
{ |
||||
public static void sample1() |
||||
{ |
||||
using (FileStream fileStream = File.Create("x.txt")) { |
||||
fileStream.WriteByte(1); |
||||
} |
||||
} |
||||
|
||||
public static void sample2() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
using (FileStream fileStream = File.Create("x.txt")) { |
||||
fileStream.WriteByte(2); |
||||
Console.WriteLine("some text"); |
||||
} |
||||
} |
||||
|
||||
public static void sample3() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
using (FileStream fileStream = File.Create("x.txt")) { |
||||
fileStream.WriteByte(3); |
||||
} |
||||
Console.WriteLine("some text"); |
||||
} |
||||
|
||||
public static void sample4() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
int num = default(int); |
||||
using (FileStream fileStream = File.OpenRead("x.txt")) { |
||||
num = fileStream.ReadByte(); |
||||
} |
||||
int num2 = num; |
||||
Console.WriteLine("read:" + num2.ToString()); |
||||
} |
||||
|
||||
public static void sample5() |
||||
{ |
||||
Console.WriteLine("some text"); |
||||
int num = default(int); |
||||
using (FileStream fileStream = File.OpenRead("x.txt")) { |
||||
num = fileStream.ReadByte(); |
||||
} |
||||
int num2 = num; |
||||
int num3 = default(int); |
||||
using (FileStream fileStream = File.OpenRead("x.txt")) { |
||||
fileStream.ReadByte(); |
||||
num3 = fileStream.ReadByte(); |
||||
} |
||||
num = num3; |
||||
Console.WriteLine("read: {0}, {1}", num2, num); |
||||
} |
||||
} |
||||
@ -0,0 +1,484 @@
@@ -0,0 +1,484 @@
|
||||
// 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; |
||||
using System.Collections.Generic; |
||||
using System.Globalization; |
||||
using System.Linq; |
||||
using System.Threading; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
||||
{ |
||||
public class InitializerTests |
||||
{ |
||||
#region Types and helpers
|
||||
public class C |
||||
{ |
||||
public int Z; |
||||
public S Y; |
||||
public List<S> L; |
||||
} |
||||
|
||||
public struct S |
||||
{ |
||||
public int A; |
||||
public int B; |
||||
|
||||
public S(int a) |
||||
{ |
||||
this.A = a; |
||||
this.B = 0; |
||||
} |
||||
} |
||||
|
||||
private enum MyEnum |
||||
{ |
||||
a = 0, |
||||
b = 1 |
||||
} |
||||
|
||||
private enum MyEnum2 |
||||
{ |
||||
c = 0, |
||||
d = 1 |
||||
} |
||||
|
||||
private class Data |
||||
{ |
||||
public List<MyEnum2> FieldList = new List<MyEnum2>(); |
||||
public MyEnum a { |
||||
get; |
||||
set; |
||||
} |
||||
public MyEnum b { |
||||
get; |
||||
set; |
||||
} |
||||
public List<MyEnum2> PropertyList { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public Data MoreData { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public StructData NestedStruct { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public Data this[int i] { |
||||
get { |
||||
return null; |
||||
} |
||||
set { |
||||
} |
||||
} |
||||
|
||||
public Data this[int i, string j] { |
||||
get { |
||||
return null; |
||||
} |
||||
set { |
||||
} |
||||
} |
||||
|
||||
public event EventHandler TestEvent; |
||||
} |
||||
|
||||
private struct StructData |
||||
{ |
||||
public int Field; |
||||
public int Property { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public Data MoreData { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public StructData(int initialValue) |
||||
{ |
||||
this = default(StructData); |
||||
this.Field = initialValue; |
||||
this.Property = initialValue; |
||||
} |
||||
} |
||||
|
||||
// Helper methods used to ensure initializers used within expressions work correctly
|
||||
private static void X(object a, object b) |
||||
{ |
||||
} |
||||
|
||||
private static object Y() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public static void TestCall(int a, Thread thread) |
||||
{ |
||||
|
||||
} |
||||
|
||||
public static C TestCall(int a, C c) |
||||
{ |
||||
return c; |
||||
} |
||||
#endregion
|
||||
|
||||
public C Test1() |
||||
{ |
||||
C c = new C(); |
||||
c.L = new List<S>(); |
||||
c.L.Add(new S(1)); |
||||
return c; |
||||
} |
||||
|
||||
public C Test1Alternative() |
||||
{ |
||||
return InitializerTests.TestCall(1, new C { |
||||
L = new List<S> { |
||||
new S(1) |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public C Test2() |
||||
{ |
||||
C c = new C(); |
||||
c.Z = 1; |
||||
c.Z = 2; |
||||
return c; |
||||
} |
||||
|
||||
public C Test3() |
||||
{ |
||||
C c = new C(); |
||||
c.Y = new S(1); |
||||
c.Y.A = 2; |
||||
return c; |
||||
} |
||||
|
||||
public C Test3b() |
||||
{ |
||||
return InitializerTests.TestCall(0, new C { |
||||
Z = 1, |
||||
Y = { |
||||
A = 2 |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public C Test4() |
||||
{ |
||||
C c = new C(); |
||||
c.Y.A = 1; |
||||
c.Z = 2; |
||||
c.Y.B = 3; |
||||
return c; |
||||
} |
||||
|
||||
|
||||
public static void CollectionInitializerList() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new List<int> { |
||||
1, |
||||
2, |
||||
3 |
||||
}); |
||||
} |
||||
|
||||
public static object RecursiveCollectionInitializer() |
||||
{ |
||||
List<object> list = new List<object>(); |
||||
list.Add(list); |
||||
return list; |
||||
} |
||||
|
||||
public static void CollectionInitializerDictionary() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Dictionary<string, int> { |
||||
{ |
||||
"First", |
||||
1 |
||||
}, |
||||
{ |
||||
"Second", |
||||
2 |
||||
}, |
||||
{ |
||||
"Third", |
||||
3 |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void CollectionInitializerDictionaryWithEnumTypes() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Dictionary<MyEnum, MyEnum2> { |
||||
{ |
||||
MyEnum.a, |
||||
MyEnum2.c |
||||
}, |
||||
{ |
||||
MyEnum.b, |
||||
MyEnum2.d |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void NotACollectionInitializer() |
||||
{ |
||||
List<int> list = new List<int>(); |
||||
list.Add(1); |
||||
list.Add(2); |
||||
list.Add(3); |
||||
InitializerTests.X(InitializerTests.Y(), list); |
||||
} |
||||
|
||||
public static void ObjectInitializer() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
a = MyEnum.a |
||||
}); |
||||
} |
||||
|
||||
public static void NotAnObjectInitializer() |
||||
{ |
||||
Data data = new Data(); |
||||
data.a = MyEnum.a; |
||||
InitializerTests.X(InitializerTests.Y(), data); |
||||
} |
||||
|
||||
public static void NotAnObjectInitializerWithEvent() |
||||
{ |
||||
Data data = new Data(); |
||||
data.TestEvent += delegate(object sender, EventArgs e) { |
||||
Console.WriteLine(); |
||||
}; |
||||
InitializerTests.X(InitializerTests.Y(), data); |
||||
} |
||||
|
||||
public static void ObjectInitializerAssignCollectionToField() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
a = MyEnum.a, |
||||
FieldList = new List<MyEnum2> { |
||||
MyEnum2.c, |
||||
MyEnum2.d |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void ObjectInitializerAddToCollectionInField() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
a = MyEnum.a, |
||||
FieldList = { |
||||
MyEnum2.c, |
||||
MyEnum2.d |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void ObjectInitializerAssignCollectionToProperty() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
a = MyEnum.a, |
||||
PropertyList = new List<MyEnum2> { |
||||
MyEnum2.c, |
||||
MyEnum2.d |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void ObjectInitializerAddToCollectionInProperty() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
a = MyEnum.a, |
||||
PropertyList = { |
||||
MyEnum2.c, |
||||
MyEnum2.d |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void ObjectInitializerWithInitializationOfNestedObjects() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
MoreData = { |
||||
a = MyEnum.a, |
||||
MoreData = { |
||||
a = MyEnum.b |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private static int GetInt() |
||||
{ |
||||
return 1; |
||||
} |
||||
|
||||
private static string GetString() |
||||
{ |
||||
return "Test"; |
||||
} |
||||
|
||||
#if !LEGACY_CSC
|
||||
public static void SimpleDictInitializer() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
MoreData = { |
||||
a = MyEnum.a, |
||||
[2] = null |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void MixedObjectAndDictInitializer() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
MoreData = { |
||||
a = MyEnum.a, |
||||
[InitializerTests.GetInt()] = { |
||||
a = MyEnum.b, |
||||
FieldList = { |
||||
MyEnum2.c |
||||
}, |
||||
[InitializerTests.GetInt(), InitializerTests.GetString()] = new Data(), |
||||
[2] = null |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
#endif
|
||||
|
||||
public static void ObjectInitializerWithInitializationOfDeeplyNestedObjects() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
a = MyEnum.b, |
||||
MoreData = { |
||||
a = MyEnum.a, |
||||
MoreData = { |
||||
MoreData = { |
||||
MoreData = { |
||||
MoreData = { |
||||
MoreData = { |
||||
MoreData = { |
||||
a = MyEnum.b |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void CollectionInitializerInsideObjectInitializers() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
MoreData = new Data { |
||||
a = MyEnum.a, |
||||
b = MyEnum.b, |
||||
PropertyList = { |
||||
MyEnum2.c |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void NotAStructInitializer_DefaultConstructor() |
||||
{ |
||||
StructData structData = default(StructData); |
||||
structData.Field = 1; |
||||
structData.Property = 2; |
||||
InitializerTests.X(InitializerTests.Y(), structData); |
||||
} |
||||
|
||||
public static void StructInitializer_DefaultConstructor() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new StructData { |
||||
Field = 1, |
||||
Property = 2 |
||||
}); |
||||
} |
||||
|
||||
public static void NotAStructInitializer_ExplicitConstructor() |
||||
{ |
||||
StructData structData = new StructData(0); |
||||
structData.Field = 1; |
||||
structData.Property = 2; |
||||
InitializerTests.X(InitializerTests.Y(), structData); |
||||
} |
||||
|
||||
public static void StructInitializer_ExplicitConstructor() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new StructData(0) { |
||||
Field = 1, |
||||
Property = 2 |
||||
}); |
||||
} |
||||
|
||||
public static void StructInitializerWithInitializationOfNestedObjects() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new StructData { |
||||
MoreData = { |
||||
a = MyEnum.a, |
||||
FieldList = { |
||||
MyEnum2.c, |
||||
MyEnum2.d |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void StructInitializerWithinObjectInitializer() |
||||
{ |
||||
InitializerTests.X(InitializerTests.Y(), new Data { |
||||
NestedStruct = new StructData(2) { |
||||
Field = 1, |
||||
Property = 2 |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void Bug270_NestedInitialisers() |
||||
{ |
||||
NumberFormatInfo[] source = null; |
||||
|
||||
InitializerTests.TestCall(0, new Thread(InitializerTests.Bug270_NestedInitialisers) { |
||||
Priority = ThreadPriority.BelowNormal, |
||||
CurrentCulture = new CultureInfo(0) { |
||||
DateTimeFormat = new DateTimeFormatInfo { |
||||
ShortDatePattern = "ddmmyy" |
||||
}, |
||||
NumberFormat = (from format in source |
||||
where format.CurrencySymbol == "$" |
||||
select format).First() |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,329 @@
@@ -0,0 +1,329 @@
|
||||
// Copyright (c) 2017 Daniel Grunwald
|
||||
//
|
||||
// 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; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using ICSharpCode.Decompiler.CSharp.Syntax; |
||||
using ICSharpCode.Decompiler.IL; |
||||
using ICSharpCode.Decompiler.Util; |
||||
|
||||
namespace ICSharpCode.Decompiler.CSharp |
||||
{ |
||||
/// <summary>
|
||||
/// Given a SyntaxTree that was output from the decompiler, constructs the list of sequence points.
|
||||
/// </summary>
|
||||
class SequencePointBuilder : DepthFirstAstVisitor |
||||
{ |
||||
struct StatePerSequencePoint |
||||
{ |
||||
/// <summary>
|
||||
/// Main AST node associated with this sequence point.
|
||||
/// </summary>
|
||||
internal readonly AstNode PrimaryNode; |
||||
|
||||
/// <summary>
|
||||
/// List of IL intervals that are associated with this sequence point.
|
||||
/// </summary>
|
||||
internal readonly List<Interval> Intervals; |
||||
|
||||
/// <summary>
|
||||
/// The function containing this sequence point.
|
||||
/// </summary>
|
||||
internal ILFunction Function; |
||||
|
||||
public StatePerSequencePoint(AstNode primaryNode) |
||||
{ |
||||
this.PrimaryNode = primaryNode; |
||||
this.Intervals = new List<Interval>(); |
||||
this.Function = null; |
||||
} |
||||
} |
||||
|
||||
readonly List<(ILFunction, SequencePoint)> sequencePoints = new List<(ILFunction, SequencePoint)>(); |
||||
readonly HashSet<ILInstruction> mappedInstructions = new HashSet<ILInstruction>(); |
||||
|
||||
// Stack holding information for outer statements.
|
||||
readonly Stack<StatePerSequencePoint> outerStates = new Stack<StatePerSequencePoint>(); |
||||
|
||||
// Collects information for the current sequence point.
|
||||
StatePerSequencePoint current; |
||||
|
||||
void VisitAsSequencePoint(AstNode node) |
||||
{ |
||||
if (node.IsNull) return; |
||||
StartSequencePoint(node); |
||||
node.AcceptVisitor(this); |
||||
EndSequencePoint(node.StartLocation, node.EndLocation); |
||||
} |
||||
|
||||
protected override void VisitChildren(AstNode node) |
||||
{ |
||||
base.VisitChildren(node); |
||||
AddToSequencePoint(node); |
||||
} |
||||
|
||||
public override void VisitBlockStatement(BlockStatement blockStatement) |
||||
{ |
||||
foreach (var stmt in blockStatement.Statements) { |
||||
VisitAsSequencePoint(stmt); |
||||
} |
||||
} |
||||
|
||||
public override void VisitForStatement(ForStatement forStatement) |
||||
{ |
||||
// Every element of a for-statement is it's own sequence point.
|
||||
foreach (var init in forStatement.Initializers) { |
||||
VisitAsSequencePoint(init); |
||||
} |
||||
VisitAsSequencePoint(forStatement.Condition); |
||||
foreach (var inc in forStatement.Iterators) { |
||||
VisitAsSequencePoint(inc); |
||||
} |
||||
VisitAsSequencePoint(forStatement.EmbeddedStatement); |
||||
} |
||||
|
||||
public override void VisitSwitchStatement(SwitchStatement switchStatement) |
||||
{ |
||||
StartSequencePoint(switchStatement); |
||||
switchStatement.Expression.AcceptVisitor(this); |
||||
foreach (var section in switchStatement.SwitchSections) { |
||||
// note: sections will not contribute to the current sequence point
|
||||
section.AcceptVisitor(this); |
||||
} |
||||
// add switch statement itself to sequence point
|
||||
// (call only after the sections are visited)
|
||||
AddToSequencePoint(switchStatement); |
||||
EndSequencePoint(switchStatement.StartLocation, switchStatement.RParToken.EndLocation); |
||||
} |
||||
|
||||
public override void VisitSwitchSection(Syntax.SwitchSection switchSection) |
||||
{ |
||||
// every statement in the switch section is its own sequence point
|
||||
foreach (var stmt in switchSection.Statements) { |
||||
VisitAsSequencePoint(stmt); |
||||
} |
||||
} |
||||
|
||||
public override void VisitLambdaExpression(LambdaExpression lambdaExpression) |
||||
{ |
||||
AddToSequencePoint(lambdaExpression); |
||||
VisitAsSequencePoint(lambdaExpression.Body); |
||||
} |
||||
|
||||
public override void VisitUsingStatement(UsingStatement usingStatement) |
||||
{ |
||||
StartSequencePoint(usingStatement); |
||||
usingStatement.ResourceAcquisition.AcceptVisitor(this); |
||||
VisitAsSequencePoint(usingStatement.EmbeddedStatement); |
||||
AddToSequencePoint(usingStatement); |
||||
EndSequencePoint(usingStatement.StartLocation, usingStatement.RParToken.EndLocation); |
||||
} |
||||
|
||||
public override void VisitForeachStatement(ForeachStatement foreachStatement) |
||||
{ |
||||
var foreachInfo = foreachStatement.Annotation<ForeachAnnotation>(); |
||||
if (foreachInfo == null) { |
||||
base.VisitForeachStatement(foreachStatement); |
||||
return; |
||||
} |
||||
// TODO : Add a sequence point on foreach token (mapped to nop before using instruction).
|
||||
StartSequencePoint(foreachStatement); |
||||
foreachStatement.InExpression.AcceptVisitor(this); |
||||
AddToSequencePoint(foreachInfo.GetEnumeratorCall); |
||||
EndSequencePoint(foreachStatement.InExpression.StartLocation, foreachStatement.InExpression.EndLocation); |
||||
StartSequencePoint(foreachStatement); |
||||
AddToSequencePoint(foreachInfo.MoveNextCall); |
||||
EndSequencePoint(foreachStatement.InToken.StartLocation, foreachStatement.InToken.EndLocation); |
||||
StartSequencePoint(foreachStatement); |
||||
AddToSequencePoint(foreachInfo.GetCurrentCall); |
||||
EndSequencePoint(foreachStatement.VariableType.StartLocation, foreachStatement.VariableNameToken.EndLocation); |
||||
VisitAsSequencePoint(foreachStatement.EmbeddedStatement); |
||||
} |
||||
|
||||
public override void VisitLockStatement(LockStatement lockStatement) |
||||
{ |
||||
StartSequencePoint(lockStatement); |
||||
lockStatement.Expression.AcceptVisitor(this); |
||||
VisitAsSequencePoint(lockStatement.EmbeddedStatement); |
||||
AddToSequencePoint(lockStatement); |
||||
EndSequencePoint(lockStatement.StartLocation, lockStatement.RParToken.EndLocation); |
||||
} |
||||
|
||||
public override void VisitIfElseStatement(IfElseStatement ifElseStatement) |
||||
{ |
||||
StartSequencePoint(ifElseStatement); |
||||
ifElseStatement.Condition.AcceptVisitor(this); |
||||
VisitAsSequencePoint(ifElseStatement.TrueStatement); |
||||
VisitAsSequencePoint(ifElseStatement.FalseStatement); |
||||
AddToSequencePoint(ifElseStatement); |
||||
EndSequencePoint(ifElseStatement.StartLocation, ifElseStatement.RParToken.EndLocation); |
||||
} |
||||
|
||||
public override void VisitWhileStatement(WhileStatement whileStatement) |
||||
{ |
||||
StartSequencePoint(whileStatement); |
||||
whileStatement.Condition.AcceptVisitor(this); |
||||
VisitAsSequencePoint(whileStatement.EmbeddedStatement); |
||||
AddToSequencePoint(whileStatement); |
||||
EndSequencePoint(whileStatement.StartLocation, whileStatement.RParToken.EndLocation); |
||||
} |
||||
|
||||
public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement) |
||||
{ |
||||
StartSequencePoint(doWhileStatement); |
||||
VisitAsSequencePoint(doWhileStatement.EmbeddedStatement); |
||||
doWhileStatement.Condition.AcceptVisitor(this); |
||||
AddToSequencePoint(doWhileStatement); |
||||
EndSequencePoint(doWhileStatement.WhileToken.StartLocation, doWhileStatement.RParToken.EndLocation); |
||||
} |
||||
|
||||
public override void VisitFixedStatement(FixedStatement fixedStatement) |
||||
{ |
||||
foreach (var v in fixedStatement.Variables) { |
||||
VisitAsSequencePoint(v); |
||||
} |
||||
VisitAsSequencePoint(fixedStatement.EmbeddedStatement); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Start a new C# statement = new sequence point.
|
||||
/// </summary>
|
||||
void StartSequencePoint(AstNode primaryNode) |
||||
{ |
||||
outerStates.Push(current); |
||||
current = new StatePerSequencePoint(primaryNode); |
||||
} |
||||
|
||||
void EndSequencePoint(TextLocation startLocation, TextLocation endLocation) |
||||
{ |
||||
Debug.Assert(!startLocation.IsEmpty, "missing startLocation"); |
||||
Debug.Assert(!endLocation.IsEmpty, "missing endLocation"); |
||||
if (current.Intervals.Count > 0 && current.Function != null) { |
||||
// use LongSet to deduplicate and merge the intervals
|
||||
var longSet = new LongSet(current.Intervals.Select(i => new LongInterval(i.Start, i.End))); |
||||
Debug.Assert(!longSet.IsEmpty); |
||||
sequencePoints.Add((current.Function, new SequencePoint { |
||||
Offset = (int)longSet.Intervals[0].Start, |
||||
EndOffset = (int)longSet.Intervals[0].End, |
||||
StartLine = startLocation.Line, |
||||
StartColumn = startLocation.Column, |
||||
EndLine = endLocation.Line, |
||||
EndColumn = endLocation.Column |
||||
})); |
||||
} |
||||
current = outerStates.Pop(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Add the ILAst instruction associated with the AstNode to the sequence point.
|
||||
/// Also add all its ILAst sub-instructions (unless they were already added to another sequence point).
|
||||
/// </summary>
|
||||
void AddToSequencePoint(AstNode node) |
||||
{ |
||||
foreach (var inst in node.Annotations.OfType<ILInstruction>()) { |
||||
AddToSequencePoint(inst); |
||||
} |
||||
} |
||||
|
||||
void AddToSequencePoint(ILInstruction inst) |
||||
{ |
||||
if (!mappedInstructions.Add(inst)) { |
||||
// inst was already used by a nested sequence point within this sequence point
|
||||
return; |
||||
} |
||||
// Add the IL range associated with this instruction to the current sequence point.
|
||||
if (HasUsableILRange(inst) && current.Intervals != null) { |
||||
current.Intervals.Add(inst.ILRange); |
||||
var function = inst.Parent.Ancestors.OfType<ILFunction>().FirstOrDefault(); |
||||
Debug.Assert(current.Function == null || current.Function == function); |
||||
current.Function = function; |
||||
} |
||||
|
||||
// Do not add instructions of lambdas/delegates.
|
||||
if (inst is ILFunction) |
||||
return; |
||||
|
||||
// Also add the child IL instructions, unless they were already processed by
|
||||
// another C# expression.
|
||||
foreach (var child in inst.Children) { |
||||
AddToSequencePoint(child); |
||||
} |
||||
} |
||||
|
||||
internal static bool HasUsableILRange(ILInstruction inst) |
||||
{ |
||||
if (inst.ILRange.IsEmpty) |
||||
return false; |
||||
return !(inst is BlockContainer || inst is Block); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Called after the visitor is done to return the results.
|
||||
/// </summary>
|
||||
internal Dictionary<ILFunction, List<SequencePoint>> GetSequencePoints() |
||||
{ |
||||
var dict = new Dictionary<ILFunction, List<SequencePoint>>(); |
||||
foreach (var (function, sequencePoint) in this.sequencePoints) { |
||||
if (!dict.TryGetValue(function, out var list)) { |
||||
dict.Add(function, list = new List<SequencePoint>()); |
||||
} |
||||
list.Add(sequencePoint); |
||||
} |
||||
foreach (var (function, list) in dict.ToList()) { |
||||
// For each function, sort sequence points and fix overlaps+gaps
|
||||
var newList = new List<SequencePoint>(); |
||||
int pos = 0; |
||||
foreach (var sequencePoint in list.OrderBy(sp => sp.Offset).ThenBy(sp => sp.EndOffset)) { |
||||
if (sequencePoint.Offset < pos) { |
||||
// overlapping sequence point?
|
||||
// delete previous sequence points that are after sequencePoint.Offset
|
||||
while (newList.Count > 0 && newList.Last().EndOffset > pos) { |
||||
var last = newList.Last(); |
||||
if (last.Offset >= sequencePoint.Offset) { |
||||
newList.RemoveAt(newList.Count - 1); |
||||
} else { |
||||
last.EndOffset = sequencePoint.Offset; |
||||
newList[newList.Count - 1] = last; |
||||
} |
||||
} |
||||
} else if (sequencePoint.Offset > pos) { |
||||
// insert hidden sequence point in the gap.
|
||||
var hidden = new SequencePoint(); |
||||
hidden.Offset = pos; |
||||
hidden.EndOffset = sequencePoint.Offset; |
||||
hidden.SetHidden(); |
||||
newList.Add(hidden); |
||||
} |
||||
newList.Add(sequencePoint); |
||||
pos = sequencePoint.EndOffset; |
||||
} |
||||
if (pos < function.CecilMethod.Body.CodeSize) { |
||||
var hidden = new SequencePoint(); |
||||
hidden.Offset = pos; |
||||
hidden.EndOffset = function.CecilMethod.Body.CodeSize; |
||||
hidden.SetHidden(); |
||||
newList.Add(hidden); |
||||
} |
||||
dict[function] = newList; |
||||
} |
||||
return dict; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,352 @@
@@ -0,0 +1,352 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Decompiler.Util; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.Decompiler |
||||
{ |
||||
public class UniversalAssemblyResolver : IAssemblyResolver |
||||
{ |
||||
DotNetCorePathFinder dotNetCorePathFinder; |
||||
readonly bool throwOnError; |
||||
readonly string mainAssemblyFileName; |
||||
readonly string baseDirectory; |
||||
readonly Dictionary<string, UnresolvedAssemblyNameReference> loadedAssemblyReferences; |
||||
readonly List<string> directories; |
||||
readonly List<string> gac_paths = GetGacPaths(); |
||||
|
||||
public static readonly bool OnMono = Type.GetType("Mono.Runtime") != null; |
||||
|
||||
public event AssemblyResolveEventHandler ResolveFailed; |
||||
|
||||
public void AddSearchDirectory(string directory) |
||||
{ |
||||
directories.Add(directory); |
||||
} |
||||
|
||||
public void RemoveSearchDirectory(string directory) |
||||
{ |
||||
directories.Remove(directory); |
||||
} |
||||
|
||||
public string[] GetSearchDirectories() |
||||
{ |
||||
return directories.ToArray(); |
||||
} |
||||
|
||||
public string TargetFramework { get; set; } |
||||
|
||||
private UniversalAssemblyResolver(string mainAssemblyFileName, bool throwOnError) |
||||
{ |
||||
this.mainAssemblyFileName = mainAssemblyFileName; |
||||
this.baseDirectory = Path.GetDirectoryName(mainAssemblyFileName); |
||||
this.throwOnError = throwOnError; |
||||
if (string.IsNullOrWhiteSpace(this.baseDirectory)) |
||||
this.baseDirectory = Environment.CurrentDirectory; |
||||
AddSearchDirectory(baseDirectory); |
||||
} |
||||
|
||||
public static ModuleDefinition LoadMainModule(string mainAssemblyFileName, bool throwOnError = true, bool inMemory = false) |
||||
{ |
||||
var resolver = new UniversalAssemblyResolver(mainAssemblyFileName, throwOnError); |
||||
|
||||
var module = ModuleDefinition.ReadModule(mainAssemblyFileName, new ReaderParameters { |
||||
AssemblyResolver = resolver, |
||||
InMemory = inMemory |
||||
}); |
||||
|
||||
resolver.TargetFramework = module.Assembly.DetectTargetFrameworkId(); |
||||
|
||||
return module; |
||||
} |
||||
|
||||
public AssemblyDefinition Resolve(AssemblyNameReference name) |
||||
{ |
||||
return Resolve(name, new ReaderParameters()); |
||||
} |
||||
|
||||
public AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters) |
||||
{ |
||||
var targetFramework = TargetFramework.Split(new[] { ",Version=v" }, StringSplitOptions.None); |
||||
string file = null; |
||||
switch (targetFramework[0]) { |
||||
case ".NETCoreApp": |
||||
case ".NETStandard": |
||||
if (targetFramework.Length != 2) goto default; |
||||
if (dotNetCorePathFinder == null) { |
||||
var version = targetFramework[1].Length == 3 ? targetFramework[1] + ".0" : targetFramework[1]; |
||||
dotNetCorePathFinder = new DotNetCorePathFinder(mainAssemblyFileName, TargetFramework, version, this.loadedAssemblyReferences); |
||||
} |
||||
file = dotNetCorePathFinder.TryResolveDotNetCore(name); |
||||
if (file == null) |
||||
goto default; |
||||
else { |
||||
var asm = ModuleDefinition.ReadModule(file, parameters).Assembly; |
||||
if (throwOnError && asm == null) |
||||
throw new AssemblyResolutionException(name); |
||||
return asm; |
||||
} |
||||
default: |
||||
return ResolveInternal(name, parameters); |
||||
} |
||||
} |
||||
|
||||
AssemblyDefinition ResolveInternal(AssemblyNameReference name, ReaderParameters parameters) |
||||
{ |
||||
if (name == null) |
||||
throw new ArgumentNullException(nameof(name)); |
||||
|
||||
if (parameters == null) |
||||
throw new ArgumentNullException(nameof(parameters)); |
||||
|
||||
var assembly = SearchDirectory(name, directories, parameters); |
||||
if (assembly != null) |
||||
return assembly; |
||||
|
||||
if (name.IsRetargetable) { |
||||
// if the reference is retargetable, zero it
|
||||
name = new AssemblyNameReference(name.Name, ZeroVersion) { |
||||
PublicKeyToken = Empty<byte>.Array, |
||||
}; |
||||
} |
||||
|
||||
var framework_dir = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName); |
||||
var framework_dirs = OnMono |
||||
? new[] { framework_dir, Path.Combine(framework_dir, "Facades") } |
||||
: new[] { framework_dir }; |
||||
|
||||
if (IsZero(name.Version)) { |
||||
assembly = SearchDirectory(name, framework_dirs, parameters); |
||||
if (assembly != null) |
||||
return assembly; |
||||
} |
||||
|
||||
if (name.Name == "mscorlib") { |
||||
assembly = GetCorlib(name, parameters); |
||||
if (assembly != null) |
||||
return assembly; |
||||
} |
||||
|
||||
assembly = GetAssemblyInGac(name, parameters); |
||||
if (assembly != null) |
||||
return assembly; |
||||
|
||||
assembly = SearchDirectory(name, framework_dirs, parameters); |
||||
if (assembly != null) |
||||
return assembly; |
||||
|
||||
if (ResolveFailed != null) { |
||||
assembly = ResolveFailed(this, name); |
||||
if (assembly != null) |
||||
return assembly; |
||||
} |
||||
|
||||
if (throwOnError) |
||||
throw new AssemblyResolutionException(name); |
||||
return null; |
||||
} |
||||
|
||||
#region .NET / mono GAC handling
|
||||
AssemblyDefinition SearchDirectory(AssemblyNameReference name, IEnumerable<string> directories, ReaderParameters parameters) |
||||
{ |
||||
var extensions = name.IsWindowsRuntime ? new[] { ".winmd", ".dll" } : new[] { ".exe", ".dll" }; |
||||
foreach (var directory in directories) { |
||||
foreach (var extension in extensions) { |
||||
string file = Path.Combine(directory, name.Name + extension); |
||||
if (!File.Exists(file)) |
||||
continue; |
||||
try { |
||||
return GetAssembly(file, parameters); |
||||
} catch (System.BadImageFormatException) { |
||||
continue; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
static bool IsZero(Version version) |
||||
{ |
||||
return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0; |
||||
} |
||||
|
||||
static Version ZeroVersion = new Version(0, 0, 0, 0); |
||||
|
||||
AssemblyDefinition GetCorlib(AssemblyNameReference reference, ReaderParameters parameters) |
||||
{ |
||||
var version = reference.Version; |
||||
var corlib = typeof(object).Assembly.GetName(); |
||||
|
||||
if (corlib.Version == version || IsZero(version)) |
||||
return GetAssembly(typeof(object).Module.FullyQualifiedName, parameters); |
||||
|
||||
var path = Directory.GetParent( |
||||
Directory.GetParent( |
||||
typeof(object).Module.FullyQualifiedName).FullName |
||||
).FullName; |
||||
|
||||
if (OnMono) { |
||||
if (version.Major == 1) |
||||
path = Path.Combine(path, "1.0"); |
||||
else if (version.Major == 2) { |
||||
if (version.MajorRevision == 5) |
||||
path = Path.Combine(path, "2.1"); |
||||
else |
||||
path = Path.Combine(path, "2.0"); |
||||
} else if (version.Major == 4) |
||||
path = Path.Combine(path, "4.0"); |
||||
else |
||||
throw new NotSupportedException("Version not supported: " + version); |
||||
} else { |
||||
switch (version.Major) { |
||||
case 1: |
||||
if (version.MajorRevision == 3300) |
||||
path = Path.Combine(path, "v1.0.3705"); |
||||
else |
||||
path = Path.Combine(path, "v1.0.5000.0"); |
||||
break; |
||||
case 2: |
||||
path = Path.Combine(path, "v2.0.50727"); |
||||
break; |
||||
case 4: |
||||
path = Path.Combine(path, "v4.0.30319"); |
||||
break; |
||||
default: |
||||
throw new NotSupportedException("Version not supported: " + version); |
||||
} |
||||
} |
||||
|
||||
var file = Path.Combine(path, "mscorlib.dll"); |
||||
if (File.Exists(file)) |
||||
return GetAssembly(file, parameters); |
||||
|
||||
return null; |
||||
} |
||||
|
||||
static List<string> GetGacPaths() |
||||
{ |
||||
if (OnMono) |
||||
return GetDefaultMonoGacPaths(); |
||||
|
||||
var paths = new List<string>(2); |
||||
var windir = Environment.GetEnvironmentVariable("WINDIR"); |
||||
if (windir == null) |
||||
return paths; |
||||
|
||||
paths.Add(Path.Combine(windir, "assembly")); |
||||
paths.Add(Path.Combine(windir, Path.Combine("Microsoft.NET", "assembly"))); |
||||
return paths; |
||||
} |
||||
|
||||
static List<string> GetDefaultMonoGacPaths() |
||||
{ |
||||
var paths = new List<string>(1); |
||||
var gac = GetCurrentMonoGac(); |
||||
if (gac != null) |
||||
paths.Add(gac); |
||||
|
||||
var gac_paths_env = Environment.GetEnvironmentVariable("MONO_GAC_PREFIX"); |
||||
if (string.IsNullOrEmpty(gac_paths_env)) |
||||
return paths; |
||||
|
||||
var prefixes = gac_paths_env.Split(Path.PathSeparator); |
||||
foreach (var prefix in prefixes) { |
||||
if (string.IsNullOrEmpty(prefix)) |
||||
continue; |
||||
|
||||
var gac_path = Path.Combine(Path.Combine(Path.Combine(prefix, "lib"), "mono"), "gac"); |
||||
if (Directory.Exists(gac_path) && !paths.Contains(gac)) |
||||
paths.Add(gac_path); |
||||
} |
||||
|
||||
return paths; |
||||
} |
||||
|
||||
static string GetCurrentMonoGac() |
||||
{ |
||||
return Path.Combine( |
||||
Directory.GetParent( |
||||
Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName)).FullName, |
||||
"gac"); |
||||
} |
||||
|
||||
AssemblyDefinition GetAssembly(string file, ReaderParameters parameters) |
||||
{ |
||||
if (parameters.AssemblyResolver == null) |
||||
parameters.AssemblyResolver = this; |
||||
|
||||
return ModuleDefinition.ReadModule(file, parameters).Assembly; |
||||
} |
||||
|
||||
AssemblyDefinition GetAssemblyInGac(AssemblyNameReference reference, ReaderParameters parameters) |
||||
{ |
||||
if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0) |
||||
return null; |
||||
|
||||
if (OnMono) |
||||
return GetAssemblyInMonoGac(reference, parameters); |
||||
|
||||
return GetAssemblyInNetGac(reference, parameters); |
||||
} |
||||
|
||||
AssemblyDefinition GetAssemblyInMonoGac(AssemblyNameReference reference, ReaderParameters parameters) |
||||
{ |
||||
for (int i = 0; i < gac_paths.Count; i++) { |
||||
var gac_path = gac_paths[i]; |
||||
var file = GetAssemblyFile(reference, string.Empty, gac_path); |
||||
if (File.Exists(file)) |
||||
return GetAssembly(file, parameters); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
AssemblyDefinition GetAssemblyInNetGac(AssemblyNameReference reference, ReaderParameters parameters) |
||||
{ |
||||
var gacs = new[] { "GAC_MSIL", "GAC_32", "GAC_64", "GAC" }; |
||||
var prefixes = new[] { string.Empty, "v4.0_" }; |
||||
|
||||
for (int i = 0; i < 2; i++) { |
||||
for (int j = 0; j < gacs.Length; j++) { |
||||
var gac = Path.Combine(gac_paths[i], gacs[j]); |
||||
var file = GetAssemblyFile(reference, prefixes[i], gac); |
||||
if (Directory.Exists(gac) && File.Exists(file)) |
||||
return GetAssembly(file, parameters); |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
static string GetAssemblyFile(AssemblyNameReference reference, string prefix, string gac) |
||||
{ |
||||
var gac_folder = new StringBuilder() |
||||
.Append(prefix) |
||||
.Append(reference.Version) |
||||
.Append("__"); |
||||
|
||||
for (int i = 0; i < reference.PublicKeyToken.Length; i++) |
||||
gac_folder.Append(reference.PublicKeyToken[i].ToString("x2")); |
||||
|
||||
return Path.Combine( |
||||
Path.Combine( |
||||
Path.Combine(gac, reference.Name), gac_folder.ToString()), |
||||
reference.Name + ".dll"); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
public void Dispose() |
||||
{ |
||||
Dispose(true); |
||||
GC.SuppressFinalize(this); |
||||
} |
||||
|
||||
protected virtual void Dispose(bool disposing) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2017 Daniel Grunwald
|
||||
//
|
||||
// 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.ComponentModel; |
||||
using System.Runtime.CompilerServices; |
||||
|
||||
namespace ICSharpCode.Decompiler.IL |
||||
{ |
||||
public class ILAstWritingOptions : INotifyPropertyChanged |
||||
{ |
||||
private bool useLogicOperationSugar; |
||||
private bool useFieldSugar; |
||||
private bool showILRanges; |
||||
|
||||
/// <summary>
|
||||
/// Sugar for logic.not/and/or.
|
||||
/// </summary>
|
||||
public bool UseLogicOperationSugar { |
||||
get { return useLogicOperationSugar; } |
||||
set { |
||||
if (useLogicOperationSugar != value) { |
||||
useLogicOperationSugar = value; |
||||
OnPropertyChanged(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sugar for ldfld/stfld.
|
||||
/// </summary>
|
||||
public bool UseFieldSugar { |
||||
get { return useFieldSugar; } |
||||
set { |
||||
if (useFieldSugar != value) { |
||||
useFieldSugar = value; |
||||
OnPropertyChanged(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Show IL ranges in ILAst output.
|
||||
/// </summary>
|
||||
public bool ShowILRanges { |
||||
get { return showILRanges; } |
||||
set { |
||||
if (showILRanges != value) { |
||||
showILRanges = value; |
||||
OnPropertyChanged(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
||||
{ |
||||
OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); |
||||
} |
||||
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) |
||||
{ |
||||
PropertyChanged?.Invoke(this, e); |
||||
} |
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2017 Siegfried Pammer
|
||||
//
|
||||
// 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; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.Decompiler.IL |
||||
{ |
||||
partial class DefaultValue |
||||
{ |
||||
/// <summary>
|
||||
/// Gets whether the IL stack was empty at the point of this instruction.
|
||||
/// (not counting the argument of the instruction itself)
|
||||
/// </summary>
|
||||
public bool ILStackWasEmpty; |
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.Decompiler.IL |
||||
{ |
||||
/// <summary>
|
||||
/// A sequence point produced by the decompiler.
|
||||
/// </summary>
|
||||
public struct SequencePoint |
||||
{ |
||||
/// <summary>
|
||||
/// IL start offset.
|
||||
/// </summary>
|
||||
public int Offset { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// IL end offset.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This does not get stored in debug information;
|
||||
/// it is used internally to create hidden sequence points
|
||||
/// for the IL fragments not covered by any sequence point.
|
||||
/// </remarks>
|
||||
public int EndOffset { get; set; } |
||||
|
||||
public int StartLine { get; set; } |
||||
public int StartColumn { get; set; } |
||||
public int EndLine { get; set; } |
||||
public int EndColumn { get; set; } |
||||
|
||||
public bool IsHidden { |
||||
get { return StartLine == 0xfeefee && StartLine == EndLine; } |
||||
} |
||||
|
||||
internal void SetHidden() |
||||
{ |
||||
StartLine = EndLine = 0xfeefee; |
||||
} |
||||
} |
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue