1 write to F
Microsoft.CodeAnalysis.CSharp (1)
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (1)
124
this.
F
= F;
428 references to F
Microsoft.CodeAnalysis.CSharp (428)
Lowering\AsyncRewriter\AsyncIteratorMethodToStateMachineRewriter.cs (60)
84
var iteratorDispatch = _iteratorStateAllocator.GenerateThrowMissingStateDispatch(
F
,
F
.Local(cachedState), HotReloadExceptionCode.CannotResumeSuspendedIteratorMethod);
90
return (asyncDispatch != null) ?
F
.Block(asyncDispatch, iteratorDispatch) : iteratorDispatch;
130
F
.Return(),
131
F
.Label(_exprReturnLabelTrue),
135
return
F
.Block(builder.ToImmutableAndFree());
141
BoundFieldAccess promiseField =
F
.InstanceField(_asyncIteratorInfo.PromiseOfValueOrEndField);
142
return
F
.ExpressionStatement(
F
.Call(promiseField, _asyncIteratorInfo.SetResultMethod,
F
.Literal(result)));
150
return
F
.Assignment(
F
.InstanceField(currentField),
F
.Default(currentField.Type));
157
return
F
.ExpressionStatement(
158
F
.Call(
159
F
.Field(
F
.This(), _asyncMethodBuilderField),
169
var combinedTokens =
F
.Field(
F
.This(), _asyncIteratorInfo.CombinedTokensField);
173
F
.If(
F
.ObjectNotEqual(combinedTokens,
F
.Null(combinedTokensType)),
174
thenClause:
F
.Block(
175
F
.ExpressionStatement(
F
.Call(combinedTokens,
F
.WellKnownMethod(WellKnownMember.System_Threading_CancellationTokenSource__Dispose))),
176
F
.Assignment(combinedTokens,
F
.Null(combinedTokensType)))));
194
builder.Add(
F
.ExpressionStatement(
F
.Call(
195
F
.InstanceField(_asyncIteratorInfo.PromiseOfValueOrEndField),
197
F
.Local(exceptionLocal))));
199
return
F
.Block(builder.ToImmutableAndFree());
205
return
F
.If(
207
F
.InstanceField(_asyncIteratorInfo.DisposeModeField),
209
thenClause:
F
.Goto(_currentDisposalLabel));
218
return
F
.Block(
231
return
F
.IntEqual(
F
.Local(cachedState),
F
.Literal(StateMachineState.NotStartedOrRunningState));
255
return
F
.Block(
256
F
.Label(resumeLabel), // initialStateResumeLabel:
284
F
.Assignment(
F
.InstanceField(_asyncIteratorInfo.CurrentField), rewrittenExpression));
292
F
.Goto(_exprReturnLabelTrue));
296
F
.Label(resumeLabel));
298
blockBuilder.Add(
F
.HiddenSequencePoint());
310
F
.HiddenSequencePoint());
312
return
F
.Block(blockBuilder.ToImmutableAndFree());
324
return
F
.Block(
328
F
.Goto(_currentDisposalLabel));
333
var useSiteInfo = new CompoundUseSiteInfo<AssemblySymbol>(
F
.Diagnostics,
F
.Compilation.Assembly);
336
F
.Diagnostics.Add(field.GetFirstLocationOrNone(), useSiteInfo);
349
return
F
.Assignment(
F
.InstanceField(_asyncIteratorInfo.DisposeModeField),
F
.Literal(value));
371
var finallyEntry =
F
.GenerateLabel("finallyEntry");
382
tryBlock:
F
.Block(node.TryBlock,
F
.Label(finallyEntry)),
Lowering\AsyncRewriter\AsyncMethodToStateMachineRewriter.cs (170)
114
if (slotAllocator == null || !slotAllocator.TryGetPreviousAwaiterSlotIndex(
F
.ModuleBuilderOpt.Translate(awaiterType,
F
.Syntax,
F
.Diagnostics.DiagnosticBag),
F
.Diagnostics.DiagnosticBag, out slotIndex))
120
result =
F
.StateMachineField(awaiterType, fieldName, SynthesizedLocalKind.AwaiterField, slotIndex);
138
F
.CurrentFunction = moveNextMethod;
146
bodyBuilder.Add(
F
.HiddenSequencePoint());
147
bodyBuilder.Add(
F
.Assignment(
F
.Local(cachedState),
F
.Field(
F
.This(), stateField)));
150
var exceptionLocal =
F
.SynthesizedLocal(
F
.WellKnownType(WellKnownType.System_Exception));
153
F
.Block(ImmutableArray<LocalSymbol>.Empty,
155
F
.HiddenSequencePoint(),
160
F
.CatchBlocks(generateExceptionHandling(exceptionLocal, rootScopeHoistedLocals)))
164
bodyBuilder.Add(
F
.Label(_exprReturnLabel));
167
var stateDone =
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(StateMachineState.FinishedState));
176
bodyBuilder.Add(
F
.SequencePointWithSpan(block, block.CloseBraceToken.Span, stateDone));
177
bodyBuilder.Add(
F
.HiddenSequencePoint());
186
bodyBuilder.Add(
F
.Label(_exitLabel));
187
bodyBuilder.Add(
F
.Return());
197
F
.SequencePoint(
199
F
.Block(
208
newBody =
F
.Instrument(newBody, instrumentation);
210
F
.CloseMethod(newBody);
228
F
.ExpressionStatement(
F
.AssignmentExpression(
F
.Field(
F
.This(), stateField),
F
.Literal(StateMachineState.FinishedState)));
234
F
.Syntax,
236
F
.Local(exceptionLocal),
240
body:
F
.Block(
250
=>
F
.Try(tryBlock, catchBlocks);
255
return
F
.ExpressionStatement(
256
F
.Call(
257
F
.Field(
F
.This(), _asyncMethodBuilderField),
259
_method.IsAsyncEffectivelyReturningGenericTask(
F
.Compilation)
260
? ImmutableArray.Create<BoundExpression>(
F
.Local(_exprRetValue))
272
var useSiteInfo = new CompoundUseSiteInfo<AssemblySymbol>(
F
.Diagnostics,
F
.Compilation.Assembly);
274
F
.Diagnostics.Add(hoistedLocal.GetFirstLocationOrNone(), useSiteInfo);
280
builder.Add(
F
.Assignment(
F
.Field(
F
.This(), hoistedLocal),
F
.NullOrDefault(hoistedLocal.Type)));
283
return
F
.Block(builder.ToImmutableAndFree());
291
return
F
.ExpressionStatement(
292
F
.Call(
293
F
.Field(
F
.This(), _asyncMethodBuilderField),
295
F
.Local(exceptionLocal)));
300
return
F
.Goto(_exitLabel);
324
return (expr != null) ? node.Update(expr) : (BoundStatement)
F
.StatementList();
373
var awaiterTemp =
F
.SynthesizedLocal(getAwaiter.Type, syntax: node.Syntax, kind: SynthesizedLocalKind.Awaiter);
374
var awaitIfIncomplete =
F
.Block(
376
F
.Assignment(
377
F
.Local(awaiterTemp),
381
F
.HiddenSequencePoint(),
384
F
.If(
385
condition:
F
.Not(GenerateGetIsCompleted(awaiterTemp, isCompletedMethod)),
388
F
.Local(awaiterTemp),
395
F
.Assignment(resultPlace, getResultCall) :
396
F
.ExpressionStatement(getResultCall);
406
return
F
.Block([awaiterTemp], statementsBuilder.ToImmutableAndFree());
426
?
F
.StaticCall(methodSymbol.ContainingType, methodSymbol, receiver)
427
:
F
.Call(receiver, methodSymbol);
449
F
.Local(awaiterTemp),
455
resultType:
F
.SpecialType(SpecialType.System_Boolean)).ToExpression();
458
return
F
.Call(
F
.Local(awaiterTemp), getIsCompletedMethod);
467
?
F
.SpecialType(SpecialType.System_Object)
480
F
.NoOp(NoOpStatementFlavor.AwaitYieldPoint));
484
F
.Assignment(
485
F
.Field(
F
.This(), awaiterField),
487
?
F
.Local(awaiterTemp)
488
:
F
.Convert(awaiterFieldType,
F
.Local(awaiterTemp))));
497
if (
F
.Compilation.Options.EnableEditAndContinue)
502
blockBuilder.Add(
F
.Label(dummyResumeLabel));
507
F
.Label(resumeLabel));
511
F
.NoOp(NoOpStatementFlavor.AwaitResumePoint));
516
F
.Assignment(
517
F
.Local(awaiterTemp),
519
?
F
.Field(
F
.This(), awaiterField)
520
:
F
.Convert(awaiterTemp.Type,
F
.Field(
F
.This(), awaiterField))));
523
F
.Assignment(
F
.Field(
F
.This(), awaiterField),
F
.NullOrDefault(awaiterField.Type)));
529
return
F
.Block(blockBuilder.ToImmutableAndFree());
549
var criticalNotifyCompletedTemp =
F
.SynthesizedLocal(
550
F
.WellKnownType(WellKnownType.System_Runtime_CompilerServices_ICriticalNotifyCompletion),
553
var notifyCompletionTemp =
F
.SynthesizedLocal(
554
F
.WellKnownType(WellKnownType.System_Runtime_CompilerServices_INotifyCompletion),
557
LocalSymbol thisTemp = (
F
.CurrentType.TypeKind == TypeKind.Class) ?
F
.SynthesizedLocal(
F
.CurrentType) : null;
562
F
.Assignment(
563
F
.Local(criticalNotifyCompletedTemp),
565
F
.As(
F
.Local(awaiterTemp), criticalNotifyCompletedTemp.Type)));
569
blockBuilder.Add(
F
.Assignment(
F
.Local(thisTemp),
F
.This()));
573
F
.If(
574
condition:
F
.ObjectEqual(
F
.Local(criticalNotifyCompletedTemp),
F
.Null(criticalNotifyCompletedTemp.Type)),
576
thenClause:
F
.Block(
578
F
.Assignment(
579
F
.Local(notifyCompletionTemp),
581
F
.Convert(notifyCompletionTemp.Type,
F
.Local(awaiterTemp), Conversion.ExplicitReference)),
582
F
.ExpressionStatement(
583
F
.Call(
584
F
.Field(
F
.This(), _asyncMethodBuilderField),
587
F
.This().Type),
588
F
.Local(notifyCompletionTemp),
F
.This(thisTemp))),
589
F
.Assignment(
590
F
.Local(notifyCompletionTemp),
591
F
.NullOrDefault(notifyCompletionTemp.Type))),
593
elseClauseOpt:
F
.Block(
594
F
.ExpressionStatement(
595
F
.Call(
596
F
.Field(
F
.This(), _asyncMethodBuilderField),
599
F
.This().Type),
600
F
.Local(criticalNotifyCompletedTemp),
F
.This(thisTemp))))));
603
F
.Assignment(
604
F
.Local(criticalNotifyCompletedTemp),
605
F
.NullOrDefault(criticalNotifyCompletedTemp.Type)));
607
return
F
.Block(
618
LocalSymbol thisTemp = (
F
.CurrentType.TypeKind == TypeKind.Class) ?
F
.SynthesizedLocal(
F
.CurrentType) : null;
621
var useUnsafeOnCompleted =
F
.Compilation.Conversions.ClassifyImplicitConversionFromType(
623
F
.Compilation.GetWellKnownType(WellKnownType.System_Runtime_CompilerServices_ICriticalNotifyCompletion),
628
_asyncMethodBuilderMemberCollection.AwaitOnCompleted).Construct(loweredAwaiterType,
F
.This().Type);
631
onCompleted.CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(
F
.Compilation,
F
.Compilation.Conversions, includeNullability: false,
F
.Syntax.Location, this.Diagnostics));
635
F
.Call(
636
F
.Field(
F
.This(), _asyncMethodBuilderField),
638
F
.Local(awaiterTemp),
F
.This(thisTemp));
642
result =
F
.Sequence(
644
ImmutableArray.Create<BoundExpression>(
F
.AssignmentExpression(
F
.Local(thisTemp),
F
.This())),
648
return
F
.ExpressionStatement(result);
660
Debug.Assert(_method.IsAsyncEffectivelyReturningGenericTask(
F
.Compilation));
661
return
F
.Block(
662
F
.Assignment(
F
.Local(_exprRetValue), (BoundExpression)Visit(node.ExpressionOpt)),
663
F
.Goto(_exprReturnLabel));
666
return
F
.Goto(_exprReturnLabel);
Lowering\IteratorRewriter\IteratorMethodToStateMachineRewriter.cs (115)
98
F
.CurrentFunction = moveNextMethod;
112
newBody =
F
.Block((object)cachedThis == null ?
116
F
.HiddenSequencePoint(),
117
F
.Assignment(
F
.Local(cachedState),
F
.Field(
F
.This(), stateField)),
121
F
.Label(initialLabel),
122
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(StateMachineState.NotStartedOrRunningState)),
147
var faultBlock =
F
.Block(
F
.ExpressionStatement(
F
.Call(
F
.This(), disposeMethod)));
148
newBody =
F
.Fault((BoundBlock)newBody, faultBlock);
151
newBody =
F
.Instrument(
F
.SequencePoint(body.Syntax, HandleReturn(newBody)), instrumentation);
153
F
.CloseMethod(newBody);
158
F
.CurrentFunction = disposeMethod;
164
var disposeBody =
F
.Block(
166
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(StateMachineState.FinishedState)),
167
F
.Return());
169
F
.CloseMethod(disposeBody);
173
var stateLocal =
F
.SynthesizedLocal(stateField.Type);
174
var state =
F
.Local(stateLocal);
176
var disposeBody =
F
.Block(
178
F
.Assignment(
F
.Local(stateLocal),
F
.Field(
F
.This(), stateField)),
181
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(StateMachineState.FinishedState)),
182
F
.Return());
184
F
.CloseMethod(disposeBody);
194
return
F
.Block(
196
F
.Return(
F
.Literal(false)));
204
return
F
.Block(
207
F
.Assignment(this.
F
.Local(_methodValue), this.
F
.Literal(true)),
208
F
.Label(_exitLabel),
209
F
.Return(this.
F
.Local(_methodValue)));
264
var breakLabel =
F
.GenerateLabel("break");
267
select
F
.SwitchSection(
270
F
.Goto(breakLabel));
272
body =
F
.Block(
273
F
.Switch(state, sections.ToImmutableArray()),
274
F
.Label(breakLabel));
279
var tryBlock = body != null ?
F
.Block(body) :
F
.Block();
280
body =
F
.Try(
283
F
.Block(
F
.ExpressionStatement(
F
.Call(
F
.This(), frame.handler))));
292
BoundLiteral result = this.
F
.Literal(!finished);
296
return
F
.Return(result);
302
_exitLabel = this.
F
.GenerateLabel("exitLabel");
303
_methodValue =
F
.SynthesizedLocal(result.Type);
306
var gotoExit =
F
.Goto(_exitLabel);
314
return this.
F
.Block(
315
F
.Assignment(this.
F
.Local(_methodValue), result),
342
return
F
.Block(
343
F
.Assignment(
F
.Field(
F
.This(), _current), rewrittenExpression),
344
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(stateNumber)),
346
F
.Label(resumeLabel),
347
F
.HiddenSequencePoint(),
348
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(_currentFinallyFrame.finalizeState)));
356
Debug.Assert(node.Label == proxyLabel || !(
F
.CurrentFunction is IteratorFinallyMethodSymbol), "should not be proxying branches in finally");
395
var origMethod =
F
.CurrentFunction;
398
F
.CurrentFunction = finallyMethod;
410
rewrittenHandler =
F
.Block((object)this.cachedThis != null ?
413
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(frame.parent.finalizeState)),
416
F
.Return()
419
F
.CloseMethod(rewrittenHandler);
420
F
.CurrentFunction = origMethod;
431
bodyStatements.Add(
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.Literal(frame.finalizeState)));
433
bodyStatements.Add(
F
.ExpressionStatement(
F
.Call(
F
.This(), finallyMethod)));
438
var dropThrough =
F
.GenerateLabel("dropThrough");
439
bodyStatements.Add(
F
.Goto(dropThrough));
448
bodyStatements.Add(
F
.Label(proxy));
451
bodyStatements.Add(
F
.ExpressionStatement(
F
.Call(
F
.This(), finallyMethod)));
455
bodyStatements.Add(
F
.Goto(parentProxy));
458
bodyStatements.Add(
F
.Label(dropThrough));
461
return
F
.Block(bodyStatements.ToImmutableAndFree());
496
var stateMachineType = (IteratorStateMachine)
F
.CurrentType;
499
F
.ModuleBuilderOpt.AddSynthesizedDefinition(stateMachineType, finallyMethod.GetCciAdapter());
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (83)
183
get { return ((SynthesizedContainer)
F
.CurrentType).TypeMap; }
188
get { return
F
.CurrentFunction; }
206
var oldSyntax =
F
.Syntax;
207
F
.Syntax = syntax;
208
var result =
F
.This();
210
F
.Syntax = oldSyntax;
236
resumeLabel =
F
.GenerateLabel("stateMachine");
250
select
F
.SwitchSection(kv.Value.SelectAsArray(state => (int)state),
F
.Goto(kv.Key));
252
var result =
F
.Switch(
F
.Local(cachedState), sections.ToImmutableArray());
265
result =
F
.Block(result, missingStateDispatch);
273
=> _resumableStateAllocator.GenerateThrowMissingStateDispatch(
F
,
F
.Local(cachedState), EncMissingStateErrorCode);
382
translatedStatement =
F
.Block(
384
F
.Block(variableCleanup.SelectAsArray((e, f) => (BoundStatement)f.ExpressionStatement(e),
F
)));
405
return
F
.Block(new BoundStateMachineScope(
F
.Syntax, hoistedLocals, statement));
436
var useSiteInfo = new CompoundUseSiteInfo<AssemblySymbol>(
F
.Diagnostics,
F
.Compilation.Assembly);
438
F
.Diagnostics.Add(field.GetFirstLocationOrNone(), useSiteInfo);
441
cleanup.Add(
F
.AssignmentExpression(
F
.Field(
F
.This(), field),
F
.NullOrDefault(field.Type)));
455
var result =
F
.Block(variableCleanup.SelectAsArray((e, f) => (BoundStatement)f.ExpressionStatement(e),
F
));
480
createdField =
F
.StateMachineField(type, fieldName, SynthesizedLocalKind.UserDefined, slotIndex);
484
createdField =
F
.StateMachineField(type, GeneratedNames.ReusableHoistedLocalFieldName(slotIndex));
530
if (
F
.Compilation.Options.OptimizationLevel == OptimizationLevel.Debug)
558
var sacrificialTemp =
F
.SynthesizedLocal(type, refKind: RefKind.Ref);
560
return
F
.Sequence(ImmutableArray.Create(sacrificialTemp), sideEffects.ToImmutableAndFree(),
F
.AssignmentExpression(
F
.Local(sacrificialTemp), replacement, isRef: true));
571
return
F
.Sequence(ImmutableArray<LocalSymbol>.Empty, sideEffects.ToImmutableAndFree(), last);
623
return
F
.Field(receiver, field.FieldSymbol);
643
F
.Diagnostics.Add(ErrorCode.ERR_RefReturningCallAndAwait,
F
.Syntax.Location, call.Method);
661
F
.Diagnostics.Add(ErrorCode.ERR_RefConditionalAndAwait,
F
.Syntax.Location);
680
if (
F
.Compilation.Options.OptimizationLevel == OptimizationLevel.Debug)
695
F
.ModuleBuilderOpt.Translate(fieldType, awaitSyntaxOpt, Diagnostics.DiagnosticBag),
705
hoistedField =
F
.StateMachineField(expr.Type, fieldName, new LocalSlotDebugInfo(kind, id), slotIndex);
715
var replacement =
F
.Field(
F
.This(), hoistedField);
716
sideEffects.Add(
F
.AssignmentExpression(replacement, expr));
726
var oldSyntax =
F
.Syntax;
727
F
.Syntax = node.Syntax;
729
F
.Syntax = oldSyntax;
745
=>
F
.Field(
F
.This(), instanceIdField);
882
BoundBlock tryBlock =
F
.Block((BoundStatement)this.Visit(node.TryBlock));
886
dispatchLabel =
F
.GenerateLabel("tryDispatch");
888
tryBlock =
F
.Block(
889
F
.HiddenSequencePoint(),
901
BoundBlock finallyBlockOpt = node.FinallyBlockOpt == null ? null :
F
.Block(
902
F
.HiddenSequencePoint(),
903
F
.If(
907
F
.HiddenSequencePoint());
913
result =
F
.Block(
914
F
.HiddenSequencePoint(),
915
F
.Label(dispatchLabel),
929
return
F
.IntLessThan(
F
.Local(cachedState),
F
.Literal(StateMachineState.FirstUnusedState));
938
return
F
.Assignment(
F
.Field(
F
.This(), stateField),
F
.AssignmentExpression(
F
.Local(cachedState),
F
.Literal(stateNumber)));
947
var fetchThis = proxy.Replacement(
F
.Syntax, static (frameType, F) => F.This(),
F
);
948
return
F
.Assignment(
F
.Local(this.cachedThis), fetchThis);
952
return
F
.StatementList();
960
return
F
.Local(this.cachedThis);
983
return proxy.Replacement(
F
.Syntax, static (frameType, F) => F.This(),
F
);
994
return
F
.Local(this.cachedThis);
999
return proxy.Replacement(
F
.Syntax, static (frameType, F) => F.This(),
F
);