本文整理汇总了C#中YieldStatementSyntax类的典型用法代码示例。如果您正苦于以下问题:C# YieldStatementSyntax类的具体用法?C# YieldStatementSyntax怎么用?C# YieldStatementSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
YieldStatementSyntax类属于命名空间,在下文中一共展示了YieldStatementSyntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIteratorElementType
// NOTE: Specifically not overriding IsIndirectlyInIterator.
internal override TypeSymbol GetIteratorElementType(YieldStatementSyntax node, DiagnosticBag diagnostics)
{
if (node != null)
{
diagnostics.Add(ErrorCode.ERR_YieldInAnonMeth, node.YieldKeyword.GetLocation());
}
return CreateErrorType();
}
示例2: MakeTaskYieldReturnStatements
private async Task<Document> MakeTaskYieldReturnStatements(Document document, YieldStatementSyntax yieldStatement, CancellationToken ct)
{
var root = await document.GetSyntaxRootAsync(ct).ConfigureAwait(false);
var semanticModel = await document.GetSemanticModelAsync(ct);
var nodes = yieldStatement.CreateFixedYieldReturn(semanticModel);
root = root.ReplaceNode(yieldStatement, nodes);
return document.WithSyntaxRoot(root);
}
示例3: Go
public static void Go(OutputWriter writer, YieldStatementSyntax yieldStatementSyntax)
{
if (yieldStatementSyntax.ReturnOrBreakKeyword.IsKind(SyntaxKind.ReturnKeyword))
{
writer.WriteLine("__iter.yieldReturn({0});", Core.WriteString(yieldStatementSyntax.Expression));
}
else
{
writer.WriteLine("__iter.yieldBreak();");
}
}
示例4: VisitYieldStatement
public override void VisitYieldStatement(YieldStatementSyntax node)
{
var nextState = GetNextState(node);
if (node.ReturnOrBreakKeyword.IsKind(SyntaxKind.BreakKeyword))
{
currentState.Add(ChangeState(nextState));
currentState.Add(Cs.Return(Cs.False()));
}
else
{
currentState.Add(ChangeState(nextState));
currentState.Add(Cs.Express(Cs.This().Member("Current").Assign(StateMachineThisFixer.Fix(node.Expression))));
currentState.Add(Cs.Return(Cs.True()));
}
SetClosed(currentState);
currentState = nextState;
}
示例5: VisitYieldStatement
public override void VisitYieldStatement(YieldStatementSyntax node)
{
var nextState = GetNextState();
if (node.ReturnOrBreakKeyword.IsKind(SyntaxKind.BreakKeyword))
{
CurrentState.Add(ChangeState(nextState));
CurrentState.Add(Js.Primitive(false).Return());
}
else
{
CurrentState.Add(ChangeState(nextState));
// if (Transformer.Model.Compilation.Assembly.AreAutoPropertiesMinimized())
// CurrentState.Add(Js.Reference(stateMachine).Member("Current").Assign((JsExpression)node.Expression.Accept(Transformer)).Express());
// else
CurrentState.Add(Js.Reference(stateMachine).Member("set_Current").Invoke((JsExpression)node.Expression.Accept(Transformer)).Express());
CurrentState.Add(Js.Primitive(true).Return());
}
CurrentState = nextState;
}
示例6: VisitYieldStatement
public void VisitYieldStatement(YieldStatementSyntax node)
{
if (node == null)
throw new ArgumentNullException("node");
node.Validate();
WriteLeadingTrivia(node);
_writer.WriteIndent();
_writer.WriteKeyword(PrinterKeyword.Yield);
_writer.WriteSpace();
switch (node.Kind)
{
case ReturnOrBreak.Break: _writer.WriteKeyword(PrinterKeyword.Break); break;
case ReturnOrBreak.Return: _writer.WriteKeyword(PrinterKeyword.Return); break;
default: throw ThrowHelper.InvalidEnumValue(node.Kind);
}
if (node.Expression != null)
{
_writer.WriteSpace();
node.Expression.Accept(this);
}
_writer.EndStatement();
WriteTrailingTrivia(node);
}
示例7: GetIteratorElementType
internal override TypeSymbol GetIteratorElementType(YieldStatementSyntax node, DiagnosticBag diagnostics)
{
if (IsScriptClass)
{
// This is the scenario where a `yield return` exists in the script file as a global statement.
// This method is to guard against hitting `BuckStopsHereBinder` and crash.
return this.Compilation.GetSpecialType(SpecialType.System_Object);
}
else
{
// This path would eventually throw, if we didn't have the case above.
return Next.GetIteratorElementType(node, diagnostics);
}
}
示例8: VisitYieldStatement
public override void VisitYieldStatement(YieldStatementSyntax node)
{
base.VisitYieldStatement(node);
isSpecial = true;
}
示例9: VisitYieldStatement
public override void VisitYieldStatement(YieldStatementSyntax node)
{
base.VisitYieldStatement(node);
_counter++;
}
示例10: VisitYieldStatement
public override void VisitYieldStatement(YieldStatementSyntax node)
{
if (node.IsKind(SyntaxKind.YieldBreakStatement))
{
// end not connected with data
curNode = builder.CreateEndNode(node);
}
else {
CreateConnectedEndNode(node);
}
}
示例11: VisitYieldStatement
public override void VisitYieldStatement(YieldStatementSyntax node)
{
_sawYield = true;
base.VisitYieldStatement(node);
}
示例12: BindYieldBreakStatement
private BoundStatement BindYieldBreakStatement(YieldStatementSyntax node, DiagnosticBag diagnostics)
{
if (this.Flags.Includes(BinderFlags.InFinallyBlock))
{
Error(diagnostics, ErrorCode.ERR_BadYieldInFinally, node.YieldKeyword);
}
GetIteratorElementType(node, diagnostics);
return new BoundYieldBreakStatement(node);
}
示例13: GetIteratorElementType
internal override TypeSymbol GetIteratorElementType(YieldStatementSyntax node, DiagnosticBag diagnostics)
{
TypeSymbol returnType = this.Owner.ReturnType;
if (!this.IsDirectlyInIterator)
{
// This should only happen when speculating, but we don't have a good way to assert that since the
// original binder isn't available here.
// If we're speculating about a yield statement inside a non-iterator method, we'll try to be nice
// and deduce an iterator element type from the return type. If we didn't do this, the
// TypeInfo.ConvertedType of the yield statement would always be an error type. However, we will
// not mutate any state (i.e. we won't store the result).
return GetIteratorElementTypeFromReturnType(returnType, node, diagnostics) ?? CreateErrorType();
}
if (this.iteratorInfo == IteratorInfo.Empty)
{
TypeSymbol elementType = null;
DiagnosticBag elementTypeDiagnostics = DiagnosticBag.GetInstance();
elementType = GetIteratorElementTypeFromReturnType(returnType, node, elementTypeDiagnostics);
if ((object)elementType == null)
{
Error(elementTypeDiagnostics, ErrorCode.ERR_BadIteratorReturn, this.Owner.Locations[0], this.Owner, returnType);
elementType = CreateErrorType();
}
var info = new IteratorInfo(elementType, elementTypeDiagnostics.ToReadOnlyAndFree());
Interlocked.CompareExchange(ref this.iteratorInfo, info, IteratorInfo.Empty);
}
if (node == null)
{
// node==null indicates this we are being called from the top-level of processing of a method. We report
// the diagnostic, if any, at that time to ensure it is reported exactly once.
diagnostics.AddRange(this.iteratorInfo.ElementTypeDiagnostics);
}
return this.iteratorInfo.ElementType;
}
示例14: VisitYieldStatement
public override SyntaxNode VisitYieldStatement(YieldStatementSyntax node)
{
this.AppendCompileIssue(node, IssueType.Error, IssueId.YieldNotSupport);
return node;
}
示例15: VisitYieldStatement
public override void VisitYieldStatement(YieldStatementSyntax node)
{
if (node.Expression != null)
{
var patternBinder = new PatternVariableBinder(node, _enclosing);
AddToMap(node, patternBinder);
Visit(node.Expression, patternBinder);
}
_sawYield = true;
}