|
|
@ -44,7 +44,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
// This is necessary to remove useless stores generated by some compilers, e.g., the F# compiler.
|
|
|
|
// This is necessary to remove useless stores generated by some compilers, e.g., the F# compiler.
|
|
|
|
// In yield return + async, the C# compiler tends to store null/default(T) to variables
|
|
|
|
// In yield return + async, the C# compiler tends to store null/default(T) to variables
|
|
|
|
// when the variable goes out of scope.
|
|
|
|
// when the variable goes out of scope.
|
|
|
|
var variableQueue = new Queue<ILVariable>(function.Variables.Where(v => v.Kind == VariableKind.Local || v.Kind == VariableKind.StackSlot)); |
|
|
|
var variableQueue = new Queue<ILVariable>(function.Variables); |
|
|
|
while (variableQueue.Count > 0) { |
|
|
|
while (variableQueue.Count > 0) { |
|
|
|
var v = variableQueue.Dequeue(); |
|
|
|
var v = variableQueue.Dequeue(); |
|
|
|
if (v.Kind != VariableKind.Local && v.Kind != VariableKind.StackSlot) |
|
|
|
if (v.Kind != VariableKind.Local && v.Kind != VariableKind.StackSlot) |
|
|
@ -58,7 +58,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
stloc.ReplaceWith(stloc.Value); |
|
|
|
stloc.ReplaceWith(stloc.Value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (stloc.Value is LdLoc ldloc && (ldloc.Variable.Kind == VariableKind.Local || ldloc.Variable.Kind == VariableKind.StackSlot)) { |
|
|
|
if (stloc.Value is LdLoc ldloc) { |
|
|
|
variableQueue.Enqueue(ldloc.Variable); |
|
|
|
variableQueue.Enqueue(ldloc.Variable); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|