/// <summary>
        ///     Generates the code for a DoWhileStatement node.
        /// </summary>
        /// <param name="dws">The DoWhileStatement node.</param>
        /// <returns>String containing C# code for DoWhileStatement dws.</returns>
        private string GenerateDoWhileStatement(DoWhileStatement dws)
        {
            StringBuilder retVal = new StringBuilder();

            retVal.Append(GenerateIndentedLine("do", dws));
            if (IsParentEnumerable)
            {
                retVal.Append(GenerateLine("{")); // SLAM!
                retVal.Append(GenerateLine("if (CheckSlice()) yield return null;"));
            }

            // CompoundStatement handles indentation itself but we need to do it
            // otherwise.
            bool indentHere = dws.kids.Top is Statement;
            if (indentHere) m_braceCount++;
            retVal.Append(GenerateNode((SYMBOL) dws.kids.Pop()));
            if (indentHere) m_braceCount--;

            if (IsParentEnumerable)
                retVal.Append(GenerateLine("}"));

            bool marc = FuncCallsMarc();

            //Forces all functions to use MoveNext() instead of .Current, as it never changes otherwise, and the loop runs infinitely

            m_isInEnumeratedDeclaration = true;

            retVal.Append(GenerateIndented("while (", dws));
            retVal.Append(GenerateNode((SYMBOL) dws.kids.Pop()));
            retVal.Append(GenerateLine(");"));

            m_isInEnumeratedDeclaration = false; //End above

            return DumpFunc(marc) + retVal.ToString() + DumpAfterFunc(marc);
        }
Пример #2
0
 public Statement(Parser yyp, DoWhileStatement ifs) : base((yyp))
 {
     kids.Add(ifs);
 }