From e215f69b2d0968c3d35888a4d1029651cff88d33 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 18 Jul 2019 21:00:04 +0200 Subject: [PATCH] Extend description of LocalFunctionDecompiler --- .../IL/Transforms/LocalFunctionDecompiler.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs b/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs index 228611a51..7937cf2a7 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs @@ -45,9 +45,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms /// /// /// local functions can either be used in method calls, i.e., call and callvirt instructions, - /// or can be used as part of the "delegate construction" pattern, i.e., newobj Delegate(<target-expression>, ldftn <method>). Note that this pattern would also be possible with ldvirtftn, but I haven't yet disovered a case where a compiler generates such code. + /// or can be used as part of the "delegate construction" pattern, i.e., newobj Delegate(<target-expression>, ldftn <method>). /// - /// As local functions can be declared practically anywhere, we have to take a look at all use-sites and infer the declaration location from that. + /// As local functions can be declared practically anywhere, we have to take a look at all use-sites and infer the declaration location from that. Use-sites can be call, callvirt and ldftn instructions. + /// After all use-sites are collected we construct the ILAst of the local function and add it to the parent function. + /// Then all use-sites of the local-function are transformed to a call to the LocalFunctionMethod or a ldftn of the LocalFunctionMethod. + /// In a next step we handle all nested local functions. + /// After all local functions are transformed, we move all local functions that do not capture any variables to the top-level function. /// public void Run(ILFunction function, ILTransformContext context) {