Inheritance: Tools.SYMBOL
コード例 #1
0
        /// <summary>
        ///     Generates the code for a StateEvent node.
        /// </summary>
        /// <param name="se">The StateEvent node.</param>
        /// <param name="parentStateName">The name of the parent state.</param>
        /// <returns>String containing C# code for StateEvent se.</returns>
        private string GenerateStateEvent(StateEvent se, string parentStateName)
        {
            StringBuilder retstr = new StringBuilder();

            // we need to separate the argument declaration list from other kids
            List<SYMBOL> argumentDeclarationListKids = new List<SYMBOL>();
            List<SYMBOL> remainingKids = new List<SYMBOL>();
            LSL2CSCodeTransformer.FixEventName(this.OriginalScript, ref se);

            _currentLocalFunctionDeclaration = se;

            MethodVariables.Clear();
            VariablesToRename.Clear();

            foreach (SYMBOL kid in se.kids)
                if (kid is ArgumentDeclarationList)
                    argumentDeclarationListKids.Add(kid);
                else
                    remainingKids.Add(kid);

            // "state" (function) declaration
            retstr.Append(GenerateIndented(
                String.Format("public System.Collections.IEnumerator {0}_event_{1}(", parentStateName, se.Name), se));

            IsParentEnumerable = true;

            // print the state arguments, if any
            List<ArgumentDeclarationList> args = new List<ArgumentDeclarationList>();
            foreach (SYMBOL kid in argumentDeclarationListKids)
            {
                args.Add(((ArgumentDeclarationList) kid));
                retstr.Append(GenerateArgumentDeclarationList((ArgumentDeclarationList) kid));
            }

            m_allMethods.Add(String.Format("{0}_event_{1}", parentStateName, se.Name), args);
            retstr.Append(GenerateLine(")"));

            foreach (SYMBOL kid in remainingKids)
                retstr.Append(GenerateNode(kid));

            if (retstr[retstr.Length - 2] == '}')
                retstr.Insert(retstr.Length - 2, GenerateLine("    yield break;"));

            return retstr.ToString();
        }
コード例 #2
0
ファイル: lsl.parser.cs プロジェクト: aurora-sim/Aurora-Libs
 public StateBody(Parser yyp, StateEvent se) : base((yyp))
 {
     kids.Add(se);
 }
コード例 #3
0
 public static void FixEventName(string script, ref StateEvent evt)
 {
     if (evt.Name == "remote_data")
     {
         string[] lines = script.Split(new [] { '\n' });
         string line = lines[evt.Line-1];
         if (line.IndexOf('(') > 0)
         {
             line = line.Substring(0, line.IndexOf('(')).Trim();
             if(_newLSLEvents.Any((ev) => ev.Name == line))
                 evt.Name = line;
         }
     }
 }
コード例 #4
0
ファイル: lsl.parser.cs プロジェクト: aurora-sim/Aurora-Libs
 public StateBody(Parser yyp, StateBody sb, StateEvent se) : base((yyp))
 {
     while (0 < sb.kids.Count) kids.Add(sb.kids.Pop());
     kids.Add(se);
 }