public override Continuation Evaluate(Continuation c, LexicalEnvironment env, Datum args) { var argArray = DatumHelpers.enumerate(args).ToArray(); Array.Reverse(argArray); c = c.PushTask(new InvokeFunction(function, argArray.Length)); return argArray.Aggregate(c, (current, arg) => current.Evaluate(env, arg)); }
public override Continuation Evaluate(Continuation c, Environment env, Datum args) { var argList = args.ToArray(); if (argList.Length != 2) throw c.error("Expected 2 arguments: (set! <symbol> <expression>). Got {0} instead", argList.Length); var name = argList[0].CastIdentifier(); var expression = argList[1]; c = c.PushTask(new SetName(env, name)); return c.Evaluate(env, expression); }
public override Continuation Evaluate(Continuation c, LexicalEnvironment env, Datum args) { var argList = args.ToArray(); if (argList.Length != 2) throw c.error("Expected 2 arguments: (define <symbol> <expression>). Got {0} instead", argList.Length); var name = argList[0].CastSymbol(); var expression = argList[1]; c = c.PushTask( tc => { env.Define(name, tc.Result); return tc;}, "define '{0}'", name); return c.Evaluate(env, expression); }
public override Continuation Evaluate(Continuation c, Environment env, Datum args) { var argList = args.ToArray(); if (argList.Length < 1) throw c.error("Expected at least 1 expression for begin. Got none."); // Scope any local definitions. var localEnv = new Environment(env); var remaining = argList.Reverse().ToArray(); for (var i = 0; i < remaining.Length; ++i) { if (i > 0) c = c.PushTask(Ignore.Instance); c = c.Evaluate(localEnv, remaining[i]); } return c; }
public override Continuation Evaluate(Continuation c, LexicalEnvironment env, Datum args) { var argList = args.ToArray(); if (argList.Length < 1) throw c.error("Expected at least 1 expression for begin. Got none."); // Scope any local definitions. var localEnv = env.NewFrame(); var remaining = argList.Reverse().ToArray(); for (var i = 0; i < remaining.Length; ++i) { if (i > 0) c = c.PushTask(popResult, "Discard result"); c = c.Evaluate(localEnv, remaining[i]); } return c; }
public override Continuation Evaluate(Continuation c, Environment env, Datum args) { c = c.PushTask(new EvaluateExpansion(env)); return argFunction.Evaluate(c, args); }
public static Continuation Evaluate(this Continuation s, Environment e, Datum expression) { return(s.PushTask(new EvaluateTask(e, expression))); }