public virtual object VisitYieldStatement(YieldStatement yieldStatement, object data) { stackMap.Push(yieldStatement); if (yieldStatement.ReturnValue != null) { yieldStatement.ReturnValue.AcceptVisitor(this, data); } stackMap.Pop(); return(null); }
private YieldStatement ParseYieldStatement() { YieldStatement node = null; if (isAnonynous > 0) { ReportError("yield not be authorized in anonymous method."); } if (curIterator != null) { //double check ... if (!curIterator.CouldBeIterator) { ReportError("yield is permitted only in iterator's body."); } else { curIterator.IsIterator = true; } } else { ReportError("yield is permitted only in iterator's body."); } AssertAndAdvance(TokenID.Yield); switch (curtok.ID) { case TokenID.Return: node = new YieldStatement(false, true, curtok); Advance(); node.ReturnValue = ParseExpression(); break; case TokenID.Break: node = new YieldStatement(true, false, curtok); Advance(); break; default: //TODO: Wait, but 'node' will still be null! ReportError("Expected return or break. Found '" + curtok.ID.ToString().ToLower() + "'."); Advance(); break; } //try .. catch .. finally checks if (isTry>0 && node.IsReturn ) { hasYieldReturnInTry = true; } if(isCatch>0) { ReportError("'yield return' and 'yield break' are not permitted in catch block."); if (hasYieldReturnInTry) { ReportError("'yield return' is not permitted in try block with catch block."); } } if(isFinally>0) { ReportError("'yield return' and 'yield break' are not permitted in finally block."); } AssertAndAdvance(TokenID.Semi); return node; }
public virtual object VisitYieldStatement(YieldStatement yieldStatement, object data) { stackMap.Push(yieldStatement); if (yieldStatement.ReturnValue != null) { yieldStatement.ReturnValue.AcceptVisitor(this, data); } stackMap.Pop(); return null; }