Browse Source

Merge pull request #1843 from shimonmagal/yield-return-move-next

yield return moveNext
pull/1855/head
Siegfried Pammer 6 years ago committed by GitHub
parent
commit
7f7b6d8cd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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