private CPUUpdateResult Resume(LuaArgs args) { try { // Setup m_updateResult = CPUUpdateResult.Continue; m_nextBootMount.Value = null; // Resume var results = m_mainRoutine.Resume(args); // Update event filter m_eventFilter.Clear(); for (int i = 0; i < results.Length; ++i) { if (results.IsNil(i)) { break; } else if (results.IsString(i)) { m_eventFilter.Add(results.GetString(i)); } else { m_eventFilter.Add(null); } } // Handle result if (m_mainRoutine.IsFinished) { Halt(); return(m_isMainCPU ? CPUUpdateResult.Shutdown : m_updateResult); } else { if (m_updateResult == CPUUpdateResult.Continue) { m_machine.CollectGarbage(); } return(m_updateResult); } } catch (LuaError e) { var bootPath = new FilePath("boot.lua"); m_computer.ErrorOutput.WriteLine("Error resuming {0}: {1}", bootPath, e.Message); Halt(); return(m_isMainCPU ? CPUUpdateResult.Shutdown : m_updateResult); } }
public static LuaValue Resume(LuaValue[] args) { LuaCoroutine c = args[0] as LuaCoroutine; List <LuaValue> args2 = new List <LuaValue>(); foreach (LuaValue v in args) { args2.Add(v); } args2.RemoveAt(0); // remove coroutine c.Resume(args2.ToArray()); return(LuaNil.Nil); }
public static LuaValue Wrap(LuaValue[] args) { LuaFunction f = args[0] as LuaFunction; LuaCoroutine c = new LuaCoroutine(f); LuaFunction f2 = new LuaFunction(new LuaFunc(delegate(LuaValue[] args2) { return(LuaBoolean.From(c.Resume(args2))); })); return(f2); }