public void Initialise(string key, Codelet value) { var halt = new HaltRunlet(); var unlock = new UnlockRunlet(halt); var pop = new PopGlobalRunlet(this._dictionary.Get(key), unlock); var init = value.Weave(pop, this._dictionary); Runlet currentInstruction = new LockRunlet(init); while (true) { currentInstruction = currentInstruction.ExecuteRunlet(this); } }
public void StartFromCodelet(Runlet codelet, bool useEvaluate) { TextWriter stdErr = Console.Error; if (codelet is FunctionRunlet fwc) { if (Debug) { stdErr.WriteLine($"Running codelet ..."); } try { Runlet currentInstruction = new LockRunlet(new CallQRunlet(fwc, new HaltRunlet())); if (Debug) { while (true) { Console.WriteLine($"Instruction: {currentInstruction}"); currentInstruction = currentInstruction.ExecuteRunlet(this); } } else { while (true) { currentInstruction = currentInstruction.ExecuteRunlet(this); } } } catch (NormalExitNutmegException) { // Normal exit. } finally { if (Debug) { stdErr.WriteLine($"Bye, bye ..."); } } } else { stdErr.WriteLine("Entry point {id} is not a function"); } }