Browse Source

yield return moveNext

pull/1843/head
Shimon Magal 6 years ago
parent
commit
c06299b284
  1. 6
      ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs

6
ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs

@ -131,7 +131,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -131,7 +131,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
AnalyzeCurrentProperty();
ResolveIEnumerableIEnumeratorFieldMapping();
ConstructExceptionTable();
newBody = AnalyzeMoveNext();
newBody = AnalyzeMoveNext(function);
} catch (SymbolicAnalysisFailedException) {
return;
}
@ -525,12 +525,14 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -525,12 +525,14 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
#endregion
#region Analyze MoveNext() and generate new body
BlockContainer AnalyzeMoveNext()
BlockContainer AnalyzeMoveNext(ILFunction function)
{
context.StepStartGroup("AnalyzeMoveNext");
MethodDefinitionHandle moveNextMethod = metadata.GetTypeDefinition(enumeratorType).GetMethods().FirstOrDefault(m => metadata.GetString(metadata.GetMethodDefinition(m).Name) == "MoveNext");
ILFunction moveNextFunction = CreateILAst(moveNextMethod, context);
function.MoveNextMethod = moveNextFunction.Method;
// Copy-propagate temporaries holding a copy of 'this'.
// This is necessary because the old (pre-Roslyn) C# compiler likes to store 'this' in temporary variables.
foreach (var stloc in moveNextFunction.Descendants.OfType<StLoc>().Where(s => s.Variable.IsSingleDefinition && s.Value.MatchLdThis()).ToList()) {

Loading…
Cancel
Save