Esempio n. 1
0
        public static IEnumerable <IJsmInstruction> Flatten(this IJsmInstruction e)
        {
            bool checktype(IJsmInstruction inst)
            {
                return
                    (typeof(Control.While.WhileSegment) == inst.GetType() ||
                     typeof(Control.If.ElseIfSegment) == inst.GetType() ||
                     typeof(Control.If.ElseSegment) == inst.GetType() ||
                     typeof(Control.If.IfSegment) == inst.GetType() ||
                     typeof(Jsm.ExecutableSegment) == inst.GetType());
            }

            if (checktype(e))
            {
                ExecutableSegment es = ((ExecutableSegment)e);
                foreach (ExecutableSegment child in es.Where(x => checktype(x)).Select(x => (ExecutableSegment)x))
                {
                    foreach (IJsmInstruction i in Flatten(child))
                    {
                        yield return(i);
                    }
                }
                foreach (IJsmInstruction child in es.Where(x => !checktype(x)))
                {
                    yield return(child);
                }
            }
            else
            {
                yield return(e);
            }
        }
Esempio n. 2
0
                    public IEnumerable <IAwaitable> Execute(IServices services)
                    {
                        while (CanExecute(_seg.Jpf, services))
                        {
                            IEnumerable <IJsmInstruction> executable = _seg.GetBodyInstructions();
                            IScriptExecuter executer = ExecutableSegment.GetExecuter(executable);
                            foreach (IAwaitable result in executer.Execute(services))
                            {
                                yield return(result);
                            }

                            // Skip one iteration to give control to other operations.
                            yield return(SpinAwaitable.Instance);
                        }
                    }
Esempio n. 3
0
                    public IEnumerable <IAwaitable> Execute(IServices services)
                    {
                        IEnumerable <IJsmInstruction> executable = GetExecutableInstructions(services);

                        if (executable == null)
                        {
                            yield break;
                        }

                        IScriptExecuter executer = ExecutableSegment.GetExecuter(executable);

                        foreach (IAwaitable result in executer.Execute(services))
                        {
                            yield return(result);
                        }
                    }
Esempio n. 4
0

        
Esempio n. 5
0
 public GameScript(int scriptId, ExecutableSegment segment)
 {
     ScriptId = scriptId;
     Segment  = segment;
 }