Inheritance: Tools.SYMBOL
        /// <summary>
        ///     Generates the code for a WhileStatement node.
        /// </summary>
        /// <param name="ws">The WhileStatement node.</param>
        /// <returns>String containing C# code for WhileStatement ws.</returns>
        private string GenerateWhileStatement(WhileStatement ws)
        {
            StringBuilder retVal = new StringBuilder();
            StringBuilder tmpVal = new StringBuilder();

            bool marc = FuncCallsMarc();

            tmpVal.Append(GenerateIndented("while (", ws));
            tmpVal.Append(GenerateNode((SYMBOL) ws.kids.Pop()));
            tmpVal.Append(GenerateLine(")"));

            //Forces all functions to use MoveNext() instead of .Current, as it never changes otherwise, and the loop runs infinitely
            m_isInEnumeratedDeclaration = true;
            retVal.Append(DumpFunc(marc));
            retVal.Append(tmpVal.ToString());
            m_isInEnumeratedDeclaration = false; //End above

            if (IsParentEnumerable)
            {
                retVal.Append(GenerateLine("{")); // SLAM! No 'while(true) doThis(); ' statements for you!
                retVal.Append(GenerateLine("if (CheckSlice()) yield return null;"));
            }

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

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

            return retVal.ToString() + DumpAfterFunc(marc);
        }
Esempio n. 2
0
 public Statement(Parser yyp, WhileStatement ifs) : base((yyp))
 {
     kids.Add(ifs);
 }