1 write to F
Microsoft.CodeAnalysis.CSharp (1)
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (1)
122
this.
F
= F;
411 references to F
Microsoft.CodeAnalysis.CSharp (411)
Lowering\AsyncRewriter\AsyncIteratorMethodToStateMachineRewriter.cs (57)
83
var iteratorDispatch = _iteratorStateAllocator.GenerateThrowMissingStateDispatch(
F
,
F
.Local(cachedState), HotReloadExceptionCode.CannotResumeSuspendedIteratorMethod);
89
return (asyncDispatch != null) ?
F
.Block(asyncDispatch, iteratorDispatch) : iteratorDispatch;
119
F
.Return(),
120
F
.Label(_exprReturnLabelTrue),
124
return
F
.Block(builder.ToImmutableAndFree());
130
BoundFieldAccess promiseField =
F
.InstanceField(_asyncIteratorInfo.PromiseOfValueOrEndField);
131
return
F
.ExpressionStatement(
F
.Call(promiseField, _asyncIteratorInfo.SetResultMethod,
F
.Literal(result)));
139
return
F
.Assignment(
F
.InstanceField(currentField),
F
.Default(currentField.Type));
146
return
F
.ExpressionStatement(
147
F
.Call(
148
F
.Field(
F
.This(), _asyncMethodBuilderField),
158
var combinedTokens =
F
.Field(
F
.This(), _asyncIteratorInfo.CombinedTokensField);
162
F
.If(
F
.ObjectNotEqual(combinedTokens,
F
.Null(combinedTokensType)),
163
thenClause:
F
.Block(
164
F
.ExpressionStatement(
F
.Call(combinedTokens,
F
.WellKnownMethod(WellKnownMember.System_Threading_CancellationTokenSource__Dispose))),
165
F
.Assignment(combinedTokens,
F
.Null(combinedTokensType)))));
183
builder.Add(
F
.ExpressionStatement(
F
.Call(
184
F
.InstanceField(_asyncIteratorInfo.PromiseOfValueOrEndField),
186
F
.Local(exceptionLocal))));
188
return
F
.Block(builder.ToImmutableAndFree());
194
return
F
.If(
196
F
.InstanceField(_asyncIteratorInfo.DisposeModeField),
198
thenClause:
F
.Goto(_currentDisposalLabel));
207
return
F
.Block(
220
return
F
.IntEqual(
F
.Local(cachedState),
F
.Literal(StateMachineState.NotStartedOrRunningState));
244
return
F
.Block(
245
F
.Label(resumeLabel), // initialStateResumeLabel:
273
F
.Assignment(
F
.InstanceField(_asyncIteratorInfo.CurrentField), rewrittenExpression));
281
F
.Goto(_exprReturnLabelTrue));
285
F
.Label(resumeLabel));
287
blockBuilder.Add(
F
.HiddenSequencePoint());
299
F
.HiddenSequencePoint());
301
return
F
.Block(blockBuilder.ToImmutableAndFree());
313
return
F
.Block(
317
F
.Goto(_currentDisposalLabel));
322
return
F
.Assignment(
F
.InstanceField(_asyncIteratorInfo.DisposeModeField),
F
.Literal(value));
344
var finallyEntry =
F
.GenerateLabel("finallyEntry");
355
tryBlock:
F
.Block(node.TryBlock,
F
.Label(finallyEntry)),
Lowering\AsyncRewriter\AsyncMethodToStateMachineRewriter.cs (170)
112
if (slotAllocator == null || !slotAllocator.TryGetPreviousAwaiterSlotIndex(
F
.ModuleBuilderOpt.Translate(awaiterType,
F
.Syntax,
F
.Diagnostics.DiagnosticBag),
F
.Diagnostics.DiagnosticBag, out slotIndex))
118
result =
F
.StateMachineField(awaiterType, fieldName, SynthesizedLocalKind.AwaiterField, slotIndex);
136
F
.CurrentFunction = moveNextMethod;
144
bodyBuilder.Add(
F
.HiddenSequencePoint());
145
bodyBuilder.Add(
F
.Assignment(
F
.Local(cachedState),
F
.Field(
F
.This(), stateField)));
148
var exceptionLocal =
F
.SynthesizedLocal(
F
.WellKnownType(WellKnownType.System_Exception));
151
F
.Block(ImmutableArray<LocalSymbol>.Empty,
153
F
.HiddenSequencePoint(),
158
F
.CatchBlocks(GenerateExceptionHandling(exceptionLocal, rootScopeHoistedLocals)))
162
bodyBuilder.Add(
F
.Label(_exprReturnLabel));
165
var stateDone =
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(StateMachineState.FinishedState));
174
bodyBuilder.Add(
F
.SequencePointWithSpan(block, block.CloseBraceToken.Span, stateDone));
175
bodyBuilder.Add(
F
.HiddenSequencePoint());
184
bodyBuilder.Add(
F
.Label(_exitLabel));
185
bodyBuilder.Add(
F
.Return());
195
F
.SequencePoint(
197
F
.Block(
206
newBody =
F
.Instrument(newBody, instrumentation);
208
F
.CloseMethod(newBody);
212
=>
F
.Try(tryBlock, catchBlocks);
217
return
F
.ExpressionStatement(
218
F
.Call(
219
F
.Field(
F
.This(), _asyncMethodBuilderField),
221
_method.IsAsyncEffectivelyReturningGenericTask(
F
.Compilation)
222
? ImmutableArray.Create<BoundExpression>(
F
.Local(_exprRetValue))
241
F
.ExpressionStatement(
F
.AssignmentExpression(
F
.Field(
F
.This(), stateField),
F
.Literal(StateMachineState.FinishedState)));
247
F
.Syntax,
249
F
.Local(exceptionLocal),
253
body:
F
.Block(
269
var useSiteInfo = new CompoundUseSiteInfo<AssemblySymbol>(
F
.Diagnostics,
F
.Compilation.Assembly);
271
F
.Diagnostics.Add(hoistedLocal.GetFirstLocationOrNone(), useSiteInfo);
277
builder.Add(
F
.Assignment(
F
.Field(
F
.This(), hoistedLocal),
F
.NullOrDefault(hoistedLocal.Type)));
280
return
F
.Block(builder.ToImmutableAndFree());
288
return
F
.ExpressionStatement(
289
F
.Call(
290
F
.Field(
F
.This(), _asyncMethodBuilderField),
292
F
.Local(exceptionLocal)));
297
return
F
.Goto(_exitLabel);
321
return (expr != null) ? node.Update(expr) : (BoundStatement)
F
.StatementList();
364
var awaiterTemp =
F
.SynthesizedLocal(getAwaiter.Type, syntax: node.Syntax, kind: SynthesizedLocalKind.Awaiter);
365
var awaitIfIncomplete =
F
.Block(
367
F
.Assignment(
368
F
.Local(awaiterTemp),
372
F
.HiddenSequencePoint(),
375
F
.If(
376
condition:
F
.Not(GenerateGetIsCompleted(awaiterTemp, isCompletedMethod)),
379
F
.Local(awaiterTemp),
386
F
.Assignment(resultPlace, getResultCall) :
387
F
.ExpressionStatement(getResultCall);
389
return
F
.Block(
412
?
F
.StaticCall(methodSymbol.ContainingType, methodSymbol, receiver)
413
:
F
.Call(receiver, methodSymbol);
435
F
.Local(awaiterTemp),
441
resultType:
F
.SpecialType(SpecialType.System_Boolean)).ToExpression();
444
return
F
.Call(
F
.Local(awaiterTemp), getIsCompletedMethod);
453
?
F
.SpecialType(SpecialType.System_Object)
466
F
.NoOp(NoOpStatementFlavor.AwaitYieldPoint));
470
F
.Assignment(
471
F
.Field(
F
.This(), awaiterField),
473
?
F
.Local(awaiterTemp)
474
:
F
.Convert(awaiterFieldType,
F
.Local(awaiterTemp))));
483
if (
F
.Compilation.Options.EnableEditAndContinue)
488
blockBuilder.Add(
F
.Label(dummyResumeLabel));
493
F
.Label(resumeLabel));
497
F
.NoOp(NoOpStatementFlavor.AwaitResumePoint));
502
F
.Assignment(
503
F
.Local(awaiterTemp),
505
?
F
.Field(
F
.This(), awaiterField)
506
:
F
.Convert(awaiterTemp.Type,
F
.Field(
F
.This(), awaiterField))));
509
F
.Assignment(
F
.Field(
F
.This(), awaiterField),
F
.NullOrDefault(awaiterField.Type)));
515
return
F
.Block(blockBuilder.ToImmutableAndFree());
535
var criticalNotifyCompletedTemp =
F
.SynthesizedLocal(
536
F
.WellKnownType(WellKnownType.System_Runtime_CompilerServices_ICriticalNotifyCompletion),
539
var notifyCompletionTemp =
F
.SynthesizedLocal(
540
F
.WellKnownType(WellKnownType.System_Runtime_CompilerServices_INotifyCompletion),
543
LocalSymbol thisTemp = (
F
.CurrentType.TypeKind == TypeKind.Class) ?
F
.SynthesizedLocal(
F
.CurrentType) : null;
548
F
.Assignment(
549
F
.Local(criticalNotifyCompletedTemp),
551
F
.As(
F
.Local(awaiterTemp), criticalNotifyCompletedTemp.Type)));
555
blockBuilder.Add(
F
.Assignment(
F
.Local(thisTemp),
F
.This()));
559
F
.If(
560
condition:
F
.ObjectEqual(
F
.Local(criticalNotifyCompletedTemp),
F
.Null(criticalNotifyCompletedTemp.Type)),
562
thenClause:
F
.Block(
564
F
.Assignment(
565
F
.Local(notifyCompletionTemp),
567
F
.Convert(notifyCompletionTemp.Type,
F
.Local(awaiterTemp), Conversion.ExplicitReference)),
568
F
.ExpressionStatement(
569
F
.Call(
570
F
.Field(
F
.This(), _asyncMethodBuilderField),
573
F
.This().Type),
574
F
.Local(notifyCompletionTemp),
F
.This(thisTemp))),
575
F
.Assignment(
576
F
.Local(notifyCompletionTemp),
577
F
.NullOrDefault(notifyCompletionTemp.Type))),
579
elseClauseOpt:
F
.Block(
580
F
.ExpressionStatement(
581
F
.Call(
582
F
.Field(
F
.This(), _asyncMethodBuilderField),
585
F
.This().Type),
586
F
.Local(criticalNotifyCompletedTemp),
F
.This(thisTemp))))));
589
F
.Assignment(
590
F
.Local(criticalNotifyCompletedTemp),
591
F
.NullOrDefault(criticalNotifyCompletedTemp.Type)));
593
return
F
.Block(
604
LocalSymbol thisTemp = (
F
.CurrentType.TypeKind == TypeKind.Class) ?
F
.SynthesizedLocal(
F
.CurrentType) : null;
607
var useUnsafeOnCompleted =
F
.Compilation.Conversions.ClassifyImplicitConversionFromType(
609
F
.Compilation.GetWellKnownType(WellKnownType.System_Runtime_CompilerServices_ICriticalNotifyCompletion),
614
_asyncMethodBuilderMemberCollection.AwaitOnCompleted).Construct(loweredAwaiterType,
F
.This().Type);
617
onCompleted.CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(
F
.Compilation,
F
.Compilation.Conversions, includeNullability: false,
F
.Syntax.Location, this.Diagnostics));
621
F
.Call(
622
F
.Field(
F
.This(), _asyncMethodBuilderField),
624
F
.Local(awaiterTemp),
F
.This(thisTemp));
628
result =
F
.Sequence(
630
ImmutableArray.Create<BoundExpression>(
F
.AssignmentExpression(
F
.Local(thisTemp),
F
.This())),
634
return
F
.ExpressionStatement(result);
646
Debug.Assert(_method.IsAsyncEffectivelyReturningGenericTask(
F
.Compilation));
647
return
F
.Block(
648
F
.Assignment(
F
.Local(_exprRetValue), (BoundExpression)Visit(node.ExpressionOpt)),
649
F
.Goto(_exprReturnLabel));
652
return
F
.Goto(_exprReturnLabel);
Lowering\IteratorRewriter\IteratorMethodToStateMachineRewriter.cs (106)
97
F
.CurrentFunction = moveNextMethod;
111
newBody =
F
.Block((object)cachedThis == null ?
115
F
.HiddenSequencePoint(),
116
F
.Assignment(
F
.Local(cachedState),
F
.Field(
F
.This(), stateField)),
120
F
.Label(initialLabel),
121
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(StateMachineState.NotStartedOrRunningState)),
146
var faultBlock =
F
.Block(
F
.ExpressionStatement(
F
.Call(
F
.This(), disposeMethod)));
147
newBody =
F
.Fault((BoundBlock)newBody, faultBlock);
150
newBody =
F
.Instrument(
F
.SequencePoint(body.Syntax, HandleReturn(newBody)), instrumentation);
152
F
.CloseMethod(newBody);
157
F
.CurrentFunction = disposeMethod;
163
F
.CloseMethod(
F
.Return());
167
var stateLocal =
F
.SynthesizedLocal(stateField.Type);
168
var state =
F
.Local(stateLocal);
170
var disposeBody =
F
.Block(
172
F
.Assignment(
F
.Local(stateLocal),
F
.Field(
F
.This(), stateField)),
174
F
.Return());
176
F
.CloseMethod(disposeBody);
186
return
F
.Block(
188
F
.Return(
F
.Literal(false)));
196
return
F
.Block(
199
F
.Assignment(this.
F
.Local(_methodValue), this.
F
.Literal(true)),
200
F
.Label(_exitLabel),
201
F
.Return(this.
F
.Local(_methodValue)));
256
var breakLabel =
F
.GenerateLabel("break");
259
select
F
.SwitchSection(
262
F
.Goto(breakLabel));
264
body =
F
.Block(
265
F
.Switch(state, sections.ToImmutableArray()),
266
F
.Label(breakLabel));
271
var tryBlock = body != null ?
F
.Block(body) :
F
.Block();
272
body =
F
.Try(
275
F
.Block(
F
.ExpressionStatement(
F
.Call(
F
.This(), frame.handler))));
284
BoundLiteral result = this.
F
.Literal(!finished);
288
return
F
.Return(result);
294
_exitLabel = this.
F
.GenerateLabel("exitLabel");
295
_methodValue =
F
.SynthesizedLocal(result.Type);
298
var gotoExit =
F
.Goto(_exitLabel);
306
return this.
F
.Block(
307
F
.Assignment(this.
F
.Local(_methodValue), result),
334
return
F
.Block(
335
F
.Assignment(
F
.Field(
F
.This(), _current), rewrittenExpression),
336
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(stateNumber)),
338
F
.Label(resumeLabel),
339
F
.HiddenSequencePoint(),
340
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(_currentFinallyFrame.finalizeState)));
348
Debug.Assert(node.Label == proxyLabel || !(
F
.CurrentFunction is IteratorFinallyMethodSymbol), "should not be proxying branches in finally");
387
var origMethod =
F
.CurrentFunction;
390
F
.CurrentFunction = finallyMethod;
402
rewrittenHandler =
F
.Block((object)this.cachedThis != null ?
405
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(frame.parent.finalizeState)),
408
F
.Return()
411
F
.CloseMethod(rewrittenHandler);
412
F
.CurrentFunction = origMethod;
423
bodyStatements.Add(
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(frame.finalizeState)));
425
bodyStatements.Add(
F
.ExpressionStatement(
F
.Call(
F
.This(), finallyMethod)));
430
var dropThrough =
F
.GenerateLabel("dropThrough");
431
bodyStatements.Add(
F
.Goto(dropThrough));
440
bodyStatements.Add(
F
.Label(proxy));
443
bodyStatements.Add(
F
.ExpressionStatement(
F
.Call(
F
.This(), finallyMethod)));
447
bodyStatements.Add(
F
.Goto(parentProxy));
450
bodyStatements.Add(
F
.Label(dropThrough));
453
return
F
.Block(bodyStatements.ToImmutableAndFree());
488
var stateMachineType = (IteratorStateMachine)
F
.CurrentType;
491
F
.ModuleBuilderOpt.AddSynthesizedDefinition(stateMachineType, finallyMethod.GetCciAdapter());
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (78)
178
get { return ((SynthesizedContainer)
F
.CurrentType).TypeMap; }
183
get { return
F
.CurrentFunction; }
201
var oldSyntax =
F
.Syntax;
202
F
.Syntax = syntax;
203
var result =
F
.This();
205
F
.Syntax = oldSyntax;
231
resumeLabel =
F
.GenerateLabel("stateMachine");
245
select
F
.SwitchSection(kv.Value.SelectAsArray(state => (int)state),
F
.Goto(kv.Key));
247
var result =
F
.Switch(
F
.Local(cachedState), sections.ToImmutableArray());
260
result =
F
.Block(result, missingStateDispatch);
268
=> _resumableStateAllocator.GenerateThrowMissingStateDispatch(
F
,
F
.Local(cachedState), EncMissingStateErrorCode);
377
translatedStatement =
F
.Block(
379
F
.Block(variableCleanup.SelectAsArray((e, f) => (BoundStatement)f.ExpressionStatement(e),
F
)));
400
return
F
.Block(new BoundStateMachineScope(
F
.Syntax, hoistedLocals, statement));
429
cleanup.Add(
F
.AssignmentExpression(
F
.Field(
F
.This(), field),
F
.NullOrDefault(field.Type)));
469
return
F
.StateMachineField(type, fieldName, SynthesizedLocalKind.UserDefined, slotIndex);
472
return
F
.StateMachineField(type, GeneratedNames.ReusableHoistedLocalFieldName(slotIndex));
513
if (
F
.Compilation.Options.OptimizationLevel == OptimizationLevel.Debug)
541
var sacrificialTemp =
F
.SynthesizedLocal(type, refKind: RefKind.Ref);
543
return
F
.Sequence(ImmutableArray.Create(sacrificialTemp), sideEffects.ToImmutableAndFree(),
F
.AssignmentExpression(
F
.Local(sacrificialTemp), replacement, isRef: true));
554
return
F
.Sequence(ImmutableArray<LocalSymbol>.Empty, sideEffects.ToImmutableAndFree(), last);
606
return
F
.Field(receiver, field.FieldSymbol);
626
F
.Diagnostics.Add(ErrorCode.ERR_RefReturningCallAndAwait,
F
.Syntax.Location, call.Method);
644
F
.Diagnostics.Add(ErrorCode.ERR_RefConditionalAndAwait,
F
.Syntax.Location);
663
if (
F
.Compilation.Options.OptimizationLevel == OptimizationLevel.Debug)
678
F
.ModuleBuilderOpt.Translate(fieldType, awaitSyntaxOpt, Diagnostics.DiagnosticBag),
688
hoistedField =
F
.StateMachineField(expr.Type, fieldName, new LocalSlotDebugInfo(kind, id), slotIndex);
697
var replacement =
F
.Field(
F
.This(), hoistedField);
698
sideEffects.Add(
F
.AssignmentExpression(replacement, expr));
708
var oldSyntax =
F
.Syntax;
709
F
.Syntax = node.Syntax;
711
F
.Syntax = oldSyntax;
727
=>
F
.Field(
F
.This(), instanceIdField);
864
BoundBlock tryBlock =
F
.Block((BoundStatement)this.Visit(node.TryBlock));
868
dispatchLabel =
F
.GenerateLabel("tryDispatch");
870
tryBlock =
F
.Block(
871
F
.HiddenSequencePoint(),
883
BoundBlock finallyBlockOpt = node.FinallyBlockOpt == null ? null :
F
.Block(
884
F
.HiddenSequencePoint(),
885
F
.If(
889
F
.HiddenSequencePoint());
895
result =
F
.Block(
896
F
.HiddenSequencePoint(),
897
F
.Label(dispatchLabel),
911
return
F
.IntLessThan(
F
.Local(cachedState),
F
.Literal(StateMachineState.FirstUnusedState));
920
return
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.AssignmentExpression(
F
.Local(cachedState),
F
.Literal(stateNumber)));
929
var fetchThis = proxy.Replacement(
F
.Syntax, static (frameType, F) => F.This(),
F
);
930
return
F
.Assignment(
F
.Local(this.cachedThis), fetchThis);
934
return
F
.StatementList();
942
return
F
.Local(this.cachedThis);
965
return proxy.Replacement(
F
.Syntax, static (frameType, F) => F.This(),
F
);
976
return
F
.Local(this.cachedThis);
981
return proxy.Replacement(
F
.Syntax, static (frameType, F) => F.This(),
F
);