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 object Eval(TextReader str, Env env) { Env curEnv = initEnv; initEnv = env; object result = Eval(str); initEnv = curEnv; return result; }
public static void AddHiddenBindings(Env env) { if (!InitCalled) return; Env curEnv = env; while (curEnv is Extended_Env) { foreach (DictionaryEntry binding in ((Extended_Env) curEnv).bindings) hiddenBindings.Add(binding.Key, binding.Value); curEnv = ((Extended_Env) curEnv).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 Extended_Env(Symbol[] inSyms, Object[] inVals, Env inEnv) { this.env = inEnv; for (int pos=0; pos < inSyms.Length; pos++) { Symbol currSym = (Symbol) inSyms[pos]; if (!currSym.ToString().Equals(".")) //this.bindings.AddNew(currSym, inVals[pos]); //Hashlist this.bindings[currSym] = inVals[pos]; else { // multiple values passed in (R5RS 4.1.4) currSym = (Symbol) inSyms[pos+1]; //this.bindings.AddNew(currSym, Pair.FromArrayAt(inVals,pos)); //Hashlist this.bindings[currSym] = Pair.FromArrayAt(inVals,pos); break; } } }
public override object Eval(Env env) { // Debug.WriteLine("Eval->Prim: " + prim.ToString()); Object[] eval_Rands = Eval_Rands(rands, env); // DebugInfo.EvalExpression(this); return prim.Call(eval_Rands); }
public override object Eval(Env env) { // Debug.WriteLine("Eval Lit: " + datum); return datum; }
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); }
// internal Marker marker; public abstract object Eval(Env env);
public static void ShowLocals(Env env) { if (!InitCalled) return; try { localsListView.Items.Clear(); vals.Clear(); Env curEnv = env; string padStr = " "; string totalpadStr = ""; while (curEnv is Extended_Env) { foreach (DictionaryEntry binding in ((Extended_Env) curEnv).bindings) { if ((!(binding.Value is Closure)) && (hiddenBindings[binding.Key] == null)) { vals.Add(binding.Value); ListViewItem lvi = localsListView.Items.Add(""); lvi.SubItems.Add(totalpadStr + binding.Key.ToString()); lvi.SubItems.Add(binding.Value.ToString()); } } curEnv = ((Extended_Env) curEnv).env; totalpadStr = totalpadStr + padStr; } if (localsListView.Items.Count > 0) localsListView.Items[0].Selected = true; } catch {} }
public Closure(Symbol[] ids, Expression body, bool all_in_one, Env env) { this.ids = ids; this.body = body; this.all_in_one = all_in_one; this.env = env; }
public override object Eval(Env env) { // DebugInfo.EvalExpression(this); // Debug.WriteLine("Eval->Proc"); return(new Closure(ids, body, all_in_one, env)); }
public override object Eval(Env env) { // Debug.WriteLine("Eval->Var: " + id); return(env.Apply(id)); }
public override object Eval(Env env) { // Debug.WriteLine("Eval Lit: " + datum); return(datum); }
// internal Marker marker; abstract public object Eval(Env env);
public override object Eval(Env env) { // DebugInfo.EvalExpression(this); // Debug.WriteLine("Eval->Proc"); return new Closure(ids, body, all_in_one, env); }
public override object Eval(Env env) { // Debug.WriteLine("Eval->Var: " + id); return env.Apply(id); }
public override object Eval(Env env) { Expression[] exps = expressions; // Debug.WriteLine("Eval->Begin"); for (int i=0; i<exps.Length-1; i++) exps[i].Eval(env); return exps[exps.Length-1].Eval(env); }
// internal void Mark(object obj) // { // if (obj is Pair) // marker = ((Pair) obj).marker; // } public static Object[] Eval_Rands(Expression[] rands, Env env) { if (rands == null) return null; Object[] dest = new Object[rands.Length]; for (int i=0; i<rands.Length; i++) dest[i] = rands[i].Eval(env); return dest; }
public static void SetEnvironment(Env env) { if (!InitCalled) return; if (command == Command.EvalImmediate) return; while (procs.Count > envs.Count) envs.Add(null); envs[procs.Count - 1] = env; }