Example #1
0
		public  Statement (Parser yyp, DoWhileStatement  ifs ):base(((LSLSyntax
		                                                             )yyp)){ kids . Add ( ifs );
		}
        /// <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)
        {
            string retstr = "";
            string tmpstr = "";

            retstr += GenerateIndentedLine("do", dws);
            if (IsParentEnumerable)
            {
                retstr += GenerateLine("{"); // SLAM!
                retstr += 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++;
            retstr += GenerateNode((SYMBOL)dws.kids.Pop());
            if (indentHere) m_braceCount--;

            if (IsParentEnumerable)
                retstr += GenerateLine("}");

            bool marc = FuncCallsMarc();

            tmpstr += GenerateIndented("while (", dws);
            tmpstr += GenerateNode((SYMBOL)dws.kids.Pop());
            tmpstr += GenerateLine(");");

            retstr += DumpFunc(marc) + tmpstr.ToString();

            return retstr.ToString();
        }
Example #3
0
        /// <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)
        {
            string retstr = "";
            string tmpstr = "";

            tmpstr += GenerateIndentedLine("do", dws);

            retstr += GenerateLine("{");
            retstr += GenerateLine("CheckSleep();");
            // CompoundStatement handles indentation itself but we need to do it
            // otherwise.
            bool indentHere = dws.kids.Top is Statement;
            if (indentHere) m_braceCount++;
            tmpstr += GenerateNode((SYMBOL)dws.kids.Pop());
            if (indentHere) m_braceCount--;

            retstr += GenerateLine("}");

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

            tmpstr += GenerateIndented("while (", dws);
            tmpstr += GenerateNode((SYMBOL)dws.kids.Pop());
            tmpstr += GenerateLine(");");

            retstr += tmpstr.ToString();

            return retstr.ToString();
        }
Example #4
0
        /// <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)
        {
            string retstr = "";
            string tmpstr = "";

            tmpstr += GenerateIndentedLine("do", dws);
            if (IsParentEnumerable)
            {
                tmpstr += GenerateLine("{"); // SLAM!
                tmpstr += 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++;
            tmpstr += GenerateNode((SYMBOL)dws.kids.Pop());
            if (indentHere) m_braceCount--;

            if (IsParentEnumerable)
                tmpstr += 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;

            tmpstr += GenerateIndented("while (", dws);
            tmpstr += GenerateNode((SYMBOL)dws.kids.Pop());
            tmpstr += GenerateLine(");");

            m_isInEnumeratedDeclaration  = false; //End above

            retstr += DumpFunc(marc) + tmpstr.ToString();

            return retstr.ToString();
        }
        /// <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 retstr = new StringBuilder();

            if (IsParentEnumerable)
            {
                retstr.Append(GenerateLine("yield return null;"));
            }

            retstr.Append(GenerateIndentedLine("do", dws));
            if (IsParentEnumerable)
            {
                retstr.Append(GenerateLine("{")); // SLAM!
                retstr.Append(GenerateLine("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++;
            retstr.Append(GenerateNode((SYMBOL) dws.kids.Pop()));
            if (indentHere) m_braceCount--;

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

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

            return retstr.ToString();
        }