public override void VisitForEachStatement(ForEachStatementSyntax node) { ContinueInfo ci = new ContinueInfo(); ci.Init(node.Statement); m_ContinueInfoStack.Push(ci); string varName = string.Format("__compiler_foreach_{0}", node.GetLocation().GetLineSpan().StartLinePosition.Line); CodeBuilder.AppendFormat("{0}local {1} = (", GetIndentString(), varName); IConversionExpression opd = null; var oper = m_Model.GetOperation(node) as IForEachLoopStatement; if (null != oper) { opd = oper.Collection as IConversionExpression; } OutputExpressionSyntax(node.Expression, opd); CodeBuilder.AppendLine("):GetEnumerator();"); CodeBuilder.AppendFormat("{0}while {1}:MoveNext() do", GetIndentString(), varName); CodeBuilder.AppendLine(); if (ci.HaveContinue) { if (ci.HaveBreak) { CodeBuilder.AppendFormat("{0}local {1} = false", GetIndentString(), ci.BreakFlagVarName); CodeBuilder.AppendLine(); } CodeBuilder.AppendFormat("{0}repeat", GetIndentString()); CodeBuilder.AppendLine(); } ++m_Indent; CodeBuilder.AppendFormat("{0}{1} = {2}.Current;", GetIndentString(), node.Identifier.Text, varName); CodeBuilder.AppendLine(); node.Statement.Accept(this); --m_Indent; if (ci.HaveContinue) { CodeBuilder.AppendFormat("{0}until true;", GetIndentString()); CodeBuilder.AppendLine(); if (ci.HaveBreak) { CodeBuilder.AppendFormat("{0}if {1} then break; end;", GetIndentString(), ci.BreakFlagVarName); CodeBuilder.AppendLine(); } } CodeBuilder.AppendFormat("{0}end;", GetIndentString()); CodeBuilder.AppendLine(); m_ContinueInfoStack.Pop(); }
public override void VisitForEachStatement(ForEachStatementSyntax node) { if (entryNode is AnonymousFunctionExpressionSyntax && embeddedNode is AnonymousFunctionExpressionSyntax) { return; } if (_weComeFromMethod && _weInAnonymousMethod) { return; } InsertLLOCMap(node.GetLocation()); InsertLLOCMap(node.InKeyword.GetLocation()); base.VisitForEachStatement(node); }