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

            bool dump = FuncCallsMarc();

            if (IsParentEnumerable)
            {
                retVal.Append(GenerateLine("{ "));
                if (rs.kids.Count == 0)
                    retVal.Append(GenerateLine("yield break;", rs));
                else
                {
                    retVal.Append(Generate(string.Format("yield return ({0})(", _currentGlobalFunctionDeclaration.ReturnType), rs));
                    foreach (SYMBOL kid in rs.kids)
                        retVal.Append(GenerateNode(kid));
                    retVal.Append(GenerateLine(");", null));
                    retVal.Append(GenerateLine("yield break;", null));
                }
                retVal.Append(GenerateLine("}"));
            }
            else
            {
                retVal.Append(Generate(string.Format("return ({0})", _currentGlobalFunctionDeclaration.ReturnType), rs));

                foreach (SYMBOL kid in rs.kids)
                    retVal.Append(GenerateNode(kid));
            }
            if (dump)
                return DumpFunc(dump) + retVal + DumpAfterFunc(dump);
            return retVal.ToString();
        }
Example #2
0
 public Statement(Parser yyp, ReturnStatement rs) : base((yyp))
 {
     kids.Add(rs);
 }