public Continuation Perform(Continuation c) { var expansion = c.Result; c = c.PopResult(); return(c.Evaluate(env, expansion)); }
public override Continuation Evaluate(Continuation c, Datum args) { var argArray = args.ToArray(); var expression = argArray[0]; var environment = (LexicalEnvironment)argArray[1].CastObject(); return(c.Evaluate(environment, expression)); }
public override Continuation Evaluate(Continuation c, Datum args) { foreach (var ab in argBodies) { var closureEnv = ab.binding(env, args); if (closureEnv == null) { continue; } return(c.Evaluate(closureEnv, ab.body)); } throw bindError(args); }
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, Datum args) { foreach (var ab in argBodies) { var frameBindings = ab.binding(args); if (frameBindings == null) { continue; } var closureEnv = env.NewFrame(frameBindings); return(c.Evaluate(closureEnv, ab.body)); } throw bindError(args); }
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, 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) { 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); }