public object Eval(Object[] args) { // Debug.WriteLine("Closure.Eval: ids:" + ids + " args: " + args); Env eval_Env; if (ids != null) { if (all_in_one) // this might bear optimization at some point (esp since +,-,*, etc. use this) { Pair pairargs = Pair.FromArrayAt(args, 0); Object[] newargs = new Object[1]; newargs[0] = pairargs; eval_Env = env.Extend(ids, newargs); } else { eval_Env = env.Extend(ids, args); //tailcall } } else { eval_Env = env; // tailcall } // DebugInfo.SetEnvironment(eval_Env); return(body.Eval(eval_Env)); }
public override object Eval(Env env) { // Debug.WriteLine("Eval->Assign: " + id); object valEval = val.Eval(env); // DebugInfo.EvalExpression(this); return(env.Bind(id, valEval)); }
public override object Eval(Env env) { object testVal = test_exp.Eval(env); // Debug.WriteLine("Eval->If: " + testVal); if (!(testVal is bool)) { throw new Exception("invalid test expression type in if " + testVal.ToString()); } if ((testVal is bool) && (((bool)testVal) == false)) // return false only if a bool false { return(false_exp.Eval(env)); } else { return(true_exp.Eval(env)); } }
public override object Eval(Env env) { Object proc = rator.Eval(env); Object[] args = Eval_Rands(rands, env); // DebugInfo.EvalExpression(this); // Debug.WriteLine("Eval->App: " + proc + " " + args); if (proc is Closure) { // DebugInfo.Push(proc as Closure, rator, args, marker); object result = (proc as Closure).Eval(args); // DebugInfo.Pop(marker); return(result); } else { throw new Exception("invalid operator" + proc.ToString()); } }
public override object Eval(Expression exp) { return exp.Eval(initEnv); }
public override object Eval(Expression exp) { return(exp.Eval(initEnv)); }