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); } }
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); } }
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); } }
public GameScript(int scriptId, ExecutableSegment segment) { ScriptId = scriptId; Segment = segment; }