Exemplo n.º 1
0
        /// <summary>
        /// If an expression node that declares synthesized short-lived locals (currently only sequence) contains an await, these locals become long-lived since their
        /// values may be read by code that follows the await. We promote these variables to long-lived of kind <see cref="SynthesizedLocalKind.AwaitSpill"/>.
        /// </summary>
        private void PromoteAndAddLocals(BoundSpillSequenceBuilder builder, ImmutableArray <LocalSymbol> locals)
        {
            foreach (var local in locals)
            {
                if (local.SynthesizedLocalKind.IsLongLived())
                {
                    builder.AddLocal(local, F.Diagnostics);
                }
                else
                {
                    SynthesizedLocal shortLived = (SynthesizedLocal)local;
                    SynthesizedLocal longLived  = shortLived.WithSynthesizedLocalKind(SynthesizedLocalKind.AwaitSpill);
                    tempSubstitution.Add(shortLived, longLived);

                    builder.AddLocal(longLived, F.Diagnostics);
                }
            }
        }