public Datum Evaluate(Continuation c) { try { while (c.Task != null) { if (debug) { Console.WriteLine("{0}", c.GetStackTrace()); Console.Write("Press enter for next step."); Console.ReadLine(); } c = c.Task.Perform(c.PopTask()); } c = c.PopTask(); var result = c.Result; c = c.PopResult(); if (c.Result != null) throw new Exception(string.Format("Additional '{0}' on result stack", c.Result)); return result; } catch (EvaluationException) { throw; } catch (Exception ex) { throw c.error(ex, "EvaluationError", ex.Message); } }
public Datum Evaluate(Continuation c) { try { while (c.Task != null) { if (debug) { Console.WriteLine("{0}", c.GetStackTrace()); Console.Write("Press enter for next step."); Console.ReadLine(); } c = c.Task.Perform(c.PopTask()); } c = c.PopTask(); var result = c.Result; c = c.PopResult(); if (c.Result != null) { throw new Exception(string.Format("Additional '{0}' on result stack", c.Result)); } return(result); } catch (EvaluationException) { throw; } catch (Exception ex) { throw c.error(ex, "EvaluationError", ex.Message); } }
private static void dumpTasks(Continuation c, TextWriter sw) { sw.WriteLine("Tasks:"); while (c.Task != null) { sw.WriteLine("{0}", c.Task); c = c.PopTask(); } }
// The following are useful for debugging. public static IEnvironment GetEnvironment(this Continuation c) { EvaluateTask t = null; while (c.Task != null && (t = c.Task as EvaluateTask) == null) { c = c.PopTask(); } return(t == null ? null : t.Env); }
private static Datum Evaluate(Continuation c) { while (c.Task != null) { try { c = c.Task.Perform(c.PopTask()); c.Statistics.Steps++; } catch (Exception ex) { c = c.ErrorHandler(c, ex); } } return(c.Result); }
private static Datum Evaluate(Continuation c) { while (c.Task != null) { try { c = c.Task.Perform(c.PopTask()); c.Statistics.Steps++; } catch (Exception ex) { c = c.ErrorHandler(c, ex); } } return c.Result; }