Пример #1
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 );
		}
Пример #2
0
		public  IfStatement (Parser yyp, SYMBOL  s , Statement  ifs , Statement  es ):base(((LSLSyntax
		                                                                                    )yyp)){ kids . Add ( s );
			AddStatement ( ifs );
			if (0< es . kids . Count && es . kids . Top  is  IfStatement ) kids . Add ( es . kids . Pop ());
			else  AddStatement ( es );
		}
Пример #3
0
		public  DoWhileStatement (Parser yyp, SYMBOL  s , Statement  st ):base(((LSLSyntax
		                                                                        )yyp)){ if (0< st . kids . Count && st . kids . Top  is  CompoundStatement ) kids . Add ( st . kids . Pop ());
			else  kids . Add ( st );
			kids . Add ( s );
		}
Пример #4
0
		private  void  AddStatement ( Statement  s ){ if (0< s . kids . Count && s . kids . Top  is  CompoundStatement ) kids . Add ( s . kids . Pop ());
			else  kids . Add ( s );
		}
Пример #5
0
		public  IfStatement (Parser yyp, SYMBOL  s , Statement  ifs ):base(((LSLSyntax
		                                                                    )yyp)){ kids . Add ( s );
			AddStatement ( ifs );
		}
Пример #6
0
		public  StatementList (Parser yyp, Statement  s ):base(((LSLSyntax
		                                                        )yyp)){ AddStatement ( s );
		}
Пример #7
0
		public  StatementList (Parser yyp, StatementList  sl , Statement  s ):base(((LSLSyntax
		                                                                            )yyp)){ while (0< sl . kids . Count ) kids . Add ( sl . kids . Pop ());
			AddStatement ( s );
		}
Пример #8
0
		private  void  AddStatement ( Statement  s ){ if ( s . kids . Top  is  IfStatement || s . kids . Top  is  WhileStatement || s . kids . Top  is  DoWhileStatement || s . kids . Top  is  ForLoop ) kids . Add ( s . kids . Pop ());
			else  kids . Add ( s );
		}
Пример #9
0
        /// <summary>
        /// Generates the code for a Statement node.
        /// </summary>
        /// <param name="s">The Statement node.</param>
        /// <returns>String containing C# code for Statement s.</returns>
        private string GenerateStatement(Statement s)
        {
            string retstr = "";

            string FunctionCalls = "";
            bool printSemicolon = true;

            bool marc = FuncCallsMarc();
            retstr += Indent();

            if (0 < s.kids.Count)
            {
                // Jump label prints its own colon, we don't need a semicolon.
                printSemicolon = !(s.kids.Top is JumpLabel);

                // If we encounter a lone Ident, we skip it, since that's a C#
                // (MONO) error.
                if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count))
                {
                    foreach (SYMBOL kid in s.kids)
                    {
                        //                        if (kid is Assignment && m_SLCompatabilityMode)
                        if (kid is Assignment)
                        {
                            Assignment a = kid as Assignment;
                            List<string> identifiers = new List<string>();
                            checkForMultipleAssignments(identifiers, a);
                            retstr += GenerateNode((SYMBOL)a.kids.Pop());
                            retstr += Generate(String.Format(" {0} ", a.AssignmentType), a);
                            foreach (SYMBOL akid in a.kids)
                            {
                                if (akid is BinaryExpression)
                                {
                                    BinaryExpression be = akid as BinaryExpression;
                                    if (be.ExpressionSymbol.Equals("&&") || be.ExpressionSymbol.Equals("||"))
                                    {
                                        // special case handling for logical and/or, see Mantis 3174
                                        retstr += "((bool)(";
                                        retstr += GenerateNode((SYMBOL)be.kids.Pop());
                                        retstr += "))";
                                        retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol.Substring(0, 1)), be);
                                        retstr += "((bool)(";
                                        foreach (SYMBOL bkid in be.kids)
                                            retstr += GenerateNode(bkid);
                                        retstr += "))";
                                    }
                                    else
                                    {
                                        retstr += GenerateNode((SYMBOL)be.kids.Pop());
                                        retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol), be);
                                        foreach (SYMBOL kidb in be.kids)
                                        {
                                            //                                            if (kidb is FunctionCallExpression)
                                            {
                                                retstr += GenerateNode(kidb);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    retstr += GenerateNode(akid);
                                }
                            }

                        }
                        else
                        {
                            if (kid is FunctionCallExpression)
                            {
                                foreach (SYMBOL akid in kid.kids)
                                {
                                    if (akid is FunctionCall)
                                        retstr += GenerateFunctionCall(akid as FunctionCall);
                                    else
                                        retstr += GenerateNode(akid);
                                }
                            }
                            else
                                retstr += GenerateNode(kid);
                        }
                    }
                }
            }

            //Nasty hack to fix if statements with yield return and yield break;
            if (retstr[retstr.Length - 1] == '}')
                printSemicolon = false;

            if (printSemicolon)
                retstr += GenerateLine(";");

            return DumpFunc(marc) + retstr.ToString();
        }
Пример #10
0
        /// <summary>
        /// Generates the code for a Statement node.
        /// </summary>
        /// <param name="s">The Statement node.</param>
        /// <returns>String containing C# code for Statement s.</returns>
        private string GenerateStatement(Statement s)
        {
            string retstr = "";

            bool printSemicolon = true;

            retstr += Indent();

            if (0 < s.kids.Count)
            {
                // Jump label prints its own colon, we don't need a semicolon.
                printSemicolon = !(s.kids.Top is JumpLabel);

                // If we encounter a lone Ident, we skip it, since that's a C#
                // (MONO) error.
                // If we encounter a lone Ident, we skip it, since that's a C#
                // (MONO) error.
                if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count))
                    foreach (SYMBOL kid in s.kids)
                        retstr += GenerateNode(kid);
            }

            if (printSemicolon)
                retstr += GenerateLine(";");

            return retstr.ToString();
        }
Пример #11
0
        /// <summary>
        /// Generates the code for a Statement node.
        /// </summary>
        /// <param name="s">The Statement node.</param>
        /// <returns>String containing C# code for Statement s.</returns>
        private string GenerateStatement(Statement s)
        {
            StringBuilder retstr = new StringBuilder();

            string FunctionCalls = "";
            bool printSemicolon = true;

            retstr.Append(Indent());

            if (0 < s.kids.Count)
            {
                // Jump label prints its own colon, we don't need a semicolon.
                printSemicolon = !(s.kids.Top is JumpLabel);

                // If we encounter a lone Ident, we skip it, since that's a C#
                // (MONO) error.
                if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count))
                    foreach (SYMBOL kid in s.kids)
                        retstr.Append(GenerateNode(kid));
            }

            if (printSemicolon)
                retstr.Append(GenerateLine(";"));

            return FunctionCalls + retstr.ToString();
        }
Пример #12
0
        /// <summary>
        /// Generates the code for a Statement node.
        /// </summary>
        /// <param name="s">The Statement node.</param>
        /// <returns>String containing C# code for Statement s.</returns>
        private string GenerateStatement(Statement s)
        {
            StringBuilder retstr = new StringBuilder();

            string FunctionCalls = "";
            bool printSemicolon = true;

            retstr.Append(Indent());

            if (0 < s.kids.Count)
            {
                // Jump label prints its own colon, we don't need a semicolon.
                printSemicolon = !(s.kids.Top is JumpLabel);

                // If we encounter a lone Ident, we skip it, since that's a C#
                // (MONO) error.
                if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count))
                {
                    foreach (SYMBOL kid in s.kids)
                    {
                        if (kid is Assignment && m_SLCompatabilityMode)
                        {
                            Assignment a = kid as Assignment;
                            List<string> identifiers = new List<string>();
                            checkForMultipleAssignments(identifiers, a);

                            retstr.Append(GenerateNode((SYMBOL)a.kids.Pop()));
                            retstr.Append(Generate(String.Format(" {0} ", a.AssignmentType), a));
                            foreach (SYMBOL akid in a.kids)
                            {
                                if (akid is BinaryExpression)
                                {
                                    BinaryExpression be = akid as BinaryExpression;
                                    if (be.ExpressionSymbol.Equals("&&") || be.ExpressionSymbol.Equals("||"))
                                    {
                                        // special case handling for logical and/or, see Mantis 3174
                                        retstr.Append("((bool)(");
                                        retstr.Append(GenerateNode((SYMBOL)be.kids.Pop()));
                                        retstr.Append("))");
                                        retstr.Append(Generate(String.Format(" {0} ", be.ExpressionSymbol.Substring(0, 1)), be));
                                        retstr.Append("((bool)(");
                                        foreach (SYMBOL bkid in be.kids)
                                            retstr.Append(GenerateNode(bkid));
                                        retstr.Append("))");
                                    }
                                    else
                                    {
                                        retstr.Append(GenerateNode((SYMBOL)be.kids.Pop()));
                                        retstr.Append(Generate(String.Format(" {0} ", be.ExpressionSymbol), be));
                                        foreach (SYMBOL kidb in be.kids)
                                        {
                                            if (kidb is FunctionCallExpression)
                                            {
                                                //Fix so that this behaves the same as in SL, calls the function first, saves the value, then adds it to the function that called it (Mantis #0004774)
                                                string randomNewFunctionName = RandomString(10, true);
                                                FunctionCalls += "object " + randomNewFunctionName + " = " + GenerateNode(kidb) + ";";
                                                retstr.Append(randomNewFunctionName);
                                            }
                                            else
                                                retstr.Append(GenerateNode(kidb));
                                        }
                                    }
                                }
                                else
                                {
                                    retstr.Append(GenerateNode(akid));
                                }
                            }

                        }
                        else
                        {
                            if (kid is FunctionCallExpression)
                            {
                                foreach (SYMBOL akid in kid.kids)
                                {
                                    if (akid is FunctionCall)
                                    {
                                        string RetString = GenerateFunctionCall(akid as FunctionCall);
                                        if (RetString.EndsWith("TESTREMOVE\n"))
                                        {
                                            printSemicolon = false; //Already been printed by the enumerator creation
                                            RetString = RetString.Remove(RetString.Length - 11, 11);
                                        }
                                        retstr.Append(RetString);
                                    }
                                    else
                                        retstr.Append(GenerateNode(akid));
                                }
                            }
                            else
                                retstr.Append(GenerateNode(kid));
                        }
                    }
                }
            }

            if (printSemicolon)
                retstr.Append(GenerateLine(";"));

            return FunctionCalls + retstr.ToString();
        }