示例#1
0
		public  ForLoopStatement (Parser yyp, ForLoopStatement  fls , SimpleAssignment  sa ):base(((LSLSyntax
		                                                                                           )yyp)){ while (0< fls . kids . Count ) kids . Add ( fls . kids . Pop ());
			kids . Add ( sa );
		}
示例#2
0
		public  ForLoop (Parser yyp, ForLoopStatement  flsa , Expression  e , ForLoopStatement  flsb , Statement  s ):base(((LSLSyntax
		                                                                                                                    )yyp)){ kids . Add ( flsa );
			kids . Add ( e );
			kids . Add ( flsb );
			if (0< s . kids . Count && s . kids . Top  is  CompoundStatement ) kids . Add ( s . kids . Pop ());
			else  kids . Add ( s );
		}
示例#3
0
		public  ForLoopStatement (Parser yyp, ForLoopStatement  fls , Expression  e ):base(((LSLSyntax
		                                                                                    )yyp)){ while (0< fls . kids . Count ) kids . Add ( fls . kids . Pop ());
			kids . Add ( e );
		}
示例#4
0
        /// <summary>
        /// Generates the code for a ForLoopStatement node.
        /// </summary>
        /// <param name="fls">The ForLoopStatement node.</param>
        /// <returns>String containing C# code for ForLoopStatement fls.</returns>
        private string GenerateForLoopStatement(ForLoopStatement fls)
        {
            string retstr = "";

            int comma = fls.kids.Count - 1;  // tells us whether to print a comma

            // It's possible that all we have is an empty Ident, for example:
            //
            //     for (x; x < 10; x++) { ... }
            //
            // Which is illegal in C# (MONO). We'll skip it.
            if (fls.kids.Top is IdentExpression && 1 == fls.kids.Count)
                return retstr.ToString();

            for (int i = 0; i < fls.kids.Count; i++)
            {
                SYMBOL s = (SYMBOL)fls.kids[i];

                // Statements surrounded by parentheses in for loops
                //
                // e.g.  for ((i = 0), (j = 7); (i < 10); (++i))
                //
                // are legal in LSL but not in C# so we need to discard the parentheses
                //
                // The following, however, does not appear to be legal in LLS
                //
                // for ((i = 0, j = 7); (i < 10); (++i))
                //
                // As of Friday 20th November 2009, the Linden Lab simulators appear simply never to compile or run this
                // script but with no debug or warnings at all!  Therefore, we won't deal with this yet (which looks
                // like it would be considerably more complicated to handle).
                while (s is ParenthesisExpression)
                    s = (SYMBOL)s.kids.Pop();

                retstr += GenerateNode(s);
                if (0 < comma--)
                    retstr += Generate(", ");
            }

            return retstr.ToString();
        }