public void Execute(IServices services) { if (IsCompleted) { throw new InvalidOperationException("The script has already been executed once."); } _en = _executer.Execute(services).GetEnumerator(); }
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 IEnumerable <IAwaitable> Execute(IServices services) { foreach (IJsmInstruction instr in _list) { if (instr is JsmInstruction singleInstruction) { yield return(singleInstruction.Execute(services)); } else if (instr is ExecutableSegment segment) { // TODO: Change recursion to the loop IScriptExecuter nested = segment.GetExecuter(); foreach (IAwaitable result in nested.Execute(services)) { yield return(result); } } else { throw new NotSupportedException($"Cannot execute instruction [{instr}] of type [{instr.GetType()}]."); } } }