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 dumpResults(Continuation c, TextWriter sw) { sw.WriteLine("Results:"); while (c.Result != null) { sw.WriteLine("{0}", c.Result); c = c.PopResult(); } }
public Continuation Perform(Continuation c) { var argResults = DatumHelpers.nil; for (var i = 0; i < argCount; ++i) { argResults = DatumHelpers.cons(c.Result, argResults); c = c.PopResult(); } return function.Evaluate(c, argResults); }
public Continuation Perform(Continuation c) { var args = new Datum[argCount]; for (var i = 0; i < argCount; ++i) { args[i] = c.Result; c = c.PopResult(); } return function.Evaluate(c, DatumHelpers.compound(args)); }
public Continuation Perform(Continuation c) { // The result datum may be a graph. This makes certain // optimizations risky. var expansion = c.Result; if(macroDatum != null) { // Cache macro expansions. In the extremely // common case of the same macro being used on the // same Datum, re-use the expansion. macroDatum.Cache = cons(macro, expansion); } return c.PopResult().PopEnv().Evaluate(c.Env, expansion); }
public Continuation Perform(Continuation c) { var expansion = c.Result; c = c.PopResult(); return c.Evaluate(env, expansion); }
public Continuation Perform(Continuation c) { return c.PopResult(); }
public Continuation Perform(Continuation c) { var fexpression = toFExpression(c); return(fexpression.Evaluate(c.PopResult(), env, args)); }
private static Continuation popResult(Continuation c) { return c.PopResult(); }